X-Git-Url: http://repo.macrolet.net/gitweb/?p=jscl.git;a=blobdiff_plain;f=tests%2Fhash-tables.lisp;fp=tests%2Fhash-tables.lisp;h=130ca988a08a2b08fee1e3143bccca84436bc00e;hp=3dc7528165d7d980dd946483b3bc7e31a5ec6fa4;hb=5ebb91faa8f2c565bf3307d8641474eee9909f5d;hpb=05b3840a974805eae28a84dd2986e55d5deac91d diff --git a/tests/hash-tables.lisp b/tests/hash-tables.lisp index 3dc7528..130ca98 100644 --- a/tests/hash-tables.lisp +++ b/tests/hash-tables.lisp @@ -20,3 +20,36 @@ (test (null (gethash "foo" ht)))) +;;; MAPHASH + +(let ((ht (make-hash-table)) + (count 0)) + (maphash (lambda (key value) + (declare (ignore key value)) + (inct count)) + ht) + (test (zerop count))) + +(let ((ht (make-hash-table)) + (count 0)) + (setf (gethash :x ht) 10) + (maphash (lambda (key value) + (setq count (1+ count))) + ht) + (test (= count 1))) + +(let ((ht (make-hash-table))) + (setf (gethash :x ht) 10) + (setf (gethash :y ht) 20) + (maphash (lambda (key value) + (when (eq key :x) + (test (= value 10))) + (when (eq key :y) + (test (= value 20)))) + ht)) + +(let ((ht (make-hash-table))) + (test + (eq nil (maphash (lambda (key value) + (declare (ignore key value))) + ht))))