summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSteven G. Johnson <stevenj@alum.mit.edu>2015-06-24 18:07:15 (GMT)
committer Steven G. Johnson <stevenj@alum.mit.edu>2015-06-24 18:07:15 (GMT)
commit6a7f92da641360fe4c0bb37288982f72d211db7b (patch)
tree0166fe857640643d09a996fd597a0f7128f1f30f /test
parent2b6aa142acd4836f86f88423f787654d08dbc228 (diff)
downloadlibutf8proc-6a7f92da641360fe4c0bb37288982f72d211db7b.tar.gz
libutf8proc-6a7f92da641360fe4c0bb37288982f72d211db7b.tar.bz2
fix #46 (make sure symbol-like codepoints have nonzero width even if they aren't in Unifont)
Diffstat (limited to 'test')
-rw-r--r--test/charwidth.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/test/charwidth.c b/test/charwidth.c
index 28554a4..986e7ca 100644
--- a/test/charwidth.c
+++ b/test/charwidth.c
@@ -10,7 +10,7 @@ int my_isprint(int c) {
int main(int argc, char **argv)
{
- int c, error = 0;
+ int c, error = 0, updates = 0;
(void) argc; /* unused */
(void) argv; /* unused */
@@ -24,6 +24,13 @@ int main(int argc, char **argv)
fprintf(stderr, "nonzero width %d for combining char %x\n", w, c);
error = 1;
}
+ if (w == 0 &&
+ ((cat >= UTF8PROC_CATEGORY_LU && cat <= UTF8PROC_CATEGORY_LO) ||
+ (cat >= UTF8PROC_CATEGORY_ND && cat <= UTF8PROC_CATEGORY_SC) ||
+ (cat >= UTF8PROC_CATEGORY_SO && cat <= UTF8PROC_CATEGORY_ZS))) {
+ fprintf(stderr, "zero width for symbol-like char %x\n", c);
+ error = 1;
+ }
if (c <= 127 && ((!isprint(c) && w > 0) ||
(isprint(c) && wcwidth(c) != w))) {
fprintf(stderr, "wcwidth %d mismatch %d for %s ASCII %x\n",
@@ -44,17 +51,20 @@ int main(int argc, char **argv)
int w = utf8proc_charwidth(c);
int wc = wcwidth(c);
if (sizeof(wchar_t) == 2 && c >= (1<<16)) continue;
-#if 0
/* lots of these errors for out-of-date system unicode tables */
- if (wc == -1 && my_isprint(c) && w > 0)
+ if (wc == -1 && my_isprint(c) && w > 0) {
+ updates += 1;
+#if 0
printf(" wcwidth(%x) = -1 for printable char\n", c);
#endif
+ }
if (wc == -1 && !my_isprint(c) && w > 0)
printf(" wcwidth(%x) = -1 for non-printable width-%d char\n", c, w);
if (wc >= 0 && wc != w)
printf(" wcwidth(%x) = %d != charwidth %d\n", c, wc, w);
}
-
+ printf(" ... (positive widths for %d chars unknown to wcwidth) ...\n",
+ updates);
printf("Character-width tests SUCCEEDED.\n");
return 0;