-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.lisp
54 lines (46 loc) · 1.32 KB
/
tests.lisp
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(cl:in-package #:cl-user)
(defpackage #:disjoint-sets.test
(:use #:cl #:disjoint-sets)
(:import-from #:parachute
#:define-test
#:is
#:true
#:false)
(:export #:run-tests))
(in-package #:disjoint-sets.test)
(define-test make-disjoint-sets
(is equalp
#()
(make-disjoint-sets))
(is equalp
#(0 1 2 3 4 5 6 7 8 9)
(make-disjoint-sets 10)))
(define-test disjoin-sets-add
(is equalp
'(0 #(0))
(let ((sets (make-disjoint-sets)))
(list (disjoint-sets-add sets)
sets)))
(is equalp
`(1 #(0 1))
(let ((sets (make-disjoint-sets 1)))
(list (disjoint-sets-add sets)
sets))))
(define-test disjoint-set-union
(is equalp
#(0 1 1 3 4 5 6 7 8 1)
(let ((sets (make-disjoint-sets 10)))
(disjoint-sets-union sets 1 2)
(disjoint-sets-union sets 1 9)
sets)))
(define-test disjoint-set-same-set-p
(is equalp
'(t t nil)
(let ((sets (make-disjoint-sets 10)))
(disjoint-sets-union sets 1 2)
(disjoint-sets-union sets 1 9)
(list (disjoint-sets-same-set-p sets 1 2)
(disjoint-sets-same-set-p sets 2 9)
(disjoint-sets-same-set-p sets 1 5)))))
(defun run-tests ()
(parachute:test '#:disjoint-sets.test))