3 (defpackage sb-simple-streams-test
4 (:use #:common-lisp #:sb-simple-streams #:sb-rt))
7 (in-package #:sb-simple-streams-test)
9 (defparameter *dumb-string* "This file created by simple-stream-tests.lisp. Nothing to see here, move along.")
11 (defparameter *test-path* (merge-pathnames
12 (make-pathname :name nil :type nil :version nil)
15 (eval-when (:load-toplevel) (ensure-directories-exist *test-path*))
17 (deftest create-file-1
18 (let* ((file (merge-pathnames #p"test-data.txt" *test-path*))
19 (stream-object (make-instance 'file-simple-stream
22 :if-exists :overwrite)))
24 (with-open-stream (s stream-object)
25 (string= (write-string *dumb-string* s) *dumb-string*))
29 (deftest create-file-2
30 (let ((file (merge-pathnames #p"test-data.txt" *test-path*)))
32 (with-open-file (s file
33 :class 'file-simple-stream
34 :direction :output :if-exists :overwrite)
35 (string= (write-string *dumb-string* s) *dumb-string*))
39 (deftest create-read-file-1
41 (file (merge-pathnames #p"test-data.txt" *test-path*)))
42 (let ((stream-object (make-instance 'file-simple-stream
45 :if-exists :overwrite)))
46 (with-open-stream (s stream-object)
47 (setf result (and result (string= (write-string *dumb-string* s)
50 (let ((stream-object (make-instance 'file-simple-stream
53 (with-open-stream (s stream-object)
54 (setf result (and result (string= (read-line s) *dumb-string*)))))
58 (deftest create-read-mapped-file-1
60 (file (merge-pathnames #p"test-data.txt" *test-path*)))
61 (with-open-file (s file
62 :class 'file-simple-stream
63 :direction :output :if-exists :overwrite)
64 (setf result (and result (string= (write-string *dumb-string* s)
66 (with-open-file (s file
67 :class 'mapped-file-simple-stream
69 (setf result (and result (string= (read-line s) *dumb-string*))))