string test detailed look
This commit is contained in:
@@ -10,9 +10,7 @@
|
|||||||
|
|
||||||
using namespace OpenVulkano;
|
using namespace OpenVulkano;
|
||||||
|
|
||||||
TEST_CASE("String")
|
TEST_CASE("Constructors")
|
||||||
{
|
|
||||||
SECTION("Constructors")
|
|
||||||
{
|
{
|
||||||
String str1;
|
String str1;
|
||||||
REQUIRE(str1 == "");
|
REQUIRE(str1 == "");
|
||||||
@@ -30,7 +28,7 @@ TEST_CASE("String")
|
|||||||
REQUIRE(str5 == "World");
|
REQUIRE(str5 == "World");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Assignment")
|
TEST_CASE("Assignment")
|
||||||
{
|
{
|
||||||
String str1;
|
String str1;
|
||||||
str1 = "Hello";
|
str1 = "Hello";
|
||||||
@@ -49,7 +47,7 @@ TEST_CASE("String")
|
|||||||
REQUIRE(str4 == "World");
|
REQUIRE(str4 == "World");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Concatenation")
|
TEST_CASE("Concatenation")
|
||||||
{
|
{
|
||||||
String str1("Hello");
|
String str1("Hello");
|
||||||
str1 += " World";
|
str1 += " World";
|
||||||
@@ -85,7 +83,7 @@ TEST_CASE("String")
|
|||||||
REQUIRE(str12 == "Hello World");
|
REQUIRE(str12 == "Hello World");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Comparison")
|
TEST_CASE("Comparison")
|
||||||
{
|
{
|
||||||
String str1("Hello");
|
String str1("Hello");
|
||||||
REQUIRE(str1 == "Hello");
|
REQUIRE(str1 == "Hello");
|
||||||
@@ -96,19 +94,19 @@ TEST_CASE("String")
|
|||||||
REQUIRE(str2 != "Hello");
|
REQUIRE(str2 != "Hello");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Trim")
|
TEST_CASE("Trim")
|
||||||
{
|
{
|
||||||
String str1(" Hello World ");
|
String str1(" Hello World ");
|
||||||
REQUIRE(str1.Trim() == "Hello World");
|
REQUIRE(str1.Trim() == "Hello World");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("FindIndex")
|
TEST_CASE("FindIndex")
|
||||||
{
|
{
|
||||||
String str1("Georg will save us all from our doom");
|
String str1("Georg will save us all from our doom");
|
||||||
REQUIRE(str1.FindStartIndexOf("save") == 11);
|
REQUIRE(str1.FindStartIndexOf("save") == 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Upper/Lower")
|
TEST_CASE("Upper/Lower")
|
||||||
{
|
{
|
||||||
String str1("Hello World");
|
String str1("Hello World");
|
||||||
str1.ToUpper();
|
str1.ToUpper();
|
||||||
@@ -119,14 +117,14 @@ TEST_CASE("String")
|
|||||||
REQUIRE(str2 == "hello world");
|
REQUIRE(str2 == "hello world");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Substring")
|
TEST_CASE("Substring")
|
||||||
{
|
{
|
||||||
String str1("Hello World");
|
String str1("Hello World");
|
||||||
REQUIRE(str1.SubString(0, 5) == "Hello");
|
REQUIRE(str1.SubString(0, 5) == "Hello");
|
||||||
REQUIRE(str1.SubString(6, 11) == "World");
|
REQUIRE(str1.SubString(6, 11) == "World");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("FromString")
|
TEST_CASE("FromString")
|
||||||
{
|
{
|
||||||
String str1("42");
|
String str1("42");
|
||||||
REQUIRE(str1.FromString<int>() == 42);
|
REQUIRE(str1.FromString<int>() == 42);
|
||||||
@@ -135,21 +133,21 @@ TEST_CASE("String")
|
|||||||
REQUIRE(str2.FromString<float>() == 42.42f);
|
REQUIRE(str2.FromString<float>() == 42.42f);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("StartsWith")
|
TEST_CASE("StartsWith")
|
||||||
{
|
{
|
||||||
String str1("Hello World");
|
String str1("Hello World");
|
||||||
REQUIRE(str1.StartsWith("Hello"));
|
REQUIRE(str1.StartsWith("Hello"));
|
||||||
REQUIRE(!str1.StartsWith("World"));
|
REQUIRE(!str1.StartsWith("World"));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("EndsWith")
|
TEST_CASE("EndsWith")
|
||||||
{
|
{
|
||||||
String str1("Hello World");
|
String str1("Hello World");
|
||||||
REQUIRE(str1.EndsWith("World"));
|
REQUIRE(str1.EndsWith("World"));
|
||||||
REQUIRE(!str1.EndsWith("Hello"));
|
REQUIRE(!str1.EndsWith("Hello"));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Contains")
|
TEST_CASE("Contains")
|
||||||
{
|
{
|
||||||
String str1("Hello World");
|
String str1("Hello World");
|
||||||
REQUIRE(str1.Contains("Hello"));
|
REQUIRE(str1.Contains("Hello"));
|
||||||
@@ -157,25 +155,25 @@ TEST_CASE("String")
|
|||||||
REQUIRE(!str1.Contains("Georg"));
|
REQUIRE(!str1.Contains("Georg"));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("FindEndIndexOf")
|
TEST_CASE("FindEndIndexOf")
|
||||||
{
|
{
|
||||||
String str1("Georg will save us all from our doom");
|
String str1("Georg will save us all from our doom");
|
||||||
REQUIRE(str1.FindEndIndexOf("save") == 11);
|
REQUIRE(str1.FindEndIndexOf("save") == 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("TrimFront")
|
TEST_CASE("TrimFront")
|
||||||
{
|
{
|
||||||
String str1(" Hello World");
|
String str1(" Hello World");
|
||||||
REQUIRE(str1.TrimFront() == "Hello World");
|
REQUIRE(str1.TrimFront() == "Hello World");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("TrimBack")
|
TEST_CASE("TrimBack")
|
||||||
{
|
{
|
||||||
String str1("Hello World ");
|
String str1("Hello World ");
|
||||||
REQUIRE(str1.TrimBack() == "Hello World");
|
REQUIRE(str1.TrimBack() == "Hello World");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Empty")
|
TEST_CASE("Empty")
|
||||||
{
|
{
|
||||||
String str1;
|
String str1;
|
||||||
REQUIRE(str1.Empty());
|
REQUIRE(str1.Empty());
|
||||||
@@ -186,42 +184,34 @@ TEST_CASE("String")
|
|||||||
REQUIRE(!!str2);
|
REQUIRE(!!str2);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Size")
|
TEST_CASE("Size")
|
||||||
{
|
{
|
||||||
String str1("Hello World");
|
String str1("Hello World");
|
||||||
REQUIRE(str1.Size() == 11);
|
REQUIRE(str1.Size() == 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Capacity")
|
TEST_CASE("Capacity")
|
||||||
{
|
{
|
||||||
String str1("Hello World");
|
String str1("Hello World");
|
||||||
REQUIRE(str1.Capacity() >= 11);
|
REQUIRE(str1.Capacity() >= 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("CharCount")
|
TEST_CASE("CharCount")
|
||||||
{
|
{
|
||||||
String str1("Hello World");
|
String str1("Hello World");
|
||||||
REQUIRE(str1.CharCount() == 11);
|
REQUIRE(str1.CharCount() == 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("PopBack")
|
TEST_CASE("PopBack")
|
||||||
{
|
{
|
||||||
String str1("Hello World");
|
String str1("Hello World");
|
||||||
str1.PopBack();
|
str1.PopBack();
|
||||||
REQUIRE(str1 == "Hello Worl");
|
REQUIRE(str1 == "Hello Worl");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Clear")
|
TEST_CASE("Clear")
|
||||||
{
|
{
|
||||||
String str1("Hello World");
|
String str1("Hello World");
|
||||||
str1.Clear();
|
str1.Clear();
|
||||||
REQUIRE(str1.Empty());
|
REQUIRE(str1.Empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("ShrinkToFit")
|
|
||||||
{
|
|
||||||
String str1("Hello World");
|
|
||||||
str1.ShrinkToFit();
|
|
||||||
REQUIRE(str1.Capacity() == 15); // 11 + 4 null terminators due to sso
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user