summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2015-04-23 09:01:00 +0600
committerDaniil Baturin <daniil@baturin.org>2015-04-23 09:01:00 +0600
commita15396525e442acc76cca061e0cbe1bc98af83d0 (patch)
tree9883e353c2b2d02d5f8c1251dc4652f4c04f61e3 /test
parent187d282353d74d185d4b1bbe4ce69bc1b2948aa9 (diff)
downloadvyconf-a15396525e442acc76cca061e0cbe1bc98af83d0.tar.gz
vyconf-a15396525e442acc76cca061e0cbe1bc98af83d0.zip
Quick and dirty path pretty printer.
Diffstat (limited to 'test')
-rw-r--r--test/util_test.ml27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/util_test.ml b/test/util_test.ml
new file mode 100644
index 0000000..ecc4b49
--- /dev/null
+++ b/test/util_test.ml
@@ -0,0 +1,27 @@
+open OUnit2
+open Util
+
+let test_find_xml_child_existent test_ctxt =
+ let elem = Xml.Element ("foo", [],
+ [Xml.Element ("bar", [], []);
+ Xml.PCData "baz"])
+ in assert_equal (Xml.tag (find_xml_child "bar" elem)) "bar"
+
+let test_find_xml_child_nonexistent test_ctxt =
+ let elem = Xml.Element ("foo", [], [Xml.Element ("quux", [], [])]) in
+ assert_raises Not_found (fun () -> find_xml_child "bar" elem)
+
+let test_string_of_path test_ctxt =
+ let path = ["foo"; "bar"; "baz"] in
+ assert_equal (string_of_path path) "[foo bar baz]"
+
+let suite =
+ "Util tests" >::: [
+ "test_find_xml_child_existent" >:: test_find_xml_child_existent;
+ "test_find_xml_child_nonexistent" >:: test_find_xml_child_nonexistent;
+ "test_string_of_path" >:: test_string_of_path;
+ ]
+
+let () =
+ run_test_tt_main suite
+