fix string according to reviews

This commit is contained in:
Metehan Tuncbilek
2024-10-17 16:00:38 +03:00
parent 03a7ca3040
commit b6d74ea4f7
2 changed files with 143 additions and 40 deletions

View File

@@ -117,10 +117,6 @@ TEST_CASE("String")
String str2("Hello World");
str2.ToLower();
REQUIRE(str2 == "hello world");
String str3("Georg will save us all from our doom");
str3.FirstLettersUpper();
REQUIRE(str3 == "Georg Will Save Us All From Our Doom");
}
SECTION("Substring")
@@ -138,4 +134,94 @@ TEST_CASE("String")
String str2("42.42");
REQUIRE(str2.FromString<float>() == 42.42f);
}
SECTION("StartsWith")
{
String str1("Hello World");
REQUIRE(str1.StartsWith("Hello"));
REQUIRE(!str1.StartsWith("World"));
}
SECTION("EndsWith")
{
String str1("Hello World");
REQUIRE(str1.EndsWith("World"));
REQUIRE(!str1.EndsWith("Hello"));
}
SECTION("Contains")
{
String str1("Hello World");
REQUIRE(str1.Contains("Hello"));
REQUIRE(str1.Contains("World"));
REQUIRE(!str1.Contains("Georg"));
}
SECTION("FindEndIndexOf")
{
String str1("Georg will save us all from our doom");
REQUIRE(str1.FindEndIndexOf("save") == 11);
}
SECTION("TrimFront")
{
String str1(" Hello World");
REQUIRE(str1.TrimFront() == "Hello World");
}
SECTION("TrimBack")
{
String str1("Hello World ");
REQUIRE(str1.TrimBack() == "Hello World");
}
SECTION("Empty")
{
String str1;
REQUIRE(str1.Empty());
REQUIRE(!str1);
String str2("Hello World");
REQUIRE(!str2.Empty());
REQUIRE(!!str2);
}
SECTION("Size")
{
String str1("Hello World");
REQUIRE(str1.Size() == 11);
}
SECTION("Capacity")
{
String str1("Hello World");
REQUIRE(str1.Capacity() >= 11);
}
SECTION("CharCount")
{
String str1("Hello World");
REQUIRE(str1.CharCount() == 11);
}
SECTION("PopBack")
{
String str1("Hello World");
str1.PopBack();
REQUIRE(str1 == "Hello Worl");
}
SECTION("Clear")
{
String str1("Hello World");
str1.Clear();
REQUIRE(str1.Empty());
}
SECTION("ShrinkToFit")
{
String str1("Hello World");
str1.ShrinkToFit();
REQUIRE(str1.Capacity() == 15); // 11 + 4 null terminators due to sso
}
}