char *u8; \
\
insist(validutf8(CHARS)); \
- ucs = utf82ucs4(CHARS); \
+ ucs = utf8_to_utf32(CHARS, strlen(CHARS), 0); \
insist(ucs != 0); \
- insist(!ucs4cmp(w, ucs)); \
- u8 = ucs42utf8(ucs); \
+ insist(!utf32_cmp(w, ucs)); \
+ u8 = utf32_to_utf8(ucs, utf32_len(ucs), 0); \
insist(u8 != 0); \
insist(!strcmp(u8, CHARS)); \
} while(0)
fprintf(stderr, "test_utf8\n");
+#define validutf8(S) utf8_valid((S), strlen(S))
/* empty string */
break;
}
if(l) {
+ uint32_t *d;
/* Case-folded data is now normalized */
- canon_expected = ucs42utf8(utf32_decompose_canon(&l, 1, 0));
+ d = utf32_decompose_canon(&l, 1, 0);
+ canon_expected = utf32_to_utf8(d, utf32_len(d), 0);
if(strcmp(canon_folded, canon_expected)) {
fprintf(stderr, "%s:%d: canon-casefolding %#lx got '%s', expected '%s'\n",
__FILE__, __LINE__, (unsigned long)c,
count_error();
}
++tests;
- compat_expected = ucs42utf8(utf32_decompose_compat(&l, 1, 0));
+ d = utf32_decompose_compat(&l, 1, 0);
+ compat_expected = utf32_to_utf8(d, utf32_len(d), 0);
if(strcmp(compat_folded, compat_expected)) {
fprintf(stderr, "%s:%d: compat-casefolding %#lx got '%s', expected '%s'\n",
__FILE__, __LINE__, (unsigned long)c,
return fp;
}
-/** @brief Run breaking tests for utf32_is_gcb() etc */
+/** @brief Run breaking tests for utf32_grapheme_boundary() etc */
static void breaktest(const char *path,
int (*breakfn)(const uint32_t *, size_t, size_t)) {
FILE *fp = open_unicode_test(path);
fprintf(stderr, \
"NormalizationTest.txt:%d: c%d != "#T"(c%d)\n", \
lineno, A, B); \
- fprintf(stderr, " c%d: %s\n", \
+ fprintf(stderr, " c%d: %s\n", \
A, format_utf32(c[A])); \
fprintf(stderr, "%4s(c%d): %s\n", \
#T, B, format_utf32(T##_c[B])); \
- count_error(); \
+ count_error(); \
} \
} while(0)
unt_check(NFD, 3, 1);
xfree(l);
}
fclose(fp);
- breaktest("auxiliary/GraphemeBreakTest.txt", utf32_is_gcb);
+ breaktest("auxiliary/GraphemeBreakTest.txt", utf32_is_grapheme_boundary);
breaktest("auxiliary/WordBreakTest.txt", utf32_is_word_boundary);
}