-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.cpp
243 lines (178 loc) · 6.95 KB
/
tests.cpp
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#include <iostream>
#include "coltext.hpp"
namespace test {
void plain_text()
{
std::cout << "Starting plain_text test:\n";
std::string msg = "Hello, world!";
Coltext ctxt(msg);
std::cout << "\t" << msg << "\n";
std::cout << "\t" << ctxt << "\n";
std::cout << "[ #g OK ] Test plain_text succeded\n\n"_col;
}
void plain_text_with_parentheses()
{
std::cout << "Starting plain_text_with_parentheses test:\n";
std::string msg = "Hello, world (and you)!";
Coltext ctxt(msg);
std::cout << "\t" << msg << "\n";
std::cout << "\t" << ctxt << "\n";
std::cout << "[ #g OK ] Test plain_text_with_parentheses succeded!\n\n"_col;
}
void standard_escapes()
{
std::cout << "Starting standard_escapes test:\n";
std::string msg = "Add tab here.\n\tAnd new lines!";
Coltext ctxt(msg);
std::cout << "\t" << msg << "\n";
std::cout << "\t" << ctxt << "\n";
std::cout << "[ #g OK ] Test standard_escapes succeded\n\n"_col;
}
void color_with_parenthese()
{
std::cout << "Starting color_with_parenthese test:\n";
std::string msg = "I love write black on #k(black!)";
Coltext ctxt(msg);
std::cout << "\t" << msg << "\n";
std::cout << "\t" << ctxt << "\n";
std::cout << "[ #g OK ] Test color_with_parenthese succeded\n\n"_col;
}
void escaped_parenthese()
{
std::cout << "Starting escaped_parenthese test:\n";
std::string msg = "#r(Text \\(With parenthese escaped\\)) is ok!";
Coltext ctxt(msg);
std::cout << "\t" << msg << "\n";
std::cout << "\t" << ctxt << "\n";
std::cout << "[ #g OK ] Test escaped_parenthese succeded\n\n"_col;
}
void escaped_right_parenthese()
{
std::cout << "Starting escaped_right_parenthese test:\n";
std::string msg = "#g(Text (With only right parenthese escaped\\)) is ok too!";
Coltext ctxt(msg);
std::cout << "\t" << msg << "\n";
std::cout << "\t" << ctxt << "\n";
std::cout << "[ #g OK ] Test escaped_right_parenthese succeded\n\n"_col;
}
void color_next_word() {
std::cout << "Starting color_next_word test:\n";
std::string msg = "Next #y word will be colored";
Coltext ctxt(msg);
std::cout << "\t" << msg << "\n";
std::cout << "\t" << ctxt << "\n";
std::cout << "[ #g OK ] Test color_next_word succeded\n\n"_col;
}
void literal()
{
std::cout << "Starting literal test:\n";
std::cout << "\t" << "\"Text colored by #b(literal)\"_col" << "\n";
std::cout << "\t" << "Text colored by #b(literal)"_col << "\n";
std::cout << "[ #g OK ] Test literal succeded\n\n"_col;
}
void bg_color()
{
std::cout << "Starting bg_color test:\n";
std::string msg = "In order to color bg, you need to put color with #M(big letter)!";
Coltext ctxt(msg);
std::cout << "\t" << msg << "\n";
std::cout << "\t" << ctxt << "\n";
std::cout << "[ #g OK ] Test bg_color succeded\n\n"_col;
}
void styles() {
std::cout << "Starting styles test:\n";
std::string msg1 = "<i> italic <b> bold <f> faint <u> underline";
std::string msg2 = "#<i> italic #<b> bold #<f> faint #<u> underline";
Coltext ctxt(msg1);
std::cout << "\t" << msg1 << "\n";
std::cout << "\t" << ctxt << "\n\n";
std::cout << "\t" << msg2 << "\n";
std::cout << "\t" << (Coltext) msg2 << "\n";
std::cout << "[ #g OK ] Test styles succeded\n\n"_col;
}
void sequence()
{
std::cout << "Starting sequence test:\n";
std::string msg = "#C(You #r(can) use much more than just 1 effect!)";
Coltext ctxt(msg);
std::cout << "\t" << msg << "\n";
std::cout << "\t" << ctxt << "\n";
std::cout << "[ #g OK ] Test sequence succeded\n\n"_col;
}
void get_from_cin()
{
std::cout << "Starting get_from_cin test:\n";
Coltext ctxt;
std::cout << "\t"; std::cin >> ctxt;
std::cout << "\t" << ctxt << "\n";
std::cout << "[ #g OK ] Test get_from_cin succeded\n\n"_col;
}
void all_colors()
{
std::cout
<< "Foreground colors:\n"
<< "\t #k(black) -> " << "#k(black)\n"_col
<< "\t #r(red) -> " << "#r(red)\n"_col
<< "\t #g(green) -> " << "#g(green)\n"_col
<< "\t #y(yellow) -> " << "#y(yellow)\n"_col
<< "\t #b(blue) -> " << "#b(blue)\n"_col
<< "\t #c(cyan) -> " << "#c(cyan)\n"_col
<< "\t #m(magenta) -> " << "#m(magenta)\n"_col
<< "\t #w(white) -> " << "#w(white)\n\n"_col
<< "\t#bk(bright_black) -> " << "#bk(bright_black)\n"_col
<< "\t#br(bright_red) -> " << "#br(bright_red)\n"_col
<< "\t#bg(bright_green) -> " << "#bg(bright_green)\n"_col
<< "\t#by(bright_yellow) -> " << "#by(bright_yellow)\n"_col
<< "\t#bb(bright_blue) -> " << "#bb(bright_blue)\n"_col
<< "\t#bc(bright_cyan) -> " << "#bc(bright_cyan)\n"_col
<< "\t#bm(bright_magenta) -> " << "#bm(bright_magenta)\n"_col
<< "\t#bw(bright_white) -> " << "#bw(bright_white)\n\n"_col
<< "Background colors:\n"
<< "\t #K( ) -> " << "#K( )\n"_col
<< "\t #R( ) -> " << "#R( )\n"_col
<< "\t #G( ) -> " << "#G( )\n"_col
<< "\t #Y( ) -> " << "#Y( )\n"_col
<< "\t #B( ) -> " << "#B( )\n"_col
<< "\t #C( ) -> " << "#C( )\n"_col
<< "\t #M( ) -> " << "#M( )\n"_col
<< "\t #W( ) -> " << "#W( )\n\n"_col
<< "\t#bK( ) -> " << "#bK( )\n"_col
<< "\t#bR( ) -> " << "#bR( )\n"_col
<< "\t#bG( ) -> " << "#bG( )\n"_col
<< "\t#bY( ) -> " << "#bY( )\n"_col
<< "\t#bB( ) -> " << "#bB( )\n"_col
<< "\t#bC( ) -> " << "#bC( )\n"_col
<< "\t#bM( ) -> " << "#bM( )\n"_col
<< "\t#bW( ) -> " << "#bW( )\n\n"_col;
}
void rgb()
{
std::cout << "Starting rgb test:\n";
std::string msg1 = "#rgb[0;255;255] next_word_rgb and other text";
std::string msg2 = "#RGB[128;128;0](background by RGB in parentheses) and other text";
std::cout << "\t" << msg1 << "\n";
std::cout << "\t" << (Coltext) msg1 << "\n\n";
std::cout << "\t" << msg2 << "\n";
std::cout << "\t" << (Coltext) msg2 << "\n";
std::cout << "[ #g OK ] Test rgb succeded\n\n"_col;
}
} // namespace test
int main(int argc, char const *argv[])
{
/* Tests for not breaking standard functionality */
test::plain_text();
test::plain_text_with_parentheses();
test::standard_escapes();
test::color_with_parenthese(); // Does #xxx()# work ?
test::escaped_parenthese(); // Does #xxx(\\(Text in patenthese\\)) work ?
test::escaped_right_parenthese(); // Does #xxx((Text in patenthese\\)) work ?
test::color_next_word(); // Does #xxx next_word other_words work ?
test::styles(); // Does #<html_tag> work ?
test::literal(); // Does "text"_col work ?
test::bg_color(); // Does #Xxx work ?
test::sequence(); // Do sequences work ?
test::all_colors();
test::rgb(); // Do #rgb and #RGB work ?
test::get_from_cin(); // Does operator>> work ?
return 0;
}