diff options
| author | Martin Hořeňovský | 2020-10-20 10:35:55 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2020-10-20 10:57:37 +0200 |
| commit | 6ffac61719934b9a6815267e680045813a125db5 (patch) | |
| tree | 1a6e0413236f5bda91ee7eeaf1ea3e8bd3228fa3 /tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp | |
| parent | faffc292535c5807f09a329961340f9e835c4af7 (diff) | |
| download | catch3-6ffac61719934b9a6815267e680045813a125db5.tar.gz | |
Fix types in generators: decay types, properly constrain forwarding
Fixes #2040
Closes #2012
Diffstat (limited to 'tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp')
| -rw-r--r-- | tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp b/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp index 169cac82..848bb1d9 100644 --- a/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp @@ -358,3 +358,33 @@ TEST_CASE("Multiple random generators in one test case output different values", REQUIRE(same < 200); } } + +TEST_CASE("#2040 - infinite compilation recursion in GENERATE with MSVC", "[generators][compilation][approvals]") { + int x = 42; + auto test = GENERATE_COPY(1, x, 2 * x); + CHECK(test < 100); +} + +namespace { + static bool always_true(int) { + return true; + } + + static bool is_even(int n) { + return n % 2 == 0; + } + + static bool is_multiple_of_3(int n) { + return n % 3 == 0; + } +} + +TEST_CASE("GENERATE handles function (pointers)", "[generators][compilation][approvals]") { + auto f = GENERATE(always_true, is_even, is_multiple_of_3); + REQUIRE(f(6)); +} + +TEST_CASE("GENERATE decays arrays", "[generators][compilation][approvals]") { + auto str = GENERATE("abc", "def", "gh"); + STATIC_REQUIRE(std::is_same<decltype(str), const char*>::value); +} |