Merge pull request #75510 from SilicDev/string_erase

Reimplement `String.erase()` as immutable method
This commit is contained in:
Clay John 2023-05-05 10:03:49 -07:00 committed by GitHub
commit 7a13cf9aeb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 0 deletions

View file

@ -395,6 +395,12 @@ TEST_CASE("[String] Insertion") {
CHECK(s == "Who is Frederic Chopin?");
}
TEST_CASE("[String] Erasing") {
String s = "Josephine is such a cute girl!";
s = s.erase(s.find("cute "), String("cute ").length());
CHECK(s == "Josephine is such a girl!");
}
TEST_CASE("[String] Number to string") {
CHECK(String::num(0) == "0");
CHECK(String::num(0.0) == "0"); // No trailing zeros.