RackUnit Abbrevs
(require rackunit-abbrevs) | package: rackunit-abbrevs |
A few helpers for writing many unit tests on a single function. The macros here repeatedly apply a standard RackUnit assertion.
1 API Functions
> (check-true* (lambda (x y #:z [z 0]) (= (+ x y z) 3)) [3 0] [1 2] [1 1 #:z 1])
> (check-true* integer? ["hello"])
--------------------
FAILURE
name: check-true
expression: (check-true (integer? "hello"))
params: (#f)
location: (eval 3 0 3 1)
Check failure
--------------------
> (check-false* string? [1] ['lemons])
> (check-false* = [2 2])
--------------------
FAILURE
name: check-false
expression: (check-false (= 2 2))
params: (#t)
location: (eval 5 0 5 1)
Check failure
--------------------
> (check-apply* map [add1 '(1 2 3) == '(2 3 4)] [append '((c)) '((a)) '((t)) != '((d o g))])
> (check-exn* exn:fail:contract? vector-ref [0 #'()] ["hi"])
> (check-exn* "\\+: contract violation" + [0 #\0 'O] ['() '()])
--------------------
ERROR
check-exn: contract violation
expected: (-> any/c any/c)
given: "\\+: contract violation"
context...:
/home/racket/build-pkgs/racket/share/pkgs/rackunit-lib/rackunit/private/check.rkt:132:29
/home/racket/build-pkgs/racket/share/pkgs/rackunit-lib/rackunit/private/check.rkt:57:0: top-level-check-around
/home/racket/build-pkgs/racket/share/pkgs/rackunit-lib/rackunit/private/check.rkt:118:21: check-exn229011
/home/racket/build-pkgs/user/.racket/6.3.90.900/pkgs/rackunit-abbrevs/private/rackunit-abbrevs.rkt:83:8
--------------------
--------------------
ERROR
check-exn: contract violation
expected: (-> any/c any/c)
given: "\\+: contract violation"
context...:
/home/racket/build-pkgs/racket/share/pkgs/rackunit-lib/rackunit/private/check.rkt:132:29
--------------------
2 Notes
You might also like Jay McCarthy’s rackunit-chk.