2
;;;; Author: Paul Dietz
3
;;;; Created: Sat Feb 14 08:41:18 2004
4
;;;; Contains: Tests of MAKE-CONCATENATED-STREAM
8
(deftest make-concatenated-stream.1
9
(let ((s (make-concatenated-stream)))
13
(deftest make-concatenated-stream.2
14
(let ((s (make-concatenated-stream)))
15
(notnot-mv (input-stream-p s)))
18
(deftest make-concatenated-stream.3
19
(let ((s (make-concatenated-stream)))
23
(deftest make-concatenated-stream.4
24
(let ((s (make-concatenated-stream)))
25
(notnot-mv (streamp s)))
28
(deftest make-concatenated-stream.5
29
(let ((s (make-concatenated-stream)))
30
(notnot-mv (typep s 'stream)))
33
(deftest make-concatenated-stream.6
34
(let ((s (make-concatenated-stream)))
35
(notnot-mv (typep s 'concatenated-stream)))
38
(deftest make-concatenated-stream.7
39
(let ((s (make-concatenated-stream)))
40
(notnot-mv (open-stream-p s)))
43
(deftest make-concatenated-stream.8
44
(let ((s (make-concatenated-stream *standard-input*)))
45
(notnot-mv (stream-element-type s)))
48
(deftest make-concatenated-stream.9
49
(let ((pn #p"tmp.dat")
50
(element-type '(unsigned-byte 8)))
51
(with-open-file (s pn :direction :output :element-type element-type
52
:if-exists :supersede)
53
(dolist (b '(1 5 9 13)) (write-byte b s)))
55
(s1 pn :direction :input :element-type element-type)
57
(s2 pn :direction :input :element-type element-type)
58
(let ((s (make-concatenated-stream s1 s2)))
59
(loop repeat 8 collect (read-byte s))))))
62
(deftest make-concatenated-stream.10
63
(let ((s (make-concatenated-stream)))
64
(read-byte s nil :eof))
67
(deftest make-concatenated-stream.11
68
(let ((s (make-concatenated-stream)))
69
(peek-char nil s nil :eof))
72
(deftest make-concatenated-stream.12
73
(with-input-from-string
75
(with-input-from-string
77
(let ((s (make-concatenated-stream s1 s2)))
83
(peek-char nil s nil :eof)))))
86
(deftest make-concatenated-stream.13
87
(with-input-from-string
89
(with-input-from-string
91
(let ((s (make-concatenated-stream s1 s2)))
97
(peek-char t s nil :eof)))))
100
(deftest make-concatenated-stream.14
101
(with-input-from-string
103
(with-input-from-string
105
(let ((s (make-concatenated-stream s1 s2)))
113
(read-char s nil :eof)))))
114
#\a nil #\a #\b nil #\b :eof)
116
(deftest make-concatenated-stream.15
117
(let ((s (make-concatenated-stream)))
118
(read-char-no-hang s nil :eof))
121
(deftest make-concatenated-stream.16
122
(with-input-from-string
124
(with-input-from-string
126
(let ((s (make-concatenated-stream s1 s2)))
128
(read-char-no-hang s)
129
(read-char-no-hang s)
130
(read-char-no-hang s nil :eof)))))
133
(deftest make-concatenated-stream.17
134
(with-input-from-string
136
(with-input-from-string
138
(let ((s (make-concatenated-stream s1 s2)))
139
(multiple-value-bind (str mnp)
141
(values str (notnot mnp))))))
144
(deftest make-concatenated-stream.18
145
(with-input-from-string
147
(with-input-from-string
149
(let ((s (make-concatenated-stream s1 s2)))
150
(multiple-value-bind (str mnp)
152
(values str (notnot mnp))))))
155
(deftest make-concatenated-stream.19
156
(with-input-from-string
158
(with-input-from-string
160
(let ((s (make-concatenated-stream s1 s2)))
161
(multiple-value-bind (str mnp)
163
(values str (notnot mnp))))))
166
(deftest make-concatenated-stream.20
167
(with-input-from-string
169
(with-input-from-string
170
(s2 (concatenate 'string (string #\Newline) "def"))
171
(let ((s (make-concatenated-stream s1 s2)))
175
(deftest make-concatenated-stream.21
176
(with-input-from-string
178
(with-input-from-string
180
(let ((s (make-concatenated-stream s1 s2)))
181
(multiple-value-bind (str mnp)
182
(read-line s nil :eof)
183
(values str (notnot mnp))))))
186
(deftest make-concatenated-stream.22
187
(let ((pn #p"tmp.dat")
188
(element-type '(unsigned-byte 8)))
189
(with-open-file (s pn :direction :output :element-type element-type
190
:if-exists :supersede)
191
(dolist (b '(1 5 9 13)) (write-byte b s)))
193
(s1 pn :direction :input :element-type element-type)
195
(s2 pn :direction :input :element-type element-type)
196
(let ((s (make-concatenated-stream s1 s2))
197
(x (vector nil nil nil nil nil nil nil nil)))
202
#(1 5 9 13 1 5 9 13))
204
(deftest make-concatenated-stream.23
205
(let ((pn #p"tmp.dat")
206
(element-type '(unsigned-byte 8)))
207
(with-open-file (s pn :direction :output :element-type element-type
208
:if-exists :supersede)
209
(dolist (b '(1 5 9 13)) (write-byte b s)))
211
(s1 pn :direction :input :element-type element-type)
213
(s2 pn :direction :input :element-type element-type)
214
(let ((s (make-concatenated-stream s1 s2))
215
(x (vector nil nil nil nil nil nil)))
222
(deftest make-concatenated-stream.24
223
(let ((pn #p"tmp.dat")
224
(element-type '(unsigned-byte 8)))
225
(with-open-file (s pn :direction :output :element-type element-type
226
:if-exists :supersede)
227
(dolist (b '(1 5 9 13)) (write-byte b s)))
229
(s1 pn :direction :input :element-type element-type)
231
(s2 pn :direction :input :element-type element-type)
232
(let ((s (make-concatenated-stream s1 s2))
233
(x (vector nil nil nil nil nil nil nil nil nil nil)))
238
#(1 5 9 13 1 5 9 13 nil nil))
240
(deftest make-concatenated-stream.25
241
(close (make-concatenated-stream))
244
(deftest make-concatenated-stream.26
245
(let ((s (make-concatenated-stream)))
246
(values (prog1 (close s) (close s))
250
(deftest make-concatenated-stream.27
251
(with-input-from-string
253
(let ((s (make-concatenated-stream s1)))
255
(notnot (open-stream-p s1))
256
(notnot (open-stream-p s))
258
(notnot (open-stream-p s1))
262
(deftest make-concatenated-stream.28
263
(with-input-from-string
265
(let ((s (make-concatenated-stream s1)))
266
(notnot-mv (listen s))))
269
(deftest make-concatenated-stream.28a
270
(listen (make-concatenated-stream))
273
(deftest make-concatenated-stream.29
274
(with-input-from-string
276
(let ((s (make-concatenated-stream s1)))
280
(deftest make-concatenated-stream.30
281
(with-input-from-string
283
(with-input-from-string
285
(let ((s (make-concatenated-stream s1 s2)))
286
(notnot-mv (listen s)))))
289
(deftest make-concatenated-stream.31
290
(with-input-from-string
292
(with-input-from-string
294
(let ((s (make-concatenated-stream s1 s2)))
298
(deftest make-concatenated-stream.32
299
(clear-input (make-concatenated-stream))
302
(deftest make-concatenated-stream.33
303
(with-input-from-string
305
(clear-input (make-concatenated-stream s1)))
310
(deftest make-concatenated-stream.error.1
311
(loop for x in *mini-universe*
312
unless (or (and (streamp x) (input-stream-p x))
313
(eval `(signals-error (make-concatenated-stream ',x) t)))
317
(deftest make-concatenated-stream.error.2
318
(loop for x in *streams*
319
unless (or (and (streamp x) (input-stream-p x))
320
(eval `(signals-error (make-concatenated-stream ',x) t)))