X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-simple-streams%2Fsimple-stream-tests.lisp;h=20c5a8efc9214893a1a2892021385d13c018396d;hb=a7699535aaba71765335f3be0a2103b2f07941af;hp=1a3199292a8f60e4d893e434102baf8ae91f9a2b;hpb=bb00c71ace38129b5870c8fe05f70a79b3c6f087;p=sbcl.git diff --git a/contrib/sb-simple-streams/simple-stream-tests.lisp b/contrib/sb-simple-streams/simple-stream-tests.lisp index 1a31992..20c5a8e 100644 --- a/contrib/sb-simple-streams/simple-stream-tests.lisp +++ b/contrib/sb-simple-streams/simple-stream-tests.lisp @@ -60,6 +60,22 @@ (progn ,@body)) ,(when delete-afterwards `(ignore-errors (delete-file ,file)))))) +(deftest non-existent-class + (handler-case + (with-test-file (s *test-file* :class 'non-existent-stream) + nil) + ;; find-class will raise a simple-error + (simple-error (c) (search "There is no class" (simple-condition-format-control c)))) + 0) + +(deftest non-stream-class + (handler-case + (with-test-file (s *test-file* :class 'standard-class) + nil) + ;; Will fall through sb-simple-streams:open as it is no stream class. + (simple-error (c) (search "Don't know how to handle" (simple-condition-format-control c)))) + 0) + (deftest create-file-1 ;; Create a file-simple-stream, write data. (prog1 @@ -930,3 +946,24 @@ Nothing to see here, move along.") :external-format :utf-8) (char-code (read-char s)))) 196) + +;; launchpad bug #491087 + +(deftest lp491087 + (labels ((read-big-int (stream) + (let ((b (make-array 1 :element-type '(signed-byte 32) + :initial-element 0))) + (declare (dynamic-extent b)) + (sb-simple-streams::read-vector b stream + :endian-swap :network-order) + (aref b 0)))) + (with-open-file (stream + (merge-pathnames #P"lp491087.txt" *test-path*) + :class 'file-simple-stream) + (let* ((start (file-position stream)) + (integer (read-big-int stream)) + (end (file-position stream))) + (and (= start 0) + (= integer #x30313233) + (= end 4))))) + T)