From f43d32d6d2cc7ecd04f4f06f20d5a6fc2c87c9ae Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 12 Mar 2024 01:08:39 +0100 Subject: Another reorganization change that diverts me from crying unable to get rid off singleton madness --- FoundationEx/test/Text.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 FoundationEx/test/Text.cpp (limited to 'FoundationEx/test/Text.cpp') 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 + +#include + +#include + + +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); +} -- cgit v1.1