|
1
|
+;;; Tests for external formats
|
|
2
|
+
|
|
3
|
+(defpackage :external-formats-tests
|
|
4
|
+ (:use :cl :lisp-unit))
|
|
5
|
+
|
|
6
|
+(in-package "EXTERNAL-FORMATS-TESTS")
|
|
7
|
+
|
|
8
|
+(defparameter *test-iso8859-1*
|
|
9
|
+ (let ((rs (kernel::make-random-object :state (kernel::init-random-state 27182828))))
|
|
10
|
+ (lisp::codepoints-string
|
|
11
|
+ (loop for k from 0 below 1000
|
|
12
|
+ collect (random 256))))
|
|
13
|
+ "Random test string with ISO8859-1 characters")
|
|
14
|
+
|
|
15
|
+(defparameter *test-unicode*
|
|
16
|
+ (let ((rs (kernel::make-random-object :state (kernel::init-random-state 27182828))))
|
|
17
|
+ (lisp::codepoints-string
|
|
18
|
+ (loop for k from 0 below 1000
|
|
19
|
+ collect (random 20000))))
|
|
20
|
+ "Random test string with codepoints below 20000")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+(defmacro test-octet-count (string format)
|
|
24
|
+ `(assert-equal (length (stream:string-to-octets ,string :external-format ,format))
|
|
25
|
+ (stream::string-octet-count ,string :external-format ,format)))
|
|
26
|
+
|
|
27
|
+(define-test octet-count.iso8859-1
|
|
28
|
+ (:tag :octet-count)
|
|
29
|
+ (test-octet-count *test-iso8859-1* :iso8859-1))
|
|
30
|
+
|
|
31
|
+(define-test octet-count.ascii
|
|
32
|
+ (:tag :octet-count)
|
|
33
|
+ (test-octet-count *test-iso8859-1* :ascii))
|
|
34
|
+
|
|
35
|
+(define-test octet-count.utf-8
|
|
36
|
+ (:tag :octet-count)
|
|
37
|
+ (test-octet-count *test-unicode* :utf-8))
|
|
38
|
+
|
|
39
|
+#+nil
|
|
40
|
+(define-test octet-count.utf-16
|
|
41
|
+ (:tag :octet-count)
|
|
42
|
+ (test-octet-count *test-unicode* :utf-16))
|
|
43
|
+
|
|
44
|
+(define-test octet-count.utf-16-be
|
|
45
|
+ (:tag :octet-count)
|
|
46
|
+ (test-octet-count *test-unicode* :utf-16-be))
|
|
47
|
+
|
|
48
|
+(define-test octet-count.utf-16-le
|
|
49
|
+ (:tag :octet-count)
|
|
50
|
+ (test-octet-count *test-unicode* :utf-16-le))
|
|
51
|
+
|
|
52
|
+#+nil
|
|
53
|
+(define-test octet-count.utf-32
|
|
54
|
+ (:tag :octet-count)
|
|
55
|
+ (test-octet-count *test-unicode* :utf-32))
|
|
56
|
+
|
|
57
|
+(define-test octet-count.utf-32-le
|
|
58
|
+ (:tag :octet-count)
|
|
59
|
+ (test-octet-count *test-unicode* :utf-32-le))
|
|
60
|
+
|
|
61
|
+(define-test octet-count.utf-32-le
|
|
62
|
+ (:tag :octet-count)
|
|
63
|
+ (test-octet-count *test-unicode* :utf-32-le))
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+ |