summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2011-04-27 21:55:42 +0200
committerLudovic Courtès <ludo@gnu.org>2011-04-27 21:55:42 +0200
commit4cadf64f9af320e897240f4287fae91d211ef008 (patch)
tree31d5464999090c4cfe392bea4b7c8cb6654451ce
parenta42d79711b2366861cf4e6fa884eae709617121d (diff)
downloadguile-4cadf64f9af320e897240f4287fae91d211ef008.tar.gz
Add tests for UTF-8 ill-formed sequence handling.
* test-suite/tests/ports.test ("string ports"): Add for `test-decoding-error' tests for ill-formed UTF-8 sequences. Thanks to Mark H Weaver <mhw@netris.org> for pointing this out.
-rw-r--r--test-suite/tests/ports.test27
1 files changed, 27 insertions, 0 deletions
diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test
index d4924fe01..69e028f36 100644
--- a/test-suite/tests/ports.test
+++ b/test-suite/tests/ports.test
@@ -558,6 +558,33 @@
(read-char -> #\A)
(read-char -> #\B)
(read-char -> #\C)
+ (read-char -> eof)))
+
+ ;; Check how ill-formed UTF-8 sequences are handled (see Table 3-7
+ ;; of the "Conformance" chapter of Unicode 6.0.0.)
+
+ (test-decoding-error (#xc0 #x80 #x41) "UTF-8" 'error
+ (tests
+ (read-char -> error) ;; C0: should be in the C2..DF range
+ (read-char -> error) ;; 80: invalid
+ (read-char -> #\A)
+ (read-char -> eof)))
+
+ (test-decoding-error (#xc0 #x80 #x41) "UTF-8" 'error
+ (tests
+ (read-char -> error) ;; C0: should be in the C2..DF range
+ (read-char -> error) ;; 80: invalid
+ (read-char -> #\A)
+ (read-char -> eof)))
+
+ (test-decoding-error (#xe0 #x88 #x88) "UTF-8" 'error
+ (tests
+ (read-char -> error) ;; 2nd byte should be in the A0..BF range
+ (read-char -> eof)))
+
+ (test-decoding-error (#xf0 #x88 #x88 #x88) "UTF-8" 'error
+ (tests
+ (read-char -> error) ;; 2nd byte should be in the 90..BF range
(read-char -> eof)))))
(with-test-prefix "call-with-output-string"