Skip to content
Permalink
Browse files

Add a from_range(Container) overload to the generator helpers

  • Loading branch information...
horenmar committed Oct 9, 2019
1 parent 1c57496 commit c8db4e77c4c9aa20776db162e982f1af693ab8fe
@@ -72,6 +72,7 @@ type, making their usage much nicer. These are
* `range(start, end)` for `RangeGenerator<T>` with a step size of `1`
* `range(start, end, step)` for `RangeGenerator<T>` with a custom step size
* `from_range(InputIterator from, InputIterator to)` for `IteratorGenerator<T>`
* `from_range(Container const&)` for `IteratorGenerator<T>`

> `chunk()`, `random()` and both `range()` functions were introduced in Catch 2.7.0.
@@ -161,6 +161,13 @@ GeneratorWrapper<ResultType> from_range(InputIterator from, InputSentinel to) {
return GeneratorWrapper<ResultType>(pf::make_unique<IteratorGenerator<ResultType>>(from, to));
}

template <typename Container,
typename ResultType = typename Container::value_type>
GeneratorWrapper<ResultType> from_range(Container const& cnt) {
return GeneratorWrapper<ResultType>(pf::make_unique<IteratorGenerator<ResultType>>(cnt.begin(), cnt.end()));
}


} // namespace Generators
} // namespace Catch

@@ -320,6 +320,14 @@ Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: call_count == 1 for: 1 == 1
Generators.tests.cpp:<line number>: passed: make_data().size() == test_count for: 6 == 6
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'custom exception - not std'; expression was: throwCustom()
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'custom exception - not std'; expression was: throwCustom(), std::exception
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'custom std exception'
@@ -1381,5 +1381,5 @@ due to unexpected exception with message:

===============================================================================
test cases: 303 | 229 passed | 70 failed | 4 failed as expected
assertions: 1589 | 1437 passed | 131 failed | 21 failed as expected
assertions: 1597 | 1445 passed | 131 failed | 21 failed as expected

@@ -2409,6 +2409,7 @@ with expansion:

-------------------------------------------------------------------------------
Copy and then generate a range
from var and iterators
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
@@ -2420,6 +2421,7 @@ with expansion:

-------------------------------------------------------------------------------
Copy and then generate a range
from var and iterators
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
@@ -2431,6 +2433,7 @@ with expansion:

-------------------------------------------------------------------------------
Copy and then generate a range
from var and iterators
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
@@ -2442,6 +2445,7 @@ with expansion:

-------------------------------------------------------------------------------
Copy and then generate a range
from var and iterators
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
@@ -2453,6 +2457,7 @@ with expansion:

-------------------------------------------------------------------------------
Copy and then generate a range
from var and iterators
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
@@ -2464,6 +2469,7 @@ with expansion:

-------------------------------------------------------------------------------
Copy and then generate a range
from var and iterators
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
@@ -2473,6 +2479,95 @@ Generators.tests.cpp:<line number>: PASSED:
with expansion:
1 == 1

-------------------------------------------------------------------------------
Copy and then generate a range
From a temporary container
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................

Generators.tests.cpp:<line number>: PASSED:
REQUIRE( elem % 2 == 1 )
with expansion:
1 == 1

-------------------------------------------------------------------------------
Copy and then generate a range
From a temporary container
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................

Generators.tests.cpp:<line number>: PASSED:
REQUIRE( elem % 2 == 1 )
with expansion:
1 == 1

-------------------------------------------------------------------------------
Copy and then generate a range
From a temporary container
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................

Generators.tests.cpp:<line number>: PASSED:
REQUIRE( elem % 2 == 1 )
with expansion:
1 == 1

-------------------------------------------------------------------------------
Copy and then generate a range
From a temporary container
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................

Generators.tests.cpp:<line number>: PASSED:
REQUIRE( elem % 2 == 1 )
with expansion:
1 == 1

-------------------------------------------------------------------------------
Copy and then generate a range
From a temporary container
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................

Generators.tests.cpp:<line number>: PASSED:
REQUIRE( elem % 2 == 1 )
with expansion:
1 == 1

-------------------------------------------------------------------------------
Copy and then generate a range
From a temporary container
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................

Generators.tests.cpp:<line number>: PASSED:
REQUIRE( elem % 2 == 1 )
with expansion:
1 == 1

-------------------------------------------------------------------------------
Copy and then generate a range
Final validation
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................

Generators.tests.cpp:<line number>: PASSED:
REQUIRE( call_count == 1 )
with expansion:
1 == 1

Generators.tests.cpp:<line number>: PASSED:
REQUIRE( make_data().size() == test_count )
with expansion:
6 == 6

-------------------------------------------------------------------------------
Custom exceptions can be translated when testing for nothrow
-------------------------------------------------------------------------------
@@ -12711,5 +12806,5 @@ Misc.tests.cpp:<line number>: PASSED:

===============================================================================
test cases: 303 | 213 passed | 86 failed | 4 failed as expected
assertions: 1606 | 1437 passed | 148 failed | 21 failed as expected
assertions: 1614 | 1445 passed | 148 failed | 21 failed as expected

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact
>
<testsuite name="<exe-name>" errors="17" failures="132" tests="1607" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testsuite name="<exe-name>" errors="17" failures="132" tests="1615" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/>
<property name="random-seed" value="1"/>
@@ -255,7 +255,9 @@ Matchers.tests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Copy and then generate a range" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Copy and then generate a range/from var and iterators" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Copy and then generate a range/From a temporary container" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Copy and then generate a range/Final validation" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Custom exceptions can be translated when testing for nothrow" time="{duration}">
<error message="throwCustom()" type="REQUIRE_NOTHROW">
custom exception - not std

0 comments on commit c8db4e7

Please sign in to comment.
You can’t perform that action at this time.