Skip to content

Commit

Permalink
update Dset tests
Browse files Browse the repository at this point in the history
  • Loading branch information
let-def committed Jan 13, 2020
1 parent 592ca7a commit c2b5cfe
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions dset/test_1.ml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
open Dset

let check ?(removed=[]) ?(added=[]) diff =
List.for_all (fun x -> List.mem x added) diff.added &&
List.for_all (fun x -> List.mem x removed) diff.removed
let check ?(right=[]) ?(left=[]) diff =
List.for_all (fun x -> List.mem x left) diff.left_only &&
List.for_all (fun x -> List.mem x right) diff.right_only

let e1 = element 1 and e2 = element 2

let () =
assert (check (diff empty empty));
assert (check (diff (element 1) (element 2)) ~removed:[1] ~added:[2]);
assert (check (diff (element 1) (element 1)) ~removed:[1] ~added:[1]);
assert (check (diff (element 1) (element 2)) ~left:[1] ~right:[2]);
assert (check (diff (element 1) (element 1)) ~left:[1] ~right:[1]);
assert (check (diff e1 e1));
assert (check (diff e1 e2) ~removed:[1] ~added:[2]);
assert (check (diff e2 e1) ~removed:[2] ~added:[1]);
assert (check (diff e1 e2) ~left:[1] ~right:[2]);
assert (check (diff e2 e1) ~left:[2] ~right:[1]);
assert (check (diff e2 e2));
assert (check (diff (union e1 e1) (union e1 e1)));
assert (check (diff (union e1 e2) (union e1 e1)) ~removed:[2]);
assert (check (diff (union e1 e1) (union e1 e2)) ~added:[2]);
assert (check (diff (union e1 e2) (union e1 e1)) ~left:[2]);
assert (check (diff (union e1 e1) (union e1 e2)) ~right:[2]);
assert (check (diff (union e1 e2) (union e1 e2)));
assert (check (diff (union e1 e2) empty) ~removed:[2; 1]);
assert (check (diff empty (union e1 e2)) ~added:[1; 2]);
assert (check (diff (union e1 e2) empty) ~left:[2; 1]);
assert (check (diff empty (union e1 e2)) ~right:[1; 2]);

0 comments on commit c2b5cfe

Please sign in to comment.