| 20 | } |
| 21 | |
| 22 | UNIT_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; |
nothing calls this directly
no test coverage detected