summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2015-03-04 22:24:09 +0600
committerDaniil Baturin <daniil@baturin.org>2015-03-04 22:24:09 +0600
commit6d6b9e94100a0ceeb72c7b030f9ae871087f6889 (patch)
tree90924afea9b5041f05d26a2774e7572e4554616f /test
parent5c19f3ef3e33ee75359b7ce9f57a678eea17b086 (diff)
downloadvyconf-6d6b9e94100a0ceeb72c7b030f9ae871087f6889.tar.gz
vyconf-6d6b9e94100a0ceeb72c7b030f9ae871087f6889.zip
Add some tests for the vylist module.
Diffstat (limited to 'test')
-rw-r--r--test/vylist_test.ml37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/vylist_test.ml b/test/vylist_test.ml
new file mode 100644
index 0000000..3f702ed
--- /dev/null
+++ b/test/vylist_test.ml
@@ -0,0 +1,37 @@
+open OUnit2
+open Vylist
+
+(* Searching for an element that is there gives Some that_element *)
+let test_find_existent test_ctxt =
+ let xs = [1; 2; 3; 4] in
+ assert_equal (find (fun x -> x = 3) xs) (Some 3)
+
+(* Searching for an element that is not there gives None *)
+let test_find_nonexistent test_ctxt =
+ let xs = [1; 2; 4] in
+ assert_equal (find (fun x -> x = 3) xs) None
+
+(* Removing a list that is there makes a list without that element *)
+let test_remove_existent test_ctct =
+ let xs = [1; 2; 3; 4] in
+ assert_equal (remove (fun x -> x = 3) xs) [1; 2; 4]
+
+(* Removing an element that is already not there returns the same list *)
+let test_remove_nonexistent test_ctct =
+ let xs = [1; 2; 4] in
+ assert_equal (remove (fun x -> x = 3) xs) [1; 2; 4]
+
+(* Replacing an element works *)
+
+
+let suite =
+ "VyConf list tests" >::: [
+ "test_find_existent" >:: test_find_existent;
+ "test_find_nonexistent" >:: test_find_nonexistent;
+ "test_remove_existent" >:: test_remove_existent;
+ "test_remove_nonexistent" >:: test_remove_nonexistent;
+ ]
+
+let () =
+ run_test_tt_main suite
+