Skip to content

Commit 41fc51f

Browse files
committed
Test_vdi_cbt: use OUnit's set comparator
for better test failure reporting - now the extra & different elements will also be reported. Signed-off-by: Gabor Igloi <[email protected]>
1 parent ab5d30d commit 41fc51f

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

ocaml/xapi/ounit_comparators.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module StringDiff =
2+
struct
3+
type t = string
4+
let compare = String.compare
5+
let pp_printer = Format.pp_print_string
6+
let pp_print_sep = OUnitDiff.pp_comma_separator
7+
end
8+
9+
module StringSet = OUnitDiff.SetMake(StringDiff)

ocaml/xapi/test_pr1510.ml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,7 @@ open Fun
44
open OUnit
55
open Network_utils
66

7-
(* Example of using OUnitDiff with a String Set *)
8-
module StringDiff =
9-
struct
10-
type t = string
11-
let compare = String.compare
12-
let pp_printer = Format.pp_print_string
13-
let pp_print_sep = OUnitDiff.pp_comma_separator
14-
end
15-
16-
module OSSet = OUnitDiff.SetMake(StringDiff)
7+
module OSSet = Ounit_comparators.StringSet
178

189
let run_bond_prop_test props c_props c_per_iface =
1910
let props, per_iface_props =

ocaml/xapi/test_vdi_cbt.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ let test_get_nbd_info =
153153
; "nbd://[10e1:bdb8:05a3:0002:03ae:8a24:0371:0003]:10809/" ^ uuid ^ "?session_id=" ^ session_id
154154
]
155155
in
156-
let sort = List.sort String.compare in
157-
OUnit.assert_equal ~printer:(String.concat ", ") (sort expected) (sort nbd_info)
156+
Ounit_comparators.StringSet.(assert_equal (of_list expected) (of_list nbd_info))
158157
in
159158

160159
let test_returns_empty_list_when_no_host_is_connected_to_sr () =

0 commit comments

Comments
 (0)