-
Notifications
You must be signed in to change notification settings - Fork 0
/
normalize.cpp
69 lines (62 loc) · 2.24 KB
/
normalize.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
#include <coil/stringutil.h>
#include <iostream>
void test(std::string&& a, std::string const& expect)
{
std::cout << "result=" << (a == expect) << " <" << a << ">\n";
}
std::string f_head(){ return " aiueo"; }
std::string f_tail(){ return "aiueo "; }
int main(void)
{
// nochange
test(coil::normalize("aiueo"), "aiueo");
test(coil::normalize("aiu eo"), "aiu eo");
test(coil::normalize(std::string()), "");
test(coil::normalize(""), "");
test(coil::normalize(" "), "");
test(coil::normalize("\t"), "");
test(coil::normalize("\n"), "\n");
test(coil::normalize("\v"), "\v");
test(coil::normalize("\f"), "\f");
test(coil::normalize("\r"), "\r");
test(coil::normalize("\r\n"), "\r\n");
//head
test(coil::normalize(" aiueo"), "aiueo");
test(coil::normalize(" aiueo"), "aiueo");
test(coil::normalize(" aiueo"), "aiueo");
std::string a0 = " aiueo";
test(coil::normalize(a0), "aiueo");
test(coil::normalize(std::move(a0)), "aiueo");
test(coil::normalize(" aiueo"), "aiueo");
std::string a1 = " aiueo";
test(coil::normalize(a1), "aiueo");
test(coil::normalize(std::move(a1)), "aiueo");
test(coil::normalize(f_head()), "aiueo");
//tail
test(coil::normalize("aiueo "), "aiueo");
test(coil::normalize("aiueo "), "aiueo");
test(coil::normalize("aiueo "), "aiueo");
std::string b0 = "aiueo ";
test(coil::normalize(b0), "aiueo");
test(coil::normalize(std::move(b0)), "aiueo");
test(coil::normalize("aiueo "), "aiueo");
std::string b1 = "aiueo ";
test(coil::normalize(b1), "aiueo");
test(coil::normalize(std::move(b1)), "aiueo");
test(coil::normalize(f_tail()), "aiueo");
//Both
test(coil::normalize(" aiueo "), "aiueo");
test(coil::normalize(" aiueo "), "aiueo");
test(coil::normalize(" aiueo "), "aiueo");
std::string c0 = " aiueo ";
test(coil::normalize(c0), "aiueo");
test(coil::normalize(std::move(c0)), "aiueo");
test(coil::normalize(" aiueo "), "aiueo");
std::string c1 = " aiueo ";
test(coil::normalize(c1), "aiueo");
test(coil::normalize(std::move(c1)), "aiueo");
test(coil::normalize(f_tail()), "aiueo");
//lower
test(coil::normalize("AIueo"), "aiueo");
test(coil::normalize(" AiUeO "), "aiueo");
}