| 76 | } |
| 77 | |
| 78 | static bool decode_good(test_utf8_entry const& entry) |
| 79 | { |
| 80 | auto const& s = entry.str; |
| 81 | unsigned int uc; |
| 82 | if (char const* e = |
| 83 | cm_utf8_decode_character(s.data(), s.data() + s.size(), &uc)) { |
| 84 | int used = static_cast<int>(e - s.data()); |
| 85 | if (uc != entry.chr) { |
| 86 | report_good(false, s); |
| 87 | printf("expected 0x%04X, got 0x%04X\n", entry.chr, uc); |
| 88 | return false; |
| 89 | } |
| 90 | if (used != int(s.size())) { |
| 91 | report_good(false, s); |
| 92 | printf("had %d bytes, used %d\n", int(s.size()), used); |
| 93 | return false; |
| 94 | } |
| 95 | report_good(true, s); |
| 96 | printf("got 0x%04X\n", uc); |
| 97 | return true; |
| 98 | } |
| 99 | report_good(false, s); |
| 100 | printf("failed\n"); |
| 101 | return false; |
| 102 | } |
| 103 | |
| 104 | static bool decode_bad(test_utf8_char s) |
| 105 | { |
no test coverage detected
searching dependent graphs…