Skip to content
Snippets Groups Projects
Commit 9c4ee94e authored by rtoy's avatar rtoy
Browse files

o Load simple-streams library if needed.

o For all tests that generate random characters, be sure to specify an
  external format of iso8859-1, just in case *default-external-format*
  is something else that might cause issues with random characters.
parent 1ae505d3
No related branches found
No related tags found
No related merge requests found
;;;; -*- lisp -*-
(require :simple-streams)
(defpackage simple-streams-test
(:use #:common-lisp #:stream #:rt))
......@@ -150,7 +152,8 @@
(let* ((stream (make-instance 'file-simple-stream
:filename *test-file* :direction :output
:if-exists :overwrite
:if-does-not-exist :create))
:if-does-not-exist :create
:external-format :iso8859-1))
(length (1+ (* 3 (device-buffer-length stream))))
(content (make-string length)))
(dotimes (i (length content))
......@@ -158,7 +161,8 @@
(with-open-stream (s stream)
(write-string content s))
(with-test-file (s *test-file* :class 'file-simple-stream
:direction :input :if-does-not-exist :error)
:direction :input :if-does-not-exist :error
:external-format :iso8859-1)
(let ((seq (make-string length)))
#+nil (read-sequence seq s)
#-nil (dotimes (i length)
......@@ -170,7 +174,8 @@
(let* ((stream (make-instance 'file-simple-stream
:filename *test-file* :direction :output
:if-exists :overwrite
:if-does-not-exist :create))
:if-does-not-exist :create
:external-format :iso8859-1))
(length (1+ (* 3 (device-buffer-length stream))))
(content (make-string length)))
(dotimes (i (length content))
......@@ -178,7 +183,8 @@
(with-open-stream (s stream)
(write-string content s))
(with-test-file (s *test-file* :class 'file-simple-stream
:direction :input :if-does-not-exist :error)
:direction :input :if-does-not-exist :error
:external-format :iso8859-1)
(let ((seq (make-string length)))
(read-sequence seq s)
(string= content seq))))
......@@ -188,7 +194,8 @@
(let* ((stream (make-instance 'file-simple-stream
:filename *test-file* :direction :output
:if-exists :overwrite
:if-does-not-exist :create))
:if-does-not-exist :create
:external-format :iso8859-1))
(length (1+ (* 3 (device-buffer-length stream))))
(content (make-array length :element-type '(unsigned-byte 8))))
(dotimes (i (length content))
......@@ -196,7 +203,8 @@
(with-open-stream (s stream)
(write-sequence content s))
(with-test-file (s *test-file* :class 'file-simple-stream
:direction :input :if-does-not-exist :error)
:direction :input :if-does-not-exist :error
:external-format :iso8859-1)
(let ((seq (make-array length :element-type '(unsigned-byte 8))))
#+nil (read-sequence seq s)
#-nil (dotimes (i length)
......@@ -208,7 +216,8 @@
(let* ((stream (make-instance 'file-simple-stream
:filename *test-file* :direction :output
:if-exists :overwrite
:if-does-not-exist :create))
:if-does-not-exist :create
:external-format :iso8859-1))
(length (1+ (* 3 (device-buffer-length stream))))
(content (make-array length :element-type '(unsigned-byte 8))))
(dotimes (i (length content))
......@@ -216,7 +225,8 @@
(with-open-stream (s stream)
(write-sequence content s))
(with-test-file (s *test-file* :class 'file-simple-stream
:direction :input :if-does-not-exist :error)
:direction :input :if-does-not-exist :error
:external-format :iso8859-1)
(let ((seq (make-array length :element-type '(unsigned-byte 8))))
(read-sequence seq s)
(equalp content seq))))
......@@ -501,4 +511,4 @@
:external-format :utf8)
(let ((seq (read-line s)))
(string= string seq))))
t)
\ No newline at end of file
t)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment