;;;; 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". (DO-TEST-GROUP ("Cash-file tests" :AFTER (PROGN ;; now clean up the cash file (hash-file:close-hash-file (cash-file:cash-file-hash-file cash-file)) (delete-file "{dsk}test.hash")) ) ;;; Test MAKE-CASH-FILE & CASH-FILE-P (DO-TEST "Test MAKE-CASH-FILE & CASH-FILE-P" (setq cash-file (cash-file:make-cash-file "{dsk}test.hash" 100 10)) (and (cash-file:cash-file-p cash-file) (typep cash-file 'cash-file:cash-file)) ;; should return T ) ;;; Test GET-CASH-FILE (DO-TEST "Test1 GET-CASH-FILE" (EQUAL (multiple-value-list (cash-file:get-cash-file :foo cash-file)) '(NIL NIL)) ;; should return (nil nil) ) (DO-TEST "Test2 GET-CASH-FILE" (EQUAL (multiple-value-list (cash-file:get-cash-file :foo cash-file :bar)) '(:bar nil)) ;; should return (:bar nil) ) (DO-TEST "Test3 GET-CASH-FILE" (EQUAL (setf (cash-file:get-cash-file :test-key cash-file) :test-value) :test-value) ;; should return :test-value ) (DO-TEST "Test4 GET-CASH-FILE" (EQUAL (multiple-value-list (cash-file:get-cash-file :test-key cash-file)) '(:test-value t)) ;; should return (:test-value t) ) ;;; Test CASH-FILE-HASH-FILE (DO-TEST "Test1 CASH-FILE-HASH-FILE" (hash-file:hash-file-p (cash-file:cash-file-hash-file cash-file)) ;; should return true ) (DO-TEST "Test2 CASH-FILE-HASH-FILE (closing)" (pathnamep (hash-file:close-hash-file (cash-file:cash-file-hash-file cash-file))) ;; should return #.(pathname "{dsk}test.hash") ) (DO-TEST "Test3 CASH-FILE-HASH-FILE" (multiple-value-list (cash-file:get-cash-file :test-key cash-file)) ;; should return (:test-value t) without opening hash file ) ;;; Test OPEN-CASH-FILE (DO-TEST "Test1 OPEN-CASH-FILE" (setq cash-file (cash-file:open-cash-file "{dsk}test.hash" 10)) (cash-file:cash-file-p cash-file) ;; should be true ) (DO-TEST "Test2 OPEN-CASH-FILE" (EXPECT-ERRORS (T) (setf (cash-file:get-cash-file :test-key cash-file) :test-value) ;; should signal an error ) ) (DO-TEST "Test3 OPEN-CASH-FILE (closing)" (pathnamep (hash-file:close-hash-file (cash-file:cash-file-hash-file cash-file))) ;; should return #.(pathname "{dsk}test.hash") ) (DO-TEST "Test4 OPEN-CASH-FILE" (setq cash-file (cash-file:open-cash-file "{dsk}test.hash" 10 :direction :io)) (cash-file:cash-file-p cash-file) ;; should be true ) (DO-TEST "Test4 OPEN-CASH-FILE" (EQUAL (setf (cash-file:get-cash-file :test-key cash-file) :test-value) :test-value) ;; should return :test-value ) ;;; Test REM-CASH-FILE (DO-TEST "Test1 REM-CASH-FILE" (cash-file:rem-cash-file :test-key cash-file) ;; should return T ) (DO-TEST "Test2 REM-CASH-FILE" (EQUAL (multiple-value-list (cash-file:get-cash-file :test-key cash-file)) '(nil nil)) ;; should return (nil nil) ) (DO-TEST "Test3 REM-CASH-FILE" (NOT (cash-file:rem-cash-file :test-key cash-file)) ;; should return NIL ) ) ; close DO-TEST-GROUPS