ocaml-core / base / core / extended / lib_test / union_find_test.ml

open OUnit;;
open Core.Std
open Core_extended.Std

open Union_find

let test =
  "union_find" >:::
    [
      "all" >::
        (fun () ->
          let t1 = create 13 in
          assert (get t1 = 13);
          set t1 15;
          assert (get t1 = 15);
          assert (same_class t1 t1);
          let t2 = create 17 in
          assert (not (same_class t1 t2));
          union t1 t2;
          assert (same_class t1 t1);
          assert (same_class t1 t2);
          assert (same_class t2 t2);
          assert (get t1 = get t2);
          assert (get t1 = 15 || get t1 = 17);
          let t3 = create 19 in
          union t1 t3;
          let t4 = create 21 in
          assert (not (same_class t3 t4));
          union t1 t4;
          assert (same_class t3 t4);
        );
      "zzz" >::
        (fun () ->
          let u1 = create () in
          let u2 = create () in
          let u3 = create () in
          let u4 = create () in
          union u1 u2;
          union u3 u4;
          union u2 u4;
          assert (same_class u1 u3);
        );
    ]
;;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.