diff options
author | Aki <please@ignore.pl> | 2024-03-12 01:08:39 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2024-03-12 01:08:39 +0100 |
commit | f43d32d6d2cc7ecd04f4f06f20d5a6fc2c87c9ae (patch) | |
tree | 0f82962432f9cd4fae60dd37c8935c1bc28f29e5 /FoundationEx/test/Text.cpp | |
parent | 2914a714cebae7f30d47362dfe50c39cb6621163 (diff) | |
download | starshatter-f43d32d6d2cc7ecd04f4f06f20d5a6fc2c87c9ae.zip starshatter-f43d32d6d2cc7ecd04f4f06f20d5a6fc2c87c9ae.tar.gz starshatter-f43d32d6d2cc7ecd04f4f06f20d5a6fc2c87c9ae.tar.bz2 |
Another reorganization change that diverts me from crying unable to get rid off singleton madness
Diffstat (limited to 'FoundationEx/test/Text.cpp')
-rw-r--r-- | FoundationEx/test/Text.cpp | 47 |
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); +} |