-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit_str_3_test.cpp
More file actions
74 lines (64 loc) · 1.89 KB
/
split_str_3_test.cpp
File metadata and controls
74 lines (64 loc) · 1.89 KB
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
66
67
68
69
70
71
72
73
74
#include <gtest/gtest.h>
#include "split_str_3_lib.h"
class TestLineOutputStrategy : public LineOutputStrategy {
public:
vector<string> getTokens();
};
vector<string> TestLineOutputStrategy::getTokens() {
return tokens;
};
TEST(SplitStr3Test, GetTokensSingleWord) {
string str("hello");
TestLineOutputStrategy tlos;
getOutput(str, &tlos);
vector<string> tokens = tlos.getTokens();
vector<string> expected = { "hello" };
EXPECT_TRUE(expected == tokens);
}
TEST(SplitStr3Test, GetTokensSingleWordSpaceBefore) {
string str(" hello");
TestLineOutputStrategy tlos;
getOutput(str, &tlos);
vector<string> tokens = tlos.getTokens();
vector<string> expected = { "hello" };
EXPECT_TRUE(expected == tokens);
}
TEST(SplitStr3Test, GetTokensSingleWordSpaceAfter) {
string str("hello ");
TestLineOutputStrategy tlos;
getOutput(str, &tlos);
vector<string> tokens = tlos.getTokens();
vector<string> expected = { "hello" };
EXPECT_TRUE(expected == tokens);
}
TEST(SplitStr3Test, GetTokensTwoWords) {
string str("hello world");
TestLineOutputStrategy tlos;
getOutput(str, &tlos);
vector<string> tokens = tlos.getTokens();
vector<string> expected = { "hello", "world" };
EXPECT_TRUE(expected == tokens);
}
TEST(SplitStr3Test, GetTokensTwoWordsDoubleSpaceBetween) {
string str("hello world");
TestLineOutputStrategy tlos;
getOutput(str, &tlos);
vector<string> tokens = tlos.getTokens();
vector<string> expected = { "hello", "world" };
EXPECT_TRUE(expected == tokens);
}
TEST(SplitStr3Test, GetOutputSingleToken) {
LineOutputStrategy los;
los.append("hello");
string out = los.output();
string expected("hello\n");
EXPECT_TRUE(expected == out);
}
TEST(SplitStr3Test, GetOutputTwoTokens) {
LineOutputStrategy los;
los.append("hello");
los.append("world");
string out = los.output();
string expected("hello\nworld\n");
EXPECT_TRUE(expected == out);
}