(module example mzscheme (require (planet "test.ss" ("schematics" "schemeunit.plt" 2 8)) (planet "text-ui.ss" ("schematics" "schemeunit.plt" 2 8)) (lib "list.ss") "join-forest.ss") (define (node-join node-1 node-2) (list node-1 node-2)) (define (node-left a-node) (first a-node)) (define (node-right a-node) (second a-node)) (define (node-depth a-node) (cond [(pair? a-node) (add1 (max (node-depth (node-left a-node)) (node-depth (node-right a-node))))] [else 0])) (define tree1 '(1 (2 3))) (define tree2 '((4 5) 6)) (define tree3 '((7 8) 9)) (define tree4 '10) (define tree5 '11) (define a-forest (list tree1 tree2 tree3 tree4 tree5)) (define example-tests (test-suite "example.ss" (test-case "comparison" (check-equal? (node-depth (naive-join-forest a-forest node-join)) 6) (check-equal? (node-depth (simple-join-forest a-forest node-join)) 5) (check-equal? (node-depth (optimal-join-forest a-forest node-join node-depth)) 4)))) (test/text-ui example-tests))