Commit e92e84f5 authored by pfdietz's avatar pfdietz

Added tests for broadcast streams, two-way streams.

parent 8c4f321f
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Thu Jan 29 22:06:28 2004
;;;; Contains: Tests of BROADCAST-STREAM-STREAMS
(in-package :cl-test)
(deftest broadcast-stream-streams.1
(broadcast-stream-streams (make-broadcast-stream))
nil)
(deftest broadcast-stream-streams.2
(equalt
(broadcast-stream-streams (make-broadcast-stream *standard-output*))
(list *standard-output*))
t)
(deftest broadcast-stream-streams.error.1
(signals-error (broadcast-stream-streams) program-error)
t)
(deftest broadcast-stream-streams.error.2
(signals-error (broadcast-stream-streams (make-broadcast-stream) nil)
program-error)
t)
......@@ -35,4 +35,9 @@
(load "finish-output.lsp")
(load "force-output.lsp")
(load "clear-output.lsp")
(load "make-synonym-stream.lsp")
(load "synonym-stream-symbol.lsp")
(load "make-broadcast-stream.lsp")
(load "broadcast-stream-streams.lsp")
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Thu Jan 29 21:28:25 2004
;;;; Contains: Tests of MAKE-BROADCAST-STREAM
(in-package :cl-test)
(deftest make-broadcast-stream.1
(let ((s (make-broadcast-stream)))
(values
(notnot (typep s 'stream))
(notnot (typep s 'broadcast-stream))
(notnot (output-stream-p s))
(progn (write-char #\x s) nil)
))
t t t nil)
(deftest make-broadcast-stream.2
(with-output-to-string
(s1)
(let ((s (make-broadcast-stream s1)))
(assert (typep s 'stream))
(assert (typep s 'broadcast-stream))
(assert (output-stream-p s))
(write-char #\x s)))
"x")
(deftest make-broadcast-stream.3
(let ((s1 (make-string-output-stream))
(s2 (make-string-output-stream)))
(let ((s (make-broadcast-stream s1 s2)))
(format s "This is a test"))
(values
(get-output-stream-string s1)
(get-output-stream-string s2)))
"This is a test"
"This is a test")
(deftest make-broadcast-stream.error.1
(loop for x in *mini-universe*
unless (or (and (typep x 'stream) (output-stream-p x))
(handler-case (progn (make-broadcast-stream x) nil)
(type-error () t)
(condition nil)))
collect x)
nil)
(deftest make-broadcast-stream.error.2
(loop for x in *streams*
unless (or (and (typep x 'stream) (output-stream-p x))
(handler-case (progn (make-broadcast-stream x) nil)
(type-error () t)
(condition nil)))
collect x)
nil)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Wed Jan 28 06:54:33 2004
;;;; Contains: Tests of MAKE-SYNONYM-STREAM
(in-package :cl-test)
(deftest make-synonym-stream.1
(with-input-from-string
(*s* "abcde")
(declare (special *s*))
(let ((ss (make-synonym-stream '*s*)))
(assert (typep ss 'stream))
(assert (typep ss 'synonym-stream))
(assert (input-stream-p ss))
(values
(read-char *s*)
(read-char ss)
(read-char *s*)
(read-char ss)
(read-char ss))))
#\a #\b #\c #\d #\e)
(deftest make-synonym-stream.2
(let ((ss (make-synonym-stream '*s*)))
(with-input-from-string
(*s* "z")
(declare (special *s*))
(assert (typep ss 'stream))
(assert (typep ss 'synonym-stream))
(assert (input-stream-p ss))
(read-char ss)))
#\z)
(deftest make-synonym-stream.3
(with-output-to-string
(*s*)
(declare (special *s*))
(let ((ss (make-synonym-stream '*s*)))
(assert (typep ss 'stream))
(assert (typep ss 'synonym-stream))
(assert (output-stream-p ss))
(write-char #\a *s*)
(write-char #\b ss)
(write-char #\x *s*)
(write-char #\y ss)))
"abxy")
;;; Error cases
(deftest make-synonym-stream.error.1
(signals-error (make-synonym-stream) program-error)
t)
(deftest make-synonym-stream.error.2
(signals-error (make-synonym-stream '*standard-input* nil) program-error)
t)
(deftest make-synonym-stream.error.3
(loop for x in *mini-universe*
unless (or (symbolp x)
(eval `(signals-error (make-synonym-stream ',x)
type-error)))
collect x)
nil)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Thu Jan 29 21:21:06 2004
;;;; Contains: Tests of SYNONYM-STREAM-SYMBOL
(in-package :cl-test)
(deftest synonym-stream-symbol.1
(synonym-stream-symbol (make-synonym-stream '*standard-input*))
*standard-input*)
(deftest synonym-stream-symbol.error.1
(signals-error (synonym-stream-symbol) program-error)
t)
(deftest synonym-stream-symbol.error.2
(signals-error (synonym-stream-symbol
(make-synonym-stream '*terminal-io*)
nil)
program-error)
t)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment