diff --git a/docs/generators.md b/docs/generators.md index 40b42004..340ff7c5 100644 --- a/docs/generators.md +++ b/docs/generators.md @@ -1,50 +1,125 @@ # Data Generators -_Generators are currently considered an experimental feature and their -API can change between versions freely._ - Data generators (also known as _data driven/parametrized test cases_) let you reuse the same set of assertions across different input values. In Catch2, this means that they respect the ordering and nesting -of the `TEST_CASE` and `SECTION` macros. - -How does combining generators and test cases work might be better -explained by an example: +of the `TEST_CASE` and `SECTION` macros, and their nested sections +are run once per each value in a generator. +This is best explained with an example: ```cpp TEST_CASE("Generators") { - auto i = GENERATE( range(1, 11) ); - - SECTION( "Some section" ) { - auto j = GENERATE( range( 11, 21 ) ); - REQUIRE(i < j); + auto i = GENERATE(1, 2, 3); + SECTION("one") { + auto j = GENERATE( -3, -2, -1 ); + REQUIRE(j < i); } } ``` -the assertion will be checked 100 times, because there are 10 possible -values for `i` (1, 2, ..., 10) and for each of them, there are 10 possible -values for `j` (11, 12, ..., 20). +The assertion in this test case will be run 9 times, because there +are 3 possible values for `i` (1, 2, and 3) and there are 3 possible +values for `j` (-3, -2, and -1). + + +There are 2 parts to generators in Catch2, the `GENERATE` macro together +with the already provided generators, and the `IGenerator` interface +that allows users to implement their own generators. + +## Provided generators + +Catch2's provided generator functionality consists of three parts, + +* `GENERATE` macro, that serves to integrate generator expression with +a test case, +* 2 fundamental generators + * `ValueGenerator` -- contains only single element + * `ValuesGenerator` -- contains multiple elements +* 4 generic generators that modify other generators + * `FilterGenerator` -- filters out elements from a generator + for which the predicate returns "false" + * `TakeGenerator` -- takes first `n` elements from a generator + * `RepeatGenerator` -- repeats output from a generator `n` times + * `MapGenerator` -- returns the result of applying `Func` + on elements from a different generator + +The generators also have associated helper functions that infer their +type, making their usage much nicer. These are + +* `value(T&&)` for `ValueGenerator` +* `values(std::initializer_list)` for `ValuesGenerator` +* `filter(predicate, GeneratorWrapper&&)` for `FilterGenerator` +* `take(count, GeneratorWrapper&&)` for `TakeGenerator` +* `repeat(repeats, GeneratorWrapper&&)` for `RepeatGenerator` +* `map(func, GeneratorWrapper&&)` for `MapGenerator` (map `T` to `T`) +* `map(func, GeneratorWrapper&&)` for `MapGenerator` (map `U` to `T`) + +And can be used as shown in the example below to create a generator +that returns 100 odd random number: -You can also combine multiple generators by concatenation: ```cpp -static int square(int x) { return x * x; } -TEST_CASE("Generators 2") { - auto i = GENERATE(0, 1, -1, range(-20, -10), range(10, 20)); - CAPTURE(i); - REQUIRE(square(i) >= 0); +TEST_CASE("Generating random ints", "[example][generator]") { + SECTION("Deducing functions") { + auto i = GENERATE(take(100, filter([](int i) { return i % 2 == 1; }, random(-100, 100)))); + REQUIRE(i > -100); + REQUIRE(i < 100); + REQUIRE(i % 2 == 1); + } } ``` -This will call `square` with arguments `0`, `1`, `-1`, `-20`, ..., `-11`, -`10`, ..., `19`. +_Note that `random` is currently not a part of the first-party generators_. ----------- -Because of the experimental nature of the current Generator implementation, -we won't list all of the first-party generators in Catch2. Instead you -should look at our current usage tests in -[projects/SelfTest/UsageTests/Generators.tests.cpp](/projects/SelfTest/UsageTests/Generators.tests.cpp). -For implementing your own generators, you can look at their implementation in -[include/internal/catch_generators.hpp](/include/internal/catch_generators.hpp). +Apart from registering generators with Catch2, the `GENERATE` macro has +one more purpose, and that is to provide simple way of generating trivial +generators, as seen in the first example on this page, where we used it +as `auto i = GENERATE(1, 2, 3);`. This usage converted each of the three +literals into a single `ValueGenerator` and then placed them all in +a special generator that concatenates other generators. It can also be +used with other generators as arguments, such as `auto i = GENERATE(0, 2, +take(100, random(300, 3000)));`. This is useful e.g. if you know that +specific inputs are problematic and want to test them separately/first. + +**For safety reasons, you cannot use variables inside the `GENERATE` macro.** + +You can also override the inferred type by using `as` as the first +argument to the macro. This can be useful when dealing with string literals, +if you want them to come out as `std::string`: + +```cpp +TEST_CASE("type conversion", "[generators]") { + auto str = GENERATE(as{}, "a", "bb", "ccc");` + REQUIRE(str.size() > 0); +} +``` + +## Generator interface + +You can also implement your own generators, by deriving from the +`IGenerator` interface: + +```cpp +template +struct IGenerator : GeneratorUntypedBase { + // via GeneratorUntypedBase: + // Attempts to move the generator to the next element. + // Returns true if successful (and thus has another element that can be read) + virtual bool next() = 0; + + // Precondition: + // The generator is either freshly constructed or the last call to next() returned true + virtual T const& get() const = 0; +}; +``` + +However, to be able to use your custom generator inside `GENERATE`, it +will need to be wrapped inside a `GeneratorWrapper`. +`GeneratorWrapper` is a value wrapper around a +`std::unique_ptr>`. + +For full example of implementing your own generator, look into Catch2's +examples, specifically +[Generators: Create your own generator](../examples/300-Gen-OwnGenerator.cpp). + diff --git a/docs/list-of-examples.md b/docs/list-of-examples.md index 5b538da0..c1aa78a1 100644 --- a/docs/list-of-examples.md +++ b/docs/list-of-examples.md @@ -14,6 +14,9 @@ - Report: [TeamCity reporter](../examples/207-Rpt-TeamCityReporter.cpp) - Listener: [Listeners](../examples/210-Evt-EventListeners.cpp) - Configuration: [Provide your own output streams](../examples/231-Cfg-OutputStreams.cpp) +- Generators: [Create your own generator](../examples/300-Gen-OwnGenerator.cpp) +- Generators: [Use variables in generator expressions](../examples/310-Gen-VariablesInGenerators.cpp) + ## Planned diff --git a/examples/300-Gen-OwnGenerator.cpp b/examples/300-Gen-OwnGenerator.cpp new file mode 100644 index 00000000..c8b6a65d --- /dev/null +++ b/examples/300-Gen-OwnGenerator.cpp @@ -0,0 +1,59 @@ +// 300-Gen-OwnGenerator.cpp +// Shows how to define a custom generator. + +// Specifically we will implement a random number generator for integers +// It will have infinite capacity and settable lower/upper bound + +#include + +#include + +// This class shows how to implement a simple generator for Catch tests +class RandomIntGenerator : public Catch::Generators::IGenerator { + std::minstd_rand m_rand; + std::uniform_int_distribution<> m_dist; + int current_number; +public: + + RandomIntGenerator(int low, int high): + m_rand(std::random_device{}()), + m_dist(low, high) + { + static_cast(next()); + } + + int const& get() const override; + bool next() override { + current_number = m_dist(m_rand); + return true; + } +}; + +// Avoids -Wweak-vtables +int const& RandomIntGenerator::get() const { + return current_number; +} + +// This helper function provides a nicer UX when instantiating the generator +// Notice that it returns an instance of GeneratorWrapper, which +// is a value-wrapper around std::unique_ptr>. +Catch::Generators::GeneratorWrapper random(int low, int high) { + return Catch::Generators::GeneratorWrapper(std::unique_ptr>(new RandomIntGenerator(low, high))); +} + +// The two sections in this test case are equivalent, but the first one +// is much more readable/nicer to use +TEST_CASE("Generating random ints", "[example][generator]") { + SECTION("Nice UX") { + auto i = GENERATE(take(100, random(-100, 100))); + REQUIRE(i >= -100); + REQUIRE(i <= 100); + } + SECTION("Creating the random generator directly") { + auto i = GENERATE(take(100, GeneratorWrapper(std::unique_ptr>(new RandomIntGenerator(-100, 100))))); + REQUIRE(i >= -100); + REQUIRE(i <= 100); + } +} + +// Compiling and running this file will result in 400 successful assertions diff --git a/examples/310-Gen-VariablesInGenerators.cpp b/examples/310-Gen-VariablesInGenerators.cpp new file mode 100644 index 00000000..96840bbb --- /dev/null +++ b/examples/310-Gen-VariablesInGenerators.cpp @@ -0,0 +1,72 @@ +// 310-Gen-VariablesInGenerator.cpp +// Shows how to use variables when creating generators. + +// Note that using variables inside generators is dangerous and should +// be done only if you know what you are doing, because the generators +// _WILL_ outlive the variables -- thus they should be either captured +// by value directly, or copied by the generators during construction. + +#include + +#include + +// Lets start by implementing a parametrizable double generator +class RandomDoubleGenerator : public Catch::Generators::IGenerator { + std::minstd_rand m_rand; + std::uniform_real_distribution<> m_dist; + double current_number; +public: + + RandomDoubleGenerator(double low, double high): + m_rand(std::random_device{}()), + m_dist(low, high) + { + static_cast(next()); + } + + double const& get() const override; + bool next() override { + current_number = m_dist(m_rand); + return true; + } +}; + +// Avoids -Wweak-vtables +double const& RandomDoubleGenerator::get() const { + return current_number; +} + + +// Also provide a nice shortcut for creating the generator +Catch::Generators::GeneratorWrapper random(double low, double high) { + return Catch::Generators::GeneratorWrapper(std::unique_ptr>(new RandomDoubleGenerator(low, high))); +} + + +TEST_CASE("Generate random doubles across different ranges", + "[generator][example][advanced]") { + // Workaround for old libstdc++ + using record = std::tuple; + // Set up 3 ranges to generate numbers from + auto r = GENERATE(table({ + record{3, 4}, + record{-4, -3}, + record{10, 1000} + })); + + // This will not compile (intentionally), because it accesses a variable + // auto number = GENERATE(take(50, random(r.first, r.second))); + + // We have to manually register the generators instead + // Notice that we are using value capture in the lambda, to avoid lifetime issues + auto number = Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, + [=]{ + using namespace Catch::Generators; + return makeGenerators(take(50, random(std::get<0>(r), std::get<1>(r)))); + } + ); + REQUIRE(std::abs(number) > 0); +} + +// Compiling and running this file will result in 150 successful assertions + diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 2551e77c..0eea900d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -44,6 +44,8 @@ set( SOURCES_IDIOMATIC_TESTS 110-Fix-ClassFixture.cpp 120-Bdd-ScenarioGivenWhenThen.cpp 210-Evt-EventListeners.cpp + 300-Gen-OwnGenerator.cpp + 310-Gen-VariablesInGenerators.cpp ) # main-s for reporter-specific test sources: diff --git a/include/internal/catch_generators.cpp b/include/internal/catch_generators.cpp index 786da736..5fbe2d23 100644 --- a/include/internal/catch_generators.cpp +++ b/include/internal/catch_generators.cpp @@ -16,35 +16,17 @@ namespace Catch { IGeneratorTracker::~IGeneratorTracker() {} +const char* GeneratorException::what() const noexcept { + return m_msg; +} + namespace Generators { - GeneratorBase::~GeneratorBase() {} - - std::vector randomiseIndices( size_t selectionSize, size_t sourceSize ) { - - assert( selectionSize <= sourceSize ); - std::vector indices; - indices.reserve( selectionSize ); - std::uniform_int_distribution uid( 0, sourceSize-1 ); - - std::set seen; - // !TBD: improve this algorithm - while( indices.size() < selectionSize ) { - auto index = uid( rng() ); - if( seen.insert( index ).second ) - indices.push_back( index ); - } - return indices; - } + GeneratorUntypedBase::~GeneratorUntypedBase() {} auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& { return getResultCapture().acquireGeneratorTracker( lineInfo ); } - template<> - auto all() -> Generator { - return range( std::numeric_limits::min(), std::numeric_limits::max() ); - } - } // namespace Generators } // namespace Catch diff --git a/include/internal/catch_generators.hpp b/include/internal/catch_generators.hpp index 4a446be1..f7dbc8c7 100644 --- a/include/internal/catch_generators.hpp +++ b/include/internal/catch_generators.hpp @@ -16,8 +16,21 @@ #include #include +#include namespace Catch { + +class GeneratorException : public std::exception { + const char* const m_msg = ""; + +public: + GeneratorException(const char* msg): + m_msg(msg) + {} + + const char* what() const noexcept override final; +}; + namespace Generators { // !TBD move this into its own location? @@ -29,202 +42,312 @@ namespace Generators { } template - struct IGenerator { - virtual ~IGenerator() {} - virtual auto get( size_t index ) const -> T = 0; + struct IGenerator : GeneratorUntypedBase { + virtual ~IGenerator() = default; + + // Returns the current element of the generator + // + // \Precondition The generator is either freshly constructed, + // or the last call to `next()` returned true + virtual T const& get() const = 0; + using type = T; }; template - class SingleValueGenerator : public IGenerator { + class SingleValueGenerator final : public IGenerator { T m_value; public: - SingleValueGenerator( T const& value ) : m_value( value ) {} + SingleValueGenerator(T const& value) : m_value( value ) {} + SingleValueGenerator(T&& value) : m_value(std::move(value)) {} - auto get( size_t ) const -> T override { + T const& get() const override { return m_value; } + bool next() override { + return false; + } }; template - class FixedValuesGenerator : public IGenerator { + class FixedValuesGenerator final : public IGenerator { std::vector m_values; - + size_t m_idx = 0; public: FixedValuesGenerator( std::initializer_list values ) : m_values( values ) {} - auto get( size_t index ) const -> T override { - return m_values[index]; + T const& get() const override { + return m_values[m_idx]; + } + bool next() override { + ++m_idx; + return m_idx < m_values.size(); } }; - template - class RangeGenerator : public IGenerator { - T const m_first; - T const m_last; - - public: - RangeGenerator( T const& first, T const& last ) : m_first( first ), m_last( last ) { - assert( m_last > m_first ); - } - - auto get( size_t index ) const -> T override { - // ToDo:: introduce a safe cast to catch potential overflows - return static_cast(m_first+index); - } - }; - - - template - struct NullGenerator : IGenerator { - auto get( size_t ) const -> T override { - CATCH_INTERNAL_ERROR("A Null Generator is always empty"); - } - }; - - template - class Generator { + template + class GeneratorWrapper final { std::unique_ptr> m_generator; - size_t m_size; - public: - Generator( size_t size, std::unique_ptr> generator ) - : m_generator( std::move( generator ) ), - m_size( size ) + GeneratorWrapper(std::unique_ptr> generator): + m_generator(std::move(generator)) {} - - auto size() const -> size_t { return m_size; } - auto operator[]( size_t index ) const -> T { - assert( index < m_size ); - return m_generator->get( index ); + T const& get() const { + return m_generator->get(); + } + bool next() { + return m_generator->next(); } }; - std::vector randomiseIndices( size_t selectionSize, size_t sourceSize ); + template + GeneratorWrapper value(T&& value) { + return GeneratorWrapper(pf::make_unique>(std::forward(value))); + } + template + GeneratorWrapper values(std::initializer_list values) { + return GeneratorWrapper(pf::make_unique>(values)); + } template - class GeneratorRandomiser : public IGenerator { - Generator m_baseGenerator; + class Generators : public IGenerator { + std::vector> m_generators; + size_t m_current = 0; - std::vector m_indices; - public: - GeneratorRandomiser( Generator&& baseGenerator, size_t numberOfItems ) - : m_baseGenerator( std::move( baseGenerator ) ), - m_indices( randomiseIndices( numberOfItems, m_baseGenerator.size() ) ) - {} - - auto get( size_t index ) const -> T override { - return m_baseGenerator[m_indices[index]]; + void populate(GeneratorWrapper&& generator) { + m_generators.emplace_back(std::move(generator)); } - }; - - template - struct RequiresASpecialisationFor; - - template - auto all() -> Generator { return RequiresASpecialisationFor(); } - - template<> - auto all() -> Generator; - - - template - auto range( T const& first, T const& last ) -> Generator { - return Generator( (last-first), pf::make_unique>( first, last ) ); - } - - template - auto random( T const& first, T const& last ) -> Generator { - auto gen = range( first, last ); - auto size = gen.size(); - - return Generator( size, pf::make_unique>( std::move( gen ), size ) ); - } - template - auto random( size_t size ) -> Generator { - return Generator( size, pf::make_unique>( all(), size ) ); - } - - template - auto values( std::initializer_list values ) -> Generator { - return Generator( values.size(), pf::make_unique>( values ) ); - } - template - auto value( T const& val ) -> Generator { - return Generator( 1, pf::make_unique>( val ) ); - } - - template - auto as() -> Generator { - return Generator( 0, pf::make_unique>() ); - } - - template - auto table( std::initializer_list>&& tuples ) -> Generator> { - return values>( std::forward>>( tuples ) ); - } - - - template - struct Generators : GeneratorBase { - std::vector> m_generators; - - using type = T; - - Generators() : GeneratorBase( 0 ) {} - - void populate( T&& val ) { - m_size += 1; - m_generators.emplace_back( value( std::move( val ) ) ); + void populate(T&& val) { + m_generators.emplace_back(value(std::move(val))); } template - void populate( U&& val ) { - populate( T( std::move( val ) ) ); + void populate(U&& val) { + populate(T(std::move(val))); } - void populate( Generator&& generator ) { - m_size += generator.size(); - m_generators.emplace_back( std::move( generator ) ); - } - template - void populate( U&& valueOrGenerator, Gs... moreGenerators ) { - populate( std::forward( valueOrGenerator ) ); - populate( std::forward( moreGenerators )... ); + void populate(U&& valueOrGenerator, Gs... moreGenerators) { + populate(std::forward(valueOrGenerator)); + populate(std::forward(moreGenerators)...); } - auto operator[]( size_t index ) const -> T { - size_t sizes = 0; - for( auto const& gen : m_generators ) { - auto localIndex = index-sizes; - sizes += gen.size(); - if( index < sizes ) - return gen[localIndex]; + public: + template + Generators(Gs... moreGenerators) { + m_generators.reserve(sizeof...(Gs)); + populate(std::forward(moreGenerators)...); + } + + T const& get() const override { + return m_generators[m_current].get(); + } + + bool next() override { + if (m_current >= m_generators.size()) { + return false; } - CATCH_INTERNAL_ERROR("Index '" << index << "' is out of range (" << sizes << ')'); + const bool current_status = m_generators[m_current].next(); + if (!current_status) { + ++m_current; + } + return m_current < m_generators.size(); } }; + + template + GeneratorWrapper> table( std::initializer_list::type...>> tuples ) { + return values>( tuples ); + } + + // Tag type to signal that a generator sequence should convert arguments to a specific type + template + struct as {}; + template - auto makeGenerators( Generator&& generator, Gs... moreGenerators ) -> Generators { - Generators generators; - generators.m_generators.reserve( 1+sizeof...(Gs) ); - generators.populate( std::move( generator ), std::forward( moreGenerators )... ); - return generators; + auto makeGenerators( GeneratorWrapper&& generator, Gs... moreGenerators ) -> Generators { + return Generators(std::move(generator), std::forward(moreGenerators)...); } template - auto makeGenerators( Generator&& generator ) -> Generators { - Generators generators; - generators.populate( std::move( generator ) ); - return generators; + auto makeGenerators( GeneratorWrapper&& generator ) -> Generators { + return Generators(std::move(generator)); } template auto makeGenerators( T&& val, Gs... moreGenerators ) -> Generators { return makeGenerators( value( std::forward( val ) ), std::forward( moreGenerators )... ); } template - auto makeGenerators( U&& val, Gs... moreGenerators ) -> Generators { + auto makeGenerators( as, U&& val, Gs... moreGenerators ) -> Generators { return makeGenerators( value( T( std::forward( val ) ) ), std::forward( moreGenerators )... ); } + template + class TakeGenerator : public IGenerator { + GeneratorWrapper m_generator; + size_t m_returned = 0; + size_t m_target; + public: + TakeGenerator(size_t target, GeneratorWrapper&& generator): + m_generator(std::move(generator)), + m_target(target) + { + assert(target != 0 && "Empty generators are not allowed"); + } + T const& get() const override { + return m_generator.get(); + } + bool next() override { + ++m_returned; + if (m_returned >= m_target) { + return false; + } + + const auto success = m_generator.next(); + // If the underlying generator does not contain enough values + // then we cut short as well + if (!success) { + m_returned = m_target; + } + return success; + } + }; + + template + GeneratorWrapper take(size_t target, GeneratorWrapper&& generator) { + return GeneratorWrapper(pf::make_unique>(target, std::move(generator))); + } + + + template + class FilterGenerator : public IGenerator { + GeneratorWrapper m_generator; + Predicate m_predicate; + public: + template + FilterGenerator(P&& pred, GeneratorWrapper&& generator): + m_generator(std::move(generator)), + m_predicate(std::forward

(pred)) + { + if (!m_predicate(m_generator.get())) { + // It might happen that there are no values that pass the + // filter. In that case we throw an exception. + auto has_initial_value = next(); + if (!has_initial_value) { + Catch::throw_exception(GeneratorException("No valid value found in filtered generator")); + } + } + } + + T const& get() const override { + return m_generator.get(); + } + + bool next() override { + bool success = m_generator.next(); + if (!success) { + return false; + } + while (!m_predicate(m_generator.get()) && (success = m_generator.next()) == true); + return success; + } + }; + + + template + GeneratorWrapper filter(Predicate&& pred, GeneratorWrapper&& generator) { + return GeneratorWrapper(std::unique_ptr>(pf::make_unique>(std::forward(pred), std::move(generator)))); + } + + template + class RepeatGenerator : public IGenerator { + GeneratorWrapper m_generator; + mutable std::vector m_returned; + size_t m_target_repeats; + size_t m_current_repeat = 0; + size_t m_repeat_index = 0; + public: + RepeatGenerator(size_t repeats, GeneratorWrapper&& generator): + m_generator(std::move(generator)), + m_target_repeats(repeats) + { + assert(m_target_repeats > 0 && "Repeat generator must repeat at least once"); + } + + T const& get() const override { + if (m_current_repeat == 0) { + m_returned.push_back(m_generator.get()); + return m_returned.back(); + } + return m_returned[m_repeat_index]; + } + + bool next() override { + // There are 2 basic cases: + // 1) We are still reading the generator + // 2) We are reading our own cache + + // In the first case, we need to poke the underlying generator. + // If it happily moves, we are left in that state, otherwise it is time to start reading from our cache + if (m_current_repeat == 0) { + const auto success = m_generator.next(); + if (!success) { + ++m_current_repeat; + } + return m_current_repeat < m_target_repeats; + } + + // In the second case, we need to move indices forward and check that we haven't run up against the end + ++m_repeat_index; + if (m_repeat_index == m_returned.size()) { + m_repeat_index = 0; + ++m_current_repeat; + } + return m_current_repeat < m_target_repeats; + } + }; + + template + GeneratorWrapper repeat(size_t repeats, GeneratorWrapper&& generator) { + return GeneratorWrapper(pf::make_unique>(repeats, std::move(generator))); + } + + template + class MapGenerator : public IGenerator { + // TBD: provide static assert for mapping function, for friendly error message + GeneratorWrapper m_generator; + Func m_function; + // To avoid returning dangling reference, we have to save the values + T m_cache; + public: + template + MapGenerator(F2&& function, GeneratorWrapper&& generator) : + m_generator(std::move(generator)), + m_function(std::forward(function)), + m_cache(m_function(m_generator.get())) + {} + + T const& get() const override { + return m_cache; + } + bool next() override { + const auto success = m_generator.next(); + if (success) { + m_cache = m_function(m_generator.get()); + } + return success; + } + }; + + template + GeneratorWrapper map(Func&& function, GeneratorWrapper&& generator) { + return GeneratorWrapper( + pf::make_unique>(std::forward(function), std::move(generator)) + ); + } + template + GeneratorWrapper map(Func&& function, GeneratorWrapper&& generator) { + return GeneratorWrapper( + pf::make_unique>(std::forward(function), std::move(generator)) + ); + } auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker&; @@ -232,15 +355,16 @@ namespace Generators { // Note: The type after -> is weird, because VS2015 cannot parse // the expression used in the typedef inside, when it is in // return type. Yeah, ¯\_(ツ)_/¯ - auto generate( SourceLineInfo const& lineInfo, L const& generatorExpression ) -> decltype(std::declval()[0]) { + auto generate( SourceLineInfo const& lineInfo, L const& generatorExpression ) -> decltype(std::declval().get()) { using UnderlyingType = typename decltype(generatorExpression())::type; IGeneratorTracker& tracker = acquireGeneratorTracker( lineInfo ); - if( !tracker.hasGenerator() ) - tracker.setGenerator( pf::make_unique>( generatorExpression() ) ); + if (!tracker.hasGenerator()) { + tracker.setGenerator(pf::make_unique>(generatorExpression())); + } - auto const& generator = static_cast const&>( *tracker.getGenerator() ); - return generator[tracker.getIndex()]; + auto const& generator = static_cast const&>( *tracker.getGenerator() ); + return generator.get(); } } // namespace Generators diff --git a/include/internal/catch_interfaces_generatortracker.h b/include/internal/catch_interfaces_generatortracker.h index 2cf6269e..c1b1391f 100644 --- a/include/internal/catch_interfaces_generatortracker.h +++ b/include/internal/catch_interfaces_generatortracker.h @@ -13,16 +13,17 @@ namespace Catch { namespace Generators { - class GeneratorBase { - protected: - size_t m_size = 0; - + class GeneratorUntypedBase { public: - GeneratorBase( size_t size ) : m_size( size ) {} - virtual ~GeneratorBase(); - auto size() const -> size_t { return m_size; } + GeneratorUntypedBase() = default; + virtual ~GeneratorUntypedBase(); + // Attempts to move the generator to the next element + // + // Returns true iff the move succeeded (and a valid element + // can be retrieved). + virtual bool next() = 0; }; - using GeneratorBasePtr = std::unique_ptr; + using GeneratorBasePtr = std::unique_ptr; } // namespace Generators @@ -31,7 +32,6 @@ namespace Catch { virtual auto hasGenerator() const -> bool = 0; virtual auto getGenerator() const -> Generators::GeneratorBasePtr const& = 0; virtual void setGenerator( Generators::GeneratorBasePtr&& generator ) = 0; - virtual auto getIndex() const -> std::size_t = 0; }; } // namespace Catch diff --git a/include/internal/catch_run_context.cpp b/include/internal/catch_run_context.cpp index ffdd2ebb..77dcaae0 100644 --- a/include/internal/catch_run_context.cpp +++ b/include/internal/catch_run_context.cpp @@ -14,7 +14,6 @@ namespace Catch { namespace Generators { struct GeneratorTracker : TestCaseTracking::TrackerBase, IGeneratorTracker { - size_t m_index = static_cast( -1 ); GeneratorBasePtr m_generator; GeneratorTracker( TestCaseTracking::NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) @@ -28,7 +27,7 @@ namespace Catch { ITracker& currentTracker = ctx.currentTracker(); if( TestCaseTracking::ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) { assert( childTracker ); - assert( childTracker->isIndexTracker() ); + assert( childTracker->isGeneratorTracker() ); tracker = std::static_pointer_cast( childTracker ); } else { @@ -37,28 +36,24 @@ namespace Catch { } if( !ctx.completedCycle() && !tracker->isComplete() ) { - if( tracker->m_runState != ExecutingChildren && tracker->m_runState != NeedsAnotherRun ) - tracker->moveNext(); tracker->open(); } return *tracker; } - void moveNext() { - m_index++; - m_children.clear(); - } - // TrackerBase interface - bool isIndexTracker() const override { return true; } + bool isGeneratorTracker() const override { return true; } auto hasGenerator() const -> bool override { return !!m_generator; } void close() override { TrackerBase::close(); - if( m_runState == CompletedSuccessfully && m_index < m_generator->size()-1 ) + // Generator interface only finds out if it has another item on atual move + if (m_runState == CompletedSuccessfully && m_generator->next()) { + m_children.clear(); m_runState = Executing; + } } // IGeneratorTracker interface @@ -68,9 +63,6 @@ namespace Catch { void setGenerator( GeneratorBasePtr&& generator ) override { m_generator = std::move( generator ); } - auto getIndex() const -> size_t override { - return m_index; - } }; GeneratorTracker::~GeneratorTracker() {} } diff --git a/include/internal/catch_test_case_tracker.cpp b/include/internal/catch_test_case_tracker.cpp index f6e5ac08..210f2730 100644 --- a/include/internal/catch_test_case_tracker.cpp +++ b/include/internal/catch_test_case_tracker.cpp @@ -121,7 +121,7 @@ namespace TestCaseTracking { } bool TrackerBase::isSectionTracker() const { return false; } - bool TrackerBase::isIndexTracker() const { return false; } + bool TrackerBase::isGeneratorTracker() const { return false; } void TrackerBase::open() { m_runState = Executing; diff --git a/include/internal/catch_test_case_tracker.h b/include/internal/catch_test_case_tracker.h index e873d788..17276001 100644 --- a/include/internal/catch_test_case_tracker.h +++ b/include/internal/catch_test_case_tracker.h @@ -54,7 +54,7 @@ namespace TestCaseTracking { // Debug/ checking virtual bool isSectionTracker() const = 0; - virtual bool isIndexTracker() const = 0; + virtual bool isGeneratorTracker() const = 0; }; class TrackerContext { @@ -120,7 +120,7 @@ namespace TestCaseTracking { void openChild() override; bool isSectionTracker() const override; - bool isIndexTracker() const override; + bool isGeneratorTracker() const override; void open(); diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt index 72627f1f..615e368b 100644 --- a/projects/SelfTest/Baselines/compact.sw.approved.txt +++ b/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -57,106 +57,87 @@ Tricky.tests.cpp:: passed: !is_true::value for: true Tricky.tests.cpp:: passed: !!is_true::value for: true Tricky.tests.cpp:: passed: is_true::value for: true Tricky.tests.cpp:: passed: !(is_true::value) for: !false -Generators.tests.cpp:: passed: x < y for: 1 < 101 -Generators.tests.cpp:: passed: x < y for: 1 < 102 -Generators.tests.cpp:: passed: x < y for: 1 < 103 -Generators.tests.cpp:: passed: x < y for: 1 < 104 -Generators.tests.cpp:: passed: x < y for: 1 < 105 -Generators.tests.cpp:: passed: x < y for: 1 < 106 -Generators.tests.cpp:: passed: x < y for: 1 < 107 -Generators.tests.cpp:: passed: x < y for: 1 < 108 -Generators.tests.cpp:: passed: x < y for: 1 < 109 -Generators.tests.cpp:: passed: x < y for: 1 < 110 -Generators.tests.cpp:: passed: x < y for: 2 < 101 -Generators.tests.cpp:: passed: x < y for: 2 < 102 -Generators.tests.cpp:: passed: x < y for: 2 < 103 -Generators.tests.cpp:: passed: x < y for: 2 < 104 -Generators.tests.cpp:: passed: x < y for: 2 < 105 -Generators.tests.cpp:: passed: x < y for: 2 < 106 -Generators.tests.cpp:: passed: x < y for: 2 < 107 -Generators.tests.cpp:: passed: x < y for: 2 < 108 -Generators.tests.cpp:: passed: x < y for: 2 < 109 -Generators.tests.cpp:: passed: x < y for: 2 < 110 -Generators.tests.cpp:: passed: x < y for: 3 < 101 -Generators.tests.cpp:: passed: x < y for: 3 < 102 -Generators.tests.cpp:: passed: x < y for: 3 < 103 -Generators.tests.cpp:: passed: x < y for: 3 < 104 -Generators.tests.cpp:: passed: x < y for: 3 < 105 -Generators.tests.cpp:: passed: x < y for: 3 < 106 -Generators.tests.cpp:: passed: x < y for: 3 < 107 -Generators.tests.cpp:: passed: x < y for: 3 < 108 -Generators.tests.cpp:: passed: x < y for: 3 < 109 -Generators.tests.cpp:: passed: x < y for: 3 < 110 -Generators.tests.cpp:: passed: x < y for: 4 < 101 -Generators.tests.cpp:: passed: x < y for: 4 < 102 -Generators.tests.cpp:: passed: x < y for: 4 < 103 -Generators.tests.cpp:: passed: x < y for: 4 < 104 -Generators.tests.cpp:: passed: x < y for: 4 < 105 -Generators.tests.cpp:: passed: x < y for: 4 < 106 -Generators.tests.cpp:: passed: x < y for: 4 < 107 -Generators.tests.cpp:: passed: x < y for: 4 < 108 -Generators.tests.cpp:: passed: x < y for: 4 < 109 -Generators.tests.cpp:: passed: x < y for: 4 < 110 -Generators.tests.cpp:: passed: x < y for: 5 < 101 -Generators.tests.cpp:: passed: x < y for: 5 < 102 -Generators.tests.cpp:: passed: x < y for: 5 < 103 -Generators.tests.cpp:: passed: x < y for: 5 < 104 -Generators.tests.cpp:: passed: x < y for: 5 < 105 -Generators.tests.cpp:: passed: x < y for: 5 < 106 -Generators.tests.cpp:: passed: x < y for: 5 < 107 -Generators.tests.cpp:: passed: x < y for: 5 < 108 -Generators.tests.cpp:: passed: x < y for: 5 < 109 -Generators.tests.cpp:: passed: x < y for: 5 < 110 -Generators.tests.cpp:: passed: x < y for: 6 < 101 -Generators.tests.cpp:: passed: x < y for: 6 < 102 -Generators.tests.cpp:: passed: x < y for: 6 < 103 -Generators.tests.cpp:: passed: x < y for: 6 < 104 -Generators.tests.cpp:: passed: x < y for: 6 < 105 -Generators.tests.cpp:: passed: x < y for: 6 < 106 -Generators.tests.cpp:: passed: x < y for: 6 < 107 -Generators.tests.cpp:: passed: x < y for: 6 < 108 -Generators.tests.cpp:: passed: x < y for: 6 < 109 -Generators.tests.cpp:: passed: x < y for: 6 < 110 -Generators.tests.cpp:: passed: x < y for: 7 < 101 -Generators.tests.cpp:: passed: x < y for: 7 < 102 -Generators.tests.cpp:: passed: x < y for: 7 < 103 -Generators.tests.cpp:: passed: x < y for: 7 < 104 -Generators.tests.cpp:: passed: x < y for: 7 < 105 -Generators.tests.cpp:: passed: x < y for: 7 < 106 -Generators.tests.cpp:: passed: x < y for: 7 < 107 -Generators.tests.cpp:: passed: x < y for: 7 < 108 -Generators.tests.cpp:: passed: x < y for: 7 < 109 -Generators.tests.cpp:: passed: x < y for: 7 < 110 -Generators.tests.cpp:: passed: x < y for: 8 < 101 -Generators.tests.cpp:: passed: x < y for: 8 < 102 -Generators.tests.cpp:: passed: x < y for: 8 < 103 -Generators.tests.cpp:: passed: x < y for: 8 < 104 -Generators.tests.cpp:: passed: x < y for: 8 < 105 -Generators.tests.cpp:: passed: x < y for: 8 < 106 -Generators.tests.cpp:: passed: x < y for: 8 < 107 -Generators.tests.cpp:: passed: x < y for: 8 < 108 -Generators.tests.cpp:: passed: x < y for: 8 < 109 -Generators.tests.cpp:: passed: x < y for: 8 < 110 -Generators.tests.cpp:: passed: x < y for: 9 < 101 -Generators.tests.cpp:: passed: x < y for: 9 < 102 -Generators.tests.cpp:: passed: x < y for: 9 < 103 -Generators.tests.cpp:: passed: x < y for: 9 < 104 -Generators.tests.cpp:: passed: x < y for: 9 < 105 -Generators.tests.cpp:: passed: x < y for: 9 < 106 -Generators.tests.cpp:: passed: x < y for: 9 < 107 -Generators.tests.cpp:: passed: x < y for: 9 < 108 -Generators.tests.cpp:: passed: x < y for: 9 < 109 -Generators.tests.cpp:: passed: x < y for: 9 < 110 -Generators.tests.cpp:: passed: x < y for: 10 < 101 -Generators.tests.cpp:: passed: x < y for: 10 < 102 -Generators.tests.cpp:: passed: x < y for: 10 < 103 -Generators.tests.cpp:: passed: x < y for: 10 < 104 -Generators.tests.cpp:: passed: x < y for: 10 < 105 -Generators.tests.cpp:: passed: x < y for: 10 < 106 -Generators.tests.cpp:: passed: x < y for: 10 < 107 -Generators.tests.cpp:: passed: x < y for: 10 < 108 -Generators.tests.cpp:: passed: x < y for: 10 < 109 -Generators.tests.cpp:: passed: x < y for: 10 < 110 +Generators.tests.cpp:: passed: x < y for: 1 < 4 +Generators.tests.cpp:: passed: y < z for: 4 < 7 +Generators.tests.cpp:: passed: x < z for: 1 < 7 +Generators.tests.cpp:: passed: x < y for: 1 < 4 +Generators.tests.cpp:: passed: y < z for: 4 < 8 +Generators.tests.cpp:: passed: x < z for: 1 < 8 +Generators.tests.cpp:: passed: x < y for: 1 < 4 +Generators.tests.cpp:: passed: y < z for: 4 < 9 +Generators.tests.cpp:: passed: x < z for: 1 < 9 +Generators.tests.cpp:: passed: x < y for: 1 < 5 +Generators.tests.cpp:: passed: y < z for: 5 < 7 +Generators.tests.cpp:: passed: x < z for: 1 < 7 +Generators.tests.cpp:: passed: x < y for: 1 < 5 +Generators.tests.cpp:: passed: y < z for: 5 < 8 +Generators.tests.cpp:: passed: x < z for: 1 < 8 +Generators.tests.cpp:: passed: x < y for: 1 < 5 +Generators.tests.cpp:: passed: y < z for: 5 < 9 +Generators.tests.cpp:: passed: x < z for: 1 < 9 +Generators.tests.cpp:: passed: x < y for: 1 < 6 +Generators.tests.cpp:: passed: y < z for: 6 < 7 +Generators.tests.cpp:: passed: x < z for: 1 < 7 +Generators.tests.cpp:: passed: x < y for: 1 < 6 +Generators.tests.cpp:: passed: y < z for: 6 < 8 +Generators.tests.cpp:: passed: x < z for: 1 < 8 +Generators.tests.cpp:: passed: x < y for: 1 < 6 +Generators.tests.cpp:: passed: y < z for: 6 < 9 +Generators.tests.cpp:: passed: x < z for: 1 < 9 +Generators.tests.cpp:: passed: x < y for: 2 < 4 +Generators.tests.cpp:: passed: y < z for: 4 < 7 +Generators.tests.cpp:: passed: x < z for: 2 < 7 +Generators.tests.cpp:: passed: x < y for: 2 < 4 +Generators.tests.cpp:: passed: y < z for: 4 < 8 +Generators.tests.cpp:: passed: x < z for: 2 < 8 +Generators.tests.cpp:: passed: x < y for: 2 < 4 +Generators.tests.cpp:: passed: y < z for: 4 < 9 +Generators.tests.cpp:: passed: x < z for: 2 < 9 +Generators.tests.cpp:: passed: x < y for: 2 < 5 +Generators.tests.cpp:: passed: y < z for: 5 < 7 +Generators.tests.cpp:: passed: x < z for: 2 < 7 +Generators.tests.cpp:: passed: x < y for: 2 < 5 +Generators.tests.cpp:: passed: y < z for: 5 < 8 +Generators.tests.cpp:: passed: x < z for: 2 < 8 +Generators.tests.cpp:: passed: x < y for: 2 < 5 +Generators.tests.cpp:: passed: y < z for: 5 < 9 +Generators.tests.cpp:: passed: x < z for: 2 < 9 +Generators.tests.cpp:: passed: x < y for: 2 < 6 +Generators.tests.cpp:: passed: y < z for: 6 < 7 +Generators.tests.cpp:: passed: x < z for: 2 < 7 +Generators.tests.cpp:: passed: x < y for: 2 < 6 +Generators.tests.cpp:: passed: y < z for: 6 < 8 +Generators.tests.cpp:: passed: x < z for: 2 < 8 +Generators.tests.cpp:: passed: x < y for: 2 < 6 +Generators.tests.cpp:: passed: y < z for: 6 < 9 +Generators.tests.cpp:: passed: x < z for: 2 < 9 +Generators.tests.cpp:: passed: x < y for: 3 < 4 +Generators.tests.cpp:: passed: y < z for: 4 < 7 +Generators.tests.cpp:: passed: x < z for: 3 < 7 +Generators.tests.cpp:: passed: x < y for: 3 < 4 +Generators.tests.cpp:: passed: y < z for: 4 < 8 +Generators.tests.cpp:: passed: x < z for: 3 < 8 +Generators.tests.cpp:: passed: x < y for: 3 < 4 +Generators.tests.cpp:: passed: y < z for: 4 < 9 +Generators.tests.cpp:: passed: x < z for: 3 < 9 +Generators.tests.cpp:: passed: x < y for: 3 < 5 +Generators.tests.cpp:: passed: y < z for: 5 < 7 +Generators.tests.cpp:: passed: x < z for: 3 < 7 +Generators.tests.cpp:: passed: x < y for: 3 < 5 +Generators.tests.cpp:: passed: y < z for: 5 < 8 +Generators.tests.cpp:: passed: x < z for: 3 < 8 +Generators.tests.cpp:: passed: x < y for: 3 < 5 +Generators.tests.cpp:: passed: y < z for: 5 < 9 +Generators.tests.cpp:: passed: x < z for: 3 < 9 +Generators.tests.cpp:: passed: x < y for: 3 < 6 +Generators.tests.cpp:: passed: y < z for: 6 < 7 +Generators.tests.cpp:: passed: x < z for: 3 < 7 +Generators.tests.cpp:: passed: x < y for: 3 < 6 +Generators.tests.cpp:: passed: y < z for: 6 < 8 +Generators.tests.cpp:: passed: x < z for: 3 < 8 +Generators.tests.cpp:: passed: x < y for: 3 < 6 +Generators.tests.cpp:: passed: y < z for: 6 < 9 +Generators.tests.cpp:: passed: x < z for: 3 < 9 Class.tests.cpp:: failed: s == "world" for: "hello" == "world" Class.tests.cpp:: passed: s == "hello" for: "hello" == "hello" Class.tests.cpp:: failed: Template_Fixture_2::m_a.size() == 1 for: 0 == 1 @@ -418,48 +399,98 @@ Matchers.tests.cpp:: passed: WithinAbs(1.f, 0.f) Matchers.tests.cpp:: passed: WithinAbs(1.f, -1.f), std::domain_error Matchers.tests.cpp:: passed: WithinULP(1.f, 0) Matchers.tests.cpp:: passed: WithinULP(1.f, -1), std::domain_error -Generators.tests.cpp:: passed: with 2 messages: 'i := "a"' and 'j := 8' -Generators.tests.cpp:: passed: with 2 messages: 'i := "a"' and 'j := 9' -Generators.tests.cpp:: passed: with 2 messages: 'i := "a"' and 'j := 10' -Generators.tests.cpp:: passed: with 2 messages: 'i := "a"' and 'j := 2' -Generators.tests.cpp:: passed: with 2 messages: 'i := "a"' and 'j := 3.141' -Generators.tests.cpp:: passed: with 2 messages: 'i := "a"' and 'j := 1.379' -Generators.tests.cpp:: passed: with 2 messages: 'i := "b"' and 'j := 8' -Generators.tests.cpp:: passed: with 2 messages: 'i := "b"' and 'j := 9' -Generators.tests.cpp:: passed: with 2 messages: 'i := "b"' and 'j := 10' -Generators.tests.cpp:: passed: with 2 messages: 'i := "b"' and 'j := 2' -Generators.tests.cpp:: passed: with 2 messages: 'i := "b"' and 'j := 3.141' -Generators.tests.cpp:: passed: with 2 messages: 'i := "b"' and 'j := 1.379' -Generators.tests.cpp:: passed: with 2 messages: 'i := "c"' and 'j := 8' -Generators.tests.cpp:: passed: with 2 messages: 'i := "c"' and 'j := 9' -Generators.tests.cpp:: passed: with 2 messages: 'i := "c"' and 'j := 10' -Generators.tests.cpp:: passed: with 2 messages: 'i := "c"' and 'j := 2' -Generators.tests.cpp:: passed: with 2 messages: 'i := "c"' and 'j := 3.141' -Generators.tests.cpp:: passed: with 2 messages: 'i := "c"' and 'j := 1.379' -GeneratorsImpl.tests.cpp:: passed: gen.size() == 2 for: 2 == 2 -GeneratorsImpl.tests.cpp:: passed: gen[0] == 1 for: 1 == 1 -GeneratorsImpl.tests.cpp:: passed: gen[1] == 2 for: 2 == 2 -GeneratorsImpl.tests.cpp:: passed: gen.size() == 4 for: 4 == 4 -GeneratorsImpl.tests.cpp:: passed: gen[0] == 3 for: 3 == 3 -GeneratorsImpl.tests.cpp:: passed: gen[1] == 1 for: 1 == 1 -GeneratorsImpl.tests.cpp:: passed: gen[2] == 4 for: 4 == 4 -GeneratorsImpl.tests.cpp:: passed: gen[3] == 1 for: 1 == 1 -GeneratorsImpl.tests.cpp:: passed: gen.size() == 4 for: 4 == 4 -GeneratorsImpl.tests.cpp:: passed: gen[0] == 1 for: 1 == 1 -GeneratorsImpl.tests.cpp:: passed: gen[1] == 2 for: 2 == 2 -GeneratorsImpl.tests.cpp:: passed: gen[2] == 9 for: 9 == 9 -GeneratorsImpl.tests.cpp:: passed: gen[3] == 7 for: 7 == 7 -GeneratorsImpl.tests.cpp:: passed: gen.size() == 2 for: 2 == 2 -GeneratorsImpl.tests.cpp:: passed: gen[0] == 3 for: 3 == 3 -GeneratorsImpl.tests.cpp:: passed: gen[1] == 1 for: 1 == 1 -GeneratorsImpl.tests.cpp:: passed: gen.size() == 2 for: 2 == 2 -GeneratorsImpl.tests.cpp:: passed: gen[0] == 3 for: 3 == 3 -GeneratorsImpl.tests.cpp:: passed: gen[1] == 1 for: 1 == 1 -GeneratorsImpl.tests.cpp:: passed: base->size() == 4 for: 4 == 4 -GeneratorsImpl.tests.cpp:: passed: typed for: 0x -GeneratorsImpl.tests.cpp:: passed: typed->size() == 4 for: 4 == 4 -GeneratorsImpl.tests.cpp:: passed: (*typed)[0] == 7 for: 7 == 7 -GeneratorsImpl.tests.cpp:: passed: (*typed)[3] == 11 for: 11 == 11 +Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 +Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 +Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 +Generators.tests.cpp:: passed: i < 4 for: 1 < 4 +Generators.tests.cpp:: passed: i < 4 for: 2 < 4 +Generators.tests.cpp:: passed: i < 4 for: 3 < 4 +Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 +Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 +Generators.tests.cpp:: passed: i % 2 == 0 for: 0 == 0 +Generators.tests.cpp:: passed: i.size() == 1 for: 1 == 1 +Generators.tests.cpp:: passed: i.size() == 1 for: 1 == 1 +Generators.tests.cpp:: passed: i.size() == 1 for: 1 == 1 +Generators.tests.cpp:: passed: j > 0 for: 1 > 0 +Generators.tests.cpp:: passed: j > 0 for: 2 > 0 +Generators.tests.cpp:: passed: j > 0 for: 3 > 0 +Generators.tests.cpp:: passed: j > 0 for: 1 > 0 +Generators.tests.cpp:: passed: j > 0 for: 2 > 0 +Generators.tests.cpp:: passed: j > 0 for: 3 > 0 +Generators.tests.cpp:: passed: j < i for: -3 < 1 +Generators.tests.cpp:: passed: j < i for: -2 < 1 +Generators.tests.cpp:: passed: j < i for: -1 < 1 +Generators.tests.cpp:: passed: 4u * i > str.size() for: 4 > 1 +Generators.tests.cpp:: passed: 4u * i > str.size() for: 4 > 2 +Generators.tests.cpp:: passed: 4u * i > str.size() for: 4 > 3 +Generators.tests.cpp:: passed: j < i for: -3 < 2 +Generators.tests.cpp:: passed: j < i for: -2 < 2 +Generators.tests.cpp:: passed: j < i for: -1 < 2 +Generators.tests.cpp:: passed: 4u * i > str.size() for: 8 > 1 +Generators.tests.cpp:: passed: 4u * i > str.size() for: 8 > 2 +Generators.tests.cpp:: passed: 4u * i > str.size() for: 8 > 3 +Generators.tests.cpp:: passed: j < i for: -3 < 3 +Generators.tests.cpp:: passed: j < i for: -2 < 3 +Generators.tests.cpp:: passed: j < i for: -1 < 3 +Generators.tests.cpp:: passed: 4u * i > str.size() for: 12 > 1 +Generators.tests.cpp:: passed: 4u * i > str.size() for: 12 > 2 +Generators.tests.cpp:: passed: 4u * i > str.size() for: 12 > 3 +GeneratorsImpl.tests.cpp:: passed: gen.get() == 123 for: 123 == 123 +GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false +GeneratorsImpl.tests.cpp:: passed: gen.get() == 1 for: 1 == 1 +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == 3 for: 3 == 3 +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == 5 for: 5 == 5 +GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false +GeneratorsImpl.tests.cpp:: passed: gen.get() == 1 for: 1 == 1 +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == 5 for: 5 == 5 +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == 2 for: 2 == 2 +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == 4 for: 4 == 4 +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == 0 for: 0 == 0 +GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false +GeneratorsImpl.tests.cpp:: passed: gen.get().size() == 2 for: 2 == 2 +GeneratorsImpl.tests.cpp:: passed: gen.get() == "aa" for: "aa" == "aa" +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == "bb" for: "bb" == "bb" +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == "cc" for: "cc" == "cc" +GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false +GeneratorsImpl.tests.cpp:: passed: gen.get() == 1 for: 1 == 1 +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == 3 for: 3 == 3 +GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false +GeneratorsImpl.tests.cpp:: passed: filter([] (int) { return false; }, value(1)), Catch::GeneratorException +GeneratorsImpl.tests.cpp:: passed: gen.get() == 1 for: 1 == 1 +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == 2 for: 2 == 2 +GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false +GeneratorsImpl.tests.cpp:: passed: gen.get() == 1 for: 1 == 1 +GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false +GeneratorsImpl.tests.cpp:: passed: gen.get() == 2.0 for: 2.0 == 2.0 +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == 4.0 for: 4.0 == 4.0 +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == 6.0 for: 6.0 == 6.0 +GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false +GeneratorsImpl.tests.cpp:: passed: gen.get() == 3 for: 3 == 3 +GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false +GeneratorsImpl.tests.cpp:: passed: gen.get() == 1 for: 1 == 1 +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == 2 for: 2 == 2 +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == 3 for: 3 == 3 +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == 1 for: 1 == 1 +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == 2 for: 2 == 2 +GeneratorsImpl.tests.cpp:: passed: gen.next() for: true +GeneratorsImpl.tests.cpp:: passed: gen.get() == 3 for: 3 == 3 +GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false Approx.tests.cpp:: passed: d >= Approx( 1.22 ) for: 1.23 >= Approx( 1.22 ) Approx.tests.cpp:: passed: d >= Approx( 1.23 ) for: 1.23 >= Approx( 1.23 ) Approx.tests.cpp:: passed: !(d >= Approx( 1.24 )) for: !(1.23 >= Approx( 1.24 )) @@ -1274,6 +1305,10 @@ Generators.tests.cpp:: passed: data.str.size() == data.len for: 3 = Generators.tests.cpp:: passed: data.str.size() == data.len for: 3 == 3 Generators.tests.cpp:: passed: data.str.size() == data.len for: 5 == 5 Generators.tests.cpp:: passed: data.str.size() == data.len for: 4 == 4 +Generators.tests.cpp:: passed: strlen(std::get<0>(data)) == static_cast(std::get<1>(data)) for: 5 == 5 +Generators.tests.cpp:: passed: strlen(std::get<0>(data)) == static_cast(std::get<1>(data)) for: 6 == 6 +Generators.tests.cpp:: passed: strlen(std::get<0>(data)) == static_cast(std::get<1>(data)) for: 5 == 5 +Generators.tests.cpp:: passed: strlen(std::get<0>(data)) == static_cast(std::get<1>(data)) for: 6 == 6 Exception.tests.cpp:: failed: unexpected exception with message: 'Why would you throw a std::string?' Misc.tests.cpp:: passed: result == "\"wide load\"" for: ""wide load"" == ""wide load"" Misc.tests.cpp:: passed: result == "\"wide load\"" for: ""wide load"" == ""wide load"" diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index dff912cf..a9ca0277 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -1170,6 +1170,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 243 | 183 passed | 56 failed | 4 failed as expected -assertions: 1262 | 1126 passed | 115 failed | 21 failed as expected +test cases: 245 | 185 passed | 56 failed | 4 failed as expected +assertions: 1297 | 1161 passed | 115 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 79334630..92a78c57 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -456,7 +456,7 @@ with expansion: !false ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -464,32 +464,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 1 < 101 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 1 < 4 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 1 < 102 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 4 < 7 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 1 < 103 + 1 < 7 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -497,32 +485,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 1 < 104 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 1 < 4 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 1 < 105 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 4 < 8 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 1 < 106 + 1 < 8 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -530,32 +506,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 1 < 107 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 1 < 4 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 1 < 108 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 4 < 9 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 1 < 109 + 1 < 9 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -563,32 +527,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 1 < 110 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 1 < 5 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 2 < 101 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 5 < 7 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 2 < 102 + 1 < 7 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -596,32 +548,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 2 < 103 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 1 < 5 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 2 < 104 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 5 < 8 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 2 < 105 + 1 < 8 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -629,32 +569,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 2 < 106 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 1 < 5 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 2 < 107 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 5 < 9 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 2 < 108 + 1 < 9 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -662,32 +590,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 2 < 109 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 1 < 6 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 2 < 110 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 6 < 7 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 3 < 101 + 1 < 7 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -695,32 +611,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 3 < 102 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 1 < 6 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 3 < 103 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 6 < 8 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 3 < 104 + 1 < 8 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -728,32 +632,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 3 < 105 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 1 < 6 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 3 < 106 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 6 < 9 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 3 < 107 + 1 < 9 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -761,32 +653,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 3 < 108 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 2 < 4 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 3 < 109 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 4 < 7 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 3 < 110 + 2 < 7 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -794,32 +674,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 4 < 101 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 2 < 4 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 4 < 102 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 4 < 8 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 4 < 103 + 2 < 8 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -827,32 +695,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 4 < 104 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 2 < 4 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 4 < 105 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 4 < 9 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 4 < 106 + 2 < 9 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -860,32 +716,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 4 < 107 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 2 < 5 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 4 < 108 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 5 < 7 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 4 < 109 + 2 < 7 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -893,32 +737,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 4 < 110 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 2 < 5 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 5 < 101 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 5 < 8 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 5 < 102 + 2 < 8 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -926,32 +758,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 5 < 103 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 2 < 5 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 5 < 104 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 5 < 9 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 5 < 105 + 2 < 9 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -959,32 +779,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 5 < 106 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 2 < 6 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 5 < 107 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 6 < 7 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 5 < 108 + 2 < 7 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -992,32 +800,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 5 < 109 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 2 < 6 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 5 < 110 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 6 < 8 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 6 < 101 + 2 < 8 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -1025,32 +821,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 6 < 102 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 2 < 6 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 6 < 103 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 6 < 9 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 6 < 104 + 2 < 9 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -1058,32 +842,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 6 < 105 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 3 < 4 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 6 < 106 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 4 < 7 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 6 < 107 + 3 < 7 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -1091,32 +863,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 6 < 108 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 3 < 4 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 6 < 109 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 4 < 8 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 6 < 110 + 3 < 8 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -1124,76 +884,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 7 < 101 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 3 < 4 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 7 < 102 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 7 < 103 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 7 < 104 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 7 < 105 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 7 < 106 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 4 < 9 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 7 < 107 + 3 < 9 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -1201,32 +905,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 7 < 108 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 3 < 5 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 7 < 109 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 5 < 7 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 7 < 110 + 3 < 7 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -1234,43 +926,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 8 < 101 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 8 < 102 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 3 < 5 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 8 < 103 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 5 < 8 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 8 < 104 + 3 < 8 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -1278,32 +947,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 8 < 105 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 3 < 5 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 8 < 106 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 5 < 9 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 8 < 107 + 3 < 9 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -1311,32 +968,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 8 < 108 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 3 < 6 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 8 < 109 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 6 < 7 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 8 < 110 + 3 < 7 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -1344,32 +989,20 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 9 < 101 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 3 < 6 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 9 < 102 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 6 < 8 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 9 < 103 + 3 < 8 ------------------------------------------------------------------------------- -10x10 ints +3x3x3 ints ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... @@ -1377,183 +1010,17 @@ Generators.tests.cpp: Generators.tests.cpp:: PASSED: CHECK( x < y ) with expansion: - 9 < 104 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 3 < 6 Generators.tests.cpp:: PASSED: - CHECK( x < y ) + CHECK( y < z ) with expansion: - 9 < 105 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... + 6 < 9 Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 9 < 106 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 9 < 107 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 9 < 108 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 9 < 109 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 9 < 110 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 10 < 101 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 10 < 102 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 10 < 103 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 10 < 104 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 10 < 105 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 10 < 106 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 10 < 107 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 10 < 108 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) -with expansion: - 10 < 109 - -------------------------------------------------------------------------------- -10x10 ints -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: - CHECK( x < y ) + REQUIRE( x < z ) with expansion: - 10 < 110 + 3 < 9 ------------------------------------------------------------------------------- A METHOD_AS_TEST_CASE based test run that fails @@ -3384,382 +2851,794 @@ Matchers.tests.cpp:: PASSED: REQUIRE_THROWS_AS( WithinULP(1.f, -1), std::domain_error ) ------------------------------------------------------------------------------- -Generators +Generators -- adapters + Filtering by predicate +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +Generators -- adapters + Filtering by predicate +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +Generators -- adapters + Filtering by predicate +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +Generators -- adapters + Shortening a range +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i < 4 ) +with expansion: + 1 < 4 + +------------------------------------------------------------------------------- +Generators -- adapters + Shortening a range +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i < 4 ) +with expansion: + 2 < 4 + +------------------------------------------------------------------------------- +Generators -- adapters + Shortening a range +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i < 4 ) +with expansion: + 3 < 4 + +------------------------------------------------------------------------------- +Generators -- adapters + Transforming elements + Same type +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +Generators -- adapters + Transforming elements + Same type +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +Generators -- adapters + Transforming elements + Same type +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i % 2 == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +Generators -- adapters + Transforming elements + Different type +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i.size() == 1 ) +with expansion: + 1 == 1 + +------------------------------------------------------------------------------- +Generators -- adapters + Transforming elements + Different type +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i.size() == 1 ) +with expansion: + 1 == 1 + +------------------------------------------------------------------------------- +Generators -- adapters + Transforming elements + Different type +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( i.size() == 1 ) +with expansion: + 1 == 1 + +------------------------------------------------------------------------------- +Generators -- adapters + Repeating a generator +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( j > 0 ) +with expansion: + 1 > 0 + +------------------------------------------------------------------------------- +Generators -- adapters + Repeating a generator +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( j > 0 ) +with expansion: + 2 > 0 + +------------------------------------------------------------------------------- +Generators -- adapters + Repeating a generator +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( j > 0 ) +with expansion: + 3 > 0 + +------------------------------------------------------------------------------- +Generators -- adapters + Repeating a generator +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( j > 0 ) +with expansion: + 1 > 0 + +------------------------------------------------------------------------------- +Generators -- adapters + Repeating a generator +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( j > 0 ) +with expansion: + 2 > 0 + +------------------------------------------------------------------------------- +Generators -- adapters + Repeating a generator +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( j > 0 ) +with expansion: + 3 > 0 + +------------------------------------------------------------------------------- +Generators -- simple one ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... Generators.tests.cpp:: PASSED: -with messages: - i := "a" - j := 8 + REQUIRE( j < i ) +with expansion: + -3 < 1 ------------------------------------------------------------------------------- -Generators +Generators -- simple one ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... Generators.tests.cpp:: PASSED: -with messages: - i := "a" - j := 9 + REQUIRE( j < i ) +with expansion: + -2 < 1 ------------------------------------------------------------------------------- -Generators +Generators -- simple one ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... Generators.tests.cpp:: PASSED: -with messages: - i := "a" - j := 10 + REQUIRE( j < i ) +with expansion: + -1 < 1 ------------------------------------------------------------------------------- -Generators - one -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: -with messages: - i := "a" - j := 2 - -------------------------------------------------------------------------------- -Generators +Generators -- simple two ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... Generators.tests.cpp:: PASSED: -with messages: - i := "a" - j := 3.141 + REQUIRE( 4u * i > str.size() ) +with expansion: + 4 > 1 ------------------------------------------------------------------------------- -Generators +Generators -- simple two ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... Generators.tests.cpp:: PASSED: -with messages: - i := "a" - j := 1.379 + REQUIRE( 4u * i > str.size() ) +with expansion: + 4 > 2 ------------------------------------------------------------------------------- -Generators - one -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: -with messages: - i := "b" - j := 8 - -------------------------------------------------------------------------------- -Generators - one -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: -with messages: - i := "b" - j := 9 - -------------------------------------------------------------------------------- -Generators - one -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: -with messages: - i := "b" - j := 10 - -------------------------------------------------------------------------------- -Generators - one -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: -with messages: - i := "b" - j := 2 - -------------------------------------------------------------------------------- -Generators +Generators -- simple two ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... Generators.tests.cpp:: PASSED: -with messages: - i := "b" - j := 3.141 + REQUIRE( 4u * i > str.size() ) +with expansion: + 4 > 3 ------------------------------------------------------------------------------- -Generators +Generators -- simple + one +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( j < i ) +with expansion: + -3 < 2 + +------------------------------------------------------------------------------- +Generators -- simple + one +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( j < i ) +with expansion: + -2 < 2 + +------------------------------------------------------------------------------- +Generators -- simple + one +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( j < i ) +with expansion: + -1 < 2 + +------------------------------------------------------------------------------- +Generators -- simple two ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... Generators.tests.cpp:: PASSED: -with messages: - i := "b" - j := 1.379 + REQUIRE( 4u * i > str.size() ) +with expansion: + 8 > 1 ------------------------------------------------------------------------------- -Generators - one -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: -with messages: - i := "c" - j := 8 - -------------------------------------------------------------------------------- -Generators - one -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: -with messages: - i := "c" - j := 9 - -------------------------------------------------------------------------------- -Generators - one -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: -with messages: - i := "c" - j := 10 - -------------------------------------------------------------------------------- -Generators - one -------------------------------------------------------------------------------- -Generators.tests.cpp: -............................................................................... - -Generators.tests.cpp:: PASSED: -with messages: - i := "c" - j := 2 - -------------------------------------------------------------------------------- -Generators +Generators -- simple two ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... Generators.tests.cpp:: PASSED: -with messages: - i := "c" - j := 3.141 + REQUIRE( 4u * i > str.size() ) +with expansion: + 8 > 2 ------------------------------------------------------------------------------- -Generators +Generators -- simple two ------------------------------------------------------------------------------- Generators.tests.cpp: ............................................................................... Generators.tests.cpp:: PASSED: -with messages: - i := "c" - j := 1.379 + REQUIRE( 4u * i > str.size() ) +with expansion: + 8 > 3 ------------------------------------------------------------------------------- -Generators impl - range +Generators -- simple + one +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( j < i ) +with expansion: + -3 < 3 + +------------------------------------------------------------------------------- +Generators -- simple + one +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( j < i ) +with expansion: + -2 < 3 + +------------------------------------------------------------------------------- +Generators -- simple + one +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( j < i ) +with expansion: + -1 < 3 + +------------------------------------------------------------------------------- +Generators -- simple + two +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( 4u * i > str.size() ) +with expansion: + 12 > 1 + +------------------------------------------------------------------------------- +Generators -- simple + two +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( 4u * i > str.size() ) +with expansion: + 12 > 2 + +------------------------------------------------------------------------------- +Generators -- simple + two +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( 4u * i > str.size() ) +with expansion: + 12 > 3 + +------------------------------------------------------------------------------- +Generators internals + Single value ------------------------------------------------------------------------------- GeneratorsImpl.tests.cpp: ............................................................................... GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen.size() == 2 ) + REQUIRE( gen.get() == 123 ) with expansion: - 2 == 2 + 123 == 123 GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen[0] == 1 ) + REQUIRE_FALSE( gen.next() ) +with expansion: + !false + +------------------------------------------------------------------------------- +Generators internals + Preset values +------------------------------------------------------------------------------- +GeneratorsImpl.tests.cpp: +............................................................................... + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == 1 ) with expansion: 1 == 1 GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen[1] == 2 ) + REQUIRE( gen.next() ) with expansion: - 2 == 2 - -------------------------------------------------------------------------------- -Generators impl - fixed values -------------------------------------------------------------------------------- -GeneratorsImpl.tests.cpp: -............................................................................... + true GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen.size() == 4 ) -with expansion: - 4 == 4 - -GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen[0] == 3 ) + REQUIRE( gen.get() == 3 ) with expansion: 3 == 3 GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen[1] == 1 ) + REQUIRE( gen.next() ) with expansion: - 1 == 1 + true GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen[2] == 4 ) + REQUIRE( gen.get() == 5 ) with expansion: - 4 == 4 + 5 == 5 GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen[3] == 1 ) + REQUIRE_FALSE( gen.next() ) with expansion: - 1 == 1 + !false ------------------------------------------------------------------------------- -Generators impl - combined +Generators internals + Generator combinator ------------------------------------------------------------------------------- GeneratorsImpl.tests.cpp: ............................................................................... GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen.size() == 4 ) -with expansion: - 4 == 4 - -GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen[0] == 1 ) + REQUIRE( gen.get() == 1 ) with expansion: 1 == 1 GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen[1] == 2 ) + REQUIRE( gen.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == 5 ) +with expansion: + 5 == 5 + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == 2 ) with expansion: 2 == 2 GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen[2] == 9 ) + REQUIRE( gen.next() ) with expansion: - 9 == 9 + true GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen[3] == 7 ) + REQUIRE( gen.get() == 4 ) with expansion: - 7 == 7 + 4 == 4 + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == 0 ) +with expansion: + 0 == 0 + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE_FALSE( gen.next() ) +with expansion: + !false ------------------------------------------------------------------------------- -Generators impl - values +Generators internals + Explicitly typed generator sequence ------------------------------------------------------------------------------- GeneratorsImpl.tests.cpp: ............................................................................... GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen.size() == 2 ) + REQUIRE( gen.get().size() == 2 ) with expansion: 2 == 2 GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen[0] == 3 ) + REQUIRE( gen.get() == "aa" ) +with expansion: + "aa" == "aa" + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == "bb" ) +with expansion: + "bb" == "bb" + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == "cc" ) +with expansion: + "cc" == "cc" + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE_FALSE( gen.next() ) +with expansion: + !false + +------------------------------------------------------------------------------- +Generators internals + Filter generator +------------------------------------------------------------------------------- +GeneratorsImpl.tests.cpp: +............................................................................... + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == 1 ) +with expansion: + 1 == 1 + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == 3 ) with expansion: 3 == 3 GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen[1] == 1 ) + REQUIRE_FALSE( gen.next() ) with expansion: - 1 == 1 + !false + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE_THROWS_AS( filter([] (int) { return false; }, value(1)), Catch::GeneratorException ) ------------------------------------------------------------------------------- -Generators impl - values2 +Generators internals + Take generator + Take less ------------------------------------------------------------------------------- GeneratorsImpl.tests.cpp: ............................................................................... GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen.size() == 2 ) + REQUIRE( gen.get() == 1 ) +with expansion: + 1 == 1 + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == 2 ) with expansion: 2 == 2 GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen[0] == 3 ) + REQUIRE_FALSE( gen.next() ) with expansion: - 3 == 3 - -GeneratorsImpl.tests.cpp:: PASSED: - CHECK( gen[1] == 1 ) -with expansion: - 1 == 1 + !false ------------------------------------------------------------------------------- -Generators impl - type erasure +Generators internals + Take generator + Take more ------------------------------------------------------------------------------- GeneratorsImpl.tests.cpp: ............................................................................... GeneratorsImpl.tests.cpp:: PASSED: - CHECK( base->size() == 4 ) + REQUIRE( gen.get() == 1 ) with expansion: - 4 == 4 + 1 == 1 GeneratorsImpl.tests.cpp:: PASSED: - REQUIRE( typed ) + REQUIRE_FALSE( gen.next() ) with expansion: - 0x + !false + +------------------------------------------------------------------------------- +Generators internals + Map +------------------------------------------------------------------------------- +GeneratorsImpl.tests.cpp: +............................................................................... GeneratorsImpl.tests.cpp:: PASSED: - CHECK( typed->size() == 4 ) + REQUIRE( gen.get() == 2.0 ) with expansion: - 4 == 4 + 2.0 == 2.0 GeneratorsImpl.tests.cpp:: PASSED: - CHECK( (*typed)[0] == 7 ) + REQUIRE( gen.next() ) with expansion: - 7 == 7 + true GeneratorsImpl.tests.cpp:: PASSED: - CHECK( (*typed)[3] == 11 ) + REQUIRE( gen.get() == 4.0 ) with expansion: - 11 == 11 + 4.0 == 4.0 + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == 6.0 ) +with expansion: + 6.0 == 6.0 + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE_FALSE( gen.next() ) +with expansion: + !false + +------------------------------------------------------------------------------- +Generators internals + Repeat + Singular repeat +------------------------------------------------------------------------------- +GeneratorsImpl.tests.cpp: +............................................................................... + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == 3 ) +with expansion: + 3 == 3 + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE_FALSE( gen.next() ) +with expansion: + !false + +------------------------------------------------------------------------------- +Generators internals + Repeat + Actual repeat +------------------------------------------------------------------------------- +GeneratorsImpl.tests.cpp: +............................................................................... + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == 1 ) +with expansion: + 1 == 1 + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == 2 ) +with expansion: + 2 == 2 + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == 3 ) +with expansion: + 3 == 3 + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == 1 ) +with expansion: + 1 == 1 + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == 2 ) +with expansion: + 2 == 2 + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.next() ) +with expansion: + true + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE( gen.get() == 3 ) +with expansion: + 3 == 3 + +GeneratorsImpl.tests.cpp:: PASSED: + REQUIRE_FALSE( gen.next() ) +with expansion: + !false ------------------------------------------------------------------------------- Greater-than inequalities with different epsilons @@ -9747,6 +9626,50 @@ Generators.tests.cpp:: PASSED: with expansion: 4 == 4 +------------------------------------------------------------------------------- +tables +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( strlen(std::get<0>(data)) == static_cast(std::get<1>(data)) ) +with expansion: + 5 == 5 + +------------------------------------------------------------------------------- +tables +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( strlen(std::get<0>(data)) == static_cast(std::get<1>(data)) ) +with expansion: + 6 == 6 + +------------------------------------------------------------------------------- +tables +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( strlen(std::get<0>(data)) == static_cast(std::get<1>(data)) ) +with expansion: + 5 == 5 + +------------------------------------------------------------------------------- +tables +------------------------------------------------------------------------------- +Generators.tests.cpp: +............................................................................... + +Generators.tests.cpp:: PASSED: + REQUIRE( strlen(std::get<0>(data)) == static_cast(std::get<1>(data)) ) +with expansion: + 6 == 6 + ------------------------------------------------------------------------------- thrown std::strings are translated ------------------------------------------------------------------------------- @@ -10224,6 +10147,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 243 | 170 passed | 69 failed | 4 failed as expected -assertions: 1276 | 1126 passed | 129 failed | 21 failed as expected +test cases: 245 | 172 passed | 69 failed | 4 failed as expected +assertions: 1311 | 1161 passed | 129 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 17cc8281..a245a37a 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -70,7 +70,7 @@ Condition.tests.cpp: - + Class.tests.cpp: @@ -339,14 +339,23 @@ Message.tests.cpp: - - - - - - - - + + + + + + + + + + + + + + + + + @@ -938,6 +947,7 @@ Tricky.tests.cpp: + Why would you throw a std::string? diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 497d8168..6558d6f2 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -522,157 +522,29 @@ - + x < y - 1 < 101 + 1 < 4 - x < y - - - 1 < 102 - - - - - x < y - - - 1 < 103 - - - - - x < y - - - 1 < 104 - - - - - x < y - - - 1 < 105 - - - - - x < y - - - 1 < 106 - - - - - x < y - - - 1 < 107 - - - - - x < y - - - 1 < 108 - - - - - x < y - - - 1 < 109 - - - - - x < y - - - 1 < 110 - - - - - x < y - - - 2 < 101 - - - - - x < y - - - 2 < 102 - - - - - x < y - - - 2 < 103 - - - - - x < y - - - 2 < 104 - - - - - x < y - - - 2 < 105 - - - - - x < y - - - 2 < 106 - - - - - x < y - - - 2 < 107 - - - - - x < y + y < z - 2 < 108 + 4 < 7 - + - x < y + x < z - 2 < 109 + 1 < 7 @@ -680,23 +552,23 @@ x < y - 2 < 110 + 1 < 4 - x < y + y < z - 3 < 101 + 4 < 8 - + - x < y + x < z - 3 < 102 + 1 < 8 @@ -704,23 +576,23 @@ x < y - 3 < 103 + 1 < 4 - x < y + y < z - 3 < 104 + 4 < 9 - + - x < y + x < z - 3 < 105 + 1 < 9 @@ -728,23 +600,23 @@ x < y - 3 < 106 + 1 < 5 - x < y + y < z - 3 < 107 + 5 < 7 - + - x < y + x < z - 3 < 108 + 1 < 7 @@ -752,23 +624,23 @@ x < y - 3 < 109 + 1 < 5 - x < y + y < z - 3 < 110 + 5 < 8 - + - x < y + x < z - 4 < 101 + 1 < 8 @@ -776,23 +648,23 @@ x < y - 4 < 102 + 1 < 5 - x < y + y < z - 4 < 103 + 5 < 9 - + - x < y + x < z - 4 < 104 + 1 < 9 @@ -800,23 +672,23 @@ x < y - 4 < 105 + 1 < 6 - x < y + y < z - 4 < 106 + 6 < 7 - + - x < y + x < z - 4 < 107 + 1 < 7 @@ -824,23 +696,23 @@ x < y - 4 < 108 + 1 < 6 - x < y + y < z - 4 < 109 + 6 < 8 - + - x < y + x < z - 4 < 110 + 1 < 8 @@ -848,23 +720,23 @@ x < y - 5 < 101 + 1 < 6 - x < y + y < z - 5 < 102 + 6 < 9 - + - x < y + x < z - 5 < 103 + 1 < 9 @@ -872,23 +744,23 @@ x < y - 5 < 104 + 2 < 4 - x < y + y < z - 5 < 105 + 4 < 7 - + - x < y + x < z - 5 < 106 + 2 < 7 @@ -896,23 +768,23 @@ x < y - 5 < 107 + 2 < 4 - x < y + y < z - 5 < 108 + 4 < 8 - + - x < y + x < z - 5 < 109 + 2 < 8 @@ -920,23 +792,23 @@ x < y - 5 < 110 + 2 < 4 - x < y + y < z - 6 < 101 + 4 < 9 - + - x < y + x < z - 6 < 102 + 2 < 9 @@ -944,23 +816,23 @@ x < y - 6 < 103 + 2 < 5 - x < y + y < z - 6 < 104 + 5 < 7 - + - x < y + x < z - 6 < 105 + 2 < 7 @@ -968,23 +840,23 @@ x < y - 6 < 106 + 2 < 5 - x < y + y < z - 6 < 107 + 5 < 8 - + - x < y + x < z - 6 < 108 + 2 < 8 @@ -992,23 +864,23 @@ x < y - 6 < 109 + 2 < 5 - x < y + y < z - 6 < 110 + 5 < 9 - + - x < y + x < z - 7 < 101 + 2 < 9 @@ -1016,23 +888,23 @@ x < y - 7 < 102 + 2 < 6 - x < y + y < z - 7 < 103 + 6 < 7 - + - x < y + x < z - 7 < 104 + 2 < 7 @@ -1040,23 +912,23 @@ x < y - 7 < 105 + 2 < 6 - x < y + y < z - 7 < 106 + 6 < 8 - + - x < y + x < z - 7 < 107 + 2 < 8 @@ -1064,23 +936,23 @@ x < y - 7 < 108 + 2 < 6 - x < y + y < z - 7 < 109 + 6 < 9 - + - x < y + x < z - 7 < 110 + 2 < 9 @@ -1088,23 +960,23 @@ x < y - 8 < 101 + 3 < 4 - x < y + y < z - 8 < 102 + 4 < 7 - + - x < y + x < z - 8 < 103 + 3 < 7 @@ -1112,23 +984,23 @@ x < y - 8 < 104 + 3 < 4 - x < y + y < z - 8 < 105 + 4 < 8 - + - x < y + x < z - 8 < 106 + 3 < 8 @@ -1136,23 +1008,23 @@ x < y - 8 < 107 + 3 < 4 - x < y + y < z - 8 < 108 + 4 < 9 - + - x < y + x < z - 8 < 109 + 3 < 9 @@ -1160,23 +1032,23 @@ x < y - 8 < 110 + 3 < 5 - x < y + y < z - 9 < 101 + 5 < 7 - + - x < y + x < z - 9 < 102 + 3 < 7 @@ -1184,23 +1056,23 @@ x < y - 9 < 103 + 3 < 5 - x < y + y < z - 9 < 104 + 5 < 8 - + - x < y + x < z - 9 < 105 + 3 < 8 @@ -1208,23 +1080,23 @@ x < y - 9 < 106 + 3 < 5 - x < y + y < z - 9 < 107 + 5 < 9 - + - x < y + x < z - 9 < 108 + 3 < 9 @@ -1232,23 +1104,23 @@ x < y - 9 < 109 + 3 < 6 - x < y + y < z - 9 < 110 + 6 < 7 - + - x < y + x < z - 10 < 101 + 3 < 7 @@ -1256,39 +1128,23 @@ x < y - 10 < 102 + 3 < 6 - x < y + y < z - 10 < 103 + 6 < 8 - - - x < y - - - 10 < 104 - - - - - x < y - - - 10 < 105 - - - + - x < y + x < z - 10 < 106 + 3 < 8 @@ -1296,31 +1152,23 @@ x < y - 10 < 107 + 3 < 6 - x < y + y < z - 10 < 108 + 6 < 9 - + - x < y - - - 10 < 109 - - - - - x < y + x < z - 10 < 110 + 3 < 9 @@ -3690,343 +3538,549 @@ - -

- - i := "a" - - - j := 8 - + +
+ + + i % 2 == 0 + + + 0 == 0 + +
-
- - i := "a" - - - j := 9 - +
+ + + i % 2 == 0 + + + 0 == 0 + +
-
- - i := "a" - - - j := 10 - +
+ + + i % 2 == 0 + + + 0 == 0 + +
-
- - i := "a" - - - j := 2 - +
+ + + i < 4 + + + 1 < 4 + +
-
- - i := "a" - - - j := 3.141 - +
+ + + i < 4 + + + 2 < 4 + +
-
- - i := "a" - - - j := 1.379 - +
+ + + i < 4 + + + 3 < 4 + +
-
- - i := "b" - - - j := 8 - +
+
+ + + i % 2 == 0 + + + 0 == 0 + + + +
-
- - i := "b" - - - j := 9 - +
+
+ + + i % 2 == 0 + + + 0 == 0 + + + +
-
- - i := "b" - - - j := 10 - +
+
+ + + i % 2 == 0 + + + 0 == 0 + + + +
-
- - i := "b" - - - j := 2 - +
+
+ + + i.size() == 1 + + + 1 == 1 + + + +
-
- - i := "b" - - - j := 3.141 - +
+
+ + + i.size() == 1 + + + 1 == 1 + + + +
-
- - i := "b" - - - j := 1.379 - +
+
+ + + i.size() == 1 + + + 1 == 1 + + + +
-
- - i := "c" - - - j := 8 - +
+ + + j > 0 + + + 1 > 0 + +
-
- - i := "c" - - - j := 9 - +
+ + + j > 0 + + + 2 > 0 + +
-
- - i := "c" - - - j := 10 - +
+ + + j > 0 + + + 3 > 0 + +
-
- - i := "c" - - - j := 2 - +
+ + + j > 0 + + + 1 > 0 + +
-
- - i := "c" - - - j := 3.141 - +
+ + + j > 0 + + + 2 > 0 + +
-
- - i := "c" - - - j := 1.379 - +
+ + + j > 0 + + + 3 > 0 + +
- -
- + +
+ - gen.size() == 2 + j < i - 2 == 2 + -3 < 1 - + +
+
+ - gen[0] == 1 + j < i + + + -2 < 1 + + + +
+
+ + + j < i + + + -1 < 1 + + + +
+
+ + + 4u * i > str.size() + + + 4 > 1 + + + +
+
+ + + 4u * i > str.size() + + + 4 > 2 + + + +
+
+ + + 4u * i > str.size() + + + 4 > 3 + + + +
+
+ + + j < i + + + -3 < 2 + + + +
+
+ + + j < i + + + -2 < 2 + + + +
+
+ + + j < i + + + -1 < 2 + + + +
+
+ + + 4u * i > str.size() + + + 8 > 1 + + + +
+
+ + + 4u * i > str.size() + + + 8 > 2 + + + +
+
+ + + 4u * i > str.size() + + + 8 > 3 + + + +
+
+ + + j < i + + + -3 < 3 + + + +
+
+ + + j < i + + + -2 < 3 + + + +
+
+ + + j < i + + + -1 < 3 + + + +
+
+ + + 4u * i > str.size() + + + 12 > 1 + + + +
+
+ + + 4u * i > str.size() + + + 12 > 2 + + + +
+
+ + + 4u * i > str.size() + + + 12 > 3 + + + +
+ +
+ +
+ + + gen.get() == 123 + + + 123 == 123 + + + + + !(gen.next()) + + + !false + + + +
+
+ + + gen.get() == 1 1 == 1 - + - gen[1] == 2 + gen.next() - 2 == 2 + true - -
-
- + - gen.size() == 4 - - - 4 == 4 - - - - - gen[0] == 3 + gen.get() == 3 3 == 3 - + - gen[1] == 1 + gen.next() - 1 == 1 + true - + - gen[2] == 4 + gen.get() == 5 - 4 == 4 + 5 == 5 - + - gen[3] == 1 + !(gen.next()) - 1 == 1 + !false - +
-
- +
+ - gen.size() == 4 - - - 4 == 4 - - - - - gen[0] == 1 + gen.get() == 1 1 == 1 - + - gen[1] == 2 + gen.next() + + + true + + + + + gen.get() == 5 + + + 5 == 5 + + + + + gen.next() + + + true + + + + + gen.get() == 2 2 == 2 - + - gen[2] == 9 + gen.next() - 9 == 9 + true - + - gen[3] == 7 - - - 7 == 7 - - - -
-
- - - gen.size() == 2 - - - 2 == 2 - - - - - gen[0] == 3 - - - 3 == 3 - - - - - gen[1] == 1 - - - 1 == 1 - - - -
-
- - - gen.size() == 2 - - - 2 == 2 - - - - - gen[0] == 3 - - - 3 == 3 - - - - - gen[1] == 1 - - - 1 == 1 - - - -
-
- - - base->size() == 4 + gen.get() == 4 4 == 4 @@ -4034,38 +4088,367 @@ - typed + gen.next() - 0x + true - + - typed->size() == 4 + gen.get() == 0 - 4 == 4 + 0 == 0 - + - (*typed)[0] == 7 + !(gen.next()) - 7 == 7 + !false - + +
+
+ - (*typed)[3] == 11 + gen.get().size() == 2 - 11 == 11 + 2 == 2 + + + + + gen.get() == "aa" + + + "aa" == "aa" + + + + + gen.next() + + + true + + + + + gen.get() == "bb" + + + "bb" == "bb" + + + + + gen.next() + + + true + + + + + gen.get() == "cc" + + + "cc" == "cc" + + + + + !(gen.next()) + + + !false + + + +
+
+ + + gen.get() == 1 + + + 1 == 1 + + + + + gen.next() + + + true + + + + + gen.get() == 3 + + + 3 == 3 + + + + + !(gen.next()) + + + !false + + + + + filter([] (int) { return false; }, value(1)), Catch::GeneratorException + + + filter([] (int) { return false; }, value(1)), Catch::GeneratorException
+
+
+ + + gen.get() == 1 + + + 1 == 1 + + + + + gen.next() + + + true + + + + + gen.get() == 2 + + + 2 == 2 + + + + + !(gen.next()) + + + !false + + + +
+ +
+
+
+ + + gen.get() == 1 + + + 1 == 1 + + + + + !(gen.next()) + + + !false + + + +
+ +
+
+ + + gen.get() == 2.0 + + + 2.0 == 2.0 + + + + + gen.next() + + + true + + + + + gen.get() == 4.0 + + + 4.0 == 4.0 + + + + + gen.next() + + + true + + + + + gen.get() == 6.0 + + + 6.0 == 6.0 + + + + + !(gen.next()) + + + !false + + + +
+
+
+ + + gen.get() == 3 + + + 3 == 3 + + + + + !(gen.next()) + + + !false + + + +
+ +
+
+
+ + + gen.get() == 1 + + + 1 == 1 + + + + + gen.next() + + + true + + + + + gen.get() == 2 + + + 2 == 2 + + + + + gen.next() + + + true + + + + + gen.get() == 3 + + + 3 == 3 + + + + + gen.next() + + + true + + + + + gen.get() == 1 + + + 1 == 1 + + + + + gen.next() + + + true + + + + + gen.get() == 2 + + + 2 == 2 + + + + + gen.next() + + + true + + + + + gen.get() == 3 + + + 3 == 3 + + + + + !(gen.next()) + + + !false + + + +
+ +
@@ -11180,7 +11563,7 @@ loose text artifact
- + data.str.size() == data.len @@ -11215,6 +11598,41 @@ loose text artifact + + + + strlen(std::get<0>(data)) == static_cast<size_t>(std::get<1>(data)) + + + 5 == 5 + + + + + strlen(std::get<0>(data)) == static_cast<size_t>(std::get<1>(data)) + + + 6 == 6 + + + + + strlen(std::get<0>(data)) == static_cast<size_t>(std::get<1>(data)) + + + 5 == 5 + + + + + strlen(std::get<0>(data)) == static_cast<size_t>(std::get<1>(data)) + + + 6 == 6 + + + + Why would you throw a std::string? @@ -11733,7 +12151,7 @@ loose text artifact
- + - + diff --git a/projects/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp b/projects/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp index b3074b2e..0f581947 100644 --- a/projects/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp +++ b/projects/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp @@ -1,93 +1,103 @@ #include "catch.hpp" -// Tests of generartor implementation details - -TEST_CASE("Generators impl", "[impl]") { +// Tests of generator implementation details +TEST_CASE("Generators internals", "[generators][internals]") { using namespace Catch::Generators; - SECTION( "range" ) { - auto gen = range(1,3); - - CHECK( gen.size() == 2 ); - - CHECK( gen[0] == 1 ); - CHECK( gen[1] == 2 ); + SECTION("Single value") { + auto gen = value(123); + REQUIRE(gen.get() == 123); + REQUIRE_FALSE(gen.next()); } - SECTION( "fixed values" ) { - auto gen = values( { 3, 1, 4, 1 } ); - - CHECK( gen.size() == 4 ); - CHECK( gen[0] == 3 ); - CHECK( gen[1] == 1 ); - CHECK( gen[2] == 4 ); - CHECK( gen[3] == 1 ); + SECTION("Preset values") { + auto gen = values({ 1, 3, 5 }); + REQUIRE(gen.get() == 1); + REQUIRE(gen.next()); + REQUIRE(gen.get() == 3); + REQUIRE(gen.next()); + REQUIRE(gen.get() == 5); + REQUIRE_FALSE(gen.next()); } - SECTION( "combined" ) { - auto gen = makeGenerators( range( 1, 3 ), values( { 9, 7 } ) ); - - CHECK( gen.size() == 4 ); - CHECK( gen[0] == 1 ); - CHECK( gen[1] == 2 ); - CHECK( gen[2] == 9 ); - CHECK( gen[3] == 7 ); + SECTION("Generator combinator") { + auto gen = makeGenerators(1, 5, values({ 2, 4 }), 0); + REQUIRE(gen.get() == 1); + REQUIRE(gen.next()); + REQUIRE(gen.get() == 5); + REQUIRE(gen.next()); + REQUIRE(gen.get() == 2); + REQUIRE(gen.next()); + REQUIRE(gen.get() == 4); + REQUIRE(gen.next()); + REQUIRE(gen.get() == 0); + REQUIRE_FALSE(gen.next()); } - - SECTION( "values" ) { - auto gen = makeGenerators( 3, 1 ); - - CHECK( gen.size() == 2 ); - CHECK( gen[0] == 3 ); - CHECK( gen[1] == 1 ); + SECTION("Explicitly typed generator sequence") { + auto gen = makeGenerators(as{}, "aa", "bb", "cc"); + // This just checks that the type is std::string: + REQUIRE(gen.get().size() == 2); + // Iterate over the generator + REQUIRE(gen.get() == "aa"); + REQUIRE(gen.next()); + REQUIRE(gen.get() == "bb"); + REQUIRE(gen.next()); + REQUIRE(gen.get() == "cc"); + REQUIRE_FALSE(gen.next()); } - SECTION( "values2" ) { - auto gen = makeGenerators( 3, 1 ); + SECTION("Filter generator") { + // Normal usage + auto gen = filter([] (int i) { return i != 2; }, values({ 2, 1, 2, 3, 2, 2 })); + REQUIRE(gen.get() == 1); + REQUIRE(gen.next()); + REQUIRE(gen.get() == 3); + REQUIRE_FALSE(gen.next()); - CHECK( gen.size() == 2 ); - CHECK( gen[0] == 3 ); - CHECK( gen[1] == 1 ); + // Completely filtered-out generator should throw on construction + REQUIRE_THROWS_AS(filter([] (int) { return false; }, value(1)), Catch::GeneratorException); } - - - SECTION( "type erasure" ) { - auto gen = makeGenerators( range( 7, 10 ), 11 ); - - // Make type erased version - auto dynCopy = pf::make_unique>( std::move( gen ) ); - std::unique_ptr base = std::move( dynCopy ); - - // Only thing we can do is ask for the size - CHECK( base->size() == 4 ); - - // Restore typed version - auto typed = dynamic_cast const*>( base.get() ); - REQUIRE( typed ); - CHECK( typed->size() == 4 ); - CHECK( (*typed)[0] == 7 ); - CHECK( (*typed)[3] == 11 ); - } -} - -TEST_CASE("Generators impl - random", "[approvals]") { - using namespace Catch::Generators; - - SECTION( "random range" ) { - auto gen = random( 3, 9 ); - - CHECK( gen.size() == 6 ); - for( size_t i = 0; i < 6; ++i ) { - CHECK( gen[i] >= 3 ); - CHECK( gen[i] <= 8 ); - if( i > 0 ) - CHECK( gen[i] != gen[i-1] ); + SECTION("Take generator") { + SECTION("Take less") { + auto gen = take(2, values({ 1, 2, 3 })); + REQUIRE(gen.get() == 1); + REQUIRE(gen.next()); + REQUIRE(gen.get() == 2); + REQUIRE_FALSE(gen.next()); + } + SECTION("Take more") { + auto gen = take(2, value(1)); + REQUIRE(gen.get() == 1); + REQUIRE_FALSE(gen.next()); } } - SECTION( "random selection" ) { - auto gen = random( 10 ); - - CHECK( gen.size() == 10 ); - for( size_t i = 0; i < 10; ++i ) { - if( i > 0 ) - CHECK( gen[i] != gen[i-1] ); + SECTION("Map") { + auto gen = map([] (int i) {return 2.0 * i; }, values({ 1, 2, 3 })); + REQUIRE(gen.get() == 2.0); + REQUIRE(gen.next()); + REQUIRE(gen.get() == 4.0); + REQUIRE(gen.next()); + REQUIRE(gen.get() == 6.0); + REQUIRE_FALSE(gen.next()); + } + SECTION("Repeat") { + SECTION("Singular repeat") { + auto gen = repeat(1, value(3)); + REQUIRE(gen.get() == 3); + REQUIRE_FALSE(gen.next()); + } + SECTION("Actual repeat") { + auto gen = repeat(2, values({ 1, 2, 3 })); + REQUIRE(gen.get() == 1); + REQUIRE(gen.next()); + REQUIRE(gen.get() == 2); + REQUIRE(gen.next()); + REQUIRE(gen.get() == 3); + REQUIRE(gen.next()); + REQUIRE(gen.get() == 1); + REQUIRE(gen.next()); + REQUIRE(gen.get() == 2); + REQUIRE(gen.next()); + REQUIRE(gen.get() == 3); + REQUIRE_FALSE(gen.next()); } } + } diff --git a/projects/SelfTest/UsageTests/Generators.tests.cpp b/projects/SelfTest/UsageTests/Generators.tests.cpp index 9242174a..0110b442 100644 --- a/projects/SelfTest/UsageTests/Generators.tests.cpp +++ b/projects/SelfTest/UsageTests/Generators.tests.cpp @@ -1,75 +1,63 @@ #include "catch.hpp" -// Examples of usage of Generators +#include -// This test doesn't do much - it just shows how you can have several generators, of different -// types (ie `i` and `j` are different types), can be sequenced using `,` and -// can be expressed as named generators (like range) or as individual values. -// Generators can be mixed with SECTIONs. -// At time of writing the generated values are not automatically reported as part of the test -// name or associated values - so we explicitly CAPTURE then (run this with `-s` to see them). -// We could also incorporate them into the section names using DYNAMIC_SECTION. See the BDD -// example later for more information. -TEST_CASE("Generators") { - auto i = GENERATE( as(), "a", "b", "c" ); - - SECTION( "one" ) { - auto j = GENERATE( range( 8, 11 ), 2 ); - - CAPTURE( i, j ); - SUCCEED(); +// Generators and sections can be nested freely +TEST_CASE("Generators -- simple", "[generators]") { + auto i = GENERATE(1, 2, 3); + SECTION("one") { + auto j = GENERATE(values({ -3, -2, -1 })); + REQUIRE(j < i); } - SECTION( "two" ) { - auto j = GENERATE( 3.141, 1.379 ); - CAPTURE( i, j ); - SUCCEED(); + + SECTION("two") { + // You can also explicitly set type for generators via Catch::Generators::as + auto str = GENERATE(as{}, "a", "bb", "ccc"); + REQUIRE(4u * i > str.size()); } } -// This one generates the cross-product of two ranges. -// It's mostly here to demonstrate the performance which, at time of writing, -// leaves a lot to be desired. -TEST_CASE( "100x100 ints", "[.][approvals]" ) { - auto x = GENERATE( range( 0,100 ) ); - auto y = GENERATE( range( 200,300 ) ); - - CHECK( x < y ); +// You can create a cartesian-product of generators by creating multiple ones +TEST_CASE("3x3x3 ints", "[generators]") { + auto x = GENERATE(1, 2, 3); + auto y = GENERATE(4, 5, 6); + auto z = GENERATE(7, 8, 9); + // These assertions will be run 27 times (3x3x3) + CHECK(x < y); + CHECK(y < z); + REQUIRE(x < z); } -// smaller version -TEST_CASE( "10x10 ints" ) { - auto x = GENERATE( range( 1,11 ) ); - auto y = GENERATE( range( 101, 111 ) ); +// You can also create data tuples +TEST_CASE("tables", "[generators]") { + // Note that this will not compile with libstdc++ older than libstdc++6 + // See https://stackoverflow.com/questions/12436586/tuple-vector-and-initializer-list + // for possible workarounds + // auto data = GENERATE(table({ + // {"first", 5}, + // {"second", 6}, + // {"third", 5}, + // {"etc...", 6} + // })); - CHECK( x < y ); + // Workaround for the libstdc++ bug mentioned above + using tuple_type = std::tuple; + auto data = GENERATE(table({ + tuple_type{"first", 5}, + tuple_type{"second", 6}, + tuple_type{"third", 5}, + tuple_type{"etc...", 6} + })); + + REQUIRE(strlen(std::get<0>(data)) == static_cast(std::get<1>(data))); } -// Some of the following tests use structured bindings for convenience and so are -// conditionally compiled using the de-facto (and soon to be formally) standard -// feature macros #ifdef __cpp_structured_bindings -// One way to do pairs of values (actual/ expected?) -// For a simple case like this I'd recommend writing out a series of REQUIREs -// but it demonstrates a possible usage. -// Spelling out the pair like this is a bit verbose, so read on for better examples -// - the use of structured bindings here is an optional convenience -TEST_CASE( "strlen", "[approvals]" ) { - auto [test_input, expected] = GENERATE( values>({ - {"one", 3}, - {"two", 3}, - {"three", 5}, - {"four", 4} - })); - - REQUIRE( test_input.size() == expected ); -} - -// A nicer way to do pairs (or more) of values - using the table generator. -// Note, you must specify the types up-front. -TEST_CASE( "strlen2", "[approvals]" ) { +// Structured bindings make the table utility much nicer to use +TEST_CASE( "strlen2", "[approvals][generators]" ) { auto [test_input, expected] = GENERATE( table({ {"one", 3}, {"two", 3}, @@ -81,11 +69,11 @@ TEST_CASE( "strlen2", "[approvals]" ) { } #endif -// An alternate way of doing data tables without structure bindings -// - I'd prefer to have the Data class within the test case but gcc 4.x doesn't seem to like it + +// An alternate way of doing data tables without structured bindings struct Data { std::string str; size_t len; }; -TEST_CASE( "strlen3" ) { +TEST_CASE( "strlen3", "[generators]" ) { auto data = GENERATE( values({ {"one", 3}, {"two", 3}, @@ -96,15 +84,7 @@ TEST_CASE( "strlen3" ) { REQUIRE( data.str.size() == data.len ); } -// A nod towards property-based testing - generate a random selection of numbers -// in a range and assert on global properties those numbers. -static auto square( int i ) -> int { return i*i; } -TEST_CASE( "Random numbers in a range", "[.][approvals]" ) { - auto x = GENERATE( random( -10000, 10000 ) ); - CAPTURE( x ); - REQUIRE( square(x) >= 0 ); -} #ifdef __cpp_structured_bindings @@ -118,7 +98,7 @@ TEST_CASE( "Random numbers in a range", "[.][approvals]" ) { static auto eatCucumbers( int start, int eat ) -> int { return start-eat; } -SCENARIO("Eating cucumbers", "[approvals]") { +SCENARIO("Eating cucumbers", "[generators][approvals]") { auto [start, eat, left] = GENERATE( table ({ { 12, 5, 7 }, @@ -132,3 +112,36 @@ SCENARIO("Eating cucumbers", "[approvals]") { } } #endif + +// There are also some generic generator manipulators +TEST_CASE("Generators -- adapters", "[generators]") { + // TODO: This won't work yet, introduce GENERATE_VAR? + //auto numbers = Catch::Generators::values({ 1, 2, 3, 4, 5, 6 }); + SECTION("Filtering by predicate") { + // This filters out all odd (false) numbers, giving [2, 4, 6] + auto i = GENERATE(filter([] (int val) { return val % 2 == 0; }, values({ 1, 2, 3, 4, 5, 6 }))); + REQUIRE(i % 2 == 0); + } + SECTION("Shortening a range") { + // This takes the first 3 elements from the values, giving back [1, 2, 3] + auto i = GENERATE(take(3, values({ 1, 2, 3, 4, 5, 6 }))); + REQUIRE(i < 4); + } + SECTION("Transforming elements") { + SECTION("Same type") { + // This doubles values [1, 2, 3] into [2, 4, 6] + auto i = GENERATE(map([] (int val) { return val * 2; }, values({ 1, 2, 3 }))); + REQUIRE(i % 2 == 0); + } + SECTION("Different type") { + // This takes a generator that returns ints and maps them into strings + auto i = GENERATE(map([] (int val) { return std::to_string(val); }, values({ 1, 2, 3 }))); + REQUIRE(i.size() == 1); + } + } + SECTION("Repeating a generator") { + // This will return values [1, 2, 3, 1, 2, 3] + auto j = GENERATE(repeat(2, values({ 1, 2, 3 }))); + REQUIRE(j > 0); + } +}