diff options
author | Christopher Wellons <wellons@nullprogram.com> | 2017-10-09 18:37:41 -0400 |
---|---|---|
committer | Christopher Wellons <wellons@nullprogram.com> | 2017-10-09 18:52:08 -0400 |
commit | f2d0e24c3864d726cd009901726df4778ad3e0d5 (patch) | |
tree | 6cf9b9dfa7908fef82fb0128a19e9cb3f1d8abb9 /test/tests.c | |
parent | ce3f8ac69ece118a88240dfa29554a279e926364 (diff) |
Diffstat (limited to 'test/tests.c')
-rw-r--r-- | test/tests.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/test/tests.c b/test/tests.c index be94789..c16576c 100644 --- a/test/tests.c +++ b/test/tests.c @@ -23,7 +23,7 @@ main(void) /* Make sure it can decode every character */ { long failures = 0; - for (unsigned long i = 0; i < 0x1ffff; i++) { + for (unsigned long i = 0; i < 0x10ffff; i++) { if (!IS_SURROGATE(i)) { int e; uint32_t c; @@ -36,6 +36,22 @@ main(void) TEST(failures == 0, "decode all, errors: %ld", failures); } + /* Reject everything outside of U+0000..U+10FFFF */ + { + long failures = 0; + for (unsigned long i = 0x110000; i < 0x1fffff; i++) { + int e; + uint32_t c; + unsigned char buf[8] = {0}; + utf8_encode(buf, i); + unsigned char *end = utf8_decode(buf, &c, &e); + failures += !e; + failures += end - buf != 4; + } + TEST(failures == 0, "out of range, errors: %ld", failures); + } + + /* Does it reject all surrogate halves? */ { long failures = 0; |