;; ;; Verifying the cis package ;; (use test cis) (define min-key 1) (define max-key 10000) (define (++ x) (fx+ 1 x)) (define (-- x) (fx- x 1)) ;; a hard-wired association between a key and a value (define compute-assoc (lambda (key) (cons key (++ key)))) (test-group (sprintf "loading a sequence [~A ... ~A] in ascending order" min-key max-key) (let recur ((i min-key) (t empty)) (let ((t1 (add i t))) (test (sprintf "in? ~A t1" i) #t (in? i t1)) (if (fx< i max-key) (recur (++ i) t1)))) ) (test-group "set operations" (let ((t (add 4 (add 1 (add 5 empty))))) (test "adding elements out of order" '(5 4 1) (elements t))) (let ((t1 (interval min-key (fx/ max-key 2))) (t2 (interval (fx/ max-key 2) max-key))) (test #t (in? min-key t1)) (test #t (in? (fx/ max-key 2) t1)) (test #f (in? max-key t1)) (test #f (in? (fx+ 1 (fx/ max-key 2)) t1)) (test #f (in? min-key t2)) (test #t (in? (fx/ max-key 2) t2)) (test #t (in? max-key t2)) (test #t (in? (fx+ 1 (fx/ max-key 2)) t2)) (test #t (in? min-key (union t1 t2))) (test #t (in? (fx/ max-key 2) (union t1 t2))) (test #t (in? max-key (union t1 t2))) (test #t (in? (fx+ 1 (fx/ max-key 2)) (union t1 t2))) (test #f (in? min-key (intersection t1 t2))) (test #t (in? (fx/ max-key 2) (union t1 t2))) (test #f (in? max-key (intersection t1 t2))) (test #f (in? (fx+ 1 (fx/ max-key 2)) (intersection t1 t2))) (test #f (in? min-key (difference (union t1 t2) t1))) (test #f (in? (fx/ max-key 2) (difference (union t1 t2) t1))) (test #t (in? max-key (difference (union t1 t2) t1))) (test #t (in? (fx+ 1 (fx/ max-key 2)) (difference (union t1 t2) t1))) (test #t (subset? t2 (union t1 t2))) (test #t (subset? t1 (union t1 t2))) )) (test-exit)