From 63bcc75d75ec0bc4642ff1d0354b6915b4b1e6a9 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Fri, 24 Apr 2015 16:18:39 +0600 Subject: Make find_xml_child return Xml.xml option rather than raise Not_found. --- test/util_test.ml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/util_test.ml b/test/util_test.ml index ecc4b49..3625957 100644 --- a/test/util_test.ml +++ b/test/util_test.ml @@ -5,11 +5,14 @@ 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" + 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_raises Not_found (fun () -> find_xml_child "bar" elem) + assert_equal (find_xml_child "bar" elem) None let test_string_of_path test_ctxt = let path = ["foo"; "bar"; "baz"] in -- cgit v1.2.3