Skip to content

Commit

Permalink
Make CTTI test pass on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
gracicot committed Jul 26, 2024
1 parent 8181dcc commit 19d18f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/kangaru/detail/ctti.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ namespace kangaru::detail::ctti {
using namespace std::literals;
auto const sig_prefix_trimmed = raw_typed_signature<T>().substr(signature_prefix_length);

if (sig_prefix_trimmed.starts_with("class")) {
return signature_prefix_length + "class"sv.size();
if (sig_prefix_trimmed.starts_with("class ")) {
return signature_prefix_length + "class "sv.size();
}

if (sig_prefix_trimmed.starts_with("struct")) {
return signature_prefix_length + "struct"sv.size();
return signature_prefix_length + "struct "sv.size();
}

return signature_prefix_length;
Expand Down
6 changes: 6 additions & 0 deletions tests/src/5-ctti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@ struct service_b {};

TEST_CASE("CTTI Gives reliable names", "[ctti]") {
using namespace kangaru::detail::ctti;

#ifndef _MSC_VER
CHECK(type_name<kangaru::injectable_reference_source<service_a>>() == "kangaru::injectable_reference_source<service_a>");
#else
// TODO: Create a parser that produce reliable cross platform results
CHECK(type_name<kangaru::injectable_reference_source<service_a>>() == "kangaru::injectable_reference_source<struct service_a>");
#endif
}

0 comments on commit 19d18f2

Please sign in to comment.