diff --git a/tests/StringTest.cpp b/tests/StringTest.cpp index 5b700d0..a14821b 100644 --- a/tests/StringTest.cpp +++ b/tests/StringTest.cpp @@ -10,218 +10,208 @@ using namespace OpenVulkano; -TEST_CASE("String") +TEST_CASE("Constructors") { - SECTION("Constructors") - { - String str1; - REQUIRE(str1 == ""); + String str1; + REQUIRE(str1 == ""); - String str2("Hello"); - REQUIRE(str2 == "Hello"); + String str2("Hello"); + REQUIRE(str2 == "Hello"); - String str3(std::string("World")); - REQUIRE(str3 == "World"); + String str3(std::string("World")); + REQUIRE(str3 == "World"); - String str4(str2); - REQUIRE(str4 == "Hello"); + String str4(str2); + REQUIRE(str4 == "Hello"); - String str5(std::move(str3)); - REQUIRE(str5 == "World"); - } + String str5(std::move(str3)); + REQUIRE(str5 == "World"); +} - SECTION("Assignment") - { - String str1; - str1 = "Hello"; - REQUIRE(str1 == "Hello"); +TEST_CASE("Assignment") +{ + String str1; + str1 = "Hello"; + REQUIRE(str1 == "Hello"); - String str2; - str2 = std::string("World"); - REQUIRE(str2 == "World"); + String str2; + str2 = std::string("World"); + REQUIRE(str2 == "World"); - String str3; - str3 = str1; - REQUIRE(str3 == "Hello"); + String str3; + str3 = str1; + REQUIRE(str3 == "Hello"); - String str4; - str4 = std::move(str2); - REQUIRE(str4 == "World"); - } + String str4; + str4 = std::move(str2); + REQUIRE(str4 == "World"); +} - SECTION("Concatenation") - { - String str1("Hello"); - str1 += " World"; - REQUIRE(str1 == "Hello World"); +TEST_CASE("Concatenation") +{ + String str1("Hello"); + str1 += " World"; + REQUIRE(str1 == "Hello World"); - String str2("Hello"); - String str3 = str2 + " World"; - REQUIRE(str3 == "Hello World"); + String str2("Hello"); + String str3 = str2 + " World"; + REQUIRE(str3 == "Hello World"); - String str4("Hello"); - str4 += std::string(" World"); - REQUIRE(str4 == "Hello World"); + String str4("Hello"); + str4 += std::string(" World"); + REQUIRE(str4 == "Hello World"); - String str5("Hello"); - String str6 = str5 + std::string(" World"); - REQUIRE(str6 == "Hello World"); + String str5("Hello"); + String str6 = str5 + std::string(" World"); + REQUIRE(str6 == "Hello World"); - String str7("Hello"); - str7 += String(" World"); - REQUIRE(str7 == "Hello World"); + String str7("Hello"); + str7 += String(" World"); + REQUIRE(str7 == "Hello World"); - String str8("Hello"); - String str9 = str8 + String(" World"); - REQUIRE(str9 == "Hello World"); + String str8("Hello"); + String str9 = str8 + String(" World"); + REQUIRE(str9 == "Hello World"); - String str10 = String("Hello") + " World"; - REQUIRE(str10 == "Hello World"); + String str10 = String("Hello") + " World"; + REQUIRE(str10 == "Hello World"); - String str11 = String("Hello") + std::string(" World"); - REQUIRE(str11 == "Hello World"); + String str11 = String("Hello") + std::string(" World"); + REQUIRE(str11 == "Hello World"); - String str12 = std::string("Hello") + String(" World"); - REQUIRE(str12 == "Hello World"); - } + String str12 = std::string("Hello") + String(" World"); + REQUIRE(str12 == "Hello World"); +} - SECTION("Comparison") - { - String str1("Hello"); - REQUIRE(str1 == "Hello"); - REQUIRE(str1 != "World"); +TEST_CASE("Comparison") +{ + String str1("Hello"); + REQUIRE(str1 == "Hello"); + REQUIRE(str1 != "World"); - String str2("World"); - REQUIRE(str2 == "World"); - REQUIRE(str2 != "Hello"); - } + String str2("World"); + REQUIRE(str2 == "World"); + REQUIRE(str2 != "Hello"); +} - SECTION("Trim") - { - String str1(" Hello World "); - REQUIRE(str1.Trim() == "Hello World"); - } +TEST_CASE("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); - } +TEST_CASE("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"); +TEST_CASE("Upper/Lower") +{ + String str1("Hello World"); + str1.ToUpper(); + REQUIRE(str1 == "HELLO WORLD"); - String str2("Hello World"); - str2.ToLower(); - REQUIRE(str2 == "hello world"); - } + String str2("Hello World"); + str2.ToLower(); + REQUIRE(str2 == "hello world"); +} - SECTION("Substring") - { - String str1("Hello World"); - REQUIRE(str1.SubString(0, 5) == "Hello"); - REQUIRE(str1.SubString(6, 11) == "World"); - } +TEST_CASE("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() == 42); +TEST_CASE("FromString") +{ + String str1("42"); + REQUIRE(str1.FromString() == 42); - String str2("42.42"); - REQUIRE(str2.FromString() == 42.42f); - } + String str2("42.42"); + REQUIRE(str2.FromString() == 42.42f); +} - SECTION("StartsWith") - { - String str1("Hello World"); - REQUIRE(str1.StartsWith("Hello")); - REQUIRE(!str1.StartsWith("World")); - } +TEST_CASE("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")); - } +TEST_CASE("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")); - } +TEST_CASE("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); - } +TEST_CASE("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"); - } +TEST_CASE("TrimFront") +{ + String str1(" Hello World"); + REQUIRE(str1.TrimFront() == "Hello World"); +} - SECTION("TrimBack") - { - String str1("Hello World "); - REQUIRE(str1.TrimBack() == "Hello World"); - } +TEST_CASE("TrimBack") +{ + String str1("Hello World "); + REQUIRE(str1.TrimBack() == "Hello World"); +} - SECTION("Empty") - { - String str1; - REQUIRE(str1.Empty()); - REQUIRE(!str1); +TEST_CASE("Empty") +{ + String str1; + REQUIRE(str1.Empty()); + REQUIRE(!str1); - String str2("Hello World"); - REQUIRE(!str2.Empty()); - REQUIRE(!!str2); - } + String str2("Hello World"); + REQUIRE(!str2.Empty()); + REQUIRE(!!str2); +} - SECTION("Size") - { - String str1("Hello World"); - REQUIRE(str1.Size() == 11); - } +TEST_CASE("Size") +{ + String str1("Hello World"); + REQUIRE(str1.Size() == 11); +} - SECTION("Capacity") - { - String str1("Hello World"); - REQUIRE(str1.Capacity() >= 11); - } +TEST_CASE("Capacity") +{ + String str1("Hello World"); + REQUIRE(str1.Capacity() >= 11); +} - SECTION("CharCount") - { - String str1("Hello World"); - REQUIRE(str1.CharCount() == 11); - } +TEST_CASE("CharCount") +{ + String str1("Hello World"); + REQUIRE(str1.CharCount() == 11); +} - SECTION("PopBack") - { - String str1("Hello World"); - str1.PopBack(); - REQUIRE(str1 == "Hello Worl"); - } +TEST_CASE("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 - } -} \ No newline at end of file +TEST_CASE("Clear") +{ + String str1("Hello World"); + str1.Clear(); + REQUIRE(str1.Empty()); +}