diff options
| author | Martin Hořeňovský | 2022-05-16 11:56:11 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2022-05-16 11:56:21 +0200 |
| commit | af8b54ecd59f8174aaaa97682e3544f2820a0900 (patch) | |
| tree | 1e9738c570b986822c235917ef20afc5ecb89017 /tests | |
| parent | 07bec74096d91e68efa97587554004740d9aa32a (diff) | |
| download | catch3-af8b54ecd59f8174aaaa97682e3544f2820a0900.tar.gz | |
Generators now keep track of the index of current element
This might become potentially useful in the future, when we want
to provide the ability to forward jump generators, to be able to
simply reproduce specific input to a test.
I am not yet sure how it would work, but the basic idea is that
it could be similar to the `-c` switch for selecting specific
`SECTION` in a test case.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp b/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp index 2aad184d..42d80741 100644 --- a/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp @@ -413,3 +413,14 @@ TEST_CASE("GENERATE decays arrays", "[generators][compilation][approvals]") { auto str = GENERATE("abc", "def", "gh"); STATIC_REQUIRE(std::is_same<decltype(str), const char*>::value); } + +TEST_CASE("Generators count returned elements", "[generators][approvals]") { + auto generator = Catch::Generators::FixedValuesGenerator<int>( { 1, 2, 3 } ); + REQUIRE( generator.currentElementIndex() == 0 ); + REQUIRE( generator.countedNext() ); + REQUIRE( generator.currentElementIndex() == 1 ); + REQUIRE( generator.countedNext() ); + REQUIRE( generator.currentElementIndex() == 2 ); + REQUIRE_FALSE( generator.countedNext() ); + REQUIRE( generator.currentElementIndex() == 2 ); +} |