io-write.lisp 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. (in-package :translator-test)
  2. (def-test-method io-write-test ((test io-test))
  3. (let ((file (concatenate-string +main-dir+ "/d")))
  4. (with-testport (p (file-name-lookup file
  5. :flags '(:read)))
  6. (multiple-value-bind (ret err)
  7. (io-write p "a")
  8. (assert-equal ret nil)
  9. (assert-equal err :invalid-argument)))
  10. (with-testport (p (file-name-lookup file
  11. :flags '(:creat :read :write)))
  12. (assert-true (file-set-size p 3))
  13. (assert-true (io-write p "456"))
  14. (%my-io-read p "456" :offset 0)
  15. (assert-true (io-seek p :offset 0
  16. :whence :seek-set))
  17. (assert-true (io-seek p :offset 1))
  18. (assert-true (io-write p "3"))
  19. (%my-io-read p "436" :offset 0)
  20. (assert-true (io-seek p :offset -1 :whence :seek-end))
  21. (assert-true (io-write p "6789"))
  22. (%my-io-read p "436789" :offset 0)
  23. (assert-true (io-write p "5" :offset 1))
  24. (%my-io-read p "456789" :offset 0)
  25. (assert-true (file-set-size p 3))
  26. (%my-io-read p "456" :offset 0))
  27. (with-testport (p (file-name-lookup file :flags '(:read :write :append)))
  28. (assert-true (io-write p "789"))
  29. (%my-io-read p "456789" :offset 0))))