diff options
author | guenther <> | 2014-05-19 02:05:10 +0000 |
---|---|---|
committer | guenther <> | 2014-05-19 02:05:10 +0000 |
commit | a831af5da83811f2e78e65ebaf841717a9eec980 (patch) | |
tree | 5b8143167f93cc21c3de61caae0fb256608166c7 /src | |
parent | bf82f8039d52950f75f37cccfd9ea3a07a98a9bc (diff) | |
download | openbsd-a831af5da83811f2e78e65ebaf841717a9eec980.tar.gz openbsd-a831af5da83811f2e78e65ebaf841717a9eec980.tar.bz2 openbsd-a831af5da83811f2e78e65ebaf841717a9eec980.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.
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/utf8/utf8test.c | 27 |
1 files changed, 18 insertions, 9 deletions
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) | |||
83 | ASSERT(value == UNCHANGED); | 83 | ASSERT(value == UNCHANGED); |
84 | } | 84 | } |
85 | 85 | ||
86 | /* | 86 | /* |
87 | * Verify handling of all two-byte sequences | 87 | * Verify handling of all two-byte sequences |
88 | */ | 88 | */ |
89 | for (i = 0xC2; i < 0xE0; i++) { | 89 | for (i = 0xC2; i < 0xE0; i++) { |
@@ -113,8 +113,7 @@ main(void) | |||
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | #if 0 | 116 | /* |
117 | /* | ||
118 | * Verify handling of all three-byte sequences | 117 | * Verify handling of all three-byte sequences |
119 | */ | 118 | */ |
120 | for (i = 0xE0; i < 0xF0; i++) { | 119 | for (i = 0xE0; i < 0xF0; i++) { |
@@ -163,7 +162,7 @@ main(void) | |||
163 | } | 162 | } |
164 | } | 163 | } |
165 | 164 | ||
166 | /* | 165 | /* |
167 | * Verify handling of all four-byte sequences | 166 | * Verify handling of all four-byte sequences |
168 | */ | 167 | */ |
169 | for (i = 0xF0; i < 0xF5; i++) { | 168 | for (i = 0xF0; i < 0xF5; i++) { |
@@ -219,7 +218,6 @@ main(void) | |||
219 | } | 218 | } |
220 | } | 219 | } |
221 | } | 220 | } |
222 | #endif | ||
223 | 221 | ||
224 | 222 | ||
225 | /* | 223 | /* |
@@ -263,10 +261,13 @@ main(void) | |||
263 | 261 | ||
264 | /* three-byte sequences */ | 262 | /* three-byte sequences */ |
265 | for (i = 0x800; i < 0x10000; i++) { | 263 | for (i = 0x800; i < 0x10000; i++) { |
266 | /* XXX skip surrogate pair code points */ | 264 | if (i >= 0xD800 && i < 0xE000) { |
267 | if (i >= 0xD800 && i < 0xE000) | 265 | /* surrogates aren't valid */ |
266 | ret = UTF8_putc(NULL, 0, i); | ||
267 | ASSERT(ret == -2); | ||
268 | continue; | 268 | continue; |
269 | 269 | } | |
270 | |||
270 | ret = UTF8_putc(NULL, 0, i); | 271 | ret = UTF8_putc(NULL, 0, i); |
271 | ASSERT(ret == 3); | 272 | ASSERT(ret == 3); |
272 | 273 | ||
@@ -301,7 +302,15 @@ main(void) | |||
301 | ASSERT(value == i); | 302 | ASSERT(value == i); |
302 | } | 303 | } |
303 | 304 | ||
304 | /* XXX What should UTF8_putc() do with values > 0x10FFFF */ | 305 | /* spot check some larger values to confirm error return */ |
306 | for (i = 0x110000; i < 0x110100; i++) { | ||
307 | ret = UTF8_putc(NULL, 0, i); | ||
308 | ASSERT(ret == -2); | ||
309 | } | ||
310 | for (value = (unsigned long)-1; value > (unsigned long)-256; value--) { | ||
311 | ret = UTF8_putc(NULL, 0, value); | ||
312 | ASSERT(ret == -2); | ||
313 | } | ||
305 | 314 | ||
306 | return 0; | 315 | return 0; |
307 | } | 316 | } |