From a831af5da83811f2e78e65ebaf841717a9eec980 Mon Sep 17 00:00:00 2001 From: guenther <> Date: Mon, 19 May 2014 02:05:10 +0000 Subject: 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. --- src/regress/lib/libcrypto/utf8/utf8test.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/regress/lib/libcrypto/utf8/utf8test.c b/src/regress/lib/libcrypto/utf8/utf8test.c index 5b737a5201..453ab43a40 100644 --- a/src/regress/lib/libcrypto/utf8/utf8test.c +++ b/src/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; } -- cgit v1.2.3-55-g6feb