... |
... |
@@ -20,9 +20,22 @@ |
20
|
20
|
"Random test string with codepoints below 20000")
|
21
|
21
|
|
22
|
22
|
|
|
23
|
+
|
23
|
24
|
(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)))
|
|
25
|
+ "Test that STRING-OCTET-COUNT returns the correct number of octets"
|
|
26
|
+ ;; We expect STRING-OCTET-COUNT returns the same number of octets
|
|
27
|
+ ;; that are produced by STRING-TO-OCTETS.
|
|
28
|
+ `(multiple-value-bind (octets count converted)
|
|
29
|
+ (stream:string-to-octets ,string :external-format ,format)
|
|
30
|
+ ;; While we're at it, make sure that the length of the octet
|
|
31
|
+ ;; buffer matches returned count. And make sure we converted all
|
|
32
|
+ ;; the characters in the string.
|
|
33
|
+ (assert-equal (length octets) count)
|
|
34
|
+ (assert-equal (length ,string) converted)
|
|
35
|
+ ;; Finally, make sure that STRING-OCTET-COUNT returns the same
|
|
36
|
+ ;; number of octets from STRING-TO-OCTETS.
|
|
37
|
+ (assert-equal (length octets)
|
|
38
|
+ (stream::string-octet-count ,string :external-format ,format))))
|
26
|
39
|
|
27
|
40
|
(define-test octet-count.iso8859-1
|
28
|
41
|
(:tag :octet-count)
|
... |
... |
@@ -32,6 +45,13 @@ |
32
|
45
|
(:tag :octet-count)
|
33
|
46
|
(test-octet-count *test-iso8859-1* :ascii))
|
34
|
47
|
|
|
48
|
+(define-test octet-count.ascii.error
|
|
49
|
+ (:tag :octet-count)
|
|
50
|
+ (assert-error 'simple-error
|
|
51
|
+ (stream::string-octet-count *test-iso8859-1*
|
|
52
|
+ :external-format :ascii
|
|
53
|
+ :error 'error)))
|
|
54
|
+
|
35
|
55
|
(define-test octet-count.utf-8
|
36
|
56
|
(:tag :octet-count)
|
37
|
57
|
(test-octet-count *test-unicode* :utf-8))
|