view tests/database.el @ 371:cc15677e0335 r21-2b1

Import from CVS: tag r21-2b1
author cvs
date Mon, 13 Aug 2007 11:03:08 +0200
parents 4f79e16b1112
children
line wrap: on
line source

;;; Test database functionality

(defun test-database (db)
  (Assert (databasep db))
  (put-database "key1" "val1" db)
  (Assert (equal "val1" (get-database "key1" db)))
  (remove-database "key1" db)
  (Assert (equal nil (get-database "key1" db)))
  (close-database db)
  (Assert (not (database-live-p db)))
  (Assert (databasep db))
  (let ((filename (database-file-name db)))
    (loop for fn in (list filename (concat filename ".db")) do
      (when (file-exists-p fn)
	(delete-file fn))))
  )

(let ((filename (expand-file-name "test-emacs" (temp-directory))))

  (when (featurep 'dbm)
  (let ((db (open-database filename 'dbm)))
    (test-database db)))
  
  (princ "\n")

  (when (featurep 'berkeley-db)
    (let ((db (open-database filename 'berkeley-db)))
      (test-database db)))
  )