Split out the rest of string manipulation tests

This commit is contained in:
Martin Hořeňovský 2019-09-07 20:22:36 +02:00
parent fe967b1f41
commit 6da00c1b64
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
5 changed files with 131 additions and 133 deletions

View File

@ -1522,26 +1522,26 @@ Message.tests.cpp:<line number>: passed: true
Misc.tests.cpp:<line number>: passed: a != b for: 1 != 2 Misc.tests.cpp:<line number>: passed: a != b for: 1 != 2
Misc.tests.cpp:<line number>: passed: b != a for: 2 != 1 Misc.tests.cpp:<line number>: passed: b != a for: 2 != 1
Misc.tests.cpp:<line number>: passed: a != b for: 1 != 2 Misc.tests.cpp:<line number>: passed: a != b for: 1 != 2
String.tests.cpp:<line number>: passed: Catch::replaceInPlace( letters, "b", "z" ) for: true StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(letters, "b", "z") for: true
String.tests.cpp:<line number>: passed: letters == "azcdefcg" for: "azcdefcg" == "azcdefcg" StringManip.tests.cpp:<line number>: passed: letters == "azcdefcg" for: "azcdefcg" == "azcdefcg"
String.tests.cpp:<line number>: passed: Catch::replaceInPlace( letters, "c", "z" ) for: true StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(letters, "c", "z") for: true
String.tests.cpp:<line number>: passed: letters == "abzdefzg" for: "abzdefzg" == "abzdefzg" StringManip.tests.cpp:<line number>: passed: letters == "abzdefzg" for: "abzdefzg" == "abzdefzg"
String.tests.cpp:<line number>: passed: Catch::replaceInPlace( letters, "a", "z" ) for: true StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(letters, "a", "z") for: true
String.tests.cpp:<line number>: passed: letters == "zbcdefcg" for: "zbcdefcg" == "zbcdefcg" StringManip.tests.cpp:<line number>: passed: letters == "zbcdefcg" for: "zbcdefcg" == "zbcdefcg"
String.tests.cpp:<line number>: passed: Catch::replaceInPlace( letters, "g", "z" ) for: true StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(letters, "g", "z") for: true
String.tests.cpp:<line number>: passed: letters == "abcdefcz" for: "abcdefcz" == "abcdefcz" StringManip.tests.cpp:<line number>: passed: letters == "abcdefcz" for: "abcdefcz" == "abcdefcz"
String.tests.cpp:<line number>: passed: Catch::replaceInPlace( letters, letters, "replaced" ) for: true StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(letters, letters, "replaced") for: true
String.tests.cpp:<line number>: passed: letters == "replaced" for: "replaced" == "replaced" StringManip.tests.cpp:<line number>: passed: letters == "replaced" for: "replaced" == "replaced"
String.tests.cpp:<line number>: passed: !(Catch::replaceInPlace( letters, "x", "z" )) for: !false StringManip.tests.cpp:<line number>: passed: !(Catch::replaceInPlace(letters, "x", "z")) for: !false
String.tests.cpp:<line number>: passed: letters == letters for: "abcdefcg" == "abcdefcg" StringManip.tests.cpp:<line number>: passed: letters == letters for: "abcdefcg" == "abcdefcg"
String.tests.cpp:<line number>: passed: Catch::replaceInPlace( s, "'", "|'" ) for: true StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(s, "'", "|'") for: true
String.tests.cpp:<line number>: passed: s == "didn|'t" for: "didn|'t" == "didn|'t" StringManip.tests.cpp:<line number>: passed: s == "didn|'t" for: "didn|'t" == "didn|'t"
Misc.tests.cpp:<line number>: failed: false with 1 message: '3' Misc.tests.cpp:<line number>: failed: false with 1 message: '3'
Message.tests.cpp:<line number>: failed: false with 2 messages: 'hi' and 'i := 7' Message.tests.cpp:<line number>: failed: false with 2 messages: 'hi' and 'i := 7'
Tag.tests.cpp:<line number>: passed: testcase.tags, Catch::VectorContains(std::string("magic-tag")) && Catch::VectorContains(std::string(".")) for: { ".", "magic-tag" } ( Contains: "magic-tag" and Contains: "." ) Tag.tests.cpp:<line number>: passed: testcase.tags, Catch::VectorContains(std::string("magic-tag")) && Catch::VectorContains(std::string(".")) for: { ".", "magic-tag" } ( Contains: "magic-tag" and Contains: "." )
String.tests.cpp:<line number>: passed: splitStringRef("", ',' ), Equals(std::vector<StringRef>() ) for: { } Equals: { } StringManip.tests.cpp:<line number>: passed: splitStringRef("", ','), Equals(std::vector<StringRef>()) for: { } Equals: { }
String.tests.cpp:<line number>: passed: splitStringRef("abc", ',' ), Equals(std::vector<StringRef>{"abc"} ) for: { abc } Equals: { abc } StringManip.tests.cpp:<line number>: passed: splitStringRef("abc", ','), Equals(std::vector<StringRef>{"abc"}) for: { abc } Equals: { abc }
String.tests.cpp:<line number>: passed: splitStringRef("abc,def", ',' ), Equals(std::vector<StringRef>{"abc", "def"} ) for: { abc, def } Equals: { abc, def } 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 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' Message.tests.cpp:<line number>: failed: false with 4 messages: 'Count 4 to 6...' and '4' and '5' and '6'
ToStringGeneral.tests.cpp:<line number>: passed: Catch::Detail::stringify( emptyMap ) == "{ }" for: "{ }" == "{ }" ToStringGeneral.tests.cpp:<line number>: passed: Catch::Detail::stringify( emptyMap ) == "{ }" for: "{ }" == "{ }"

View File

@ -11441,15 +11441,15 @@ with expansion:
replaceInPlace replaceInPlace
replace single char replace single char
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
String.tests.cpp:<line number> StringManip.tests.cpp:<line number>
............................................................................... ...............................................................................
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK( Catch::replaceInPlace(letters, "b", "z") ) CHECK( Catch::replaceInPlace(letters, "b", "z") )
with expansion: with expansion:
true true
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK( letters == "azcdefcg" ) CHECK( letters == "azcdefcg" )
with expansion: with expansion:
"azcdefcg" == "azcdefcg" "azcdefcg" == "azcdefcg"
@ -11458,15 +11458,15 @@ with expansion:
replaceInPlace replaceInPlace
replace two chars replace two chars
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
String.tests.cpp:<line number> StringManip.tests.cpp:<line number>
............................................................................... ...............................................................................
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK( Catch::replaceInPlace(letters, "c", "z") ) CHECK( Catch::replaceInPlace(letters, "c", "z") )
with expansion: with expansion:
true true
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK( letters == "abzdefzg" ) CHECK( letters == "abzdefzg" )
with expansion: with expansion:
"abzdefzg" == "abzdefzg" "abzdefzg" == "abzdefzg"
@ -11475,15 +11475,15 @@ with expansion:
replaceInPlace replaceInPlace
replace first char replace first char
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
String.tests.cpp:<line number> StringManip.tests.cpp:<line number>
............................................................................... ...............................................................................
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK( Catch::replaceInPlace(letters, "a", "z") ) CHECK( Catch::replaceInPlace(letters, "a", "z") )
with expansion: with expansion:
true true
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK( letters == "zbcdefcg" ) CHECK( letters == "zbcdefcg" )
with expansion: with expansion:
"zbcdefcg" == "zbcdefcg" "zbcdefcg" == "zbcdefcg"
@ -11492,15 +11492,15 @@ with expansion:
replaceInPlace replaceInPlace
replace last char replace last char
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
String.tests.cpp:<line number> StringManip.tests.cpp:<line number>
............................................................................... ...............................................................................
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK( Catch::replaceInPlace(letters, "g", "z") ) CHECK( Catch::replaceInPlace(letters, "g", "z") )
with expansion: with expansion:
true true
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK( letters == "abcdefcz" ) CHECK( letters == "abcdefcz" )
with expansion: with expansion:
"abcdefcz" == "abcdefcz" "abcdefcz" == "abcdefcz"
@ -11509,15 +11509,15 @@ with expansion:
replaceInPlace replaceInPlace
replace all chars replace all chars
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
String.tests.cpp:<line number> StringManip.tests.cpp:<line number>
............................................................................... ...............................................................................
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK( Catch::replaceInPlace(letters, letters, "replaced") ) CHECK( Catch::replaceInPlace(letters, letters, "replaced") )
with expansion: with expansion:
true true
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK( letters == "replaced" ) CHECK( letters == "replaced" )
with expansion: with expansion:
"replaced" == "replaced" "replaced" == "replaced"
@ -11526,15 +11526,15 @@ with expansion:
replaceInPlace replaceInPlace
replace no chars replace no chars
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
String.tests.cpp:<line number> StringManip.tests.cpp:<line number>
............................................................................... ...............................................................................
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK_FALSE( Catch::replaceInPlace(letters, "x", "z") ) CHECK_FALSE( Catch::replaceInPlace(letters, "x", "z") )
with expansion: with expansion:
!false !false
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK( letters == letters ) CHECK( letters == letters )
with expansion: with expansion:
"abcdefcg" == "abcdefcg" "abcdefcg" == "abcdefcg"
@ -11543,15 +11543,15 @@ with expansion:
replaceInPlace replaceInPlace
escape ' escape '
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
String.tests.cpp:<line number> StringManip.tests.cpp:<line number>
............................................................................... ...............................................................................
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK( Catch::replaceInPlace(s, "'", "|'") ) CHECK( Catch::replaceInPlace(s, "'", "|'") )
with expansion: with expansion:
true true
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK( s == "didn|'t" ) CHECK( s == "didn|'t" )
with expansion: with expansion:
"didn|'t" == "didn|'t" "didn|'t" == "didn|'t"
@ -11602,20 +11602,20 @@ with expansion:
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
splitString splitString
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
String.tests.cpp:<line number> StringManip.tests.cpp:<line number>
............................................................................... ...............................................................................
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK_THAT( splitStringRef("", ','), Equals(std::vector<StringRef>()) ) CHECK_THAT( splitStringRef("", ','), Equals(std::vector<StringRef>()) )
with expansion: with expansion:
{ } Equals: { } { } Equals: { }
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK_THAT( splitStringRef("abc", ','), Equals(std::vector<StringRef>{"abc"}) ) CHECK_THAT( splitStringRef("abc", ','), Equals(std::vector<StringRef>{"abc"}) )
with expansion: with expansion:
{ abc } Equals: { abc } { abc } Equals: { abc }
String.tests.cpp:<line number>: PASSED: StringManip.tests.cpp:<line number>: PASSED:
CHECK_THAT( splitStringRef("abc,def", ','), Equals(std::vector<StringRef>{"abc", "def"}) ) CHECK_THAT( splitStringRef("abc,def", ','), Equals(std::vector<StringRef>{"abc", "def"}) )
with expansion: with expansion:
{ abc, def } Equals: { abc, def } { abc, def } Equals: { abc, def }

View File

@ -13732,9 +13732,9 @@ loose text artifact
</Section> </Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="replaceInPlace" tags="[StringManip][Strings]" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <TestCase name="replaceInPlace" tags="[string-manip]" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Section name="replace single char" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Section name="replace single char" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
Catch::replaceInPlace(letters, "b", "z") Catch::replaceInPlace(letters, "b", "z")
</Original> </Original>
@ -13742,7 +13742,7 @@ loose text artifact
true true
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
letters == "azcdefcg" letters == "azcdefcg"
</Original> </Original>
@ -13752,8 +13752,8 @@ loose text artifact
</Expression> </Expression>
<OverallResults successes="2" failures="0" expectedFailures="0"/> <OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section> </Section>
<Section name="replace two chars" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Section name="replace two chars" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
Catch::replaceInPlace(letters, "c", "z") Catch::replaceInPlace(letters, "c", "z")
</Original> </Original>
@ -13761,7 +13761,7 @@ loose text artifact
true true
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
letters == "abzdefzg" letters == "abzdefzg"
</Original> </Original>
@ -13771,8 +13771,8 @@ loose text artifact
</Expression> </Expression>
<OverallResults successes="2" failures="0" expectedFailures="0"/> <OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section> </Section>
<Section name="replace first char" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Section name="replace first char" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
Catch::replaceInPlace(letters, "a", "z") Catch::replaceInPlace(letters, "a", "z")
</Original> </Original>
@ -13780,7 +13780,7 @@ loose text artifact
true true
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
letters == "zbcdefcg" letters == "zbcdefcg"
</Original> </Original>
@ -13790,8 +13790,8 @@ loose text artifact
</Expression> </Expression>
<OverallResults successes="2" failures="0" expectedFailures="0"/> <OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section> </Section>
<Section name="replace last char" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Section name="replace last char" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
Catch::replaceInPlace(letters, "g", "z") Catch::replaceInPlace(letters, "g", "z")
</Original> </Original>
@ -13799,7 +13799,7 @@ loose text artifact
true true
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
letters == "abcdefcz" letters == "abcdefcz"
</Original> </Original>
@ -13809,8 +13809,8 @@ loose text artifact
</Expression> </Expression>
<OverallResults successes="2" failures="0" expectedFailures="0"/> <OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section> </Section>
<Section name="replace all chars" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Section name="replace all chars" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
Catch::replaceInPlace(letters, letters, "replaced") Catch::replaceInPlace(letters, letters, "replaced")
</Original> </Original>
@ -13818,7 +13818,7 @@ loose text artifact
true true
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
letters == "replaced" letters == "replaced"
</Original> </Original>
@ -13828,8 +13828,8 @@ loose text artifact
</Expression> </Expression>
<OverallResults successes="2" failures="0" expectedFailures="0"/> <OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section> </Section>
<Section name="replace no chars" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Section name="replace no chars" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
!(Catch::replaceInPlace(letters, "x", "z")) !(Catch::replaceInPlace(letters, "x", "z"))
</Original> </Original>
@ -13837,7 +13837,7 @@ loose text artifact
!false !false
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
letters == letters letters == letters
</Original> </Original>
@ -13847,8 +13847,8 @@ loose text artifact
</Expression> </Expression>
<OverallResults successes="2" failures="0" expectedFailures="0"/> <OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section> </Section>
<Section name="escape '" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Section name="escape '" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
Catch::replaceInPlace(s, "'", "|'") Catch::replaceInPlace(s, "'", "|'")
</Original> </Original>
@ -13856,7 +13856,7 @@ loose text artifact
true true
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
s == "didn|'t" s == "didn|'t"
</Original> </Original>
@ -13913,8 +13913,8 @@ loose text artifact
</Expression> </Expression>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="splitString" tags="[Strings]" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <TestCase name="splitString" tags="[string-manip]" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
splitStringRef("", ','), Equals(std::vector&lt;StringRef>()) splitStringRef("", ','), Equals(std::vector&lt;StringRef>())
</Original> </Original>
@ -13922,7 +13922,7 @@ loose text artifact
{ } Equals: { } { } Equals: { }
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
splitStringRef("abc", ','), Equals(std::vector&lt;StringRef>{"abc"}) splitStringRef("abc", ','), Equals(std::vector&lt;StringRef>{"abc"})
</Original> </Original>
@ -13930,7 +13930,7 @@ loose text artifact
{ abc } Equals: { abc } { abc } Equals: { abc }
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original> <Original>
splitStringRef("abc,def", ','), Equals(std::vector&lt;StringRef>{"abc", "def"}) splitStringRef("abc,def", ','), Equals(std::vector&lt;StringRef>{"abc", "def"})
</Original> </Original>

View File

@ -160,48 +160,3 @@ TEST_CASE( "StringRef", "[Strings][StringRef]" ) {
} }
} }
} }
TEST_CASE( "replaceInPlace", "[Strings][StringManip]" ) {
std::string letters = "abcdefcg";
SECTION( "replace single char" ) {
CHECK( Catch::replaceInPlace( letters, "b", "z" ) );
CHECK( letters == "azcdefcg" );
}
SECTION( "replace two chars" ) {
CHECK( Catch::replaceInPlace( letters, "c", "z" ) );
CHECK( letters == "abzdefzg" );
}
SECTION( "replace first char" ) {
CHECK( Catch::replaceInPlace( letters, "a", "z" ) );
CHECK( letters == "zbcdefcg" );
}
SECTION( "replace last char" ) {
CHECK( Catch::replaceInPlace( letters, "g", "z" ) );
CHECK( letters == "abcdefcz" );
}
SECTION( "replace all chars" ) {
CHECK( Catch::replaceInPlace( letters, letters, "replaced" ) );
CHECK( letters == "replaced" );
}
SECTION( "replace no chars" ) {
CHECK_FALSE( Catch::replaceInPlace( letters, "x", "z" ) );
CHECK( letters == letters );
}
SECTION( "escape '" ) {
std::string s = "didn't";
CHECK( Catch::replaceInPlace( s, "'", "|'" ) );
CHECK( s == "didn|'t" );
}
}
TEST_CASE( "splitString", "[Strings]" ) {
using namespace Catch::Matchers;
using Catch::splitStringRef;
using Catch::StringRef;
CHECK_THAT( splitStringRef("", ',' ), Equals(std::vector<StringRef>() ) );
CHECK_THAT( splitStringRef("abc", ',' ), Equals(std::vector<StringRef>{"abc"} ) );
CHECK_THAT( splitStringRef("abc,def", ',' ), Equals(std::vector<StringRef>{"abc", "def"} ) );
}

View File

@ -22,3 +22,46 @@ TEST_CASE("Trim strings", "[string-manip]") {
REQUIRE(trim(StringRef(trailing_whitespace)) == StringRef(no_whitespace)); REQUIRE(trim(StringRef(trailing_whitespace)) == StringRef(no_whitespace));
REQUIRE(trim(StringRef(whitespace_at_both_ends)) == StringRef(no_whitespace)); REQUIRE(trim(StringRef(whitespace_at_both_ends)) == StringRef(no_whitespace));
} }
TEST_CASE("replaceInPlace", "[string-manip]") {
std::string letters = "abcdefcg";
SECTION("replace single char") {
CHECK(Catch::replaceInPlace(letters, "b", "z"));
CHECK(letters == "azcdefcg");
}
SECTION("replace two chars") {
CHECK(Catch::replaceInPlace(letters, "c", "z"));
CHECK(letters == "abzdefzg");
}
SECTION("replace first char") {
CHECK(Catch::replaceInPlace(letters, "a", "z"));
CHECK(letters == "zbcdefcg");
}
SECTION("replace last char") {
CHECK(Catch::replaceInPlace(letters, "g", "z"));
CHECK(letters == "abcdefcz");
}
SECTION("replace all chars") {
CHECK(Catch::replaceInPlace(letters, letters, "replaced"));
CHECK(letters == "replaced");
}
SECTION("replace no chars") {
CHECK_FALSE(Catch::replaceInPlace(letters, "x", "z"));
CHECK(letters == letters);
}
SECTION("escape '") {
std::string s = "didn't";
CHECK(Catch::replaceInPlace(s, "'", "|'"));
CHECK(s == "didn|'t");
}
}
TEST_CASE("splitString", "[string-manip]") {
using namespace Catch::Matchers;
using Catch::splitStringRef;
using Catch::StringRef;
CHECK_THAT(splitStringRef("", ','), Equals(std::vector<StringRef>()));
CHECK_THAT(splitStringRef("abc", ','), Equals(std::vector<StringRef>{"abc"}));
CHECK_THAT(splitStringRef("abc,def", ','), Equals(std::vector<StringRef>{"abc", "def"}));
}