From 7117768feb2b2acb8d2498229cbaa4afbad377f1 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 18 Mar 2024 00:20:38 +0100 Subject: Text operations that return new Text are now const --- FoundationEx/test/Text.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'FoundationEx/test/Text.cpp') 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); +} -- cgit v1.1