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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
#include "all.hpp"
#include <gtest/gtest.h>
TEST(StringTests, traits2)
{
ZString print_non = "\t\e";
ZString print_mix = "n\t";
RString print_all = "n ";
EXPECT_FALSE(print_non.has_print());
EXPECT_TRUE(print_mix.has_print());
EXPECT_TRUE(print_all.has_print());
EXPECT_FALSE(print_non.is_print());
EXPECT_FALSE(print_mix.is_print());
EXPECT_TRUE(print_all.is_print());
EXPECT_EQ("__", print_non.to_print());
EXPECT_EQ("n_", print_mix.to_print());
EXPECT_EQ("n ", print_all.to_print());
EXPECT_EQ(print_all.begin(), print_all.to_print().begin());
ZString graph_non = " \e";
ZString graph_mix = "n ";
RString graph_all = "n.";
EXPECT_FALSE(graph_non.has_graph());
EXPECT_TRUE(graph_mix.has_graph());
EXPECT_TRUE(graph_all.has_graph());
EXPECT_FALSE(graph_non.is_graph());
EXPECT_FALSE(graph_mix.is_graph());
EXPECT_TRUE(graph_all.is_graph());
ZString lower_non = "0A";
ZString lower_mix = "Oa";
RString lower_all = "oa";
EXPECT_FALSE(lower_non.has_lower());
EXPECT_TRUE(lower_mix.has_lower());
EXPECT_TRUE(lower_all.has_lower());
EXPECT_FALSE(lower_non.is_lower());
EXPECT_FALSE(lower_mix.is_lower());
EXPECT_TRUE(lower_all.is_lower());
EXPECT_EQ("0a", lower_non.to_lower());
EXPECT_EQ("oa", lower_mix.to_lower());
EXPECT_EQ("oa", lower_all.to_lower());
EXPECT_EQ(lower_all.begin(), lower_all.to_lower().begin());
ZString upper_non = "0a";
ZString upper_mix = "oA";
RString upper_all = "OA";
EXPECT_FALSE(upper_non.has_upper());
EXPECT_TRUE(upper_mix.has_upper());
EXPECT_TRUE(upper_all.has_upper());
EXPECT_FALSE(upper_non.is_upper());
EXPECT_FALSE(upper_mix.is_upper());
EXPECT_TRUE(upper_all.is_upper());
EXPECT_EQ("0A", upper_non.to_upper());
EXPECT_EQ("OA", upper_mix.to_upper());
EXPECT_EQ("OA", upper_all.to_upper());
EXPECT_EQ(upper_all.begin(), upper_all.to_upper().begin());
ZString alpha_non = " 0";
ZString alpha_mix = "n ";
RString alpha_all = "nA";
EXPECT_FALSE(alpha_non.has_alpha());
EXPECT_TRUE(alpha_mix.has_alpha());
EXPECT_TRUE(alpha_all.has_alpha());
EXPECT_FALSE(alpha_non.is_alpha());
EXPECT_FALSE(alpha_mix.is_alpha());
EXPECT_TRUE(alpha_all.is_alpha());
ZString digit2_non = "a9";
ZString digit2_mix = "20";
RString digit2_all = "01";
EXPECT_FALSE(digit2_non.has_digit2());
EXPECT_TRUE(digit2_mix.has_digit2());
EXPECT_TRUE(digit2_all.has_digit2());
EXPECT_FALSE(digit2_non.is_digit2());
EXPECT_FALSE(digit2_mix.is_digit2());
EXPECT_TRUE(digit2_all.is_digit2());
ZString digit8_non = "a9";
ZString digit8_mix = "80";
RString digit8_all = "37";
EXPECT_FALSE(digit8_non.has_digit8());
EXPECT_TRUE(digit8_mix.has_digit8());
EXPECT_TRUE(digit8_all.has_digit8());
EXPECT_FALSE(digit8_non.is_digit8());
EXPECT_FALSE(digit8_mix.is_digit8());
EXPECT_TRUE(digit8_all.is_digit8());
ZString digit10_non = "az";
ZString digit10_mix = "a9";
RString digit10_all = "42";
EXPECT_FALSE(digit10_non.has_digit10());
EXPECT_TRUE(digit10_mix.has_digit10());
EXPECT_TRUE(digit10_all.has_digit10());
EXPECT_FALSE(digit10_non.is_digit10());
EXPECT_FALSE(digit10_mix.is_digit10());
EXPECT_TRUE(digit10_all.is_digit10());
ZString digit16_non = "gz";
ZString digit16_mix = "ao";
RString digit16_all = "be";
EXPECT_FALSE(digit16_non.has_digit16());
EXPECT_TRUE(digit16_mix.has_digit16());
EXPECT_TRUE(digit16_all.has_digit16());
EXPECT_FALSE(digit16_non.is_digit16());
EXPECT_FALSE(digit16_mix.is_digit16());
EXPECT_TRUE(digit16_all.is_digit16());
ZString alnum_non = " .";
ZString alnum_mix = "n ";
RString alnum_all = "n0";
EXPECT_FALSE(alnum_non.has_alnum());
EXPECT_TRUE(alnum_mix.has_alnum());
EXPECT_TRUE(alnum_all.has_alnum());
EXPECT_FALSE(alnum_non.is_alnum());
EXPECT_FALSE(alnum_mix.is_alnum());
EXPECT_TRUE(alnum_all.is_alnum());
}
TEST(StringTests, rempty)
{
const char empty_text[] = "";
RString r = empty_text;
EXPECT_EQ(r.size(), 0);
AString a = empty_text;
EXPECT_EQ(r, a);
AString r2 = r, r3;
RString a2 = a, a3;
XString r1 = r2;
XString a1 = a2;
r3 = r1;
a3 = a1;
EXPECT_EQ(r, r1);
EXPECT_EQ(a, a1);
EXPECT_EQ(r, r2);
EXPECT_EQ(a, a2);
EXPECT_EQ(r, r3);
EXPECT_EQ(a, a3);
EXPECT_EQ(&*r.begin(), &*r1.begin());
EXPECT_EQ(&*a.begin(), &*a1.begin());
EXPECT_EQ(&*r.begin(), &*r2.begin());
EXPECT_EQ(&*a.begin(), &*a2.begin());
EXPECT_EQ(&*r.begin(), &*r3.begin());
EXPECT_EQ(&*a.begin(), &*a3.begin());
}
TEST(StringTests, rshort)
{
const char short_text[] = "0123456789";
RString r = short_text;
EXPECT_EQ(r.size(), 10);
AString a = short_text;
EXPECT_EQ(r, a);
AString r2 = r, r3;
RString a2 = a, a3;
XString r1 = r2;
XString a1 = a2;
r3 = r1;
a3 = a1;
EXPECT_EQ(r, r1);
EXPECT_EQ(a, a1);
EXPECT_EQ(r, r2);
EXPECT_EQ(a, a2);
EXPECT_EQ(r, r3);
EXPECT_EQ(a, a3);
EXPECT_EQ(&*r.begin(), &*r1.begin());
EXPECT_NE(&*a.begin(), &*a1.begin());
EXPECT_EQ(&*r.begin(), &*r2.begin());
EXPECT_NE(&*a.begin(), &*a2.begin());
EXPECT_EQ(&*r.begin(), &*r3.begin());
EXPECT_NE(&*a.begin(), &*a3.begin());
}
TEST(StringTests, rlong)
{
const char long_text[] =
"01234567890123456789012345678901234567890123456789"
"0123456789012345678901234567890123456789012345 100"
"01234567890123456789012345678901234567890123456789"
"0123456789012345678901234567890123456789012345 200"
"01234567890123456789012345678901234567890123456789"
"0123456789012345678901234567890123456789012345 300";
RString r = long_text;
EXPECT_EQ(r.size(), 300);
AString a = long_text;
EXPECT_EQ(r, a);
AString r2 = r, r3;
RString a2 = a, a3;
XString r1 = r2;
XString a1 = a2;
r3 = r1;
a3 = a1;
EXPECT_EQ(r, r1);
EXPECT_EQ(a, a1);
EXPECT_EQ(r, r2);
EXPECT_EQ(a, a2);
EXPECT_EQ(r, r3);
EXPECT_EQ(a, a3);
EXPECT_EQ(&*r.begin(), &*r1.begin());
EXPECT_EQ(&*a.begin(), &*a1.begin());
EXPECT_EQ(&*r.begin(), &*r2.begin());
EXPECT_EQ(&*a.begin(), &*a2.begin());
EXPECT_EQ(&*r.begin(), &*r3.begin());
EXPECT_EQ(&*a.begin(), &*a3.begin());
}
|