1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#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)
{
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");
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);
}
|