summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2014-05-19 02:05:10 +0000
committerguenther <guenther@openbsd.org>2014-05-19 02:05:10 +0000
commit388ed389a70366cb77ade81aec3b1b8d79e1f8db (patch)
tree8dccae2d4a2bfbeae22a4e75947306d5a2866015
parentAdd regression test for UTF8_{getc,putc}() (diff)
downloadwireguard-openbsd-388ed389a70366cb77ade81aec3b1b8d79e1f8db.tar.xz
wireguard-openbsd-388ed389a70366cb77ade81aec3b1b8d79e1f8db.zip
Enable the 3- and 4-byte sequence tests for UTF8_getc()
Add surrogate and out-of-range tests for UTF8_putc() on the assumption we'll make it return -2. Maybe.
-rw-r--r--regress/lib/libcrypto/utf8/utf8test.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/regress/lib/libcrypto/utf8/utf8test.c b/regress/lib/libcrypto/utf8/utf8test.c
index 5b737a52010..453ab43a408 100644
--- a/regress/lib/libcrypto/utf8/utf8test.c
+++ b/regress/lib/libcrypto/utf8/utf8test.c
@@ -83,7 +83,7 @@ main(void)
ASSERT(value == UNCHANGED);
}
- /*
+ /*
* Verify handling of all two-byte sequences
*/
for (i = 0xC2; i < 0xE0; i++) {
@@ -113,8 +113,7 @@ main(void)
}
}
-#if 0
- /*
+ /*
* Verify handling of all three-byte sequences
*/
for (i = 0xE0; i < 0xF0; i++) {
@@ -163,7 +162,7 @@ main(void)
}
}
- /*
+ /*
* Verify handling of all four-byte sequences
*/
for (i = 0xF0; i < 0xF5; i++) {
@@ -219,7 +218,6 @@ main(void)
}
}
}
-#endif
/*
@@ -263,10 +261,13 @@ main(void)
/* three-byte sequences */
for (i = 0x800; i < 0x10000; i++) {
- /* XXX skip surrogate pair code points */
- if (i >= 0xD800 && i < 0xE000)
+ if (i >= 0xD800 && i < 0xE000) {
+ /* surrogates aren't valid */
+ ret = UTF8_putc(NULL, 0, i);
+ ASSERT(ret == -2);
continue;
-
+ }
+
ret = UTF8_putc(NULL, 0, i);
ASSERT(ret == 3);
@@ -301,7 +302,15 @@ main(void)
ASSERT(value == i);
}
- /* XXX What should UTF8_putc() do with values > 0x10FFFF */
+ /* spot check some larger values to confirm error return */
+ for (i = 0x110000; i < 0x110100; i++) {
+ ret = UTF8_putc(NULL, 0, i);
+ ASSERT(ret == -2);
+ }
+ for (value = (unsigned long)-1; value > (unsigned long)-256; value--) {
+ ret = UTF8_putc(NULL, 0, value);
+ ASSERT(ret == -2);
+ }
return 0;
}