-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cc
40 lines (37 loc) · 1.34 KB
/
test.cc
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
#include "main.cc"
#include <iostream>
#include <string>
const char* cases[][2] = {
{"i\xd0\x98\xcc\x86", "\xd0\x98\xcc\x86i"},
{"", ""},
{"a", "a"},
{"ab", "ba"},
{"a b", "b a"},
{"\xd1\x84", "\xd1\x84"}, // single russian letter
{"x\xd1\x84", "\xd1\x84x"},
{"y\xd1\x84z", "z\xd1\x84y"},
{"\xd1\x84\xd1\x85", "\xd1\x85\xd1\x84"},
{"\xd0\x98\xcc\x86", "\xd0\x98\xcc\x86"}, // single russian letter
{"i\xd0\x98\xcc\x86", "\xd0\x98\xcc\x86i"},
{"\xd0\x98\xcc\x86i", "i\xd0\x98\xcc\x86"},
{"\xd0\x98\xcc\x86\xd1\x84", "\xd1\x84\xd0\x98\xcc\x86"},
{"z\xd0\x98\xcc\x86\xcc\x88y", "y\xd0\x98\xcc\x86\xcc\x88z"},
{"qu\xe2\x80\xaewz", "zw\xe2\x80\xaeuq"} // BiDi control sequence
};
int main() {
size_t arraysize = sizeof(cases) / sizeof(cases[0]);
for (size_t test_case = 0; test_case < arraysize; ++test_case) {
icu::UnicodeString s = icu::UnicodeString::fromUTF8(cases[test_case][0]);
UnicodeStringReverter r(s);
r.Revert();
std::string result;
s.toUTF8String(result);
if (result == std::string(cases[test_case][1])) {
std::cout << "Test " << test_case + 1 << '/' << arraysize << " Ok\n";
} else {
std::cout << "Test " << test_case + 1 << '/' << arraysize << " Failed!\n"
<< " Expected: " << cases[test_case][1] << " but got "
<< result << '\n';
}
}
}