From 5b00a034d6962e6db7d449f0374b4ced90f43b0b Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Sat, 28 Mar 2015 06:44:06 +0600 Subject: Add tests for Vylist.replace --- test/vylist_test.ml | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') diff --git a/test/vylist_test.ml b/test/vylist_test.ml index 3f702ed..812a28c 100644 --- a/test/vylist_test.ml +++ b/test/vylist_test.ml @@ -22,7 +22,14 @@ let test_remove_nonexistent test_ctct = assert_equal (remove (fun x -> x = 3) xs) [1; 2; 4] (* Replacing an element works *) +let test_replace_element_existent test_ctxt = + let xs = [1; 2; 3; 4] in + assert_equal (replace ((=) 3) 7 xs) [1; 2; 7; 4] +(* Attempt to replace a nonexisten child rauses an exception *) +let test_replace_element_nonexistent test_ctxt = + let xs = [1; 2; 3] in + assert_raises Not_found (fun () -> replace ((=) 4) 7 xs) let suite = "VyConf list tests" >::: [ @@ -30,6 +37,8 @@ let suite = "test_find_nonexistent" >:: test_find_nonexistent; "test_remove_existent" >:: test_remove_existent; "test_remove_nonexistent" >:: test_remove_nonexistent; + "test_replace_element_existent" >:: test_replace_element_existent; + "test_replace_element_nonexistent" >:: test_replace_element_nonexistent; ] let () = -- cgit v1.2.3