Add test showing literals and complex generators in one GENERATE

This commit is contained in:
Martin Hořeňovský 2023-12-10 16:38:48 +01:00
parent 21d2da23bc
commit 9a1e73568c
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
18 changed files with 223 additions and 21 deletions

View File

@ -154,6 +154,7 @@ Nor would this
:test-result: PASS Filter generator throws exception for empty generator
:test-result: PASS Floating point matchers: double
:test-result: PASS Floating point matchers: float
:test-result: PASS GENERATE can combine literals and generators
:test-result: PASS Generators -- adapters
:test-result: PASS Generators -- simple
:test-result: PASS Generators internals

View File

@ -152,6 +152,7 @@
:test-result: PASS Filter generator throws exception for empty generator
:test-result: PASS Floating point matchers: double
:test-result: PASS Floating point matchers: float
:test-result: PASS GENERATE can combine literals and generators
:test-result: PASS Generators -- adapters
:test-result: PASS Generators -- simple
:test-result: PASS Generators internals

View File

@ -666,6 +666,10 @@ Matchers.tests.cpp:<line number>: passed: 1., !IsNaN() for: 1.0 not is NaN
Generators.tests.cpp:<line number>: passed: i % 2 == 0 for: 0 == 0
Generators.tests.cpp:<line number>: passed: i % 2 == 0 for: 0 == 0
Generators.tests.cpp:<line number>: passed: i % 2 == 0 for: 0 == 0
Generators.tests.cpp:<line number>: passed: i % 2 == 0 for: 0 == 0
Generators.tests.cpp:<line number>: passed: i % 2 == 0 for: 0 == 0
Generators.tests.cpp:<line number>: passed: i % 2 == 0 for: 0 == 0
Generators.tests.cpp:<line number>: passed: i % 2 == 0 for: 0 == 0
Generators.tests.cpp:<line number>: passed: filter([] (int) {return false; }, value(1)), Catch::GeneratorException
Generators.tests.cpp:<line number>: passed: i < 4 for: 1 < 4
Generators.tests.cpp:<line number>: passed: i < 4 for: 2 < 4
@ -2683,7 +2687,7 @@ InternalBenchmark.tests.cpp:<line number>: passed: med == 18. for: 18.0 == 18.0
InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0
Misc.tests.cpp:<line number>: passed:
Misc.tests.cpp:<line number>: passed:
test cases: 415 | 310 passed | 85 failed | 6 skipped | 14 failed as expected
assertions: 2254 | 2073 passed | 146 failed | 35 failed as expected
test cases: 416 | 311 passed | 85 failed | 6 skipped | 14 failed as expected
assertions: 2258 | 2077 passed | 146 failed | 35 failed as expected

View File

@ -664,6 +664,10 @@ Matchers.tests.cpp:<line number>: passed: 1., !IsNaN() for: 1.0 not is NaN
Generators.tests.cpp:<line number>: passed: i % 2 == 0 for: 0 == 0
Generators.tests.cpp:<line number>: passed: i % 2 == 0 for: 0 == 0
Generators.tests.cpp:<line number>: passed: i % 2 == 0 for: 0 == 0
Generators.tests.cpp:<line number>: passed: i % 2 == 0 for: 0 == 0
Generators.tests.cpp:<line number>: passed: i % 2 == 0 for: 0 == 0
Generators.tests.cpp:<line number>: passed: i % 2 == 0 for: 0 == 0
Generators.tests.cpp:<line number>: passed: i % 2 == 0 for: 0 == 0
Generators.tests.cpp:<line number>: passed: filter([] (int) {return false; }, value(1)), Catch::GeneratorException
Generators.tests.cpp:<line number>: passed: i < 4 for: 1 < 4
Generators.tests.cpp:<line number>: passed: i < 4 for: 2 < 4
@ -2672,7 +2676,7 @@ InternalBenchmark.tests.cpp:<line number>: passed: med == 18. for: 18.0 == 18.0
InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0
Misc.tests.cpp:<line number>: passed:
Misc.tests.cpp:<line number>: passed:
test cases: 415 | 310 passed | 85 failed | 6 skipped | 14 failed as expected
assertions: 2254 | 2073 passed | 146 failed | 35 failed as expected
test cases: 416 | 311 passed | 85 failed | 6 skipped | 14 failed as expected
assertions: 2258 | 2077 passed | 146 failed | 35 failed as expected

View File

@ -1588,6 +1588,6 @@ due to unexpected exception with message:
Why would you throw a std::string?
===============================================================================
test cases: 415 | 324 passed | 70 failed | 7 skipped | 14 failed as expected
assertions: 2237 | 2073 passed | 129 failed | 35 failed as expected
test cases: 416 | 325 passed | 70 failed | 7 skipped | 14 failed as expected
assertions: 2241 | 2077 passed | 129 failed | 35 failed as expected

View File

@ -4889,6 +4889,50 @@ Matchers.tests.cpp:<line number>: PASSED:
with expansion:
1.0 not is NaN
-------------------------------------------------------------------------------
GENERATE can combine literals and generators
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( i % 2 == 0 )
with expansion:
0 == 0
-------------------------------------------------------------------------------
GENERATE can combine literals and generators
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( i % 2 == 0 )
with expansion:
0 == 0
-------------------------------------------------------------------------------
GENERATE can combine literals and generators
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( i % 2 == 0 )
with expansion:
0 == 0
-------------------------------------------------------------------------------
GENERATE can combine literals and generators
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( i % 2 == 0 )
with expansion:
0 == 0
-------------------------------------------------------------------------------
Generators -- adapters
Filtering by predicate
@ -18691,6 +18735,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:
===============================================================================
test cases: 415 | 310 passed | 85 failed | 6 skipped | 14 failed as expected
assertions: 2254 | 2073 passed | 146 failed | 35 failed as expected
test cases: 416 | 311 passed | 85 failed | 6 skipped | 14 failed as expected
assertions: 2258 | 2077 passed | 146 failed | 35 failed as expected

View File

@ -4887,6 +4887,50 @@ Matchers.tests.cpp:<line number>: PASSED:
with expansion:
1.0 not is NaN
-------------------------------------------------------------------------------
GENERATE can combine literals and generators
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( i % 2 == 0 )
with expansion:
0 == 0
-------------------------------------------------------------------------------
GENERATE can combine literals and generators
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( i % 2 == 0 )
with expansion:
0 == 0
-------------------------------------------------------------------------------
GENERATE can combine literals and generators
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( i % 2 == 0 )
with expansion:
0 == 0
-------------------------------------------------------------------------------
GENERATE can combine literals and generators
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( i % 2 == 0 )
with expansion:
0 == 0
-------------------------------------------------------------------------------
Generators -- adapters
Filtering by predicate
@ -18680,6 +18724,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:
===============================================================================
test cases: 415 | 310 passed | 85 failed | 6 skipped | 14 failed as expected
assertions: 2254 | 2073 passed | 146 failed | 35 failed as expected
test cases: 416 | 311 passed | 85 failed | 6 skipped | 14 failed as expected
assertions: 2258 | 2077 passed | 146 failed | 35 failed as expected

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact
>
<testsuite name="<exe-name>" errors="17" failures="129" skipped="12" tests="2266" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testsuite name="<exe-name>" errors="17" failures="129" skipped="12" tests="2270" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="random-seed" value="1"/>
<property name="filters" value="&quot;*&quot; ~[!nonportable] ~[!benchmark] ~[approvals]"/>
@ -708,6 +708,7 @@ at Message.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Floating point matchers: float/Composed" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Floating point matchers: float/Constructor validation" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Floating point matchers: float/IsNaN" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="GENERATE can combine literals and generators" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Generators -- adapters/Filtering by predicate/Basic usage" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Generators -- adapters/Filtering by predicate/Throws if there are no matching values" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Generators -- adapters/Shortening a range" time="{duration}" status="run"/>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="<exe-name>" errors="17" failures="129" skipped="12" tests="2266" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testsuite name="<exe-name>" errors="17" failures="129" skipped="12" tests="2270" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="random-seed" value="1"/>
<property name="filters" value="&quot;*&quot; ~[!nonportable] ~[!benchmark] ~[approvals]"/>
@ -707,6 +707,7 @@ at Message.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Floating point matchers: float/Composed" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Floating point matchers: float/Constructor validation" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Floating point matchers: float/IsNaN" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="GENERATE can combine literals and generators" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Generators -- adapters/Filtering by predicate/Basic usage" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Generators -- adapters/Filtering by predicate/Throws if there are no matching values" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Generators -- adapters/Shortening a range" time="{duration}" status="run"/>

View File

@ -1071,6 +1071,7 @@ at Generators.tests.cpp:<line number>
<testCase name="Copy and then generate a range/from var and iterators" duration="{duration}"/>
<testCase name="Copy and then generate a range/From a temporary container" duration="{duration}"/>
<testCase name="Copy and then generate a range/Final validation" duration="{duration}"/>
<testCase name="GENERATE can combine literals and generators" duration="{duration}"/>
<testCase name="Generators -- adapters/Filtering by predicate/Basic usage" duration="{duration}"/>
<testCase name="Generators -- adapters/Filtering by predicate/Throws if there are no matching values" duration="{duration}"/>
<testCase name="Generators -- adapters/Shortening a range" duration="{duration}"/>

View File

@ -1070,6 +1070,7 @@ at Generators.tests.cpp:<line number>
<testCase name="Copy and then generate a range/from var and iterators" duration="{duration}"/>
<testCase name="Copy and then generate a range/From a temporary container" duration="{duration}"/>
<testCase name="Copy and then generate a range/Final validation" duration="{duration}"/>
<testCase name="GENERATE can combine literals and generators" duration="{duration}"/>
<testCase name="Generators -- adapters/Filtering by predicate/Basic usage" duration="{duration}"/>
<testCase name="Generators -- adapters/Filtering by predicate/Throws if there are no matching values" duration="{duration}"/>
<testCase name="Generators -- adapters/Shortening a range" duration="{duration}"/>

View File

@ -1258,6 +1258,14 @@ ok {test-number} - WithinRel( 1.f, -0.2f ), std::domain_error
ok {test-number} - WithinRel( 1.f, 1.f ), std::domain_error
# Floating point matchers: float
ok {test-number} - 1., !IsNaN() for: 1.0 not is NaN
# GENERATE can combine literals and generators
ok {test-number} - i % 2 == 0 for: 0 == 0
# GENERATE can combine literals and generators
ok {test-number} - i % 2 == 0 for: 0 == 0
# GENERATE can combine literals and generators
ok {test-number} - i % 2 == 0 for: 0 == 0
# GENERATE can combine literals and generators
ok {test-number} - i % 2 == 0 for: 0 == 0
# Generators -- adapters
ok {test-number} - i % 2 == 0 for: 0 == 0
# Generators -- adapters
@ -4537,5 +4545,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
1..2266
1..2270

View File

@ -1256,6 +1256,14 @@ ok {test-number} - WithinRel( 1.f, -0.2f ), std::domain_error
ok {test-number} - WithinRel( 1.f, 1.f ), std::domain_error
# Floating point matchers: float
ok {test-number} - 1., !IsNaN() for: 1.0 not is NaN
# GENERATE can combine literals and generators
ok {test-number} - i % 2 == 0 for: 0 == 0
# GENERATE can combine literals and generators
ok {test-number} - i % 2 == 0 for: 0 == 0
# GENERATE can combine literals and generators
ok {test-number} - i % 2 == 0 for: 0 == 0
# GENERATE can combine literals and generators
ok {test-number} - i % 2 == 0 for: 0 == 0
# Generators -- adapters
ok {test-number} - i % 2 == 0 for: 0 == 0
# Generators -- adapters
@ -4526,5 +4534,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
1..2266
1..2270

View File

@ -377,6 +377,8 @@
##teamcity[testFinished name='Floating point matchers: double' duration="{duration}"]
##teamcity[testStarted name='Floating point matchers: float']
##teamcity[testFinished name='Floating point matchers: float' duration="{duration}"]
##teamcity[testStarted name='GENERATE can combine literals and generators']
##teamcity[testFinished name='GENERATE can combine literals and generators' duration="{duration}"]
##teamcity[testStarted name='Generators -- adapters']
##teamcity[testFinished name='Generators -- adapters' duration="{duration}"]
##teamcity[testStarted name='Generators -- simple']

View File

@ -377,6 +377,8 @@
##teamcity[testFinished name='Floating point matchers: double' duration="{duration}"]
##teamcity[testStarted name='Floating point matchers: float']
##teamcity[testFinished name='Floating point matchers: float' duration="{duration}"]
##teamcity[testStarted name='GENERATE can combine literals and generators']
##teamcity[testFinished name='GENERATE can combine literals and generators' duration="{duration}"]
##teamcity[testStarted name='Generators -- adapters']
##teamcity[testFinished name='Generators -- adapters' duration="{duration}"]
##teamcity[testStarted name='Generators -- simple']

View File

@ -667,7 +667,7 @@ Nor would this
</Expression>
<OverallResult success="true" skips="0"/>
</TestCase>
<TestCase name="#2615 - Throwing in constructor generator fails test case but does not abort" tags="[!shouldfail]" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<TestCase name="#2615 - Throwing in constructor generator fails test case but does not abort" tags="[!shouldfail][generators][regression]" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<Exception filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
failure to init
</Exception>
@ -5583,6 +5583,41 @@ C
</Section>
<OverallResult success="true" skips="0"/>
</TestCase>
<TestCase name="GENERATE can combine literals and generators" tags="[generators]" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<Original>
i % 2 == 0
</Original>
<Expanded>
0 == 0
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<Original>
i % 2 == 0
</Original>
<Expanded>
0 == 0
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<Original>
i % 2 == 0
</Original>
<Expanded>
0 == 0
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<Original>
i % 2 == 0
</Original>
<Expanded>
0 == 0
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
</TestCase>
<TestCase name="Generators -- adapters" tags="[generators][generic]" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<Section name="Filtering by predicate" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<Section name="Basic usage" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
@ -21653,6 +21688,6 @@ b1!
</Section>
<OverallResult success="true" skips="0"/>
</TestCase>
<OverallResults successes="2073" failures="146" expectedFailures="35" skips="12"/>
<OverallResultsCases successes="310" failures="85" expectedFailures="14" skips="6"/>
<OverallResults successes="2077" failures="146" expectedFailures="35" skips="12"/>
<OverallResultsCases successes="311" failures="85" expectedFailures="14" skips="6"/>
</Catch2TestRun>

View File

@ -667,7 +667,7 @@ Nor would this
</Expression>
<OverallResult success="true" skips="0"/>
</TestCase>
<TestCase name="#2615 - Throwing in constructor generator fails test case but does not abort" tags="[!shouldfail]" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<TestCase name="#2615 - Throwing in constructor generator fails test case but does not abort" tags="[!shouldfail][generators][regression]" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<Exception filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
failure to init
</Exception>
@ -5583,6 +5583,41 @@ C
</Section>
<OverallResult success="true" skips="0"/>
</TestCase>
<TestCase name="GENERATE can combine literals and generators" tags="[generators]" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<Original>
i % 2 == 0
</Original>
<Expanded>
0 == 0
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<Original>
i % 2 == 0
</Original>
<Expanded>
0 == 0
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<Original>
i % 2 == 0
</Original>
<Expanded>
0 == 0
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<Original>
i % 2 == 0
</Original>
<Expanded>
0 == 0
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
</TestCase>
<TestCase name="Generators -- adapters" tags="[generators][generic]" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<Section name="Filtering by predicate" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
<Section name="Basic usage" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" >
@ -21652,6 +21687,6 @@ b1!
</Section>
<OverallResult success="true" skips="0"/>
</TestCase>
<OverallResults successes="2073" failures="146" expectedFailures="35" skips="12"/>
<OverallResultsCases successes="310" failures="85" expectedFailures="14" skips="6"/>
<OverallResults successes="2077" failures="146" expectedFailures="35" skips="12"/>
<OverallResultsCases successes="311" failures="85" expectedFailures="14" skips="6"/>
</Catch2TestRun>

View File

@ -305,9 +305,19 @@ namespace {
} // namespace
TEST_CASE( "#2615 - Throwing in constructor generator fails test case but does not abort", "[!shouldfail]" ) {
TEST_CASE( "#2615 - Throwing in constructor generator fails test case but does not abort",
"[!shouldfail][regression][generators]" ) {
// this should fail the test case, but not abort the application
auto sample = GENERATE( make_test_generator() );
// this assertion shouldn't trigger
REQUIRE( sample == 0 );
}
TEST_CASE( "GENERATE can combine literals and generators", "[generators]" ) {
auto i = GENERATE( 2,
4,
take( 2,
filter( []( int val ) { return val % 2 == 0; },
random( -100, 100 ) ) ) );
REQUIRE( i % 2 == 0 );
}