Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Karsten Poeck
ansi-test
Commits
3059a1f8
Commit
3059a1f8
authored
Feb 12, 2004
by
pfdietz
Browse files
More tests for operations on echo streams.
parent
55e0efaf
Changes
1
Hide whitespace changes
Inline
Side-by-side
ansi-tests/make-echo-stream.lsp
View file @
3059a1f8
...
...
@@ -53,10 +53,90 @@
(s pn2 :direction :input :element-type element-type)
(loop repeat 6 collect (read-byte s nil :eof2))))))
(2 3 5 7 11 :eof1)
(2 3 5 7 11 :eof2))
(2 3 5 7 11 :eof2))
;;; More tests of stream functions on echo streams go here
(deftest make-echo-stream.5
(let ((pn #p"tmp.dat")
(pn2 #p"tmp2.dat")
(element-type '(unsigned-byte 8)))
(with-open-file (os pn
:direction :output
:element-type element-type
:if-exists :supersede)
(loop for x in '(2 3 5 7 11)
do (write-byte x os)))
(with-open-file
(is pn :direction :input :element-type element-type)
(values
(with-open-file
(os pn2 :direction :output :if-exists :supersede
:element-type element-type)
(let ((s (make-echo-stream is os)))
(loop repeat 6 collect (read-byte s nil 100))))
(with-open-file
(s pn2 :direction :input :element-type element-type)
(loop repeat 6 collect (read-byte s nil 200))))))
(2 3 5 7 11 100)
(2 3 5 7 11 200))
(deftest make-echo-stream.6
(let* ((is (make-string-input-stream "foo"))
(os (make-string-output-stream))
(s (make-echo-stream is os)))
(values (coerce (loop repeat 3 collect (read-char-no-hang s)) 'string)
(get-output-stream-string os)))
"foo" "foo")
(deftest make-echo-stream.7
(let* ((is (make-string-input-stream "foo"))
(os (make-string-output-stream))
(s (make-echo-stream is os)))
(values (coerce (loop repeat 4 collect (read-char-no-hang s nil '#\z))
'string)
(get-output-stream-string os)))
"fooz" "foo")
;;; peek-char + echo streams is tested in peek-char.lsp
(deftest make-echo-stream.8
(let* ((is (make-string-input-stream "foo"))
(os (make-string-output-stream))
(s (make-echo-stream is os))
(x (copy-seq "xxxxxx")))
(values
(read-sequence x s)
x
(get-output-stream-string os)))
3
"fooxxx"
"foo")
(deftest make-echo-stream.9
(let ((pn #p"tmp.dat")
(pn2 #p"tmp2.dat")
(element-type '(unsigned-byte 8)))
(with-open-file (os pn
:direction :output
:element-type element-type
:if-exists :supersede)
(loop for x in '(2 3 5 7 11)
do (write-byte x os)))
(with-open-file
(is pn :direction :input :element-type element-type)
(values
(with-open-file
(os pn2 :direction :output :if-exists :supersede
:element-type element-type)
(let ((s (make-echo-stream is os))
(x (vector 0 0 0 0 0 0 0 0)))
(list (read-sequence x s)
x)))
(with-open-file
(s pn2 :direction :input :element-type element-type)
(loop repeat 8 collect (read-byte s nil nil))))))
(5 #(2 3 5 7 11 0 0 0))
(2 3 5 7 11 nil nil nil))
;;; Error tests
(deftest make-echo-stream.error.1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment