diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-01-19 16:22:35 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-01-19 16:22:35 +0300 |
commit | 3d6211f4d5e744622c8e55ef31b42cf066a32da0 (patch) | |
tree | 470f141d3474cf69815ff502940f753c94c11e6c /src/utils | |
parent | b257d71a41b0662db3b954e44ba9bfca2fb6c6cc (diff) | |
download | mv-3d6211f4d5e744622c8e55ef31b42cf066a32da0.tar.gz mv-3d6211f4d5e744622c8e55ef31b42cf066a32da0.tar.bz2 mv-3d6211f4d5e744622c8e55ef31b42cf066a32da0.tar.xz mv-3d6211f4d5e744622c8e55ef31b42cf066a32da0.zip |
Add some more xml unit tests.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/xml_unittest.cc | 30 |
1 files changed, 30 insertions, 0 deletions
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 version=\"1.0\" encoding=\"utf-8\"?>" + "<!-- comment here\nand here -->" + "<root><data option1=\"false\" option2=\"true\"/></root>"; + 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 version=\"1.0\" encoding=\"utf-8\"?>" + "<!-- comment --><root><!-- comment -->" + "<data option1=\"false\" option2=\"true\" " + "option3=\"10.5\"/><!-- comment --></root>"; + 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( |