mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-25 14:56:10 +01:00
Support sentinel-based ranges in default stringify (#2004)
This commit is contained in:
parent
08fb5cbab2
commit
31d4831245
@ -311,8 +311,8 @@ namespace Catch {
|
||||
#endif
|
||||
|
||||
namespace Detail {
|
||||
template<typename InputIterator>
|
||||
std::string rangeToString(InputIterator first, InputIterator last) {
|
||||
template<typename InputIterator, typename Sentinel = InputIterator>
|
||||
std::string rangeToString(InputIterator first, Sentinel last) {
|
||||
ReusableStringStream rss;
|
||||
rss << "{ ";
|
||||
if (first != last) {
|
||||
|
@ -180,6 +180,7 @@ Nor would this
|
||||
:test-result: PASS Product with differing arities - std::tuple<int, double, float>
|
||||
:test-result: PASS Product with differing arities - std::tuple<int, double>
|
||||
:test-result: PASS Product with differing arities - std::tuple<int>
|
||||
:test-result: PASS Range type with sentinel
|
||||
:test-result: FAIL Reconstruction should be based on stringification: #914
|
||||
:test-result: FAIL Regex string matcher
|
||||
:test-result: PASS Regression test #1
|
||||
|
@ -1265,6 +1265,7 @@ CmdLine.tests.cpp:<line number>: passed: config.benchmarkWarmupTime == 10 for: 1
|
||||
Misc.tests.cpp:<line number>: passed: std::tuple_size<TestType>::value >= 1 for: 3 >= 1
|
||||
Misc.tests.cpp:<line number>: passed: std::tuple_size<TestType>::value >= 1 for: 2 >= 1
|
||||
Misc.tests.cpp:<line number>: passed: std::tuple_size<TestType>::value >= 1 for: 1 >= 1
|
||||
ToString.tests.cpp:<line number>: passed: Catch::Detail::stringify(UsesSentinel{}) == "{ }" for: "{ }" == "{ }"
|
||||
Decomposition.tests.cpp:<line number>: failed: truthy(false) for: Hey, its truthy!
|
||||
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Matches("this STRING contains 'abc' as a substring") for: "this string contains 'abc' as a substring" matches "this STRING contains 'abc' as a substring" case sensitively
|
||||
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Matches("contains 'abc' as a substring") for: "this string contains 'abc' as a substring" matches "contains 'abc' as a substring" case sensitively
|
||||
|
@ -1380,6 +1380,6 @@ due to unexpected exception with message:
|
||||
Why would you throw a std::string?
|
||||
|
||||
===============================================================================
|
||||
test cases: 349 | 275 passed | 70 failed | 4 failed as expected
|
||||
assertions: 1989 | 1837 passed | 131 failed | 21 failed as expected
|
||||
test cases: 350 | 276 passed | 70 failed | 4 failed as expected
|
||||
assertions: 1990 | 1838 passed | 131 failed | 21 failed as expected
|
||||
|
||||
|
@ -9326,6 +9326,17 @@ Misc.tests.cpp:<line number>: PASSED:
|
||||
with expansion:
|
||||
1 >= 1
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Range type with sentinel
|
||||
-------------------------------------------------------------------------------
|
||||
ToString.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
ToString.tests.cpp:<line number>: PASSED:
|
||||
CHECK( Catch::Detail::stringify(UsesSentinel{}) == "{ }" )
|
||||
with expansion:
|
||||
"{ }" == "{ }"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Reconstruction should be based on stringification: #914
|
||||
-------------------------------------------------------------------------------
|
||||
@ -15654,6 +15665,6 @@ Misc.tests.cpp:<line number>
|
||||
Misc.tests.cpp:<line number>: PASSED:
|
||||
|
||||
===============================================================================
|
||||
test cases: 349 | 259 passed | 86 failed | 4 failed as expected
|
||||
assertions: 2006 | 1837 passed | 148 failed | 21 failed as expected
|
||||
test cases: 350 | 260 passed | 86 failed | 4 failed as expected
|
||||
assertions: 2007 | 1838 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="2007" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testsuite name="<exe-name>" errors="17" failures="132" tests="2008" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<properties>
|
||||
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
|
||||
<property name="random-seed" value="1"/>
|
||||
@ -1063,6 +1063,7 @@ Message.tests.cpp:<line number>
|
||||
<testcase classname="<exe-name>.global" name="Product with differing arities - std::tuple<int, double, float>" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="Product with differing arities - std::tuple<int, double>" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="Product with differing arities - std::tuple<int>" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="Range type with sentinel" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="Reconstruction should be based on stringification: #914" time="{duration}" status="run">
|
||||
<failure message="truthy(false)" type="CHECK">
|
||||
FAILED:
|
||||
|
@ -187,6 +187,7 @@
|
||||
</file>
|
||||
<file path="tests/<exe-name>/IntrospectiveTests/ToString.tests.cpp">
|
||||
<testCase name="Directly creating an EnumInfo" duration="{duration}"/>
|
||||
<testCase name="Range type with sentinel" duration="{duration}"/>
|
||||
<testCase name="parseEnums/No enums" duration="{duration}"/>
|
||||
<testCase name="parseEnums/One enum value" duration="{duration}"/>
|
||||
<testCase name="parseEnums/Multiple enum values" duration="{duration}"/>
|
||||
|
@ -2452,6 +2452,8 @@ ok {test-number} - std::tuple_size<TestType>::value >= 1 for: 3 >= 1
|
||||
ok {test-number} - std::tuple_size<TestType>::value >= 1 for: 2 >= 1
|
||||
# Product with differing arities - std::tuple<int>
|
||||
ok {test-number} - std::tuple_size<TestType>::value >= 1 for: 1 >= 1
|
||||
# Range type with sentinel
|
||||
ok {test-number} - Catch::Detail::stringify(UsesSentinel{}) == "{ }" for: "{ }" == "{ }"
|
||||
# Reconstruction should be based on stringification: #914
|
||||
not ok {test-number} - truthy(false) for: Hey, its truthy!
|
||||
# Regex string matcher
|
||||
@ -4004,5 +4006,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
|
||||
ok {test-number} -
|
||||
# xmlentitycheck
|
||||
ok {test-number} -
|
||||
1..2006
|
||||
1..2007
|
||||
|
||||
|
@ -461,6 +461,8 @@ Message.tests.cpp:<line number>|nexplicit failure with message:|n "Message from
|
||||
##teamcity[testFinished name='Product with differing arities - std::tuple<int, double>' duration="{duration}"]
|
||||
##teamcity[testStarted name='Product with differing arities - std::tuple<int>']
|
||||
##teamcity[testFinished name='Product with differing arities - std::tuple<int>' duration="{duration}"]
|
||||
##teamcity[testStarted name='Range type with sentinel']
|
||||
##teamcity[testFinished name='Range type with sentinel' duration="{duration}"]
|
||||
##teamcity[testStarted name='Reconstruction should be based on stringification: #914']
|
||||
Decomposition.tests.cpp:<line number>|nexpression failed|n CHECK( truthy(false) )|nwith expansion:|n Hey, its truthy!|n']
|
||||
##teamcity[testFinished name='Reconstruction should be based on stringification: #914' duration="{duration}"]
|
||||
|
@ -11404,6 +11404,17 @@ Nor would this
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Range type with sentinel" filename="tests/<exe-name>/IntrospectiveTests/ToString.tests.cpp" >
|
||||
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/ToString.tests.cpp" >
|
||||
<Original>
|
||||
Catch::Detail::stringify(UsesSentinel{}) == "{ }"
|
||||
</Original>
|
||||
<Expanded>
|
||||
"{ }" == "{ }"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Reconstruction should be based on stringification: #914" tags="[.][Decomposition][failing]" filename="tests/<exe-name>/UsageTests/Decomposition.tests.cpp" >
|
||||
<Expression success="false" type="CHECK" filename="tests/<exe-name>/UsageTests/Decomposition.tests.cpp" >
|
||||
<Original>
|
||||
@ -18568,9 +18579,9 @@ loose text artifact
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<OverallResults successes="1837" failures="149" expectedFailures="21"/>
|
||||
<OverallResultsCases successes="259" failures="86" expectedFailures="4"/>
|
||||
<OverallResults successes="1838" failures="149" expectedFailures="21"/>
|
||||
<OverallResultsCases successes="260" failures="86" expectedFailures="4"/>
|
||||
</Group>
|
||||
<OverallResults successes="1837" failures="148" expectedFailures="21"/>
|
||||
<OverallResultsCases successes="259" failures="86" expectedFailures="4"/>
|
||||
<OverallResults successes="1838" failures="148" expectedFailures="21"/>
|
||||
<OverallResultsCases successes="260" failures="86" expectedFailures="4"/>
|
||||
</Catch>
|
||||
|
@ -4,6 +4,13 @@
|
||||
|
||||
enum class EnumClass3 { Value1, Value2, Value3, Value4 };
|
||||
|
||||
struct UsesSentinel {
|
||||
using const_iterator = int const*;
|
||||
using const_sentinel = std::nullptr_t;
|
||||
|
||||
const_iterator begin() const { return nullptr; }
|
||||
const_iterator end() const { return nullptr; }
|
||||
};
|
||||
|
||||
TEST_CASE( "parseEnums", "[Strings][enums]" ) {
|
||||
using namespace Catch::Matchers;
|
||||
@ -40,3 +47,7 @@ TEST_CASE( "Directly creating an EnumInfo" ) {
|
||||
CHECK( enumInfo->lookup(1) == "Value2" );
|
||||
CHECK( enumInfo->lookup(3) == "{** unexpected enum value **}" );
|
||||
}
|
||||
|
||||
TEST_CASE("Range type with sentinel") {
|
||||
CHECK( Catch::Detail::stringify(UsesSentinel{}) == "{ }" );
|
||||
}
|
Loading…
Reference in New Issue
Block a user