Skip to content

Commit 0920daf

Browse files
Add some more CI tests for String::replace (#6193)
1 parent fe01433 commit 0920daf

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/host/core/test_string.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -494,3 +494,21 @@ TEST_CASE("Strings with NULs", "[core][String]")
494494
const char *p = str3.c_str();
495495
REQUIRE(!memcmp(p, zeros, 64));
496496
}
497+
498+
TEST_CASE("Replace and string expansion", "[core][String]")
499+
{
500+
String s, l;
501+
// Make these large enough to span SSO and non SSO
502+
String whole = "#123456789012345678901234567890";
503+
const char *res = "abcde123456789012345678901234567890";
504+
for (size_t i=1; i < whole.length(); i++) {
505+
s = whole.substring(0, i);
506+
l = s;
507+
l.replace("#", "abcde");
508+
char buff[64];
509+
strcpy(buff, res);
510+
buff[5 + i-1] = 0;
511+
REQUIRE(!strcmp(l.c_str(), buff));
512+
REQUIRE(l.length() == strlen(buff));
513+
}
514+
}

0 commit comments

Comments
 (0)