Skip to content

Commit

Permalink
Fix linkage error in tests (travis, gcc, x86)
Browse files Browse the repository at this point in the history
  • Loading branch information
Smertig committed Jan 6, 2021
1 parent 7f01a4e commit 66c33d0
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions test/test_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
#error Unknown compiler
#endif

int sum(int a, int b) {
return a + b;
}
static_assert(std::is_same_v<decltype(&sum), int(*)(int, int)>);

// TODO: remove 'if' when jmp relocation is ready
#if RCMP_GET_ARCH() == RCMP_ARCH_X86

Expand Down Expand Up @@ -112,10 +117,8 @@ TEST_CASE("cdecl calling convention") {

REQUIRE(g1(10, 10.0f) == Approx(198.0f));

constexpr auto sum = +[](int a, int b) { return a + b; };
constexpr auto converted_sum = rcmp::with_signature<sum, rcmp::cdecl_t<int(int, int)>>;
REQUIRE(converted_sum(1, 2) == sum(1, 2));
STATIC_REQUIRE(std::is_same_v<decltype(sum), int(* const)(int, int)>);
STATIC_REQUIRE(std::is_same_v<decltype(converted_sum), int(RCMP_DETAIL_CDECL* const)(int, int)>);
}

Expand Down Expand Up @@ -150,10 +153,8 @@ TEST_CASE("stdcall calling convention") {

REQUIRE(g2(10, 10) == 198);

constexpr auto sum = +[](int a, int b) { return a + b; };
constexpr auto converted_sum = rcmp::with_signature<sum, rcmp::stdcall_t<int(int, int)>>;
REQUIRE(converted_sum(1, 2) == sum(1, 2));
STATIC_REQUIRE(std::is_same_v<decltype(sum), int(* const)(int, int)>);
STATIC_REQUIRE(std::is_same_v<decltype(converted_sum), int(RCMP_DETAIL_STDCALL* const)(int, int)>);
}

Expand All @@ -178,10 +179,8 @@ TEST_CASE("thiscall calling convention") {

REQUIRE(g3(10, 10) == 198);

constexpr auto sum = +[](int a, int b) { return a + b; };
constexpr auto converted_sum = rcmp::with_signature<sum, rcmp::thiscall_t<int(int, int)>>;
REQUIRE(converted_sum(1, 2) == sum(1, 2));
STATIC_REQUIRE(std::is_same_v<decltype(sum), int(* const)(int, int)>);
STATIC_REQUIRE(std::is_same_v<decltype(converted_sum), int(RCMP_DETAIL_THISCALL* const)(int, int)>);
}

Expand Down Expand Up @@ -216,10 +215,8 @@ TEST_CASE("fastcall calling convention") {

REQUIRE(g4(10, 10) == 198);

constexpr auto sum = +[](int a, int b) { return a + b; };
constexpr auto converted_sum = rcmp::with_signature<sum, rcmp::fastcall_t<int(int, int)>>;
REQUIRE(converted_sum(1, 2) == sum(1, 2));
STATIC_REQUIRE(std::is_same_v<decltype(sum), int(* const)(int, int)>);
STATIC_REQUIRE(std::is_same_v<decltype(converted_sum), int(RCMP_DETAIL_FASTCALL* const)(int, int)>);
}

Expand Down

0 comments on commit 66c33d0

Please sign in to comment.