blob: 2f5bf5da411a274511489ca5fc0e865ce69b4a8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
open OUnit2
open Util
let test_find_xml_child_existent test_ctxt =
let elem = Xml.Element ("foo", [],
[Xml.Element ("bar", [], []);
Xml.PCData "baz"])
in
match (find_xml_child "bar" elem) with
| None -> assert_failure "find_xml_child returned None"
| Some x -> assert_equal (Xml.tag x) "bar"
let test_find_xml_child_nonexistent test_ctxt =
let elem = Xml.Element ("foo", [], [Xml.Element ("quux", [], [])]) in
assert_equal (find_xml_child "bar" elem) None
let test_string_of_list test_ctxt =
let path = ["foo"; "bar"; "baz"] in
assert_equal (String.trim (string_of_list 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_list;
]
let () =
run_test_tt_main suite
|