mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Change startsWith(char) to take StringRef as argument
This commit is contained in:
parent
7bb00a42be
commit
d42e7a23a0
@ -25,7 +25,7 @@ namespace Catch {
|
||||
bool startsWith( std::string const& s, std::string const& prefix ) {
|
||||
return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin());
|
||||
}
|
||||
bool startsWith( std::string const& s, char prefix ) {
|
||||
bool startsWith( StringRef s, char prefix ) {
|
||||
return !s.empty() && s[0] == prefix;
|
||||
}
|
||||
bool endsWith( std::string const& s, std::string const& suffix ) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
namespace Catch {
|
||||
|
||||
bool startsWith( std::string const& s, std::string const& prefix );
|
||||
bool startsWith( std::string const& s, char prefix );
|
||||
bool startsWith( StringRef s, char prefix );
|
||||
bool endsWith( std::string const& s, std::string const& suffix );
|
||||
bool endsWith( std::string const& s, char suffix );
|
||||
bool contains( std::string const& s, std::string const& infix );
|
||||
|
@ -330,6 +330,7 @@ loose text artifact
|
||||
:test-result: PASS shortened hide tags are split apart
|
||||
:test-result: PASS splitString
|
||||
:test-result: FAIL stacks unscoped info in loops
|
||||
:test-result: PASS startsWith
|
||||
:test-result: PASS std::map is convertible string
|
||||
:test-result: PASS std::pair<int,const std::string> -> toString
|
||||
:test-result: PASS std::pair<int,std::string> -> toString
|
||||
|
@ -2224,6 +2224,9 @@ StringManip.tests.cpp:<line number>: passed: splitStringRef("abc", ','), Equals(
|
||||
StringManip.tests.cpp:<line number>: passed: splitStringRef("abc,def", ','), Equals(std::vector<StringRef>{"abc", "def"}) for: { abc, def } Equals: { abc, def }
|
||||
Message.tests.cpp:<line number>: failed: false with 4 messages: 'Count 1 to 3...' and '1' and '2' and '3'
|
||||
Message.tests.cpp:<line number>: failed: false with 4 messages: 'Count 4 to 6...' and '4' and '5' and '6'
|
||||
StringManip.tests.cpp:<line number>: passed: !(startsWith("", 'c')) for: !false
|
||||
StringManip.tests.cpp:<line number>: passed: startsWith(std::string("abc"), 'a') for: true
|
||||
StringManip.tests.cpp:<line number>: passed: startsWith("def"_catch_sr, 'd') for: true
|
||||
ToStringGeneral.tests.cpp:<line number>: passed: Catch::Detail::stringify( emptyMap ) == "{ }" for: "{ }" == "{ }"
|
||||
ToStringGeneral.tests.cpp:<line number>: passed: Catch::Detail::stringify( map ) == "{ { \"one\", 1 } }" for: "{ { "one", 1 } }" == "{ { "one", 1 } }"
|
||||
ToStringGeneral.tests.cpp:<line number>: passed: Catch::Detail::stringify( map ) == "{ { \"abc\", 1 }, { \"def\", 2 }, { \"ghi\", 3 } }" for: "{ { "abc", 1 }, { "def", 2 }, { "ghi", 3 } }"
|
||||
|
@ -1386,6 +1386,6 @@ due to unexpected exception with message:
|
||||
Why would you throw a std::string?
|
||||
|
||||
===============================================================================
|
||||
test cases: 368 | 292 passed | 70 failed | 6 failed as expected
|
||||
assertions: 2103 | 1951 passed | 129 failed | 23 failed as expected
|
||||
test cases: 369 | 293 passed | 70 failed | 6 failed as expected
|
||||
assertions: 2106 | 1954 passed | 129 failed | 23 failed as expected
|
||||
|
||||
|
@ -15855,6 +15855,27 @@ with messages:
|
||||
5
|
||||
6
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
startsWith
|
||||
-------------------------------------------------------------------------------
|
||||
StringManip.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
StringManip.tests.cpp:<line number>: PASSED:
|
||||
CHECK_FALSE( startsWith("", 'c') )
|
||||
with expansion:
|
||||
!false
|
||||
|
||||
StringManip.tests.cpp:<line number>: PASSED:
|
||||
CHECK( startsWith(std::string("abc"), 'a') )
|
||||
with expansion:
|
||||
true
|
||||
|
||||
StringManip.tests.cpp:<line number>: PASSED:
|
||||
CHECK( startsWith("def"_catch_sr, 'd') )
|
||||
with expansion:
|
||||
true
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
std::map is convertible string
|
||||
empty
|
||||
@ -16933,6 +16954,6 @@ Misc.tests.cpp:<line number>
|
||||
Misc.tests.cpp:<line number>: PASSED:
|
||||
|
||||
===============================================================================
|
||||
test cases: 368 | 276 passed | 86 failed | 6 failed as expected
|
||||
assertions: 2120 | 1951 passed | 146 failed | 23 failed as expected
|
||||
test cases: 369 | 277 passed | 86 failed | 6 failed as expected
|
||||
assertions: 2123 | 1954 passed | 146 failed | 23 failed as expected
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuitesloose text artifact
|
||||
>
|
||||
<testsuite name="<exe-name>" errors="17" failures="129" tests="2120" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testsuite name="<exe-name>" errors="17" failures="129" tests="2123" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<properties>
|
||||
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
|
||||
<property name="random-seed" value="1"/>
|
||||
@ -1756,6 +1756,7 @@ Count 4 to 6...
|
||||
Message.tests.cpp:<line number>
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase classname="<exe-name>.global" name="startsWith" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="std::map is convertible string/empty" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="std::map is convertible string/single item" time="{duration}" status="run"/>
|
||||
<testcase classname="<exe-name>.global" name="std::map is convertible string/several items" time="{duration}" status="run"/>
|
||||
|
@ -215,6 +215,7 @@
|
||||
<testCase name="replaceInPlace/replace no chars" duration="{duration}"/>
|
||||
<testCase name="replaceInPlace/escape '" duration="{duration}"/>
|
||||
<testCase name="splitString" duration="{duration}"/>
|
||||
<testCase name="startsWith" duration="{duration}"/>
|
||||
</file>
|
||||
<file path="tests/<exe-name>/IntrospectiveTests/Tag.tests.cpp">
|
||||
<testCase name="Tag alias can be registered against tag patterns/The same tag alias can only be registered once" duration="{duration}"/>
|
||||
|
@ -4004,6 +4004,12 @@ ok {test-number} - splitStringRef("abc,def", ','), Equals(std::vector<StringRef>
|
||||
not ok {test-number} - false with 4 messages: 'Count 1 to 3...' and '1' and '2' and '3'
|
||||
# stacks unscoped info in loops
|
||||
not ok {test-number} - false with 4 messages: 'Count 4 to 6...' and '4' and '5' and '6'
|
||||
# startsWith
|
||||
ok {test-number} - !(startsWith("", 'c')) for: !false
|
||||
# startsWith
|
||||
ok {test-number} - startsWith(std::string("abc"), 'a') for: true
|
||||
# startsWith
|
||||
ok {test-number} - startsWith("def"_catch_sr, 'd') for: true
|
||||
# std::map is convertible string
|
||||
ok {test-number} - Catch::Detail::stringify( emptyMap ) == "{ }" for: "{ }" == "{ }"
|
||||
# std::map is convertible string
|
||||
@ -4242,5 +4248,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
|
||||
ok {test-number} -
|
||||
# xmlentitycheck
|
||||
ok {test-number} -
|
||||
1..2120
|
||||
1..2123
|
||||
|
||||
|
@ -803,6 +803,8 @@ Message.tests.cpp:<line number>|nexpression failed with messages:|n "hi"|n "i
|
||||
Message.tests.cpp:<line number>|nexpression failed with messages:|n "Count 1 to 3..."|n "1"|n "2"|n "3"|n CHECK( false )|nwith expansion:|n false|n']
|
||||
Message.tests.cpp:<line number>|nexpression failed with messages:|n "Count 4 to 6..."|n "4"|n "5"|n "6"|n CHECK( false )|nwith expansion:|n false|n']
|
||||
##teamcity[testFinished name='stacks unscoped info in loops' duration="{duration}"]
|
||||
##teamcity[testStarted name='startsWith']
|
||||
##teamcity[testFinished name='startsWith' duration="{duration}"]
|
||||
##teamcity[testStarted name='std::map is convertible string']
|
||||
##teamcity[testFinished name='std::map is convertible string' duration="{duration}"]
|
||||
##teamcity[testStarted name='std::pair<int,const std::string> -> toString']
|
||||
|
@ -18761,6 +18761,33 @@ loose text artifact
|
||||
</Expression>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="startsWith" tags="[string-manip]" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
|
||||
<Expression success="true" type="CHECK_FALSE" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
|
||||
<Original>
|
||||
!(startsWith("", 'c'))
|
||||
</Original>
|
||||
<Expanded>
|
||||
!false
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
|
||||
<Original>
|
||||
startsWith(std::string("abc"), 'a')
|
||||
</Original>
|
||||
<Expanded>
|
||||
true
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
|
||||
<Original>
|
||||
startsWith("def"_catch_sr, 'd')
|
||||
</Original>
|
||||
<Expanded>
|
||||
true
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="std::map is convertible string" tags="[toString]" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
<Section name="empty" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
|
||||
@ -19926,6 +19953,6 @@ loose text artifact
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<OverallResults successes="1951" failures="146" expectedFailures="23"/>
|
||||
<OverallResultsCases successes="276" failures="86" expectedFailures="6"/>
|
||||
<OverallResults successes="1954" failures="146" expectedFailures="23"/>
|
||||
<OverallResultsCases successes="277" failures="86" expectedFailures="6"/>
|
||||
</Catch2TestRun>
|
||||
|
@ -65,3 +65,11 @@ TEST_CASE("splitString", "[string-manip]") {
|
||||
CHECK_THAT(splitStringRef("abc", ','), Equals(std::vector<StringRef>{"abc"}));
|
||||
CHECK_THAT(splitStringRef("abc,def", ','), Equals(std::vector<StringRef>{"abc", "def"}));
|
||||
}
|
||||
|
||||
TEST_CASE("startsWith", "[string-manip]") {
|
||||
using Catch::startsWith;
|
||||
|
||||
CHECK_FALSE(startsWith("", 'c'));
|
||||
CHECK(startsWith(std::string("abc"), 'a'));
|
||||
CHECK(startsWith("def"_catch_sr, 'd'));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user