test-union-find.ss
(module test-union-find mzscheme
  (require (planet "test.ss" ("schematics" "schemeunit.plt" 2 8))
           (planet "text-ui.ss" ("schematics" "schemeunit.plt" 2 8))
           (lib "etc.ss")
           "union-find.ss")
  
  (define union-find-tests
    (test-suite
     "union-find.ss"
     (test-case
      "simple test of disjointness"
      (local ((define f (make-forest 'equal)))
        (make-set f 3)
        (make-set f 5)
        (check-false (eq? (find-set f 3)
                          (find-set f 5)))))
     
     (test-case
      "simple test of joint-ness"
      (local ((define f (make-forest 'equal)))
        (make-set f 3)
        (make-set f 5)
        (union-set f 3 5)
        (check-true (eq? (find-set f 3)
                         (find-set f 5)))))
     
     (test-case
      "slightly larger example"
      (local ((define forest (make-forest)))
        (for-each (lambda (x) (make-set forest x)) '(a b c d e f g h))
        (union-set forest 'c 'h)
        (union-set forest 'c 'e)
        (union-set forest 'h 'b)
        (union-set forest 'd 'g)
        (union-set forest 'd 'f)
        (check-true (eq? (find-set forest 'e)
                         (find-set forest 'b)))
        (check-false (eq? (find-set forest 'c)
                          (find-set forest 'g)))
        (union-set forest 'e 'g)
        (check-true (eq? (find-set forest 'c)
                         (find-set forest 'g)))))))
  
  (test/text-ui union-find-tests))