Skip to content

Commit

Permalink
Fix WITH-HASH-TABLE-ITERATOR test
Browse files Browse the repository at this point in the history
  • Loading branch information
metawilm committed Mar 2, 2017
1 parent 4e9b34d commit 78f01ae
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions test-suite.lisp
Expand Up @@ -46,24 +46,27 @@
(flet ((expected-p (set)
(and (null (set-difference set expected :test 'equal))
(null (set-difference expected set :test 'equal)))))
;; Check MAPHASH
(let (items)
(maphash (lambda (k v) (push (cons k v) items)) *foo-ht*)
(is (expected-p items)))
(block iter-test
(let (items)
(with-hash-table-iterator (next *foo-ht*)
(multiple-value-bind (entry-p key val) (next)
(if entry-p
(push (cons key val) items)
(progn (is (expected-p items))
(return-from iter-test)))))))))
;; Check WITH-HASH-TABLE-ITERATOR
(let (items)
(with-hash-table-iterator (next *foo-ht*)
(loop named iter-test
do (multiple-value-bind (entry-p key val) (next)
(if entry-p
(push (cons key val) items)
(return-from iter-test)))))
(is (expected-p items)))))
(clrhash *foo-ht*)
(is (zerop (hash-table-count *foo-ht*)))
(is (plusp (hash-table-rehash-size *foo-ht*)))
(is (plusp (hash-table-rehash-threshold *foo-ht*)))
(is (plusp (hash-table-size *foo-ht*))))
(terpri)
(format t "Test success!~%")
t)

(defun run ()
(basic-test))
(basic-test))

0 comments on commit 78f01ae

Please sign in to comment.