#include #include #define CATCH_CONFIG_RUNNER #include "catch.hpp" #include "test_cases.h" /*#pragma comment(lib, "advanced_instructions.obj") #pragma comment(lib, "simple_tests.obj") #pragma comment(lib, "backwards.obj")*/ static Catch::Session session; _declspec(dllexport) 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(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(2, 3) == 8); REQUIRE(_loop(5, 3) == 125); REQUIRE(_loop(5, 0) == 1); REQUIRE(_loop(5, 1) == 5); REQUIRE(_tail_recursion(0) == 1); REQUIRE(_tail_recursion(1) == 1); REQUIRE(_tail_recursion(2) == 2); REQUIRE(_tail_recursion(5) == 120); }