|
1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #include <cstdint>
- #include <iostream>
-
- #define CATCH_CONFIG_RUNNER
- #include "catch.hpp"
- #include "test_cases.h"
-
- static Catch::Session session;
-
- void SelfTest() {
- session.run();
- }
-
- TEST_CASE("Simple functions work as expected, unhooked") {
- REQUIRE(_small() == 0);
-
- REQUIRE(_branch(1) == 0);
- REQUIRE(_branch(0) == 0);
-
- for (int i = 0; i < 1000; i++) {
- REQUIRE(_rip_relative() == rand());
- }
- }
-
- TEST_CASE("Advanced instruction functions work as expected, unhokked") {
- double result[4];
- _AVX(9., static_cast<void*>(result));
- REQUIRE((result[0] - result[1]) < DBL_EPSILON);
- REQUIRE((result[1] - result[2]) < DBL_EPSILON);
- REQUIRE((result[2] - result[3]) < DBL_EPSILON);
- REQUIRE((result[0] - 3.) < DBL_EPSILON);
- }
-
- TEST_CASE("Loops & tail recursion work as expected, unhook") {
- REQUIRE(_loop(1) == 1);
- REQUIRE(_loop(2) == 4);
- REQUIRE(_loop(3) == 18);
- REQUIRE(_loop(5) == 25*24);
-
- REQUIRE(_tail_recursion(0) == 1);
- REQUIRE(_tail_recursion(1) == 1);
- REQUIRE(_tail_recursion(2) == 2);
- REQUIRE(_tail_recursion(5) == 120);
- }
|