#include "../src/unicode.h" #include #include #include #include int main() { const std::vector, std::vector>> normalization = { {{}, {}}, {{0x65, 0x301}, {0xE9}}, {{0xE9}, {0xE9}}, {{0x212B}, {0xC5}}, {{0x61, 0x315, 0x300}, {0xE0, 0x315}}, {{0x61, 0x305, 0x301}, {0x61, 0x305, 0x301}}, {{0x301, 0x327}, {0x327, 0x301}}, {{0x1100, 0x1161, 0x11A8}, {0xAC01}}, {{0xAC01}, {0xAC01}}, {{0xFB01, 0xFF21}, {0xFB01, 0xFF21}}, {{0x958}, {0x915, 0x93C}}, {{0x1D15E}, {0x1D157, 0x1D165}}, }; for (const auto & test : normalization) { if (unicode_cpts_normalize_nfc(test.first) != test.second || unicode_cpts_normalize_nfc(test.second) != test.second) { fprintf(stderr, "unexpected NFC normalization\n"); return 1; } } const std::vector regex_exprs = { "[~][A-Za-z]+| ?[\\p{S}]+|\\s+", }; const std::vector expected = { " ~", "foo" }; const auto actual = unicode_regex_split(" ~foo", regex_exprs, false); if (actual != expected) { fprintf(stderr, "unexpected split:"); for (const auto & piece : actual) { fprintf(stderr, " [%s]", piece.c_str()); } fprintf(stderr, "\n"); return 1; } return 0; }