summaryrefslogtreecommitdiffhomepage
path: root/FoundationEx/test/Text.cpp
blob: 7400eb1bbd551556a7677eeed08c6cb7bd6748a5 (plain)
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
#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);
}