1
0
mirror of synced 2026-01-22 19:00:53 +00:00

67 lines
2.2 KiB
Plaintext

;;;; Test code for CASH-FILE
;;; Start with an XCL exec. Copy each non-commented statement
;;; from this file into the executive and observe that it behaves
;;; as described in the comments.
;;; These tests are meant to be done IN ORDER, and ONLY ONCE
;;; as many tests depend upon the sucess of previous tests.
;;; Set up a package for testing in.
;;; MAKE-PACKAGE will report an error if a package named "TEST" exists.
;;; If this happens, use a name besides "TEST".
(make-package "TEST")
(in-package "TEST")
(use-package "CASH-FILE")
(use-package "HASH-FILE")
;;; Test MAKE-CASH-FILE & CASH-FILE-P
(setq cash-file (make-cash-file "{dsk}test.hash" 100 10))
(and (cash-file-p cash-file) (typep cash-file 'cash-file))
;; should return T
;;; Test GET-CASH-FILE
(multiple-value-list (get-cash-file :foo cash-file))
;; should return (nil nil)
(multiple-value-list (get-cash-file :foo cash-file :bar))
;; should return (:bar nil)
(setf (get-cash-file :test-key cash-file) :test-value)
;; should return :test-value
(multiple-value-list (get-cash-file :test-key cash-file))
;; should return (:test-value t)
;;; Test CASH-FILE-HASH-FILE
(hash-file-p (cash-file-hash-file cash-file))
;; should return true
(close-hash-file (cash-file-hash-file cash-file))
;; should return #.(pathname "{dsk}test.hash")
(multiple-value-list (get-cash-file :test-key cash-file))
;; should return (:test-value t) without opening hash file
;;; Test OPEN-CASH-FILE
(setq cash-file (open-cash-file "{dsk}test.hash" 10))
(cash-file-p cash-file)
;; should be true
(setf (get-cash-file :test-key cash-file) :test-value)
;; should signal an error
(close-hash-file (cash-file-hash-file cash-file))
;; should return #.(pathname "{dsk}test.hash")
(setq cash-file (open-cash-file "{dsk}test.hash" 10 :direction :io))
(cash-file-p cash-file)
;; should be true
(setf (get-cash-file :test-key cash-file) :test-value)
;; should return :test-value
;;; Test REM-CASH-FILE
(rem-cash-file :test-key cash-file)
;; should return T
(multiple-value-list (get-cash-file :test-key cash-file))
;; should return (nil nil)
(rem-cash-file :test-key cash-file)
;; should return NIL
;; now clean up the cash file
(close-hash-file (cash-file-hash-file cash-file))
(delete-file "{dsk}test.hash")