-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathhash-table-test.ss
More file actions
26 lines (21 loc) · 1.04 KB
/
hash-table-test.ss
File metadata and controls
26 lines (21 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#lang mzscheme
(require (only mzlib/list sort)
"hash-table.ss"
"test-base.ss")
; test-suite
(define/provide-test-suite hash-table-tests
(test-case "make-hash-table/pairs"
(let ([hash (make-hash-table/pairs '(a . 1) '(b . (1 2 3)) '(c . ()))])
(check-equal? (hash-table-get hash 'a #f) 1)
(check-equal? (hash-table-get hash 'b #f) '(1 2 3))
(check-equal? (hash-table-get hash 'c #f) null)
(check-equal? (hash-table-get hash 'd #f) #f)))
(test-case "hash-table-mapped?"
(let ([hash (make-hash-table/pairs '(a . 1) '(b . (1 2 3)))])
(check equal? (hash-table-mapped? hash 'a) #t)
(check equal? (hash-table-mapped? hash 'b) #t)
(check equal? (hash-table-mapped? hash 'c) #f)))
(test-case "hash-table-keys and hash-table-values"
(let ([hash (make-hash-table/pairs '(1 . "3") '(2 . "2") '(3 . "1"))])
(check-equal? (sort (hash-table-keys hash) <) (list 1 2 3) "keys")
(check-equal? (sort (hash-table-values hash) string<?) (list "1" "2" "3") "values"))))