Skip to content

Commit edb2230

Browse files
committed
update replacement test
1 parent 6d28d99 commit edb2230

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

tests/host/core/test_string.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,24 @@ TEST_CASE("String::trim", "[core][String]")
4444

4545
TEST_CASE("String::replace", "[core][String]")
4646
{
47-
String str;
48-
str = "The quick brown fox jumped over the lazy dog.";
49-
String find = "fox";
50-
String replace = "vulpes vulpes";
51-
str.replace(find, replace);
47+
const char data[] = "The quick brown fox jumped over the lazy dog.";
48+
String str = data;
49+
str.replace("fox", "vulpes vulpes");
5250
REQUIRE(str == "The quick brown vulpes vulpes jumped over the lazy dog.");
51+
str.replace("vulpes", "lis lis");
52+
REQUIRE(str == "The quick brown lis lis lis lis jumped over the lazy dog.");
53+
str.replace("lazy dog.", "canis piger");
54+
REQUIRE(str == "The quick brown lis lis lis lis jumped over the canis piger");
55+
str.replace("brown lis lis", "lis");
56+
REQUIRE(str == "The quick lis lis lis jumped over the canis piger");
57+
str.replace("lis lis", "fox");
58+
REQUIRE(str == "The quick fox lis jumped over the canis piger");
59+
str.replace("fox lis jumped", "brown fox");
60+
REQUIRE(str == "The quick brown fox over the canis piger");
61+
str.replace(" over ", " jumped over ");
62+
str.replace("canis piger", "lazy dog");
63+
str.replace("dog", "dog.");
64+
REQUIRE(str == data);
5365
}
5466

5567
TEST_CASE("String(value, base)", "[core][String]")

0 commit comments

Comments
 (0)