summaryrefslogtreecommitdiffhomepage
path: root/FoundationEx/test
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2024-03-18 00:20:38 +0100
committerAki <please@ignore.pl>2024-03-18 00:20:38 +0100
commit7117768feb2b2acb8d2498229cbaa4afbad377f1 (patch)
treec5abefb044bc885604afa9cb48e3af1434e279db /FoundationEx/test
parent5b1ce74b74a47f8812470efe9c56e03bcb0e456d (diff)
downloadstarshatter-7117768feb2b2acb8d2498229cbaa4afbad377f1.zip
starshatter-7117768feb2b2acb8d2498229cbaa4afbad377f1.tar.gz
starshatter-7117768feb2b2acb8d2498229cbaa4afbad377f1.tar.bz2
Text operations that return new Text are now const
Diffstat (limited to 'FoundationEx/test')
-rw-r--r--FoundationEx/test/Text.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/FoundationEx/test/Text.cpp b/FoundationEx/test/Text.cpp
index 7400eb1..deaf742 100644
--- a/FoundationEx/test/Text.cpp
+++ b/FoundationEx/test/Text.cpp
@@ -31,7 +31,7 @@ TEST(FoundationEx, TextCanBeCopied)
TEST(FoundationEx, ConcatenateTextWithLiteralWithoutSideEffects)
{
- const Text a {"Hello"};
+ Text a {"Hello"};
const auto b = a + ", there";
ASSERT_EQ("Hello", a);
ASSERT_EQ("Hello, there", b);
@@ -41,7 +41,25 @@ TEST(FoundationEx, ConcatenateTextWithLiteralWithoutSideEffects)
TEST(FoundationEx, ReplaceInTextWithoutSideEffects)
{
Text a {"Hello, all"};
- const auto b = a.replace("Hello", "Goodbye"); // Test::replace should be const
+ const auto b = a.replace("Hello", "Goodbye");
ASSERT_EQ("Hello, all", a);
ASSERT_EQ("Goodbye, all", b);
}
+
+
+TEST(FoundationEx, SubstringFromTextWithoutSideEffects)
+{
+ Text a {"Hello, all"};
+ const auto b = a.substring(7, 3);
+ ASSERT_EQ("Hello, all", a);
+ ASSERT_EQ("all", b);
+}
+
+
+TEST(FoundationEx, TrimTextWithoutSideEffects)
+{
+ Text a {" Hi! "};
+ const auto b = a.trim();
+ ASSERT_EQ(" Hi! ", a);
+ ASSERT_EQ("Hi!", b);
+}