diff --git a/tests/dune b/tests/dune index 28fe605a..ba9e0732 100644 --- a/tests/dune +++ b/tests/dune @@ -220,22 +220,22 @@ ;; Rules for the test_components test -;; (rule -;; (with-stdout-to -;; test_components.output -;; (run ./test_components.exe))) - -;; (rule -;; (alias runtest) -;; (action -;; (progn -;; (diff test_components.expected test_components.output) -;; (echo "test_components: all tests succeeded.\n")))) - -;; (executable -;; (name test_components) -;; (modules test_components) -;; (libraries graph)) +(rule + (with-stdout-to + test_components.output + (run ./test_components.exe))) + +(rule + (alias runtest) + (action + (progn + (diff test_components.expected test_components.output) + (echo "test_components: all tests succeeded.\n")))) + +(executable + (name test_components) + (modules test_components) + (libraries graph)) ;; rules for the dot test diff --git a/tests/test_components.expected b/tests/test_components.expected index dd46d104..ea543a27 100644 --- a/tests/test_components.expected +++ b/tests/test_components.expected @@ -1,11 +1,9 @@ -7 components +4 components 0 -> 0 1 -> 1 -2 -> 2 -3 -> 3 -4 -> 1 -5 -> 1 -6 -> 4 -7 -> 1 -8 -> 5 -9 -> 6 +2 -> 0 +3 -> 2 +4 -> 2 +5 -> 3 +6 -> 2 +7 -> 0 diff --git a/tests/test_components.ml b/tests/test_components.ml index a46b8b55..2141d6b5 100644 --- a/tests/test_components.ml +++ b/tests/test_components.ml @@ -22,19 +22,20 @@ module C = Components.Undirected(Pack.Graph) open Pack.Graph -(* FIXME: do not use Random here, as OCaml 5.0 seems to generate a - different graph *) +(* 0 -- 2 -- 7 1 3 -- 4 5 + \ / + 6 + +component: 0 1 2 3 +*) let () = - Random.init 42; - let g = Rand.graph ~v:10 ~e:3 () in + let g = create () in + let v = Array.init 8 V.create in + Array.iter (add_vertex g) v; + let add i j = add_edge g v.(i) v.(j) in + add 0 2; add 7 2; add 3 4; add 4 6; add 3 6; let n, f = C.components g in printf "%d components@." n; iter_vertex (fun v -> printf "%d -> %d@." (V.label v) (f v)) g - -(* -Local Variables: -compile-command: "ocaml -I .. graph.cma test_components.ml" -End: -*)