Commit 6fb386df authored by Daniel Kochmanski's avatar Daniel Kochmanski

streams: add 3 new tests for broadcast and string-output streams

broadcast-stream-streams.3: ensure that last component is taken for file-*
broadcast-stream-streams.4: ensure conforming results when no components
make-string-output-stream.error.4: file-length returns error
parent e5677433
......@@ -15,6 +15,34 @@
(list *standard-output*))
t)
;;; Ensure that the last component is taken for
;;; file-{position,length,string-length} functions.
(deftest broadcast-stream-streams.3
(let ((first-stream (make-string-output-stream)))
(with-open-file (last-stream "bss-last.txt"
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(format last-stream "Hello world!~%")
(finish-output last-stream) ; for buffered streams
(let ((broadcast (make-broadcast-stream first-stream last-stream)))
(values
(= 13 (file-length last-stream))
(= 13 (file-length broadcast) (file-length last-stream))
(= 13 (file-position broadcast) (file-position last-stream))
(= 2
(file-string-length broadcast "jd")
(file-string-length last-stream "jd"))))))
t t t t)
(deftest broadcast-stream-streams.4
(let ((stream (make-broadcast-stream)))
(values (= 0 (file-length stream))
(= 0 (file-position stream))
(= 1 (file-string-length stream "foo"))
(eq :default (stream-external-format stream))))
t t t t)
(deftest broadcast-stream-streams.error.1
(signals-error (broadcast-stream-streams) program-error)
t)
......@@ -23,8 +51,3 @@
(signals-error (broadcast-stream-streams (make-broadcast-stream) nil)
program-error)
t)
......@@ -134,6 +134,8 @@
program-error)
t)
(deftest make-string-output-stream.error.4
(signals-error (file-length (make-string-output-stream)) type-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