Skip to content

Commit 4ad137f

Browse files
committed
test_component not using Random anymore
1 parent d37c5bf commit 4ad137f

File tree

3 files changed

+34
-35
lines changed

3 files changed

+34
-35
lines changed

tests/dune

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -220,22 +220,22 @@
220220

221221
;; Rules for the test_components test
222222

223-
;; (rule
224-
;; (with-stdout-to
225-
;; test_components.output
226-
;; (run ./test_components.exe)))
227-
228-
;; (rule
229-
;; (alias runtest)
230-
;; (action
231-
;; (progn
232-
;; (diff test_components.expected test_components.output)
233-
;; (echo "test_components: all tests succeeded.\n"))))
234-
235-
;; (executable
236-
;; (name test_components)
237-
;; (modules test_components)
238-
;; (libraries graph))
223+
(rule
224+
(with-stdout-to
225+
test_components.output
226+
(run ./test_components.exe)))
227+
228+
(rule
229+
(alias runtest)
230+
(action
231+
(progn
232+
(diff test_components.expected test_components.output)
233+
(echo "test_components: all tests succeeded.\n"))))
234+
235+
(executable
236+
(name test_components)
237+
(modules test_components)
238+
(libraries graph))
239239

240240
;; rules for the dot test
241241

tests/test_components.expected

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
7 components
1+
4 components
22
0 -> 0
33
1 -> 1
4-
2 -> 2
5-
3 -> 3
6-
4 -> 1
7-
5 -> 1
8-
6 -> 4
9-
7 -> 1
10-
8 -> 5
11-
9 -> 6
4+
2 -> 0
5+
3 -> 2
6+
4 -> 2
7+
5 -> 3
8+
6 -> 2
9+
7 -> 0

tests/test_components.ml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,20 @@ module C = Components.Undirected(Pack.Graph)
2222

2323
open Pack.Graph
2424

25-
(* FIXME: do not use Random here, as OCaml 5.0 seems to generate a
26-
different graph *)
25+
(* 0 -- 2 -- 7 1 3 -- 4 5
26+
\ /
27+
6
28+
29+
component: 0 1 2 3
30+
*)
2731

2832
let () =
29-
Random.init 42;
30-
let g = Rand.graph ~v:10 ~e:3 () in
33+
let g = create () in
34+
let v = Array.init 8 V.create in
35+
Array.iter (add_vertex g) v;
36+
let add i j = add_edge g v.(i) v.(j) in
37+
add 0 2; add 7 2; add 3 4; add 4 6; add 3 6;
3138
let n, f = C.components g in
3239
printf "%d components@." n;
3340
iter_vertex (fun v -> printf "%d -> %d@." (V.label v) (f v)) g
3441

35-
36-
(*
37-
Local Variables:
38-
compile-command: "ocaml -I .. graph.cma test_components.ml"
39-
End:
40-
*)

0 commit comments

Comments
 (0)