mirror of
https://github.com/catchorg/Catch2.git
synced 2025-05-27 23:19:32 +00:00
Fixed replace(inPlace) function
and added tests (should have done that in the first place - I'll never learn!)
This commit is contained in:
parent
db0421e840
commit
458b3ae257
4 changed files with 50 additions and 15 deletions
|
@ -348,6 +348,34 @@ private:
|
|||
std::vector<ColourIndex> colours;
|
||||
};
|
||||
|
||||
TEST_CASE( "replaceInPlace", "" ) {
|
||||
std::string letters = "abcdefcg";
|
||||
SECTION( "replace single char" ) {
|
||||
CHECK( replaceInPlace( letters, "b", "z" ) );
|
||||
CHECK( letters == "azcdefcg" );
|
||||
}
|
||||
SECTION( "replace two chars" ) {
|
||||
CHECK( replaceInPlace( letters, "c", "z" ) );
|
||||
CHECK( letters == "abzdefzg" );
|
||||
}
|
||||
SECTION( "replace first char" ) {
|
||||
CHECK( replaceInPlace( letters, "a", "z" ) );
|
||||
CHECK( letters == "zbcdefcg" );
|
||||
}
|
||||
SECTION( "replace last char" ) {
|
||||
CHECK( replaceInPlace( letters, "g", "z" ) );
|
||||
CHECK( letters == "abcdefcz" );
|
||||
}
|
||||
SECTION( "replace all chars" ) {
|
||||
CHECK( replaceInPlace( letters, letters, "replaced" ) );
|
||||
CHECK( letters == "replaced" );
|
||||
}
|
||||
SECTION( "replace no chars" ) {
|
||||
CHECK_FALSE( replaceInPlace( letters, "x", "z" ) );
|
||||
CHECK( letters == letters );
|
||||
}
|
||||
}
|
||||
|
||||
// !TBD: This will be folded into Text class
|
||||
TEST_CASE( "Strings can be rendered with colour", "[.colour]" ) {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue