Skip to content

Commit

Permalink
windows
Browse files Browse the repository at this point in the history
  • Loading branch information
TinyTinni committed Nov 16, 2024
1 parent 8399b59 commit 944ec3a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 14 deletions.
2 changes: 1 addition & 1 deletion tests/proptests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ target_compile_options(rapidcheck_tests PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wextra -Wconversion -pedantic-errors -Wsign-conversion>
$<$<CXX_COMPILER_ID:MSVC>:
/W4>)
/W4 /bigobj>)

if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
target_link_libraries(rapidcheck_tests PUBLIC -fsanitize=address,undefined)
Expand Down
56 changes: 43 additions & 13 deletions tests/proptests/main_rapidcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,29 @@ template <> std::wstring genValidUnescapedNameString<wchar_t>()
}

////////////////////////////////////////////////////////////////
template <typename T> const char *getName();
template <typename T> constexpr std::string_view getName();

template <> const char *getName<tyti::vdf::multikey_object>()
template <> constexpr std::string_view getName<tyti::vdf::multikey_object>()
{
return "multikey_object";
}
template <> const char *getName<tyti::vdf::wmultikey_object>()
template <> constexpr std::string_view getName<tyti::vdf::wmultikey_object>()
{
return "wmultikey_object";
}

template <> const char *getName<tyti::vdf::object>() { return "object"; }
template <> const char *getName<tyti::vdf::wobject>() { return "wobject"; }
template <> constexpr std::string_view getName<tyti::vdf::object>()
{
return "object";
}
template <> constexpr std::string_view getName<tyti::vdf::wobject>()
{
return "wobject";
}

template <> const char *getName<char>() { return "char"; }
template <> constexpr std::string_view getName<char>() { return "char"; }

template <> const char *getName<wchar_t>() { return "wchar_t"; }
template <> constexpr std::string_view getName<wchar_t>() { return "wchar_t"; }
////////////////////////////////////////////////////////////////

template <typename charT, template <typename T> typename basic_obj>
Expand All @@ -72,22 +78,46 @@ bool executeTest(std::string_view test_name, auto test_f)
auto f = [test_f = std::move(test_f)]()
{ test_f.template operator()<charT, obj>(); };

return rc::check(std::format("{} - {} - {}", std::string{test_name},
getName<charT>(), getName<obj>()),
f);
return rc::check(std::string{test_name} + " - " +
std::string{getName<charT>()} + " - " +
std::string{getName<obj>()},
std::move(f));
}

bool forAllObjectPermutations(std::string_view test_name, auto test_f)
{
using namespace tyti;
bool ret = false;
bool ret = true;
ret &= executeTest<char, vdf::basic_object>(test_name, std::move(test_f));

ret &= executeTest<char, vdf::basic_multikey_object>(test_name,
std::move(test_f));
ret &=
executeTest<wchar_t, vdf::basic_object>(test_name, std::move(test_f));

ret &= executeTest<wchar_t, vdf::basic_multikey_object>(test_name,
std::move(test_f));
return ret;
}

bool forLimitedObjectPermutation(std::string_view test_name, auto test_f)
{
using namespace tyti;
bool ret = true;
ret &= executeTest<char, vdf::basic_object>(test_name, std::move(test_f));

ret &= executeTest<char, vdf::basic_multikey_object>(test_name,
std::move(test_f));
// todo, remove surrogate to the wobject generator and it's
// attributes for linux support
// afterwards, use "forAllObjectPermutations" and delete this function
#if defined(WIN32) || defined(__APPLE__)
ret &=
executeTest<wchar_t, vdf::basic_object>(test_name, std::move(test_f));

ret &= executeTest<wchar_t, vdf::basic_multikey_object>(test_name,
std::move(test_f));
#endif
return ret;
}

Expand Down Expand Up @@ -135,7 +165,7 @@ int main()
RC_ASSERT(obj.name == to_test.name);
});

success &= forAllObjectPermutations(
success &= forLimitedObjectPermutation(
"check if the attributes are also written and parsed correctly",
[]<typename charT, typename objType>()
{
Expand All @@ -146,7 +176,7 @@ int main()
RC_ASSERT(in == to_test);
});

success &= forAllObjectPermutations(
success &= forLimitedObjectPermutation(
"check if the childs are also written and parsed correctly",
[]<typename charT, typename objType>()
{
Expand Down

0 comments on commit 944ec3a

Please sign in to comment.