couple new features for string wrapper

This commit is contained in:
Metehan Tuncbilek
2024-10-16 14:02:10 +03:00
parent 5256ef8ff3
commit 6d53ff9c76
2 changed files with 95 additions and 1 deletions

View File

@@ -86,4 +86,47 @@ TEST_CASE("String")
REQUIRE(str2 == "World");
REQUIRE(str2 != "Hello");
}
SECTION("Trim")
{
String str1(" Hello World ");
REQUIRE(str1.Trim() == "Hello World");
}
SECTION("FindIndex")
{
String str1("Georg will save us all from our doom");
REQUIRE(str1.FindStartIndexOf("save") == 11);
}
SECTION("Upper/Lower")
{
String str1("Hello World");
str1.ToUpper();
REQUIRE(str1 == "HELLO WORLD");
String str2("Hello World");
str2.ToLower();
REQUIRE(str2 == "hello world");
String str3("Georg will save us all from our doom");
str3.ToUpperStarters();
REQUIRE(str3 == "Georg Will Save Us All From Our Doom");
}
SECTION("Substring")
{
String str1("Hello World");
REQUIRE(str1.Substring(0, 5) == "Hello");
REQUIRE(str1.Substring(6, 11) == "World");
}
SECTION("FromString")
{
String str1("42");
REQUIRE(str1.FromString<int>() == 42);
String str2("42.42");
REQUIRE(str2.FromString<float>() == 42.42f);
}
}