catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Add Concat generator for combining multiple generators
- Commit
44c597f0742b491399994afa00070b99d3ef2885- Author
- Martin Hořeňovský ·
- Parents
6aedc79870e7
Changes
docs/generators.md | 40 ++++- .../generators/catch_generators_adapters.hpp | 43 +++++ tests/SelfTest/Baselines/automake.sw.approved.txt | 2 + .../Baselines/automake.sw.multi.approved.txt | 2 + tests/SelfTest/Baselines/compact.sw.approved.txt | 24 ++- .../Baselines/compact.sw.multi.approved.txt | 24 ++- tests/SelfTest/Baselines/console.std.approved.txt | 4 +- tests/SelfTest/Baselines/console.sw.approved.txt | 174 +++++++++++++++++- .../Baselines/console.sw.multi.approved.txt | 174 +++++++++++++++++- tests/SelfTest/Baselines/junit.sw.approved.txt | 8 +- .../SelfTest/Baselines/junit.sw.multi.approved.txt | 8 +- tests/SelfTest/Baselines/sonarqube.sw.approved.txt | 6 + .../Baselines/sonarqube.sw.multi.approved.txt | 6 + tests/SelfTest/Baselines/tap.sw.approved.txt | 42 ++++- tests/SelfTest/Baselines/tap.sw.multi.approved.txt | 42 ++++- tests/SelfTest/Baselines/teamcity.sw.approved.txt | 4 + .../Baselines/teamcity.sw.multi.approved.txt | 4 + tests/SelfTest/Baselines/xml.sw.approved.txt | 200 ++++++++++++++++++++- tests/SelfTest/Baselines/xml.sw.multi.approved.txt | 200 ++++++++++++++++++++- .../IntrospectiveTests/GeneratorsImpl.tests.cpp | 20 ++- tests/SelfTest/UsageTests/Generators.tests.cpp | 13 ++ 21 files changed, 1020 insertions(+), 20 deletions(-) diff --git a/docs/generators.md b/docs/generators.md index 27bedacc..b01ec906 100644 --- a/docs/generators.md +++ b/docs/generators.md @@ -1,6 +1,12 @@ <a id="top"></a> # Data Generators +**Contents**<br> +[Combining `GENERATE` and `SECTION`.](#combining-generate-and-section)<br> +[Provided generators](#provided-generators)<br> +[Generator interface](#generator-interface)<br> +[Other usage examples](#other-usage-examples)<br> + > Introduced in Catch2 2.6.0. Data generators (also known as _data driven/parametrized test cases_) @@ -106,7 +112,7 @@ a test case, * 2 fundamental generators * `SingleValueGenerator<T>` -- contains only single element * `FixedValuesGenerator<T>` -- contains multiple elements -* 5 generic generators that modify other generators (defined in `catch2/generators/catch_generators_adapters.hpp`) +* 6 generic generators that modify other generators (defined in `catch2/generators/catch_generators_adapters.hpp`) * `FilterGenerator<T, Predicate>` -- filters out elements from a generator for which the predicate returns "false" * `TakeGenerator<T>` -- takes first `n` elements from a generator @@ -114,6 +120,7 @@ a test case, * `MapGenerator<T, U, Func>` -- returns the result of applying `Func` on elements from a different generator * `ChunkGenerator<T>` -- returns chunks (inside `std::vector`) of n elements from a generator + * `ConcatGenerator<T>` -- returns elements from multiple generators as if they were one * 2 random generators (defined in `catch2/generators/catch_generators_random.hpp`) * `RandomIntegerGenerator<Integral>` -- generates random Integrals from range * `RandomFloatGenerator<Float>` -- generates random Floats from range @@ -125,6 +132,8 @@ a test case, > `IteratorGenerator<T>` was introduced in Catch2 2.10.0. +> `ConcatGenerator<T>` was introduced in Catch2 X.Y.Z + The generators also have associated helper functions that infer their type, making their usage much nicer. These are @@ -142,6 +151,7 @@ type, making their usage much nicer. These are * `range(Arithmetic start, Arithmetic end, Arithmetic step)` for `RangeGenerator<Arithmetic>` with a custom step size * `from_range(InputIterator from, InputIterator to)` for `IteratorGenerator<T>` * `from_range(Container const&)` for `IteratorGenerator<T>` +* `cat(GeneratorWrapper<T>&&...)` for `ConcatGenerator<T>` > `chunk()`, `random()` and both `range()` functions were introduced in Catch2 2.7.0. @@ -149,6 +159,8 @@ type, making their usage much nicer. These are > `range()` for floating point numbers has been introduced in Catch2 2.11.0 +> `cat` has been introduced in Catch2 X.Y.Z + And can be used as shown in the example below to create a generator that returns 100 odd random number: @@ -278,6 +290,32 @@ to be an error or not. * If empty generator **is not** an error, use the [`SKIP` macro](skipping-passing-failing.md#skipping-test-cases-at-runtime) in constructor. +## Other usage examples + +### Adding a reproducer to random tests + +If you use generators to generate random inputs for testing, you might +want to combine them with specific inputs, e.g. reproducers for previously +found issues. + +Because `GENERATE` accepts multiple values/generators, the basic case is simple: +```cpp +const int input = GENERATE(1, 2, take(10, random(10, 10'000'000))); +``` +This will set `input` first to "1", then to "2", and then to 10 random +integers. + +But if you process the random inputs further (e.g. via `map`), you can't +rely on `GENERATE`'s support for multiple generators. In that case, you +have to use the `cat` generator combinator. +```cpp +const auto input = GENERATE( + map( foo, + cat( value( 4 ), take( 10, random( 10, 10'000'000 ) ) ) ) ); +``` +This will set `input` first to `foo(4)`, before transforming the 10 random +integers through `foo`. + --- diff --git a/src/catch2/generators/catch_generators_adapters.hpp b/src/catch2/generators/catch_generators_adapters.hpp index e5ddc25e..01f7c622 100644 --- a/src/catch2/generators/catch_generators_adapters.hpp +++ b/src/catch2/generators/catch_generators_adapters.hpp @@ -234,6 +234,49 @@ namespace Generators { ); } + template <typename T> + class ConcatGenerator final : public IGenerator<T> { + std::vector<GeneratorWrapper<T>> m_generators; + size_t m_current_generator = 0; + + void InsertGenerators( GeneratorWrapper<T>&& gen ) { + m_generators.push_back( CATCH_MOVE( gen ) ); + } + + template <typename... Generators> + void InsertGenerators( GeneratorWrapper<T>&& gen, Generators&&... gens ) { + m_generators.push_back( CATCH_MOVE( gen ) ); + InsertGenerators( CATCH_MOVE( gens )... ); + } + + public: + template <typename... Generators> + ConcatGenerator( Generators&&... generators ) { + InsertGenerators( CATCH_MOVE( generators )... ); + } + + T const& get() const override { + return m_generators[m_current_generator].get(); + } + bool next() override { + const bool success = m_generators[m_current_generator].next(); + if ( success ) { return true; } + + // If current generator is used up, we have to move to the next one + ++m_current_generator; + return m_current_generator < m_generators.size(); + } + }; + + template <typename T, typename... Generators> + GeneratorWrapper<T> cat( GeneratorWrapper<T>&& generator, + Generators&&... generators ) { + return GeneratorWrapper<T>( + Catch::Detail::make_unique<ConcatGenerator<T>>( + CATCH_MOVE( generator ), CATCH_MOVE( generators )... ) ); + } + + } // namespace Generators } // namespace Catch diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt index 05c6384b..606d7ac3 100644 --- a/tests/SelfTest/Baselines/automake.sw.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.approved.txt @@ -131,6 +131,7 @@ Nor would this :test-result: PASS Comparisons with int literals don't warn when mixing signed/ unsigned :test-result: PASS Composed generic matchers shortcircuit :test-result: PASS Composed matchers shortcircuit +:test-result: PASS ConcatGenerator :test-result: FAIL Contains string matcher :test-result: PASS Copy and then generate a range :test-result: PASS Cout stream properly declares it writes to stdout @@ -334,6 +335,7 @@ Message from section two :test-result: PASS array<int, N> -> toString :test-result: PASS benchmark function call :test-result: PASS boolean member +:test-result: PASS cat generator :test-result: PASS checkedElse :test-result: FAIL checkedElse, failing :test-result: PASS checkedIf diff --git a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt index 75c116d5..fd146fe7 100644 --- a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt @@ -129,6 +129,7 @@ :test-result: PASS Comparisons with int literals don't warn when mixing signed/ unsigned :test-result: PASS Composed generic matchers shortcircuit :test-result: PASS Composed matchers shortcircuit +:test-result: PASS ConcatGenerator :test-result: FAIL Contains string matcher :test-result: PASS Copy and then generate a range :test-result: PASS Cout stream properly declares it writes to stdout @@ -327,6 +328,7 @@ :test-result: PASS array<int, N> -> toString :test-result: PASS benchmark function call :test-result: PASS boolean member +:test-result: PASS cat generator :test-result: PASS checkedElse :test-result: FAIL checkedElse, failing :test-result: PASS checkedIf diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index ea8d519a..a366d006 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -540,6 +540,18 @@ Matchers.tests.cpp:<line number>: passed: !second.matchCalled for: true Matchers.tests.cpp:<line number>: passed: matcher.match( 1 ) for: true Matchers.tests.cpp:<line number>: passed: first.matchCalled for: true Matchers.tests.cpp:<line number>: passed: !second.matchCalled for: true +GeneratorsImpl.tests.cpp:<line number>: passed: c.get() == 1 for: 1 == 1 +GeneratorsImpl.tests.cpp:<line number>: passed: !(c.next()) for: !false +GeneratorsImpl.tests.cpp:<line number>: passed: c.get() == i + 1 for: 1 == 1 +GeneratorsImpl.tests.cpp:<line number>: passed: c.next() for: true +GeneratorsImpl.tests.cpp:<line number>: passed: c.get() == i + 1 for: 2 == 2 +GeneratorsImpl.tests.cpp:<line number>: passed: c.next() for: true +GeneratorsImpl.tests.cpp:<line number>: passed: c.get() == i + 1 for: 3 == 3 +GeneratorsImpl.tests.cpp:<line number>: passed: c.next() for: true +GeneratorsImpl.tests.cpp:<line number>: passed: c.get() == i + 1 for: 4 == 4 +GeneratorsImpl.tests.cpp:<line number>: passed: c.next() for: true +GeneratorsImpl.tests.cpp:<line number>: passed: c.get() == 5 for: 5 == 5 +GeneratorsImpl.tests.cpp:<line number>: passed: !(c.next()) for: !false Matchers.tests.cpp:<line number>: failed: testStringForMatching(), ContainsSubstring( "not there", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" contains: "not there" (case insensitive) Matchers.tests.cpp:<line number>: failed: testStringForMatching(), ContainsSubstring( "STRING" ) for: "this string contains 'abc' as a substring" contains: "STRING" Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1 @@ -2483,6 +2495,14 @@ InternalBenchmark.tests.cpp:<line number>: passed: model.started == 0 for: 0 == InternalBenchmark.tests.cpp:<line number>: passed: model.finished == 0 for: 0 == 0 InternalBenchmark.tests.cpp:<line number>: passed: called == 1 for: 1 == 1 Tricky.tests.cpp:<line number>: passed: obj.prop != 0 for: 0x<hex digits> != 0 +Generators.tests.cpp:<line number>: passed: input < 3 for: 0 < 3 +Generators.tests.cpp:<line number>: passed: input < 3 for: 1 < 3 +Generators.tests.cpp:<line number>: passed: input < 3 for: 2 < 3 +Generators.tests.cpp:<line number>: passed: input % 2 == 0 for: 0 == 0 +Generators.tests.cpp:<line number>: passed: input % 2 == 0 for: 0 == 0 +Generators.tests.cpp:<line number>: passed: input % 2 == 0 for: 0 == 0 +Generators.tests.cpp:<line number>: passed: input % 2 == 0 for: 0 == 0 +Generators.tests.cpp:<line number>: passed: input % 2 == 0 for: 0 == 0 Misc.tests.cpp:<line number>: passed: flag for: true Misc.tests.cpp:<line number>: passed: testCheckedElse( true ) for: true Misc.tests.cpp:<line number>: failed - but was ok: flag for: false @@ -2895,7 +2915,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: 437 | 317 passed | 96 failed | 6 skipped | 18 failed as expected -assertions: 2311 | 2110 passed | 158 failed | 43 failed as expected +test cases: 439 | 319 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2331 | 2130 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt index dbfab609..dab12a55 100644 --- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt @@ -538,6 +538,18 @@ Matchers.tests.cpp:<line number>: passed: !second.matchCalled for: true Matchers.tests.cpp:<line number>: passed: matcher.match( 1 ) for: true Matchers.tests.cpp:<line number>: passed: first.matchCalled for: true Matchers.tests.cpp:<line number>: passed: !second.matchCalled for: true +GeneratorsImpl.tests.cpp:<line number>: passed: c.get() == 1 for: 1 == 1 +GeneratorsImpl.tests.cpp:<line number>: passed: !(c.next()) for: !false +GeneratorsImpl.tests.cpp:<line number>: passed: c.get() == i + 1 for: 1 == 1 +GeneratorsImpl.tests.cpp:<line number>: passed: c.next() for: true +GeneratorsImpl.tests.cpp:<line number>: passed: c.get() == i + 1 for: 2 == 2 +GeneratorsImpl.tests.cpp:<line number>: passed: c.next() for: true +GeneratorsImpl.tests.cpp:<line number>: passed: c.get() == i + 1 for: 3 == 3 +GeneratorsImpl.tests.cpp:<line number>: passed: c.next() for: true +GeneratorsImpl.tests.cpp:<line number>: passed: c.get() == i + 1 for: 4 == 4 +GeneratorsImpl.tests.cpp:<line number>: passed: c.next() for: true +GeneratorsImpl.tests.cpp:<line number>: passed: c.get() == 5 for: 5 == 5 +GeneratorsImpl.tests.cpp:<line number>: passed: !(c.next()) for: !false Matchers.tests.cpp:<line number>: failed: testStringForMatching(), ContainsSubstring( "not there", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" contains: "not there" (case insensitive) Matchers.tests.cpp:<line number>: failed: testStringForMatching(), ContainsSubstring( "STRING" ) for: "this string contains 'abc' as a substring" contains: "STRING" Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1 @@ -2476,6 +2488,14 @@ InternalBenchmark.tests.cpp:<line number>: passed: model.started == 0 for: 0 == InternalBenchmark.tests.cpp:<line number>: passed: model.finished == 0 for: 0 == 0 InternalBenchmark.tests.cpp:<line number>: passed: called == 1 for: 1 == 1 Tricky.tests.cpp:<line number>: passed: obj.prop != 0 for: 0x<hex digits> != 0 +Generators.tests.cpp:<line number>: passed: input < 3 for: 0 < 3 +Generators.tests.cpp:<line number>: passed: input < 3 for: 1 < 3 +Generators.tests.cpp:<line number>: passed: input < 3 for: 2 < 3 +Generators.tests.cpp:<line number>: passed: input % 2 == 0 for: 0 == 0 +Generators.tests.cpp:<line number>: passed: input % 2 == 0 for: 0 == 0 +Generators.tests.cpp:<line number>: passed: input % 2 == 0 for: 0 == 0 +Generators.tests.cpp:<line number>: passed: input % 2 == 0 for: 0 == 0 +Generators.tests.cpp:<line number>: passed: input % 2 == 0 for: 0 == 0 Misc.tests.cpp:<line number>: passed: flag for: true Misc.tests.cpp:<line number>: passed: testCheckedElse( true ) for: true Misc.tests.cpp:<line number>: failed - but was ok: flag for: false @@ -2884,7 +2904,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: 437 | 317 passed | 96 failed | 6 skipped | 18 failed as expected -assertions: 2311 | 2110 passed | 158 failed | 43 failed as expected +test cases: 439 | 319 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2331 | 2130 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt index 7de7b1f9..48bcec18 100644 --- a/tests/SelfTest/Baselines/console.std.approved.txt +++ b/tests/SelfTest/Baselines/console.std.approved.txt @@ -1743,6 +1743,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 437 | 335 passed | 76 failed | 7 skipped | 19 failed as expected -assertions: 2289 | 2110 passed | 136 failed | 43 failed as expected +test cases: 439 | 337 passed | 76 failed | 7 skipped | 19 failed as expected +assertions: 2309 | 2130 passed | 136 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt index ab18d08c..eb9f7367 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -3911,6 +3911,80 @@ Matchers.tests.cpp:<line number>: PASSED: with expansion: true +------------------------------------------------------------------------------- +ConcatGenerator + Cat support single-generator construction +------------------------------------------------------------------------------- +GeneratorsImpl.tests.cpp:<line number> +............................................................................... + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.get() == 1 ) +with expansion: + 1 == 1 + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE_FALSE( c.next() ) +with expansion: + !false + +------------------------------------------------------------------------------- +ConcatGenerator + Iterating over multiple generators +------------------------------------------------------------------------------- +GeneratorsImpl.tests.cpp:<line number> +............................................................................... + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.get() == i + 1 ) +with expansion: + 1 == 1 + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.get() == i + 1 ) +with expansion: + 2 == 2 + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.get() == i + 1 ) +with expansion: + 3 == 3 + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.get() == i + 1 ) +with expansion: + 4 == 4 + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.get() == 5 ) +with expansion: + 5 == 5 + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE_FALSE( c.next() ) +with expansion: + !false + ------------------------------------------------------------------------------- Contains string matcher ------------------------------------------------------------------------------- @@ -16440,6 +16514,102 @@ Tricky.tests.cpp:<line number>: PASSED: with expansion: 0x<hex digits> != 0 +------------------------------------------------------------------------------- +cat generator + Simple usage +------------------------------------------------------------------------------- +Generators.tests.cpp:<line number> +............................................................................... + +Generators.tests.cpp:<line number>: PASSED: + REQUIRE( input < 3 ) +with expansion: + 0 < 3 + +------------------------------------------------------------------------------- +cat generator + Simple usage +------------------------------------------------------------------------------- +Generators.tests.cpp:<line number> +............................................................................... + +Generators.tests.cpp:<line number>: PASSED: + REQUIRE( input < 3 ) +with expansion: + 1 < 3 + +------------------------------------------------------------------------------- +cat generator + Simple usage +------------------------------------------------------------------------------- +Generators.tests.cpp:<line number> +............................................................................... + +Generators.tests.cpp:<line number>: PASSED: + REQUIRE( input < 3 ) +with expansion: + 2 < 3 + +------------------------------------------------------------------------------- +cat generator + Used in map +------------------------------------------------------------------------------- +Generators.tests.cpp:<line number> +............................................................................... + +Generators.tests.cpp:<line number>: PASSED: + REQUIRE( input % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +cat generator + Used in map +------------------------------------------------------------------------------- +Generators.tests.cpp:<line number> +............................................................................... + +Generators.tests.cpp:<line number>: PASSED: + REQUIRE( input % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +cat generator + Used in map +------------------------------------------------------------------------------- +Generators.tests.cpp:<line number> +............................................................................... + +Generators.tests.cpp:<line number>: PASSED: + REQUIRE( input % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +cat generator + Used in map +------------------------------------------------------------------------------- +Generators.tests.cpp:<line number> +............................................................................... + +Generators.tests.cpp:<line number>: PASSED: + REQUIRE( input % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +cat generator + Used in map +------------------------------------------------------------------------------- +Generators.tests.cpp:<line number> +............................................................................... + +Generators.tests.cpp:<line number>: PASSED: + REQUIRE( input % 2 == 0 ) +with expansion: + 0 == 0 + ------------------------------------------------------------------------------- checkedElse ------------------------------------------------------------------------------- @@ -19372,6 +19542,6 @@ Misc.tests.cpp:<line number> Misc.tests.cpp:<line number>: PASSED: =============================================================================== -test cases: 437 | 317 passed | 96 failed | 6 skipped | 18 failed as expected -assertions: 2311 | 2110 passed | 158 failed | 43 failed as expected +test cases: 439 | 319 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2331 | 2130 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt index 05d6eb6c..4d0bd8f4 100644 --- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt @@ -3909,6 +3909,80 @@ Matchers.tests.cpp:<line number>: PASSED: with expansion: true +------------------------------------------------------------------------------- +ConcatGenerator + Cat support single-generator construction +------------------------------------------------------------------------------- +GeneratorsImpl.tests.cpp:<line number> +............................................................................... + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.get() == 1 ) +with expansion: + 1 == 1 + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE_FALSE( c.next() ) +with expansion: + !false + +------------------------------------------------------------------------------- +ConcatGenerator + Iterating over multiple generators +------------------------------------------------------------------------------- +GeneratorsImpl.tests.cpp:<line number> +............................................................................... + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.get() == i + 1 ) +with expansion: + 1 == 1 + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.get() == i + 1 ) +with expansion: + 2 == 2 + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.get() == i + 1 ) +with expansion: + 3 == 3 + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.get() == i + 1 ) +with expansion: + 4 == 4 + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE( c.get() == 5 ) +with expansion: + 5 == 5 + +GeneratorsImpl.tests.cpp:<line number>: PASSED: + REQUIRE_FALSE( c.next() ) +with expansion: + !false + ------------------------------------------------------------------------------- Contains string matcher ------------------------------------------------------------------------------- @@ -16433,6 +16507,102 @@ Tricky.tests.cpp:<line number>: PASSED: with expansion: 0x<hex digits> != 0 +------------------------------------------------------------------------------- +cat generator + Simple usage +------------------------------------------------------------------------------- +Generators.tests.cpp:<line number> +............................................................................... + +Generators.tests.cpp:<line number>: PASSED: + REQUIRE( input < 3 ) +with expansion: + 0 < 3 + +------------------------------------------------------------------------------- +cat generator + Simple usage +------------------------------------------------------------------------------- +Generators.tests.cpp:<line number> +............................................................................... + +Generators.tests.cpp:<line number>: PASSED: + REQUIRE( input < 3 ) +with expansion: + 1 < 3 + +------------------------------------------------------------------------------- +cat generator + Simple usage +------------------------------------------------------------------------------- +Generators.tests.cpp:<line number> +............................................................................... + +Generators.tests.cpp:<line number>: PASSED: + REQUIRE( input < 3 ) +with expansion: + 2 < 3 + +------------------------------------------------------------------------------- +cat generator + Used in map +------------------------------------------------------------------------------- +Generators.tests.cpp:<line number> +............................................................................... + +Generators.tests.cpp:<line number>: PASSED: + REQUIRE( input % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +cat generator + Used in map +------------------------------------------------------------------------------- +Generators.tests.cpp:<line number> +............................................................................... + +Generators.tests.cpp:<line number>: PASSED: + REQUIRE( input % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +cat generator + Used in map +------------------------------------------------------------------------------- +Generators.tests.cpp:<line number> +............................................................................... + +Generators.tests.cpp:<line number>: PASSED: + REQUIRE( input % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +cat generator + Used in map +------------------------------------------------------------------------------- +Generators.tests.cpp:<line number> +............................................................................... + +Generators.tests.cpp:<line number>: PASSED: + REQUIRE( input % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +cat generator + Used in map +------------------------------------------------------------------------------- +Generators.tests.cpp:<line number> +............................................................................... + +Generators.tests.cpp:<line number>: PASSED: + REQUIRE( input % 2 == 0 ) +with expansion: + 0 == 0 + ------------------------------------------------------------------------------- checkedElse ------------------------------------------------------------------------------- @@ -19361,6 +19531,6 @@ Misc.tests.cpp:<line number> Misc.tests.cpp:<line number>: PASSED: =============================================================================== -test cases: 437 | 317 passed | 96 failed | 6 skipped | 18 failed as expected -assertions: 2311 | 2110 passed | 158 failed | 43 failed as expected +test cases: 439 | 319 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2331 | 2130 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt index 10523416..d08e4f81 100644 --- a/tests/SelfTest/Baselines/junit.sw.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <testsuitesloose text artifact > - <testsuite name="<exe-name>" errors="17" failures="141" skipped="12" tests="2323" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> + <testsuite name="<exe-name>" errors="17" failures="141" skipped="12" tests="2343" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <properties> <property name="random-seed" value="1"/> <property name="filters" value=""*" ~[!nonportable] ~[!benchmark] ~[approvals]"/> @@ -501,6 +501,9 @@ at Message.tests.cpp:<line number> <testcase classname="<exe-name>.global" name="Composed matchers shortcircuit" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Composed matchers shortcircuit/MatchAllOf" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Composed matchers shortcircuit/MatchAnyOf" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="ConcatGenerator" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="ConcatGenerator/Cat support single-generator construction" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="ConcatGenerator/Iterating over multiple generators" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Contains string matcher" time="{duration}" status="run"> <failure message="testStringForMatching(), ContainsSubstring( "not there", Catch::CaseSensitive::No )" type="CHECK_THAT"> FAILED: @@ -1993,6 +1996,9 @@ at Skip.tests.cpp:<line number> <testcase classname="<exe-name>.global" name="benchmark function call/without chronometer" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="benchmark function call/with chronometer" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="boolean member" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="cat generator" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="cat generator/Simple usage" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="cat generator/Used in map" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="checkedElse" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="checkedElse, failing" time="{duration}" status="run"> <failure message="testCheckedElse( false )" type="REQUIRE"> diff --git a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt index 2199b7f7..5d7dce1d 100644 --- a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <testsuites> - <testsuite name="<exe-name>" errors="17" failures="141" skipped="12" tests="2323" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> + <testsuite name="<exe-name>" errors="17" failures="141" skipped="12" tests="2343" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <properties> <property name="random-seed" value="1"/> <property name="filters" value=""*" ~[!nonportable] ~[!benchmark] ~[approvals]"/> @@ -500,6 +500,9 @@ at Message.tests.cpp:<line number> <testcase classname="<exe-name>.global" name="Composed matchers shortcircuit" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Composed matchers shortcircuit/MatchAllOf" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Composed matchers shortcircuit/MatchAnyOf" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="ConcatGenerator" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="ConcatGenerator/Cat support single-generator construction" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="ConcatGenerator/Iterating over multiple generators" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Contains string matcher" time="{duration}" status="run"> <failure message="testStringForMatching(), ContainsSubstring( "not there", Catch::CaseSensitive::No )" type="CHECK_THAT"> FAILED: @@ -1992,6 +1995,9 @@ at Skip.tests.cpp:<line number> <testcase classname="<exe-name>.global" name="benchmark function call/without chronometer" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="benchmark function call/with chronometer" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="boolean member" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="cat generator" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="cat generator/Simple usage" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="cat generator/Used in map" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="checkedElse" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="checkedElse, failing" time="{duration}" status="run"> <failure message="testCheckedElse( false )" type="REQUIRE"> diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt index 27dc2cdd..2c5d4a90 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -145,6 +145,9 @@ at AssertionHandler.tests.cpp:<line number> <testCase name="convertToBits" duration="{duration}"/> </file> <file path="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp"> + <testCase name="ConcatGenerator" duration="{duration}"/> + <testCase name="ConcatGenerator/Cat support single-generator construction" duration="{duration}"/> + <testCase name="ConcatGenerator/Iterating over multiple generators" duration="{duration}"/> <testCase name="Filter generator throws exception for empty generator" duration="{duration}"/> <testCase name="Generators internals" duration="{duration}"/> <testCase name="Generators internals/Single value" duration="{duration}"/> @@ -1242,6 +1245,9 @@ at Generators.tests.cpp:<line number> <testCase name="Generators -- simple/one" duration="{duration}"/> <testCase name="Generators -- simple/two" duration="{duration}"/> <testCase name="Nested generators and captured variables" duration="{duration}"/> + <testCase name="cat generator" duration="{duration}"/> + <testCase name="cat generator/Simple usage" duration="{duration}"/> + <testCase name="cat generator/Used in map" duration="{duration}"/> <testCase name="strlen3" duration="{duration}"/> <testCase name="tables" duration="{duration}"/> </file> diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt index 93e3bcc8..9baa1c15 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt @@ -144,6 +144,9 @@ at AssertionHandler.tests.cpp:<line number> <testCase name="convertToBits" duration="{duration}"/> </file> <file path="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp"> + <testCase name="ConcatGenerator" duration="{duration}"/> + <testCase name="ConcatGenerator/Cat support single-generator construction" duration="{duration}"/> + <testCase name="ConcatGenerator/Iterating over multiple generators" duration="{duration}"/> <testCase name="Filter generator throws exception for empty generator" duration="{duration}"/> <testCase name="Generators internals" duration="{duration}"/> <testCase name="Generators internals/Single value" duration="{duration}"/> @@ -1241,6 +1244,9 @@ at Generators.tests.cpp:<line number> <testCase name="Generators -- simple/one" duration="{duration}"/> <testCase name="Generators -- simple/two" duration="{duration}"/> <testCase name="Nested generators and captured variables" duration="{duration}"/> + <testCase name="cat generator" duration="{duration}"/> + <testCase name="cat generator/Simple usage" duration="{duration}"/> + <testCase name="cat generator/Used in map" duration="{duration}"/> <testCase name="strlen3" duration="{duration}"/> <testCase name="tables" duration="{duration}"/> </file> diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index 0b5e1c91..5804c06a 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -980,6 +980,30 @@ ok {test-number} - matcher.match( 1 ) for: true ok {test-number} - first.matchCalled for: true # Composed matchers shortcircuit ok {test-number} - !second.matchCalled for: true +# ConcatGenerator +ok {test-number} - c.get() == 1 for: 1 == 1 +# ConcatGenerator +ok {test-number} - !(c.next()) for: !false +# ConcatGenerator +ok {test-number} - c.get() == i + 1 for: 1 == 1 +# ConcatGenerator +ok {test-number} - c.next() for: true +# ConcatGenerator +ok {test-number} - c.get() == i + 1 for: 2 == 2 +# ConcatGenerator +ok {test-number} - c.next() for: true +# ConcatGenerator +ok {test-number} - c.get() == i + 1 for: 3 == 3 +# ConcatGenerator +ok {test-number} - c.next() for: true +# ConcatGenerator +ok {test-number} - c.get() == i + 1 for: 4 == 4 +# ConcatGenerator +ok {test-number} - c.next() for: true +# ConcatGenerator +ok {test-number} - c.get() == 5 for: 5 == 5 +# ConcatGenerator +ok {test-number} - !(c.next()) for: !false # Contains string matcher not ok {test-number} - testStringForMatching(), ContainsSubstring( "not there", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" contains: "not there" (case insensitive) # Contains string matcher @@ -3933,6 +3957,22 @@ ok {test-number} - model.finished == 0 for: 0 == 0 ok {test-number} - called == 1 for: 1 == 1 # boolean member ok {test-number} - obj.prop != 0 for: 0x<hex digits> != 0 +# cat generator +ok {test-number} - input < 3 for: 0 < 3 +# cat generator +ok {test-number} - input < 3 for: 1 < 3 +# cat generator +ok {test-number} - input < 3 for: 2 < 3 +# cat generator +ok {test-number} - input % 2 == 0 for: 0 == 0 +# cat generator +ok {test-number} - input % 2 == 0 for: 0 == 0 +# cat generator +ok {test-number} - input % 2 == 0 for: 0 == 0 +# cat generator +ok {test-number} - input % 2 == 0 for: 0 == 0 +# cat generator +ok {test-number} - input % 2 == 0 for: 0 == 0 # checkedElse ok {test-number} - flag for: true # checkedElse @@ -4641,5 +4681,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2323 +1..2343 diff --git a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt index de5c68fb..85e5a226 100644 --- a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt @@ -978,6 +978,30 @@ ok {test-number} - matcher.match( 1 ) for: true ok {test-number} - first.matchCalled for: true # Composed matchers shortcircuit ok {test-number} - !second.matchCalled for: true +# ConcatGenerator +ok {test-number} - c.get() == 1 for: 1 == 1 +# ConcatGenerator +ok {test-number} - !(c.next()) for: !false +# ConcatGenerator +ok {test-number} - c.get() == i + 1 for: 1 == 1 +# ConcatGenerator +ok {test-number} - c.next() for: true +# ConcatGenerator +ok {test-number} - c.get() == i + 1 for: 2 == 2 +# ConcatGenerator +ok {test-number} - c.next() for: true +# ConcatGenerator +ok {test-number} - c.get() == i + 1 for: 3 == 3 +# ConcatGenerator +ok {test-number} - c.next() for: true +# ConcatGenerator +ok {test-number} - c.get() == i + 1 for: 4 == 4 +# ConcatGenerator +ok {test-number} - c.next() for: true +# ConcatGenerator +ok {test-number} - c.get() == 5 for: 5 == 5 +# ConcatGenerator +ok {test-number} - !(c.next()) for: !false # Contains string matcher not ok {test-number} - testStringForMatching(), ContainsSubstring( "not there", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" contains: "not there" (case insensitive) # Contains string matcher @@ -3926,6 +3950,22 @@ ok {test-number} - model.finished == 0 for: 0 == 0 ok {test-number} - called == 1 for: 1 == 1 # boolean member ok {test-number} - obj.prop != 0 for: 0x<hex digits> != 0 +# cat generator +ok {test-number} - input < 3 for: 0 < 3 +# cat generator +ok {test-number} - input < 3 for: 1 < 3 +# cat generator +ok {test-number} - input < 3 for: 2 < 3 +# cat generator +ok {test-number} - input % 2 == 0 for: 0 == 0 +# cat generator +ok {test-number} - input % 2 == 0 for: 0 == 0 +# cat generator +ok {test-number} - input % 2 == 0 for: 0 == 0 +# cat generator +ok {test-number} - input % 2 == 0 for: 0 == 0 +# cat generator +ok {test-number} - input % 2 == 0 for: 0 == 0 # checkedElse ok {test-number} - flag for: true # checkedElse @@ -4630,5 +4670,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2323 +1..2343 diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt index 45e97905..6705806c 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt @@ -303,6 +303,8 @@ ##teamcity[testFinished name='Composed generic matchers shortcircuit' duration="{duration}"] ##teamcity[testStarted name='Composed matchers shortcircuit'] ##teamcity[testFinished name='Composed matchers shortcircuit' duration="{duration}"] +##teamcity[testStarted name='ConcatGenerator'] +##teamcity[testFinished name='ConcatGenerator' duration="{duration}"] ##teamcity[testStarted name='Contains string matcher'] ##teamcity[testFailed name='Contains string matcher' message='Matchers.tests.cpp:<line number>|n...............................................................................|n|nMatchers.tests.cpp:<line number>|nexpression failed|n CHECK_THAT( testStringForMatching(), ContainsSubstring( "not there", Catch::CaseSensitive::No ) )|nwith expansion:|n "this string contains |'abc|' as a substring" contains: "not there" (case insensitive)|n'] ##teamcity[testFailed name='Contains string matcher' message='Matchers.tests.cpp:<line number>|nexpression failed|n CHECK_THAT( testStringForMatching(), ContainsSubstring( "STRING" ) )|nwith expansion:|n "this string contains |'abc|' as a substring" contains: "STRING"|n'] @@ -818,6 +820,8 @@ ##teamcity[testFinished name='benchmark function call' duration="{duration}"] ##teamcity[testStarted name='boolean member'] ##teamcity[testFinished name='boolean member' duration="{duration}"] +##teamcity[testStarted name='cat generator'] +##teamcity[testFinished name='cat generator' duration="{duration}"] ##teamcity[testStarted name='checkedElse'] ##teamcity[testFinished name='checkedElse' duration="{duration}"] ##teamcity[testStarted name='checkedElse, failing'] diff --git a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt index 787bd222..80d53df2 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt @@ -303,6 +303,8 @@ ##teamcity[testFinished name='Composed generic matchers shortcircuit' duration="{duration}"] ##teamcity[testStarted name='Composed matchers shortcircuit'] ##teamcity[testFinished name='Composed matchers shortcircuit' duration="{duration}"] +##teamcity[testStarted name='ConcatGenerator'] +##teamcity[testFinished name='ConcatGenerator' duration="{duration}"] ##teamcity[testStarted name='Contains string matcher'] ##teamcity[testFailed name='Contains string matcher' message='Matchers.tests.cpp:<line number>|n...............................................................................|n|nMatchers.tests.cpp:<line number>|nexpression failed|n CHECK_THAT( testStringForMatching(), ContainsSubstring( "not there", Catch::CaseSensitive::No ) )|nwith expansion:|n "this string contains |'abc|' as a substring" contains: "not there" (case insensitive)|n'] ##teamcity[testFailed name='Contains string matcher' message='Matchers.tests.cpp:<line number>|nexpression failed|n CHECK_THAT( testStringForMatching(), ContainsSubstring( "STRING" ) )|nwith expansion:|n "this string contains |'abc|' as a substring" contains: "STRING"|n'] @@ -818,6 +820,8 @@ ##teamcity[testFinished name='benchmark function call' duration="{duration}"] ##teamcity[testStarted name='boolean member'] ##teamcity[testFinished name='boolean member' duration="{duration}"] +##teamcity[testStarted name='cat generator'] +##teamcity[testFinished name='cat generator' duration="{duration}"] ##teamcity[testStarted name='checkedElse'] ##teamcity[testFinished name='checkedElse' duration="{duration}"] ##teamcity[testStarted name='checkedElse, failing'] diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index 95a7cb2f..b719f1a0 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -4376,6 +4376,111 @@ C </Section> <OverallResult success="true" skips="0"/> </TestCase> + <TestCase name="ConcatGenerator" tags="[concat][generators]" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Section name="Cat support single-generator construction" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.get() == 1 + </Original> + <Expanded> + 1 == 1 + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE_FALSE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + !(c.next()) + </Original> + <Expanded> + !false + </Expanded> + </Expression> + <OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <Section name="Iterating over multiple generators" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.get() == i + 1 + </Original> + <Expanded> + 1 == 1 + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.next() + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.get() == i + 1 + </Original> + <Expanded> + 2 == 2 + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.next() + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.get() == i + 1 + </Original> + <Expanded> + 3 == 3 + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.next() + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.get() == i + 1 + </Original> + <Expanded> + 4 == 4 + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.next() + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.get() == 5 + </Original> + <Expanded> + 5 == 5 + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE_FALSE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + !(c.next()) + </Original> + <Expanded> + !false + </Expanded> + </Expression> + <OverallResults successes="10" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <OverallResult success="true" skips="0"/> + </TestCase> <TestCase name="Contains string matcher" tags="[.][failing][matchers]" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" > <Expression success="false" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" > <Original> @@ -19155,6 +19260,97 @@ Approx( 1.23999999999999999 ) </Expression> <OverallResult success="true" skips="0"/> </TestCase> + <TestCase name="cat generator" tags="[concat][generators]" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Section name="Simple usage" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Original> + input < 3 + </Original> + <Expanded> + 0 < 3 + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <Section name="Simple usage" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Original> + input < 3 + </Original> + <Expanded> + 1 < 3 + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <Section name="Simple usage" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Original> + input < 3 + </Original> + <Expanded> + 2 < 3 + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <Section name="Used in map" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Original> + input % 2 == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <Section name="Used in map" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Original> + input % 2 == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <Section name="Used in map" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Original> + input % 2 == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <Section name="Used in map" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Original> + input % 2 == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <Section name="Used in map" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Original> + input % 2 == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <OverallResult success="true" skips="0"/> + </TestCase> <TestCase name="checkedElse" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" > <Expression success="true" type="CHECKED_ELSE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" > <Original> @@ -22416,6 +22612,6 @@ Approx( -1.95996398454005449 ) </Section> <OverallResult success="true" skips="0"/> </TestCase> - <OverallResults successes="2110" failures="158" expectedFailures="43" skips="12"/> - <OverallResultsCases successes="317" failures="96" expectedFailures="18" skips="6"/> + <OverallResults successes="2130" failures="158" expectedFailures="43" skips="12"/> + <OverallResultsCases successes="319" failures="96" expectedFailures="18" skips="6"/> </Catch2TestRun> diff --git a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt index 68ae54fe..051f9a82 100644 --- a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt @@ -4376,6 +4376,111 @@ C </Section> <OverallResult success="true" skips="0"/> </TestCase> + <TestCase name="ConcatGenerator" tags="[concat][generators]" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Section name="Cat support single-generator construction" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.get() == 1 + </Original> + <Expanded> + 1 == 1 + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE_FALSE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + !(c.next()) + </Original> + <Expanded> + !false + </Expanded> + </Expression> + <OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <Section name="Iterating over multiple generators" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.get() == i + 1 + </Original> + <Expanded> + 1 == 1 + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.next() + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.get() == i + 1 + </Original> + <Expanded> + 2 == 2 + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.next() + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.get() == i + 1 + </Original> + <Expanded> + 3 == 3 + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.next() + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.get() == i + 1 + </Original> + <Expanded> + 4 == 4 + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.next() + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + c.get() == 5 + </Original> + <Expanded> + 5 == 5 + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE_FALSE" filename="tests/<exe-name>/IntrospectiveTests/GeneratorsImpl.tests.cpp" > + <Original> + !(c.next()) + </Original> + <Expanded> + !false + </Expanded> + </Expression> + <OverallResults successes="10" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <OverallResult success="true" skips="0"/> + </TestCase> <TestCase name="Contains string matcher" tags="[.][failing][matchers]" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" > <Expression success="false" type="CHECK_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" > <Original> @@ -19155,6 +19260,97 @@ Approx( 1.23999999999999999 ) </Expression> <OverallResult success="true" skips="0"/> </TestCase> + <TestCase name="cat generator" tags="[concat][generators]" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Section name="Simple usage" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Original> + input < 3 + </Original> + <Expanded> + 0 < 3 + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <Section name="Simple usage" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Original> + input < 3 + </Original> + <Expanded> + 1 < 3 + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <Section name="Simple usage" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Original> + input < 3 + </Original> + <Expanded> + 2 < 3 + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <Section name="Used in map" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Original> + input % 2 == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <Section name="Used in map" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Original> + input % 2 == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <Section name="Used in map" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Original> + input % 2 == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <Section name="Used in map" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Original> + input % 2 == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <Section name="Used in map" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Generators.tests.cpp" > + <Original> + input % 2 == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0" skipped="false"/> + </Section> + <OverallResult success="true" skips="0"/> + </TestCase> <TestCase name="checkedElse" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" > <Expression success="true" type="CHECKED_ELSE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" > <Original> @@ -22415,6 +22611,6 @@ Approx( -1.95996398454005449 ) </Section> <OverallResult success="true" skips="0"/> </TestCase> - <OverallResults successes="2110" failures="158" expectedFailures="43" skips="12"/> - <OverallResultsCases successes="317" failures="96" expectedFailures="18" skips="6"/> + <OverallResults successes="2130" failures="158" expectedFailures="43" skips="12"/> + <OverallResultsCases successes="319" failures="96" expectedFailures="18" skips="6"/> </Catch2TestRun> diff --git a/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp b/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp index c044547d..0ba4ab43 100644 --- a/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp @@ -85,7 +85,7 @@ TEST_CASE("Generators internals", "[generators][internals]") { filter([](int) { return false; }, values({ 1, 2, 3 })), Catch::GeneratorException); } - + // Non-trivial usage SECTION("Out-of-line predicates are copied into the generator") { auto evilNumber = Catch::Detail::make_unique<int>(2); @@ -586,3 +586,21 @@ TEST_CASE("from_range(container) supports ADL begin/end and arrays", "[generator } } + +TEST_CASE( "ConcatGenerator", "[generators][concat]" ) { + using namespace Catch::Generators; + SECTION( "Cat support single-generator construction" ) { + ConcatGenerator<int> c( value( 1 ) ); + REQUIRE( c.get() == 1 ); + REQUIRE_FALSE( c.next() ); + } + SECTION( "Iterating over multiple generators" ) { + ConcatGenerator<int> c( value( 1 ), values( { 2, 3, 4 } ), value( 5 ) ); + for ( int i = 0; i < 4; ++i ) { + REQUIRE( c.get() == i + 1 ); + REQUIRE( c.next() ); + } + REQUIRE( c.get() == 5 ); + REQUIRE_FALSE( c.next() ); + } +} diff --git a/tests/SelfTest/UsageTests/Generators.tests.cpp b/tests/SelfTest/UsageTests/Generators.tests.cpp index f04cf4f0..b03192cf 100644 --- a/tests/SelfTest/UsageTests/Generators.tests.cpp +++ b/tests/SelfTest/UsageTests/Generators.tests.cpp @@ -321,3 +321,16 @@ TEST_CASE( "GENERATE can combine literals and generators", "[generators]" ) { random( -100, 100 ) ) ) ); REQUIRE( i % 2 == 0 ); } + +TEST_CASE( "cat generator", "[generators][concat]" ) { + SECTION("Simple usage") { + const int input = GENERATE( cat( value( 0 ) ), cat( value( 1 ), value( 2 ) ) ); + REQUIRE( input < 3 ); + } + SECTION( "Used in map" ) { + const int input = GENERATE( + map( []( int i ) { return i * 2; }, + cat( value( 1 ), take( 4, random( 10, 10'000'000 ) ) ) ) ); + REQUIRE( input % 2 == 0 ); + } +}