MCPcopy Create free account
hub / github.com/comaps/comaps / UNIT_TEST

Function UNIT_TEST

libs/base/base_tests/string_utils_test.cpp:22–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22UNIT_TEST(LowerUniChar)
23{
24 // Load unicode case folding table.
25
26 static char constexpr kFile[] = "./data/test_data/CaseFolding.test";
27 std::ifstream file(kFile);
28 TEST(file.is_open(), (kFile));
29
30 size_t fCount = 0, cCount = 0;
31 ankerl::unordered_dense::map<strings::UniChar, strings::UniString> m;
32 std::string line;
33 while (file.good())
34 {
35 std::getline(file, line);
36
37 // strip comments
38 size_t const sharp = line.find('#');
39 if (sharp != std::string::npos)
40 line.erase(sharp);
41 strings::SimpleTokenizer semicolon(line, ";");
42 if (!semicolon)
43 continue;
44
45 std::istringstream stream{std::string{*semicolon}};
46 uint32_t uc;
47 stream >> std::hex >> uc;
48 ASSERT(stream, ("Overflow"));
49 ++semicolon;
50
51 auto const type = *semicolon;
52 if (type == " S" || type == " T")
53 continue;
54 if (type != " C" && type != " F")
55 continue;
56 ++semicolon;
57
58 strings::UniString us;
59 strings::SimpleTokenizer spacer(*semicolon, " ");
60 while (spacer)
61 {
62 stream.clear();
63 stream.str(std::string(*spacer));
64 uint32_t smallCode;
65 stream >> std::hex >> smallCode;
66 us.push_back(smallCode);
67 ++spacer;
68 }
69
70 switch (us.size())
71 {
72 case 0: continue;
73 case 1:
74 {
75 m[uc] = us;
76 ++cCount;
77 TEST_EQUAL(strings::LowerUniChar(uc), us[0], ());
78 TEST_EQUAL(type, " C", ());
79 break;

Callers

nothing calls this directly

Calls 15

TESTFunction · 0.85
ASSERTFunction · 0.85
LowerUniCharFunction · 0.85
MakeLowerCaseFunction · 0.85
EqualNoCaseFunction · 0.85
to_intFunction · 0.85
ToUIntTestFunction · 0.85
to_uintFunction · 0.85
to_uint64Function · 0.85
to_uint32Function · 0.85
to_int64Function · 0.85
to_int32Function · 0.85

Tested by

no test coverage detected