source: trunk/source/tests/ansi-tests/write-string.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 3.4 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sun Jan 18 21:13:32 2004
4;;;; Contains: Tests of WRITE-STRING
5
6(in-package :cl-test)
7
8(deftest write-string.1
9  (let (result)
10    (values
11     (with-output-to-string
12       (*standard-output*)
13       (setq result (multiple-value-list (write-string ""))))
14     result))
15  "" (""))
16
17(deftest write-string.2
18  :notes (:nil-vectors-are-strings)
19  (let (result)
20    (values
21     (with-output-to-string
22       (*standard-output*)
23       (setq result
24             (multiple-value-list
25              (write-string (make-array '(0) :element-type nil)))))
26     result))
27  "" (""))
28
29(deftest write-string.3
30  (let (result)
31    (values
32     (with-output-to-string
33       (*standard-output*)
34       (setq result (multiple-value-list (write-string "abcde"))))
35     result))
36  "abcde" ("abcde"))
37
38(deftest write-string.4
39  (let (result)
40    (values
41     (with-output-to-string
42       (s)
43       (setq result (multiple-value-list (write-string "abcde" s :start 1))))
44     result))
45  "bcde" ("abcde"))
46
47(deftest write-string.5
48  (let (result)
49    (values
50     (with-output-to-string
51       (s)
52       (setq result (multiple-value-list
53                     (write-string "abcde" s :start 1 :end 3))))
54     result))
55  "bc" ("abcde"))
56
57(deftest write-string.6
58  (let (result)
59    (values
60     (with-output-to-string
61       (s)
62       (setq result (multiple-value-list
63                     (write-string "abcde" s :start 1 :end nil))))
64     result))
65  "bcde" ("abcde"))
66
67(deftest write-string.7
68  (let (result)
69    (values
70     (with-output-to-string
71       (s)
72       (setq result (multiple-value-list (write-string "abcde" s :end 3))))
73     result))
74  "abc" ("abcde"))
75
76(deftest write-string.8
77  (let (result)
78    (values
79     (with-output-to-string
80       (s)
81       (setq result (multiple-value-list
82                     (write-string "abcde" s :end 3 :allow-other-keys nil))))
83     result))
84  "abc" ("abcde"))
85
86(deftest write-string.9
87  (let (result)
88    (values
89     (with-output-to-string
90       (s)
91       (setq result
92             (multiple-value-list
93              (write-string "abcde" s :end 3 :allow-other-keys t :foo 'bar))))
94     result))
95  "abc" ("abcde"))
96
97(deftest write-string.10
98  (let (result)
99    (values
100     (with-output-to-string
101       (s)
102       (setq result (multiple-value-list
103                     (write-string "abcde" s :end 3 :end 2))))
104     result))
105  "abc" ("abcde"))
106
107(deftest write-string.11
108  (with-input-from-string
109   (is "abcd")
110   (with-output-to-string
111     (os)
112     (let ((*terminal-io* (make-two-way-stream is os)))
113       (write-string "951" t)
114       (close *terminal-io*))))
115  "951")
116
117(deftest write-string.12
118  (with-output-to-string
119    (*standard-output*)
120    (write-string "-=|!" nil))
121  "-=|!")
122
123;;; Specialized string tests
124
125(deftest write-string.13
126  (let (result)
127    (do-special-strings
128     (s "abcde" nil)
129     (assert (equal
130              (with-output-to-string
131                (*standard-output*)
132                (setq result (multiple-value-list (write-string "abcde"))))
133              "abcde"))
134     (assert (equal result '("abcde")))))
135  nil)
136
137;;; Error tests
138
139(deftest write-string.error.1
140  (signals-error (write-string) program-error)
141  t)
142
143(deftest write-string.error.2
144  (signals-error (write-string "" *standard-output* :start) program-error)
145  t)
146
147(deftest write-string.error.3
148  (signals-error (write-string "" *standard-output* :foo nil) program-error)
149  t)
150
151(deftest write-string.error.4
152  (signals-error (write-string "" *standard-output*
153                               :allow-other-keys nil
154                               :foo nil)
155                 program-error)
156  t)
Note: See TracBrowser for help on using the repository browser.