finish handling NormalizationTest test vectors
authorChristophe Rhodes <csr21@cantab.net>
Fri, 19 Apr 2013 08:17:15 +0000 (09:17 +0100)
committerChristophe Rhodes <csr21@cantab.net>
Sat, 18 May 2013 19:04:04 +0000 (20:04 +0100)
NFC/NFKC still not hooked in, but otherwise complete.

tests/unicode-normalization.impure.lisp

index 06d555f..29b7ff2 100644 (file)
          (assert (string= "@Part0" line :end2 6))
          (assert (char= #\# (char (read-line s) 0)))))
     ;; Part0: specific cases
-    (do ((line (read-line s) (read-line s)))
-        ((char= #\# (char line 0))
-         (assert (string= "@Part1" (read-line s) :end2 6))
-         (assert (char= #\# (char (read-line s) 0)))
-         (assert (char= #\# (char (read-line s) 0))))
-      (destructuring-bind (c1 c2 c3 c4 c5)
-          (parse-one-line line)
-        (write-line line)
-        (test-line c1 c2 c3 c4 c5)))
+    (with-test (:name (:unicode-normalization :part0))
+      (do ((line (read-line s) (read-line s)))
+          ((char= #\# (char line 0))
+           (assert (string= "@Part1" (read-line s) :end2 6))
+           (assert (char= #\# (char (read-line s) 0)))
+           (assert (char= #\# (char (read-line s) 0))))
+        (destructuring-bind (c1 c2 c3 c4 c5)
+            (parse-one-line line)
+          (test-line c1 c2 c3 c4 c5))))
     ;; Part1: single characters.  (Extra work to check for conformance
     ;; on unlisted entries)
-    (do ((line (read-line s) (read-line s))
-         (code 0))
-        ((char= #\# (char line 0))
-         (do ((code code (1+ code)))
-             ((= code #x110000))
-           (test-no-normalization (string (code-char code)))))
-      (destructuring-bind (c1 c2 c3 c4 c5)
-          (parse-one-line line)
-        (do ((c code (1+ c)))
-            ((= c (char-code (char c1 0)))
-             (test-line c1 c2 c3 c4 c5)
-             (setf code (1+ c)))
-          (test-no-normalization (string (code-char code))))))))
\ No newline at end of file
+    (with-test (:name (:unicode-normalization :part1))
+      (do ((line (read-line s) (read-line s))
+           (code 0))
+          ((char= #\# (char line 0))
+           (do ((code code (1+ code)))
+               ((= code #x110000))
+             (test-no-normalization (string (code-char code))))
+           (assert (string= "@Part2" (read-line s) :end2 6))
+           (assert (char= #\# (char (read-line s) 0))))
+        (destructuring-bind (c1 c2 c3 c4 c5)
+            (parse-one-line line)
+          (do ((c code (1+ c)))
+              ((= c (char-code (char c1 0)))
+               (test-line c1 c2 c3 c4 c5)
+               (setf code (1+ c)))
+            (test-no-normalization (string (code-char code)))))))
+    ;; Part2: Canonical Order Test
+    (with-test (:name (:unicode-normalization :part2))
+      (do ((line (read-line s) (read-line s)))
+          ((char= #\# (char line 0))
+           (assert (string= "@Part3" (read-line s) :end2 6))
+           (assert (char= #\# (char (read-line s) 0))))
+        (destructuring-bind (c1 c2 c3 c4 c5)
+            (parse-one-line line)
+          (test-line c1 c2 c3 c4 c5))))
+    ;; Part3: PRI #29 Test
+    (with-test (:name (:unicode-normalization :part3))
+      (do ((line (read-line s) (read-line s)))
+          ((char= #\# (char line 0))
+           (assert (char= #\# (char (read-line s) 0)))
+           (assert (null (read-line s nil nil))))))))
+
+(test-normalization)