annotate tests/automated/database-tests.el @ 380:8626e4521993 r21-2-5

Import from CVS: tag r21-2-5
author cvs
date Mon, 13 Aug 2007 11:07:10 +0200
parents
children aabb7f5b1c81
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
1 ;; Copyright (C) 1998 Free Software Foundation, Inc.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
2
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
3 ;; Author: Martin Buchholz <martin@xemacs.org>
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
4 ;; Maintainer: Martin Buchholz <martin@xemacs.org>
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
5 ;; Created: 1998
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
6 ;; Keywords: tests, database
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
7
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
9
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
13 ;; any later version.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
14
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
18 ;; General Public License for more details.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
19
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
23 ;; 02111-1307, USA.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
24
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
25 ;;; Synched up with: not in FSF Emacs.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
26
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
27 ;;; Commentary:
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
28
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
29 ;;; Test database functionality
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
30 ;;; See test-harness.el
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
31
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
32 (condition-case err
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
33 (require 'test-harness)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
34 (file-error
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
35 (when (and (boundp 'load-file-name) (stringp load-file-name))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
36 (push (file-name-directory load-file-name) load-path)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
37 (require 'test-harness))))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
38
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
39 (flet ((test-database
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
40 (db)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
41 (Assert (databasep db))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
42 (put-database "key1" "val1" db)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
43 (Assert (equal "val1" (get-database "key1" db)))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
44 (remove-database "key1" db)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
45 (Assert (equal nil (get-database "key1" db)))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
46 (close-database db)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
47 (Assert (not (database-live-p db)))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
48 (Assert (databasep db))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
49 (let ((filename (database-file-name db)))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
50 (dolist (fn (list filename (concat filename ".db")))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
51 (condition-case nil (delete-file fn) (file-error nil))))))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
52
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
53 (let ((filename (expand-file-name "test-harness" (temp-directory))))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
54
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
55 (dolist (fn (list filename (concat filename ".db")))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
56 (condition-case nil (delete-file fn) (file-error nil)))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
57
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
58 (dolist (db-type `(dbm berkeley-db))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
59 (when (featurep db-type)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
60 (princ "\n")
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
61 (test-database (open-database filename db-type))))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents:
diff changeset
62 ))