summaryrefslogtreecommitdiffhomepage
path: root/FoundationEx/test/Text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'FoundationEx/test/Text.cpp')
-rw-r--r--FoundationEx/test/Text.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/FoundationEx/test/Text.cpp b/FoundationEx/test/Text.cpp
new file mode 100644
index 0000000..7400eb1
--- /dev/null
+++ b/FoundationEx/test/Text.cpp
@@ -0,0 +1,47 @@
+#include <utility>
+
+#include <gtest/gtest.h>
+
+#include <Text.h>
+
+
+TEST(FoundationEx, DefaultConstructedTextIsEmpty)
+{
+ Text t;
+ ASSERT_EQ(0, t.length());
+ ASSERT_TRUE(t.empty());
+}
+
+
+TEST(FoundationEx, TextCanBeInitializedWithLiteral)
+{
+ Text t {"Hello, there"};
+ ASSERT_EQ("Hello, there", t);
+ ASSERT_EQ(12, t.length());
+}
+
+
+TEST(FoundationEx, TextCanBeCopied)
+{
+ Text a {"Hello, there"};
+ Text b(a);
+ ASSERT_EQ(a, b);
+}
+
+
+TEST(FoundationEx, ConcatenateTextWithLiteralWithoutSideEffects)
+{
+ const Text a {"Hello"};
+ const auto b = a + ", there";
+ ASSERT_EQ("Hello", a);
+ ASSERT_EQ("Hello, there", b);
+}
+
+
+TEST(FoundationEx, ReplaceInTextWithoutSideEffects)
+{
+ Text a {"Hello, all"};
+ const auto b = a.replace("Hello", "Goodbye"); // Test::replace should be const
+ ASSERT_EQ("Hello, all", a);
+ ASSERT_EQ("Goodbye, all", b);
+}