You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6 anni fa
6 anni fa
6 anni fa
6 anni fa
6 anni fa
1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <cstdint>
  2. #include <iostream>
  3. #define CATCH_CONFIG_RUNNER
  4. #include "catch.hpp"
  5. #include "test_cases.h"
  6. static Catch::Session session;
  7. void SelfTest() {
  8. session.run();
  9. }
  10. TEST_CASE("Simple functions work as expected, unhooked") {
  11. REQUIRE(_small() == 0);
  12. REQUIRE(_branch(1) == 0);
  13. REQUIRE(_branch(0) == 0);
  14. for (int i = 0; i < 1000; i++) {
  15. REQUIRE(_rip_relative() == rand());
  16. }
  17. }
  18. TEST_CASE("Advanced instruction functions work as expected, unhokked") {
  19. double result[4];
  20. _AVX(9., static_cast<void*>(result));
  21. REQUIRE((result[0] - result[1]) < DBL_EPSILON);
  22. REQUIRE((result[1] - result[2]) < DBL_EPSILON);
  23. REQUIRE((result[2] - result[3]) < DBL_EPSILON);
  24. REQUIRE((result[0] - 3.) < DBL_EPSILON);
  25. }
  26. TEST_CASE("Loops & tail recursion work as expected, unhook") {
  27. REQUIRE(_loop(1) == 1);
  28. REQUIRE(_loop(2) == 4);
  29. REQUIRE(_loop(3) == 18);
  30. REQUIRE(_loop(5) == 25*24);
  31. REQUIRE(_tail_recursion(0) == 1);
  32. REQUIRE(_tail_recursion(1) == 1);
  33. REQUIRE(_tail_recursion(2) == 2);
  34. REQUIRE(_tail_recursion(5) == 120);
  35. }