summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2015-03-28 08:47:01 +0600
committerDaniil Baturin <daniil@baturin.org>2015-03-28 08:47:01 +0600
commit8fdefc9d6c7c76cb295b1c5b42a371d2394238a6 (patch)
tree2124ac34178c69436a494ba01c484a3f04af9e1a /test
parentef4e6d0bf2e62fd854533fa135ed96247b94d1ff (diff)
downloadvyconf-8fdefc9d6c7c76cb295b1c5b42a371d2394238a6.tar.gz
vyconf-8fdefc9d6c7c76cb295b1c5b42a371d2394238a6.zip
Add tests for insert_before and insert_after.
Diffstat (limited to 'test')
-rw-r--r--test/vylist_test.ml12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/vylist_test.ml b/test/vylist_test.ml
index 812a28c..c27aa5c 100644
--- a/test/vylist_test.ml
+++ b/test/vylist_test.ml
@@ -31,6 +31,16 @@ let test_replace_element_nonexistent test_ctxt =
let xs = [1; 2; 3] in
assert_raises Not_found (fun () -> replace ((=) 4) 7 xs)
+(* insert_before works if the element is there *)
+let test_insert_before_existent test_ctxt =
+ let xs = [1; 2; 3] in
+ assert_equal (insert_before ((=) 2) 7 xs) [1; 7; 2; 3]
+
+(* insert_before raises Not_found if there's not such element *)
+let test_insert_before_nonexistent test_ctxt =
+ let xs = [1; 2; 3] in
+ assert_raises Not_found (fun () -> insert_before ((=) 9) 7 xs)
+
let suite =
"VyConf list tests" >::: [
"test_find_existent" >:: test_find_existent;
@@ -39,6 +49,8 @@ let suite =
"test_remove_nonexistent" >:: test_remove_nonexistent;
"test_replace_element_existent" >:: test_replace_element_existent;
"test_replace_element_nonexistent" >:: test_replace_element_nonexistent;
+ "test_insert_before_existent" >:: test_insert_before_existent;
+ "test_insert_before_nonexistent" >:: test_insert_before_nonexistent;
]
let () =