diff --git a/tests/fd-streams.lisp b/tests/fd-streams.lisp new file mode 100644 index 0000000000000000000000000000000000000000..263ce1fdcae056001caad1b29db2f0b9d96a08c7 --- /dev/null +++ b/tests/fd-streams.lisp @@ -0,0 +1,36 @@ +;;;; -*- Lisp -*- + +(defpackage fd-streams-tests + (:use #:common-lisp #:lisp-unit)) + +(in-package #:fd-streams-tests) + +(defparameter *test-path* + (merge-pathnames (make-pathname :name :unspecific :type :unspecific + :version :unspecific) + *load-truename*) + "Directory for temporary test files.") + +(defparameter *test-file* + (merge-pathnames #p"test-data.tmp" *test-path*)) + +(eval-when (:load-toplevel) + (ensure-directories-exist *test-path* :verbose t)) + +(define-test clear-output-1 + (:tag :trac) + (assert-eql + 0 + (unwind-protect + (let ((s (open *test-file* + :direction :output + :if-exists :supersede))) + ;; Write a character to the (fully buffered) output + ;; stream. Clear the output and close the file. Nothing + ;; should have been written to the file. + (write-char #\a s) + (clear-output s) + (close s) + (setf s (open *test-file*)) + (file-length s)) + (delete-file *test-file*)))) diff --git a/tests/gray-streams.lisp b/tests/gray-streams.lisp new file mode 100644 index 0000000000000000000000000000000000000000..6308882acea9d772294a55a082b201b69adf8174 --- /dev/null +++ b/tests/gray-streams.lisp @@ -0,0 +1,39 @@ +;;;; -*- Lisp -*- + +(require :gray-streams) + +(defpackage gray-streams-tests + (:use #:common-lisp #:lisp-unit)) + +(in-package #:gray-streams-tests) + +(defparameter *test-path* + (merge-pathnames (make-pathname :name :unspecific :type :unspecific + :version :unspecific) + *load-truename*) + "Directory for temporary test files.") + +(defparameter *test-file* + (merge-pathnames #p"test-data.tmp" *test-path*)) + +(eval-when (:load-toplevel) + (ensure-directories-exist *test-path* :verbose t)) + +(define-test clear-output-1 + (:tag :trac) + ;; Create a Gray stream and make sure that clear-output works. + (assert-eql + 0 + (unwind-protect + (let ((s (open *test-file* + :direction :output + :if-exists :supersede + :class 'lisp::character-output-stream))) + (write-char #\a s) + (clear-output s) + (close s) + (setf s (open *test-file*)) + (file-length s)) + (delete-file *test-file*)))) + + \ No newline at end of file