Skip to content

Commit

Permalink
Add tests to check if numbers can be used in hashmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
nagy committed Aug 22, 2022
1 parent 5b0f2b4 commit 65e4d35
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/hash-tables.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,19 @@
(let ((h (temp-hash-table :fill t)))
(remhash 'one h)
h))))

;;; Test numbers as keys
(let ((ht (make-hash-table)))
(test (eq nil (gethash 123 ht)))
(test (eq 'foo (setf (gethash 123 ht) 'foo)))
(test (eq 'foo (gethash 123 ht))))

;;; Test numbers are different than strings
(let ((ht (make-hash-table :test #'equal)))
(test (equal 'foo (setf (gethash 123 ht) 'foo)))
(test (equal 'bar (setf (gethash "123" ht) 'bar)))
(test (equal 'foo (gethash 123 ht)))
(test (equal 'bar (gethash "123" ht)))
(test (eq 2 (length (hash-table-keys ht)))))

;;; EOF

0 comments on commit 65e4d35

Please sign in to comment.