Mercurial > hg > xemacs-beta
comparison 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 |
comparison
equal
deleted
inserted
replaced
370:bd866891f083 | 371:cc15677e0335 |
---|---|
1 ;;; Test database functionality | 1 ;;; Test database functionality |
2 | 2 |
3 (flet ((delete-database-files (filename) | 3 (defun test-database (db) |
4 (dolist (fn (list filename (concat filename ".db"))) | 4 (Assert (databasep db)) |
5 (condition-case nil (delete-file fn) (file-error nil)))) | 5 (put-database "key1" "val1" db) |
6 (Assert (equal "val1" (get-database "key1" db))) | |
7 (remove-database "key1" db) | |
8 (Assert (equal nil (get-database "key1" db))) | |
9 (close-database db) | |
10 (Assert (not (database-live-p db))) | |
11 (Assert (databasep db)) | |
12 (let ((filename (database-file-name db))) | |
13 (loop for fn in (list filename (concat filename ".db")) do | |
14 (when (file-exists-p fn) | |
15 (delete-file fn)))) | |
16 ) | |
6 | 17 |
7 (test-database (db) | 18 (let ((filename (expand-file-name "test-emacs" (temp-directory)))) |
8 (Assert (databasep db)) | |
9 (put-database "key1" "val1" db) | |
10 (Assert (equal "val1" (get-database "key1" db))) | |
11 (remove-database "key1" db) | |
12 (Assert (equal nil (get-database "key1" db))) | |
13 (close-database db) | |
14 (Assert (not (database-live-p db))) | |
15 (Assert (databasep db)))) | |
16 | 19 |
17 (let ((filename (expand-file-name "test-harness" (temp-directory)))) | 20 (when (featurep 'dbm) |
21 (let ((db (open-database filename 'dbm))) | |
22 (test-database db))) | |
23 | |
24 (princ "\n") | |
18 | 25 |
19 (dolist (db-type `(dbm berkeley-db)) | 26 (when (featurep 'berkeley-db) |
20 (when (featurep db-type) | 27 (let ((db (open-database filename 'berkeley-db))) |
21 (princ "\n") | 28 (test-database db))) |
22 (delete-database-files filename) | 29 ) |
23 (test-database (open-database filename db-type)) | |
24 (delete-database-files filename))))) |