...
|
...
|
@@ -210,3 +210,91 @@ |
210
|
210
|
(assert-eql 3d0 (funcall tester 3d0))
|
211
|
211
|
(assert-eql 4w0 (funcall tester 4w0))))
|
212
|
212
|
|
|
213
|
(define-test issue.25a
|
|
214
|
(:tag :issues)
|
|
215
|
;; The original test from issue 25, modified slightly for lisp-unit
|
|
216
|
;; testing.
|
|
217
|
(let* ((in-string (format nil "A line.~%And another.~%")))
|
|
218
|
(with-output-to-string (out-stream nil)
|
|
219
|
(with-input-from-string (in-stream in-string)
|
|
220
|
(ext:run-program "cat" nil
|
|
221
|
:wait t
|
|
222
|
:input in-stream
|
|
223
|
:output out-stream))
|
|
224
|
(let ((out-string (get-output-stream-string out-stream)))
|
|
225
|
(assert-eql (length in-string) (length out-string))
|
|
226
|
(assert-equal in-string out-string)))))
|
|
227
|
|
|
228
|
(define-test issue.25b
|
|
229
|
(:tag :issues)
|
|
230
|
;; Modified test to verify that we only write the low 8-bits of each
|
|
231
|
;; string character to run-program.
|
|
232
|
(let* ((in-string (concatenate 'string '(#\greek_small_letter_alpha
|
|
233
|
#\greek_small_letter_beta)))
|
|
234
|
(expected (map 'string #'(lambda (c)
|
|
235
|
(code-char (ldb (byte 8 0) (char-code c))))
|
|
236
|
in-string)))
|
|
237
|
(with-output-to-string (out-stream nil)
|
|
238
|
(with-input-from-string (in-stream in-string)
|
|
239
|
(ext:run-program "cat" nil
|
|
240
|
:wait t
|
|
241
|
:input in-stream
|
|
242
|
:output out-stream))
|
|
243
|
(let ((out-string (get-output-stream-string out-stream)))
|
|
244
|
(assert-eql (length out-string) (length out-string))
|
|
245
|
;; For comparison, convert the strings to codes so failures are easier to read
|
|
246
|
(assert-equal (map 'list #'char-code out-string)
|
|
247
|
(map 'list #'char-code expected))))))
|
|
248
|
|
|
249
|
(define-test issue.25c
|
|
250
|
(:tag :issues)
|
|
251
|
;; Modified test to verify that each octet read from run-program is
|
|
252
|
;; read into the low 8-bits of each character of the resulting
|
|
253
|
;; string.
|
|
254
|
(let* ((in-string (concatenate 'string '(#\greek_small_letter_alpha
|
|
255
|
#\greek_small_letter_beta)))
|
|
256
|
(expected (stream:string-encode in-string :utf16-be))
|
|
257
|
(path #p"issue25c.txt"))
|
|
258
|
(with-open-file (s path :direction :output :if-exists :supersede :external-format :utf16-be)
|
|
259
|
(write-string in-string s)
|
|
260
|
(force-output s)
|
|
261
|
(file-position s 0)
|
|
262
|
(with-open-file (s1 path :direction :input :element-type '(unsigned-byte 8))
|
|
263
|
(with-output-to-string (out-stream)
|
|
264
|
(ext:run-program "cat" nil
|
|
265
|
:wait t
|
|
266
|
:input s1
|
|
267
|
:output out-stream)
|
|
268
|
(let ((out-string (get-output-stream-string out-stream)))
|
|
269
|
(assert-equal (length out-string) (length expected))
|
|
270
|
(assert-equal (map 'list #'char-code out-string)
|
|
271
|
(map 'list #'char-code expected))))))))
|
|
272
|
|
|
273
|
|
|
274
|
(define-test issue.25d
|
|
275
|
(:tag :issues)
|
|
276
|
;; The original test from issue 25, but using non-ascii characters
|
|
277
|
;; and using string-encode/decode to verify that the output and the
|
|
278
|
;; input match.
|
|
279
|
(let* ((in-string (concatenate 'string '(#\greek_small_letter_alpha
|
|
280
|
#\greek_small_letter_beta
|
|
281
|
#\greek_small_letter_gamma
|
|
282
|
#\greek_small_letter_delta
|
|
283
|
#\greek_small_letter_epsilon
|
|
284
|
#\greek_small_letter_zeta
|
|
285
|
#\greek_small_letter_eta
|
|
286
|
#\greek_small_letter_theta
|
|
287
|
#\greek_small_letter_iota
|
|
288
|
#\greek_small_letter_kappa
|
|
289
|
#\greek_small_letter_lamda))))
|
|
290
|
(with-output-to-string (out-stream nil)
|
|
291
|
(with-input-from-string (in-stream (stream:string-encode in-string :utf8))
|
|
292
|
(ext:run-program "cat" nil
|
|
293
|
:wait t
|
|
294
|
:input in-stream
|
|
295
|
:output out-stream))
|
|
296
|
(let ((out-string (stream:string-decode (get-output-stream-string out-stream)
|
|
297
|
:utf8)))
|
|
298
|
(assert-eql (length in-string) (length out-string))
|
|
299
|
(assert-equal in-string out-string)))))
|
|
300
|
|