]> dreyeck.freedombox.rocks Git - topic-maps.git/blob - tests/ctm-iso-8859-5.lisp
Qualify closed XML/C14N 1.0 infrastructure for XTM resourceData
[topic-maps.git] / tests / ctm-iso-8859-5.lisp
1 (defpackage #:topic-maps.encoding.tests
2 (:use #:cl #:topic-maps.tmdm)
3 (:import-from #:topic-maps.registered-original.tests
4 #:check #:fields #:binary #:case-state #:identity-fields #:captured-read #:condition-data)
5 (:export #:run-tests #:write-reports))
6 (in-package #:topic-maps.encoding.tests)
7 (defparameter *doc* "https://example.invalid/encoding/main.ctm")
8 (defparameter *child* "https://example.invalid/encoding/child.ctm")
9 (defparameter *iso-names*
10 '("ISO-8859-5" "ISO_8859-5:1988" "ISO_8859-5" "iso-ir-144" "cyrillic" "csISOLatinCyrillic"))
11 (defparameter *utf8-names* '("UTF-8" "csUTF8"))
12 ;; Independent expected A0..FF codepoints, matching the Unicode mapping table.
13 ;; 00..9F are identity mappings. Production code uses the qualified SBCL codec.
14 (defparameter *iso-high*
15 #(
16 #x00A0 #x0401 #x0402 #x0403 #x0404 #x0405 #x0406 #x0407 #x0408 #x0409 #x040A #x040B #x040C #x00AD #x040E #x040F
17 #x0410 #x0411 #x0412 #x0413 #x0414 #x0415 #x0416 #x0417 #x0418 #x0419 #x041A #x041B #x041C #x041D #x041E #x041F
18 #x0420 #x0421 #x0422 #x0423 #x0424 #x0425 #x0426 #x0427 #x0428 #x0429 #x042A #x042B #x042C #x042D #x042E #x042F
19 #x0430 #x0431 #x0432 #x0433 #x0434 #x0435 #x0436 #x0437 #x0438 #x0439 #x043A #x043B #x043C #x043D #x043E #x043F
20 #x0440 #x0441 #x0442 #x0443 #x0444 #x0445 #x0446 #x0447 #x0448 #x0449 #x044A #x044B #x044C #x044D #x044E #x044F
21 #x2116 #x0451 #x0452 #x0453 #x0454 #x0455 #x0456 #x0457 #x0458 #x0459 #x045A #x045B #x045C #x00A7 #x045E #x045F
22 ))
23 (defvar *checks* nil)
24 (defvar *positives* nil)
25 (defvar *negatives* nil)
26 (defvar *codepoints* nil)
27 (defvar *selection* nil)
28 (defvar *original* nil)
29 (defvar *entry-statuses* nil)
30 (defun octets (text &optional (encoding :iso-8859-5))
31 (sb-ext:string-to-octets text :external-format encoding))
32 (defun header (name body)
33 (if name (format nil "%encoding \"~A\"~%~A" name body) body))
34 (defun canonical (map) (topic-maps.cxtm:canonicalize-octets map :base-locator *doc*))
35 (defun source-hex (bytes) (format nil "~{~2,'0X~^ ~}" (coerce bytes 'list)))
36 (defun file-values (label bytes encoding &optional resolver)
37 (uiop:with-temporary-file (:pathname path :type "ctm")
38 (with-open-file (out path :direction :output :if-exists :supersede :element-type '(unsigned-byte 8))
39 (write-sequence bytes out))
40 (unwind-protect
41 (handler-case
42 (multiple-value-bind (map counter)
43 (topic-maps.ctm:deserialize-file path :document-iri *doc* :source-name label :encoding encoding
44 :wildcard-counter 17 :resource-resolver resolver)
45 (values map counter nil))
46 (topic-maps.ctm:ctm-error (condition) (values nil nil condition)))
47 (check (concatenate 'string label ":file-bytes-preserved") (equalp bytes (binary path))))))
48 (defun observe-positive (label map counter &optional input encoding)
49 (let* ((held (topic-maps.import.tests::handles map))
50 (before (topic-maps.import.tests::state map held)) (actual (canonical map)))
51 (check (concatenate 'string label ":current-model-and-pure-canonicalization")
52 (and (topic-maps.reference.tests::references-current-p map)
53 (equal before (topic-maps.import.tests::state map held)) (equalp actual (canonical map))))
54 (push (fields "label" label "suppliedEncoding" encoding "inputHex" (when input (source-hex input))
55 "finalCounter" counter "actualCXTM" (topic-maps.ctm::decode-utf8 actual)
56 "model" (topic-maps.template.tests::observe map)) *positives*)))
57 (defun good-file (label input body &optional encoding)
58 (multiple-value-bind (map counter condition) (file-values label input encoding)
59 (check (concatenate 'string label ":actual-deserialization") (and map (null condition)))
60 (multiple-value-bind (expected expected-counter)
61 (topic-maps.ctm:deserialize-string body :document-iri *doc* :wildcard-counter 17)
62 (check (concatenate 'string label ":Unicode-reference-CXTM-and-identities")
63 (and (= counter expected-counter) (equalp (canonical map) (canonical expected)))))
64 (observe-positive label map counter input encoding)
65 (values map counter)))
66 (defun specific (label condition class code position unit &optional (source label) purpose byte-position)
67 (check (concatenate 'string label ":condition-code-source-position-and-unit")
68 (and condition (eq class (type-of condition)) (eq code (topic-maps.ctm:error-code condition))
69 (= position (topic-maps.ctm:error-position condition)) (eq unit (topic-maps.ctm:error-position-unit condition))
70 (equal source (topic-maps.ctm:error-source condition)) (null (topic-maps.ctm:error-cause condition))
71 (if purpose (eq purpose (getf (first (topic-maps.ctm:error-context condition)) :purpose))
72 (null (topic-maps.ctm:error-context condition)))))
73 (check (concatenate 'string label ":line-and-column-units")
74 (if (eq unit :byte)
75 (and (null (topic-maps.ctm:error-line condition)) (null (topic-maps.ctm:error-column condition)))
76 (and (integerp (topic-maps.ctm:error-line condition)) (integerp (topic-maps.ctm:error-column condition)))))
77 (push (fields "label" label "condition" (condition-data condition)
78 "positionInOriginalBytes" byte-position) *negatives*))
79 (defun bad-file (label input encoding class code position unit &optional line column byte-position)
80 (multiple-value-bind (map counter condition) (file-values label input encoding)
81 (declare (ignore counter)) (check (concatenate 'string label ":not-accepted") (null map))
82 (specific label condition class code position unit label nil byte-position)
83 (when line
84 (check (concatenate 'string label ":exact-line-and-column")
85 (and (= line (topic-maps.ctm:error-line condition)) (= column (topic-maps.ctm:error-column condition)))))))
86 (defun decoder-table-tests ()
87 (let* ((bytes (make-array 256 :element-type '(unsigned-byte 8) :initial-contents (loop for i below 256 collect i)))
88 (before (copy-seq bytes)) (decoded (topic-maps.ctm::decode-iso-8859-5 bytes)))
89 (check "table:total-256-scalars-no-replacement-and-exact-roundtrip"
90 (and (= 256 (length decoded)) (not (find (code-char #xfffd) decoded))
91 (equalp before bytes) (equalp bytes (octets decoded))))
92 (loop for byte below 256 for c across decoded do
93 (check (format nil "table:byte-~2,'0X" byte)
94 (= (char-code c) (if (< byte 160) byte (aref *iso-high* (- byte 160))))))
95 (check "table:generic-resource-vector-also-decodes"
96 (equal decoded (topic-maps.ctm::decode-ctm-octets (coerce bytes 'simple-vector) :encoding "cyrillic")))
97 (setf *codepoints* (map 'vector #'char-code decoded))))
98 (defun alias-and-model-tests ()
99 (let ((body "russia - \"Россия\". ? - \"ASCII\". ?named - \"Ё№я§џ\". ?named - \"Ё№я§џ\"."))
100 (dolist (declared *iso-names*)
101 (dolist (supplied (cons nil *iso-names*))
102 (let ((label (format nil "iso:decl=~A:provided=~A" declared supplied)))
103 (multiple-value-bind (map counter) (good-file label (octets (header declared body)) body supplied)
104 (let* ((russia (topic-maps.registered-original.tests::local map *doc* "russia"))
105 (generated (loop for topic in (topic-map-topics map) append
106 (remove-if-not (lambda (iri) (search "#$__" iri)) (topic-item-identifiers topic)))))
107 (check (concatenate 'string label ":name-and-wildcard-identities")
108 (and (= 19 counter) (equal "Россия" (topic-name-value (first (topic-names russia))))
109 (topic-maps.registered-original.tests::same-set generated
110 (list (concatenate 'string *doc* "#$__18") (concatenate 'string *doc* "#$__19.named"))))))))))
111 (dolist (supplied *iso-names*)
112 (good-file (concatenate 'string "iso:external-only:" supplied) (octets body) body supplied))
113 (good-file "iso:mixed-case-alias" (octets (header "CyRiLlIc" body)) body "iSo-Ir-144")
114 ;; Unicode strings are already decoded; their valid header must pass prolog.
115 (dolist (alias *iso-names*)
116 (multiple-value-bind (map counter)
117 (topic-maps.ctm:deserialize-string (header alias body) :document-iri *doc* :wildcard-counter 17)
118 (check (concatenate 'string "string-prolog:" alias ":same-value-and-counter")
119 (and (= 19 counter) (equal "Россия" (topic-name-value (first (topic-names
120 (topic-maps.registered-original.tests::local map *doc* "russia"))))))))))
121 (dolist (body (list "russia - \"ASCII\"."
122 (format nil "russia - \"~A\"." (map 'string #'code-char *iso-high*))))
123 (good-file (if (find (code-char #xa0) body) "iso:all-A0-FF-in-name" "iso:ASCII-syntax")
124 (octets (header "ISO-8859-5" body)) body))
125 (let ((body "russia - \"Россия Grüße🙂\"."))
126 (dolist (provided (cons nil *utf8-names*))
127 (dolist (declared (cons nil *utf8-names*))
128 (dolist (bom '(nil t))
129 (good-file (format nil "utf8:decl=~A:provided=~A:bom=~A" declared provided bom)
130 (concatenate '(vector (unsigned-byte 8)) (if bom #(239 187 191) #())
131 (octets (header declared body) :utf-8)) body provided))))))
132 (defun negative-tests ()
133 (dolist (spec
134 (list
135 (list "BOM-vs-ISO" (concatenate '(vector (unsigned-byte 8)) #(239 187 191) (octets (header "cyrillic" "russia.") :utf-8) #(255))
136 nil 'topic-maps.ctm:ctm-rejection :encoding-conflict 14 :byte)
137 (list "external-ISO-vs-BOM" #(239 187 191 255) "iso-ir-144" 'topic-maps.ctm:ctm-rejection :encoding-conflict 0 :byte)
138 (list "external-UTF8-vs-ISO-declaration" (octets (header "cyrillic" "russia.")) "csUTF8"
139 'topic-maps.ctm:ctm-rejection :encoding-conflict 11 :byte)
140 (list "external-ISO-vs-UTF8-declaration" (octets (header "csUTF8" "russia.")) "cyrillic"
141 'topic-maps.ctm:ctm-rejection :encoding-conflict 11 :byte)
142 (list "unknown-declaration" (octets (header "x-no-such" "russia.")) nil
143 'topic-maps.ctm:ctm-unsupported :unsupported-encoding 11 :byte)
144 (list "unsupported-declaration" (octets (header "ISO-8859-1" "russia.")) "iso-8859-1"
145 'topic-maps.ctm:ctm-unsupported :unsupported-encoding 11 :byte)
146 (list "unsupported-external" (octets "russia.") "ISO-8859-1"
147 'topic-maps.ctm:ctm-unsupported :unsupported-encoding 0 :byte)
148 (list "unknown-external" (octets "russia.") "x-no-such"
149 'topic-maps.ctm:ctm-unsupported :unsupported-encoding 0 :byte)
150 (list "unregistered-UTF8-name" (octets (header "UTF8" "russia.")) nil
151 'topic-maps.ctm:ctm-unsupported :unsupported-encoding 11 :byte)
152 (list "unregistered-ISO-name" (octets (header "ISO8859-5" "russia.")) nil
153 'topic-maps.ctm:ctm-unsupported :unsupported-encoding 11 :byte)
154 (list "ISO-bytes-without-declaration" (octets "russia - \"Россия\".") nil
155 'topic-maps.ctm:ctm-rejection :invalid-utf8 10 :byte)
156 (list "ISO-bytes-after-UTF8-BOM" (concatenate '(vector (unsigned-byte 8)) #(239 187 191) (octets "russia - \"Россия\".")) nil
157 'topic-maps.ctm:ctm-rejection :invalid-utf8 13 :byte)
158 (list "encoding-unquoted" (octets "%encoding ISO-8859-5") nil
159 'topic-maps.ctm:ctm-rejection :invalid-encoding-declaration 10 :byte)
160 (list "encoding-leading-space" (octets " %encoding \"ISO-8859-5\" russia.") nil
161 'topic-maps.ctm:ctm-rejection :misplaced-encoding 1 :character)
162 (list "encoding-after-version" (octets "%version 1.0 %encoding \"ISO-8859-5\" russia.") "cyrillic"
163 'topic-maps.ctm:ctm-rejection :misplaced-encoding 13 :character)
164 (list "encoding-after-body" (octets "topic. %encoding \"ISO-8859-5\"") nil
165 'topic-maps.ctm:ctm-rejection :misplaced-encoding 7 :character)
166 (list "encoding-repeated" (octets "%encoding \"ISO-8859-5\" %encoding \"ISO-8859-5\"") nil
167 'topic-maps.ctm:ctm-rejection :misplaced-encoding 23 :character)))
168 (apply #'bad-file spec))
169 (dolist (charset '("ISO-8859-5" "csUTF8"))
170 (let* ((text (header charset (format nil "russia - \"Россия\";~%!.")))
171 (encoding (if (equal charset "csUTF8") :utf-8 :iso-8859-5))
172 (input (octets text encoding)) (position (position #\! text)) (byte-position (position 33 input))
173 (label (concatenate 'string "source-position:" charset)))
174 (check (concatenate 'string label ":byte-and-character-offsets-explicit")
175 (if (eq encoding :utf-8) (> byte-position position) (= byte-position position)))
176 (bad-file label input nil 'topic-maps.ctm:ctm-rejection :unexpected-character position :character 3 1 byte-position)))
177 (let* ((text (header "cyrillic" "%version 2.0")) (position (search "2.0" text)))
178 (bad-file "version-after-ISO-header" (octets text) nil 'topic-maps.ctm:ctm-rejection :invalid-version position :character 2 10))
179 (multiple-value-bind (map condition)
180 (captured-read (lambda () (topic-maps.ctm:deserialize-string "%encoding \"x-no-such\"" :document-iri *doc* :source-name "unknown-string-prolog")))
181 (check "unknown-string-prolog:not-accepted" (null map))
182 (specific "unknown-string-prolog" condition 'topic-maps.ctm:ctm-unsupported :unsupported-encoding 11 :character)))
183 (defun selection-order-tests ()
184 (let ((utf8 (symbol-function 'topic-maps.ctm::decode-utf8))
185 (iso (symbol-function 'topic-maps.ctm::decode-iso-8859-5))
186 (utf8-calls 0) (iso-calls 0))
187 (unwind-protect
188 (progn
189 (setf (symbol-function 'topic-maps.ctm::decode-utf8) (lambda (&rest args) (incf utf8-calls) (apply utf8 args))
190 (symbol-function 'topic-maps.ctm::decode-iso-8859-5) (lambda (&rest args) (incf iso-calls) (apply iso args)))
191 (dolist (spec (list (list #(239 187 191 255) "cyrillic" :encoding-conflict)
192 (list (concatenate '(vector (unsigned-byte 8)) #(239 187 191) (octets (header "cyrillic" "")) #(255)) nil :encoding-conflict)
193 (list (octets (header "x-no-such" "")) nil :unsupported-encoding)))
194 (destructuring-bind (input supplied code) spec
195 (let ((condition (nth-value 1 (captured-read (lambda () (topic-maps.ctm::decode-ctm-octets input :encoding supplied))))))
196 (check (format nil "selection:~A:provided=~A:both-codecs-unreached" code supplied)
197 (and condition (eq code (topic-maps.ctm:error-code condition)) (= 0 utf8-calls iso-calls))))))
198 (setf *selection* (fields "conflictAndUnsupportedUTF8Calls" utf8-calls "conflictAndUnsupportedISOCalls" iso-calls))
199 (topic-maps.ctm::decode-ctm-octets (octets "abc") :encoding "cyrillic")
200 (check "selection:ISO-only-one-call" (and (= 1 iso-calls) (zerop utf8-calls)))
201 (topic-maps.ctm::decode-ctm-octets (octets "abc" :utf-8))
202 (check "selection:default-UTF8-only-one-call" (= 1 iso-calls utf8-calls)))
203 (setf (symbol-function 'topic-maps.ctm::decode-utf8) utf8
204 (symbol-function 'topic-maps.ctm::decode-iso-8859-5) iso))))
205 (defun resource-tests ()
206 (dolist (purpose '(:include :mergemap))
207 (dolist (generic '(nil t))
208 (let* ((label (format nil "resource:~A:generic=~A" purpose generic))
209 (parent (concatenate 'string (if (eq purpose :include) "%include <child.ctm>"
210 "%mergemap <child.ctm> <http://psi.topicmaps.org/iso13250/ctm>") " ? - \"Parent\"."))
211 (body "russia - \"Россия\". ? - \"Child\". ?named - \"Щ\".")
212 (bytes (octets (header "cyrillic" body)))
213 (payload (if generic (coerce bytes 'simple-vector) bytes))
214 (before (copy-seq payload)) (calls 0) (decoder-calls 0)
215 (saved (symbol-function 'topic-maps.ctm::decode-ctm-resource)) (map nil) (counter nil))
216 (flet ((resolver (iri &key purpose from-document-iri notation)
217 (assert (equal iri *child*)) (assert (equal from-document-iri *doc*))
218 (assert (if (eq purpose :include) (null notation) (equal notation "http://psi.topicmaps.org/iso13250/ctm")))
219 (incf calls) (values payload "source:iso-child")))
220 (unwind-protect
221 (progn
222 (setf (symbol-function 'topic-maps.ctm::decode-ctm-resource)
223 (lambda (raw source)
224 (assert (eq raw payload)) (assert (equal source "source:iso-child")) (incf decoder-calls)
225 (funcall saved raw source)))
226 (multiple-value-setq (map counter)
227 (topic-maps.ctm:deserialize-string parent :document-iri *doc* :source-name label
228 :wildcard-counter 17 :resource-resolver #'resolver)))
229 (setf (symbol-function 'topic-maps.ctm::decode-ctm-resource) saved)))
230 (let* ((reference-bytes (octets body :utf-8))
231 (reference (topic-maps.ctm:deserialize-string parent :document-iri *doc* :wildcard-counter 17
232 :resource-resolver (lambda (&rest args) (declare (ignore args)) (values reference-bytes "source:utf8-reference"))))
233 (owner (topic-maps.registered-original.tests::local map *child* "russia")))
234 (check (concatenate 'string label ":raw-bytes-model-identities-and-counter")
235 (and (= calls 1 decoder-calls) (equalp before payload)
236 (equal "Россия" (topic-name-value (first (topic-names owner))))
237 (= counter (if (eq purpose :include) 20 18))
238 (if (eq purpose :include)
239 (member (concatenate 'string *doc* "#russia") (topic-item-identifiers owner) :test #'equal)
240 (not (member (concatenate 'string *doc* "#russia") (topic-item-identifiers owner) :test #'equal)))
241 (equalp (canonical map) (canonical reference)))))
242 (observe-positive label map counter payload)
243 (dolist (spec
244 (list (list "conflict" (concatenate '(vector (unsigned-byte 8)) #(239 187 191) (octets (header "cyrillic" ""))) 'topic-maps.ctm:ctm-rejection :encoding-conflict 14 :byte)
245 (list "unsupported" (octets (header "ISO-8859-1" "")) 'topic-maps.ctm:ctm-unsupported :unsupported-encoding 11 :byte)
246 (list "invalid-default-UTF8" (octets "russia - \"Россия\".") 'topic-maps.ctm:ctm-rejection :invalid-utf8 10 :byte)))
247 (destructuring-bind (suffix input class code position unit) spec
248 (let* ((key (concatenate 'string label ":" suffix))
249 (condition (nth-value 1 (captured-read (lambda ()
250 (topic-maps.ctm:deserialize-string parent :document-iri *doc* :source-name key
251 :resource-resolver (lambda (&rest args) (declare (ignore args)) (values input "source:bad-child"))))))))
252 (specific key condition class code position unit "source:bad-child" purpose)))))))
253 ;; An external parent charset never leaks into a child resource's default.
254 (let* ((parent "%include <child.ctm>") (child (octets "russia - \"Россия🙂\"." :utf-8)))
255 (multiple-value-bind (map counter condition)
256 (file-values "resource:external-parent-child-default-UTF8" (octets parent) "cyrillic"
257 (lambda (&rest args) (declare (ignore args)) (values child "source:UTF8-child")))
258 (check "resource:external-parent-encoding-not-inherited"
259 (and (null condition) (= counter 17)
260 (equal "Россия🙂" (topic-name-value (first (topic-names
261 (topic-maps.registered-original.tests::local map *child* "russia")))))))
262 (observe-positive "resource:external-parent-child-default-UTF8" map counter child "cyrillic"))))
263 (defun original-contract ()
264 (let* ((corpus topic-maps.ctm.tests::*cxtm-corpus*) (root (topic-maps.test-foundation:corpus-root corpus))
265 (id "ctm/in/encoding-8859-5.ctm") (selected (topic-maps.test-foundation:select-cases corpus :id id))
266 (case (first selected)) (cases (topic-maps.test-foundation:corpus-cases corpus))
267 (previous (mapcar (lambda (c) (cons c (case-state c))) cases))
268 (old-results (copy-tree topic-maps.ctm.tests::*cxtm-results*))
269 (*doc* (topic-maps.test-foundation:test-case-document-iri case)))
270 (setf *entry-statuses* (copy-list (getf (topic-maps.test-foundation:summarize-corpus corpus) :statuses)))
271 (check "original:existing-positive-NOT-RUN-record-and-Document-IRI"
272 (and (= 1 (length selected)) (member case cases :test #'eq)
273 (eq :valid (topic-maps.test-foundation:test-case-category case))
274 (eq :cxtm-equal (topic-maps.test-foundation:test-case-expected-outcome case))
275 (eq :not-run (topic-maps.test-foundation:test-case-status case))
276 (null (topic-maps.test-foundation:test-case-actual-outcome case))
277 (equal (truename (merge-pathnames id root)) (truename (topic-maps.test-foundation:test-case-source-pathname case)))
278 (equal *doc* (format nil "https://ctm-tests.example.invalid/~A/~A" (getf (topic-maps.test-foundation:corpus-metadata corpus) :commit) id))))
279 (check "original:unchanged-42-octets"
280 (equalp (binary (topic-maps.test-foundation:test-case-source-pathname case))
281 (concatenate '(vector (unsigned-byte 8)) (octets (format nil "%encoding \"iso-8859-5\"~%russia - \"") :utf-8)
282 #(192 222 225 225 216 239) (octets "\" ." :utf-8))))
283 (multiple-value-bind (row result) (topic-maps.registered-original.tests::exercise-case case :escapes)
284 (setf *original* row)
285 (check "original:actual-pinned-CXTM-comparison-PASS"
286 (and result (getf result :match)
287 (= (length (binary (topic-maps.test-foundation:test-case-expected-baseline case))) (getf result :bytes))
288 (eq :pass (topic-maps.test-foundation:test-case-status case))))
289 (let* ((control (topic-maps.ctm:deserialize-string "russia - \"Россия\" ." :document-iri *doc*))
290 (name (first (topic-names (topic-maps.registered-original.tests::local control *doc* "russia")))))
291 (check "original:Unicode-name-and-UTF8-reference-baseline"
292 (and (equal "Россия" (topic-name-value name))
293 (equalp (canonical control) (binary (topic-maps.test-foundation:test-case-expected-baseline case))))))
294 (check "original:all-prior-records-and-observations-preserved"
295 (and (eq corpus topic-maps.ctm.tests::*cxtm-corpus*) (equal cases (topic-maps.test-foundation:corpus-cases corpus))
296 (equal old-results topic-maps.ctm.tests::*cxtm-results*)
297 (every (lambda (entry) (if (eq case (car entry)) (equal (first (cdr entry)) (identity-fields case))
298 (equal (cdr entry) (case-state (car entry))))) previous)))
299 (setf topic-maps.ctm.tests::*cxtm-results* (append old-results (list result))))
300 (let ((after (getf (topic-maps.test-foundation:summarize-corpus corpus) :statuses)))
301 (check "original:exactly-one-NOT-RUN-to-PASS"
302 (and (= (1+ (getf *entry-statuses* :pass)) (getf after :pass))
303 (= (1- (getf *entry-statuses* :not-run)) (getf after :not-run))
304 (= (getf *entry-statuses* :fail) (getf after :fail))
305 (= (getf *entry-statuses* :unsupported) (getf after :unsupported)))))
306 (format t "~&ENCODING-ORIGINAL ~A: PASS; ~D byte-exact CXTM bytes~%" id
307 (length (binary (topic-maps.test-foundation:test-case-expected-baseline case))))))
308 (defun run-tests ()
309 (unless topic-maps.ctm.tests::*cxtm-corpus*
310 (topic-maps.registered-original.tests:run-tests) (topic-maps.registered-original.tests:run-negative-tests)
311 (topic-maps.prolog.tests:run-tests) (topic-maps.registered-original.tests:run-empty2-tests)
312 (topic-maps.ctm-integer.tests:run-tests) (topic-maps.triple.tests:run-tests))
313 (setf *positives* nil *negatives* nil *original* nil)
314 (let ((topic-maps.registered-original.tests::*checks* nil))
315 (decoder-table-tests) (alias-and-model-tests) (negative-tests) (selection-order-tests) (resource-tests) (original-contract)
316 (check "encoding:unique-check-names"
317 (= (length topic-maps.registered-original.tests::*checks*)
318 (length (remove-duplicates topic-maps.registered-original.tests::*checks* :test #'equal))))
319 (setf *checks* (nreverse topic-maps.registered-original.tests::*checks*)))
320 (setf *positives* (nreverse *positives*) *negatives* (nreverse *negatives*))
321 (format t "~&ENCODING-PASS: ~D checks; 256 byte mappings, one original, ~D positive and ~D negative controls~%"
322 (length *checks*) (length *positives*) (length *negatives*)) t)
323 (defun write-reports (prefix)
324 (with-open-file (out (concatenate 'string prefix ".encoding.json") :direction :output :if-exists :supersede)
325 (topic-maps.test-foundation::emit-json-value
326 (fields "kind" "ctm-iso-8859-5-execution" "passed" (length *checks*) "failed" 0
327 "entryStatuses" (topic-maps.test-foundation::counts-object *entry-statuses*)
328 "checks" (coerce *checks* 'vector) "positives" (coerce *positives* 'vector)
329 "negativeControls" (coerce *negatives* 'vector) "decoderCodepoints" *codepoints* "selectionEvidence" *selection*
330 "ISO88595Names" (coerce *iso-names* 'vector) "UTF8Names" (coerce *utf8-names* 'vector) "original" *original*) out) (terpri out))
331 (topic-maps.ctm.tests::write-cxtm-report
332 (concatenate 'string prefix ".validation.json") (concatenate 'string prefix ".cxtm.json")
333 :additional-checks *checks*
334 :scope "Slice 20H: ISO-8859-5 original, all 256 byte mappings and IANA aliases; encoding conflicts before decoding, unchanged UTF-8, Document IRIs/Wildcards and explicit Include/Mergemap resource bytes. Prior contracts and four known FAILs preserved."))