mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-11-04 05:59:32 +01:00 
			
		
		
		
	Add another test for FilterGenerator
This commit is contained in:
		@@ -402,6 +402,7 @@ Matchers.tests.cpp:<line number>: passed: WithinULP(1.f, -1), std::domain_error
 | 
				
			|||||||
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: 1 < 4
 | 
				
			||||||
Generators.tests.cpp:<line number>: passed: i < 4 for: 2 < 4
 | 
					Generators.tests.cpp:<line number>: passed: i < 4 for: 2 < 4
 | 
				
			||||||
Generators.tests.cpp:<line number>: passed: i < 4 for: 3 < 4
 | 
					Generators.tests.cpp:<line number>: passed: i < 4 for: 3 < 4
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1175,5 +1175,5 @@ due to unexpected exception with message:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
===============================================================================
 | 
					===============================================================================
 | 
				
			||||||
test cases:  245 |  185 passed |  56 failed |  4 failed as expected
 | 
					test cases:  245 |  185 passed |  56 failed |  4 failed as expected
 | 
				
			||||||
assertions: 1378 | 1242 passed | 115 failed | 21 failed as expected
 | 
					assertions: 1379 | 1243 passed | 115 failed | 21 failed as expected
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2861,6 +2861,7 @@ Matchers.tests.cpp:<line number>: PASSED:
 | 
				
			|||||||
-------------------------------------------------------------------------------
 | 
					-------------------------------------------------------------------------------
 | 
				
			||||||
Generators -- adapters
 | 
					Generators -- adapters
 | 
				
			||||||
  Filtering by predicate
 | 
					  Filtering by predicate
 | 
				
			||||||
 | 
					  Basic usage
 | 
				
			||||||
-------------------------------------------------------------------------------
 | 
					-------------------------------------------------------------------------------
 | 
				
			||||||
Generators.tests.cpp:<line number>
 | 
					Generators.tests.cpp:<line number>
 | 
				
			||||||
...............................................................................
 | 
					...............................................................................
 | 
				
			||||||
@@ -2873,6 +2874,7 @@ with expansion:
 | 
				
			|||||||
-------------------------------------------------------------------------------
 | 
					-------------------------------------------------------------------------------
 | 
				
			||||||
Generators -- adapters
 | 
					Generators -- adapters
 | 
				
			||||||
  Filtering by predicate
 | 
					  Filtering by predicate
 | 
				
			||||||
 | 
					  Basic usage
 | 
				
			||||||
-------------------------------------------------------------------------------
 | 
					-------------------------------------------------------------------------------
 | 
				
			||||||
Generators.tests.cpp:<line number>
 | 
					Generators.tests.cpp:<line number>
 | 
				
			||||||
...............................................................................
 | 
					...............................................................................
 | 
				
			||||||
@@ -2885,6 +2887,7 @@ with expansion:
 | 
				
			|||||||
-------------------------------------------------------------------------------
 | 
					-------------------------------------------------------------------------------
 | 
				
			||||||
Generators -- adapters
 | 
					Generators -- adapters
 | 
				
			||||||
  Filtering by predicate
 | 
					  Filtering by predicate
 | 
				
			||||||
 | 
					  Basic usage
 | 
				
			||||||
-------------------------------------------------------------------------------
 | 
					-------------------------------------------------------------------------------
 | 
				
			||||||
Generators.tests.cpp:<line number>
 | 
					Generators.tests.cpp:<line number>
 | 
				
			||||||
...............................................................................
 | 
					...............................................................................
 | 
				
			||||||
@@ -2894,6 +2897,17 @@ Generators.tests.cpp:<line number>: PASSED:
 | 
				
			|||||||
with expansion:
 | 
					with expansion:
 | 
				
			||||||
  0 == 0
 | 
					  0 == 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Generators -- adapters
 | 
				
			||||||
 | 
					  Filtering by predicate
 | 
				
			||||||
 | 
					  Throws if there are no matching values
 | 
				
			||||||
 | 
					-------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					Generators.tests.cpp:<line number>
 | 
				
			||||||
 | 
					...............................................................................
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Generators.tests.cpp:<line number>: PASSED:
 | 
				
			||||||
 | 
					  REQUIRE_THROWS_AS( filter([] (int) {return false; }, value(1)), Catch::GeneratorException )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-------------------------------------------------------------------------------
 | 
					-------------------------------------------------------------------------------
 | 
				
			||||||
Generators -- adapters
 | 
					Generators -- adapters
 | 
				
			||||||
  Shortening a range
 | 
					  Shortening a range
 | 
				
			||||||
@@ -10685,5 +10699,5 @@ Misc.tests.cpp:<line number>: PASSED:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
===============================================================================
 | 
					===============================================================================
 | 
				
			||||||
test cases:  245 |  172 passed |  69 failed |  4 failed as expected
 | 
					test cases:  245 |  172 passed |  69 failed |  4 failed as expected
 | 
				
			||||||
assertions: 1392 | 1242 passed | 129 failed | 21 failed as expected
 | 
					assertions: 1393 | 1243 passed | 129 failed | 21 failed as expected
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,7 @@
 | 
				
			|||||||
    <property name="random-seed" value="1"/>
 | 
					    <property name="random-seed" value="1"/>
 | 
				
			||||||
  </properties>
 | 
					  </properties>
 | 
				
			||||||
loose text artifact
 | 
					loose text artifact
 | 
				
			||||||
  <testsuite name="<exe-name>" errors="17" failures="113" tests="1393" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
 | 
					  <testsuite name="<exe-name>" errors="17" failures="113" tests="1394" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
 | 
				
			||||||
    <testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
 | 
					    <testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
 | 
				
			||||||
    <testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/>
 | 
					    <testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/>
 | 
				
			||||||
    <testcase classname="<exe-name>.global" name="#1027" time="{duration}"/>
 | 
					    <testcase classname="<exe-name>.global" name="#1027" time="{duration}"/>
 | 
				
			||||||
@@ -342,7 +342,8 @@ Message.tests.cpp:<line number>
 | 
				
			|||||||
    <testcase classname="<exe-name>.global" name="Floating point matchers: float/ULPs" time="{duration}"/>
 | 
					    <testcase classname="<exe-name>.global" name="Floating point matchers: float/ULPs" time="{duration}"/>
 | 
				
			||||||
    <testcase classname="<exe-name>.global" name="Floating point matchers: float/Composed" time="{duration}"/>
 | 
					    <testcase classname="<exe-name>.global" name="Floating point matchers: float/Composed" time="{duration}"/>
 | 
				
			||||||
    <testcase classname="<exe-name>.global" name="Floating point matchers: float/Constructor validation" time="{duration}"/>
 | 
					    <testcase classname="<exe-name>.global" name="Floating point matchers: float/Constructor validation" time="{duration}"/>
 | 
				
			||||||
    <testcase classname="<exe-name>.global" name="Generators -- adapters/Filtering by predicate" time="{duration}"/>
 | 
					    <testcase classname="<exe-name>.global" name="Generators -- adapters/Filtering by predicate/Basic usage" time="{duration}"/>
 | 
				
			||||||
 | 
					    <testcase classname="<exe-name>.global" name="Generators -- adapters/Filtering by predicate/Throws if there are no matching values" time="{duration}"/>
 | 
				
			||||||
    <testcase classname="<exe-name>.global" name="Generators -- adapters/Shortening a range" time="{duration}"/>
 | 
					    <testcase classname="<exe-name>.global" name="Generators -- adapters/Shortening a range" time="{duration}"/>
 | 
				
			||||||
    <testcase classname="<exe-name>.global" name="Generators -- adapters/Transforming elements/Same type" time="{duration}"/>
 | 
					    <testcase classname="<exe-name>.global" name="Generators -- adapters/Transforming elements/Same type" time="{duration}"/>
 | 
				
			||||||
    <testcase classname="<exe-name>.global" name="Generators -- adapters/Transforming elements/Different type" time="{duration}"/>
 | 
					    <testcase classname="<exe-name>.global" name="Generators -- adapters/Transforming elements/Different type" time="{duration}"/>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3540,36 +3540,59 @@
 | 
				
			|||||||
    </TestCase>
 | 
					    </TestCase>
 | 
				
			||||||
    <TestCase name="Generators -- adapters" tags="[generators][generic]" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
					    <TestCase name="Generators -- adapters" tags="[generators][generic]" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
				
			||||||
      <Section name="Filtering by predicate" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
					      <Section name="Filtering by predicate" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
				
			||||||
        <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
					        <Section name="Basic usage" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
				
			||||||
          <Original>
 | 
					          <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
				
			||||||
            i % 2 == 0
 | 
					            <Original>
 | 
				
			||||||
          </Original>
 | 
					              i % 2 == 0
 | 
				
			||||||
          <Expanded>
 | 
					            </Original>
 | 
				
			||||||
            0 == 0
 | 
					            <Expanded>
 | 
				
			||||||
          </Expanded>
 | 
					              0 == 0
 | 
				
			||||||
        </Expression>
 | 
					            </Expanded>
 | 
				
			||||||
 | 
					          </Expression>
 | 
				
			||||||
 | 
					          <OverallResults successes="1" failures="0" expectedFailures="0"/>
 | 
				
			||||||
 | 
					        </Section>
 | 
				
			||||||
        <OverallResults successes="1" failures="0" expectedFailures="0"/>
 | 
					        <OverallResults successes="1" failures="0" expectedFailures="0"/>
 | 
				
			||||||
      </Section>
 | 
					      </Section>
 | 
				
			||||||
      <Section name="Filtering by predicate" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
					      <Section name="Filtering by predicate" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
				
			||||||
        <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
					        <Section name="Basic usage" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
				
			||||||
          <Original>
 | 
					          <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
				
			||||||
            i % 2 == 0
 | 
					            <Original>
 | 
				
			||||||
          </Original>
 | 
					              i % 2 == 0
 | 
				
			||||||
          <Expanded>
 | 
					            </Original>
 | 
				
			||||||
            0 == 0
 | 
					            <Expanded>
 | 
				
			||||||
          </Expanded>
 | 
					              0 == 0
 | 
				
			||||||
        </Expression>
 | 
					            </Expanded>
 | 
				
			||||||
 | 
					          </Expression>
 | 
				
			||||||
 | 
					          <OverallResults successes="1" failures="0" expectedFailures="0"/>
 | 
				
			||||||
 | 
					        </Section>
 | 
				
			||||||
        <OverallResults successes="1" failures="0" expectedFailures="0"/>
 | 
					        <OverallResults successes="1" failures="0" expectedFailures="0"/>
 | 
				
			||||||
      </Section>
 | 
					      </Section>
 | 
				
			||||||
      <Section name="Filtering by predicate" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
					      <Section name="Filtering by predicate" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
				
			||||||
        <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
					        <Section name="Basic usage" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
				
			||||||
          <Original>
 | 
					          <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
				
			||||||
            i % 2 == 0
 | 
					            <Original>
 | 
				
			||||||
          </Original>
 | 
					              i % 2 == 0
 | 
				
			||||||
          <Expanded>
 | 
					            </Original>
 | 
				
			||||||
            0 == 0
 | 
					            <Expanded>
 | 
				
			||||||
          </Expanded>
 | 
					              0 == 0
 | 
				
			||||||
        </Expression>
 | 
					            </Expanded>
 | 
				
			||||||
 | 
					          </Expression>
 | 
				
			||||||
 | 
					          <OverallResults successes="1" failures="0" expectedFailures="0"/>
 | 
				
			||||||
 | 
					        </Section>
 | 
				
			||||||
 | 
					        <OverallResults successes="1" failures="0" expectedFailures="0"/>
 | 
				
			||||||
 | 
					      </Section>
 | 
				
			||||||
 | 
					      <Section name="Filtering by predicate" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
				
			||||||
 | 
					        <Section name="Throws if there are no matching values" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
				
			||||||
 | 
					          <Expression success="true" type="REQUIRE_THROWS_AS" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
				
			||||||
 | 
					            <Original>
 | 
				
			||||||
 | 
					              filter([] (int) {return false; }, value(1)), Catch::GeneratorException
 | 
				
			||||||
 | 
					            </Original>
 | 
				
			||||||
 | 
					            <Expanded>
 | 
				
			||||||
 | 
					              filter([] (int) {return false; }, value(1)), Catch::GeneratorException
 | 
				
			||||||
 | 
					            </Expanded>
 | 
				
			||||||
 | 
					          </Expression>
 | 
				
			||||||
 | 
					          <OverallResults successes="1" failures="0" expectedFailures="0"/>
 | 
				
			||||||
 | 
					        </Section>
 | 
				
			||||||
        <OverallResults successes="1" failures="0" expectedFailures="0"/>
 | 
					        <OverallResults successes="1" failures="0" expectedFailures="0"/>
 | 
				
			||||||
      </Section>
 | 
					      </Section>
 | 
				
			||||||
      <Section name="Shortening a range" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
					      <Section name="Shortening a range" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
 | 
				
			||||||
@@ -12925,7 +12948,7 @@ loose text artifact
 | 
				
			|||||||
      </Section>
 | 
					      </Section>
 | 
				
			||||||
      <OverallResult success="true"/>
 | 
					      <OverallResult success="true"/>
 | 
				
			||||||
    </TestCase>
 | 
					    </TestCase>
 | 
				
			||||||
    <OverallResults successes="1242" failures="130" expectedFailures="21"/>
 | 
					    <OverallResults successes="1243" failures="130" expectedFailures="21"/>
 | 
				
			||||||
  </Group>
 | 
					  </Group>
 | 
				
			||||||
  <OverallResults successes="1242" failures="129" expectedFailures="21"/>
 | 
					  <OverallResults successes="1243" failures="129" expectedFailures="21"/>
 | 
				
			||||||
</Catch>
 | 
					</Catch>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -118,9 +118,15 @@ TEST_CASE("Generators -- adapters", "[generators][generic]") {
 | 
				
			|||||||
    // TODO: This won't work yet, introduce GENERATE_VAR?
 | 
					    // TODO: This won't work yet, introduce GENERATE_VAR?
 | 
				
			||||||
    //auto numbers = Catch::Generators::values({ 1, 2, 3, 4, 5, 6 });
 | 
					    //auto numbers = Catch::Generators::values({ 1, 2, 3, 4, 5, 6 });
 | 
				
			||||||
    SECTION("Filtering by predicate") {
 | 
					    SECTION("Filtering by predicate") {
 | 
				
			||||||
        // This filters out all odd (false) numbers, giving [2, 4, 6]
 | 
					        SECTION("Basic usage") {
 | 
				
			||||||
        auto i = GENERATE(filter([] (int val) { return val % 2 == 0; }, values({ 1, 2, 3, 4, 5, 6 })));
 | 
					            // This filters out all odd (false) numbers, giving [2, 4, 6]
 | 
				
			||||||
        REQUIRE(i % 2 == 0);
 | 
					            auto i = GENERATE(filter([] (int val) { return val % 2 == 0; }, values({ 1, 2, 3, 4, 5, 6 })));
 | 
				
			||||||
 | 
					            REQUIRE(i % 2 == 0);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        SECTION("Throws if there are no matching values") {
 | 
				
			||||||
 | 
					            using namespace Catch::Generators;
 | 
				
			||||||
 | 
					            REQUIRE_THROWS_AS(filter([] (int) {return false; }, value(1)), Catch::GeneratorException);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    SECTION("Shortening a range") {
 | 
					    SECTION("Shortening a range") {
 | 
				
			||||||
        // This takes the first 3 elements from the values, giving back [1, 2, 3]
 | 
					        // This takes the first 3 elements from the values, giving back [1, 2, 3]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user