summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2015-03-28 06:44:06 +0600
committerDaniil Baturin <daniil@baturin.org>2015-03-28 06:44:06 +0600
commit5b00a034d6962e6db7d449f0374b4ced90f43b0b (patch)
tree616698f9fc46dd1e304a9bd5445e87a1f31dabb8 /test
parent2f75b0e951989ff04b1e116a1190390b871bdbed (diff)
downloadvyconf-5b00a034d6962e6db7d449f0374b4ced90f43b0b.tar.gz
vyconf-5b00a034d6962e6db7d449f0374b4ced90f43b0b.zip
Add tests for Vylist.replace
Diffstat (limited to 'test')
-rw-r--r--test/vylist_test.ml9
1 files changed, 9 insertions, 0 deletions
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 () =