hash-table-count.lsp 1.54 KB
Newer Older
1 2 3 4 5
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Fri Nov 28 05:14:25 2003
;;;; Contains: Tests of HASH-TABLE-COUNT

6

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45

(deftest hash-table-count.1
  (hash-table-count (make-hash-table))
  0)

(deftest hash-table-count.2
  (hash-table-count (make-hash-table :test 'eq))
  0)

(deftest hash-table-count.3
  (hash-table-count (make-hash-table :test 'eql))
  0)

(deftest hash-table-count.4
  (hash-table-count (make-hash-table :test 'equal))
  0)

(deftest hash-table-count.5
  (hash-table-count (make-hash-table :test 'equalp))
  0)

(deftest hash-table-count.6
  (hash-table-count (make-hash-table :test #'eq))
  0)

(deftest hash-table-count.7
  (hash-table-count (make-hash-table :test #'eql))
  0)

(deftest hash-table-count.8
  (hash-table-count (make-hash-table :test #'equal))
  0)

(deftest hash-table-count.9
  (hash-table-count (make-hash-table :test #'equalp))
  0)

(deftest hash-table-count.10
  (hash-table-count (let ((table (make-hash-table)))
sds's avatar
sds committed
46 47
                      (setf (gethash 'x table) 1)
                      table))
48 49 50 51 52 53
  1)

(deftest hash-table-count.11
  (let ((table (make-hash-table)))
    (setf (gethash 'x table) 1)
    (values (hash-table-count table)
sds's avatar
sds committed
54 55 56
            (progn
              (remhash 'x table)
              (hash-table-count table))))
57 58 59 60 61
  1 0)

;; This function is mostly tested by calls to test-hash-table-1

(deftest hash-table-count.error.1
62 63
  (signals-error (hash-table-count) program-error)
  t)
64 65

(deftest hash-table-count.error.2
66
  (signals-error (hash-table-count (make-hash-table) nil)
sds's avatar
sds committed
67
                 program-error)
68
  t)