Split out the rest of string manipulation tests
This commit is contained in:
parent
fe967b1f41
commit
6da00c1b64
5 changed files with 131 additions and 133 deletions
|
@ -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"} ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue