From 3d6211f4d5e744622c8e55ef31b42cf066a32da0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 19 Jan 2016 16:22:35 +0300 Subject: Add some more xml unit tests. --- src/utils/xml_unittest.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/utils') diff --git a/src/utils/xml_unittest.cc b/src/utils/xml_unittest.cc index 9da507981..07edfe7c6 100644 --- a/src/utils/xml_unittest.cc +++ b/src/utils/xml_unittest.cc @@ -62,6 +62,18 @@ TEST_CASE("xml doc") REQUIRE(xmlNameEqual(doc.rootNode(), "root") == true); } + SECTION("load3") + { + const std::string xml = "" + "" + ""; + XML::Document doc(xml.c_str(), xml.size()); + REQUIRE(doc.isLoaded() == true); + REQUIRE(doc.isValid() == true); + REQUIRE(doc.rootNode() != nullptr); + REQUIRE(xmlNameEqual(doc.rootNode(), "root") == true); + } + SECTION("properties") { XML::Document doc("graphics/gui/browserbox.xml", @@ -146,6 +158,24 @@ TEST_CASE("xml doc") REQUIRE(opt3 < 11); } + SECTION("child3") + { + const std::string xml = "" + "" + ""; + XML::Document doc(xml.c_str(), xml.size()); + const XmlNodePtr rootNode = doc.rootNode(); + XmlNodePtr node = XML::findFirstChildByName(rootNode, "data"); + REQUIRE(node != nullptr); + REQUIRE(xmlNameEqual(node, "data") == true); + REQUIRE(XML::getBoolProperty(node, "option1", true) == false); + REQUIRE(XML::getBoolProperty(node, "option2", false) == true); + const float opt3 = XML::getFloatProperty(node, "option3", 0.0); + REQUIRE(opt3 > 10); + REQUIRE(opt3 < 11); + } + SECTION("validate") { // REQUIRE(XML::Document::validateXml( -- cgit v1.2.3-70-g09d2