diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-01-19 22:26:08 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-01-19 22:26:08 +0300 |
commit | 858d471f921c75d3963acff3dd3022b47c96f5dd (patch) | |
tree | a8dcb57ff8a0c963beedf8e0b4a5649c68f8880b /src/utils/xml_unittest.cc | |
parent | 3d6211f4d5e744622c8e55ef31b42cf066a32da0 (diff) | |
download | mv-858d471f921c75d3963acff3dd3022b47c96f5dd.tar.gz mv-858d471f921c75d3963acff3dd3022b47c96f5dd.tar.bz2 mv-858d471f921c75d3963acff3dd3022b47c96f5dd.tar.xz mv-858d471f921c75d3963acff3dd3022b47c96f5dd.zip |
Add tests for xml macroses.
Diffstat (limited to 'src/utils/xml_unittest.cc')
-rw-r--r-- | src/utils/xml_unittest.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/utils/xml_unittest.cc b/src/utils/xml_unittest.cc index 07edfe7c6..ba89a3b70 100644 --- a/src/utils/xml_unittest.cc +++ b/src/utils/xml_unittest.cc @@ -49,6 +49,8 @@ TEST_CASE("xml doc") REQUIRE(doc.isValid() == true); REQUIRE(doc.rootNode() != nullptr); REQUIRE(xmlNameEqual(doc.rootNode(), "skinset") == true); + REQUIRE(xmlNameEqual(doc.rootNode(), "skinset123") == false); + REQUIRE(xmlTypeEqual(doc.rootNode(), XML_ELEMENT_NODE) == true); } SECTION("load2") @@ -60,6 +62,10 @@ TEST_CASE("xml doc") REQUIRE(doc.isValid() == true); REQUIRE(doc.rootNode() != nullptr); REQUIRE(xmlNameEqual(doc.rootNode(), "root") == true); + REQUIRE(xmlNameEqual(doc.rootNode(), "root123") == false); + REQUIRE(xmlTypeEqual(doc.rootNode(), XML_ELEMENT_NODE) == true); + REQUIRE(XmlHasProp(doc.rootNode(), "option1") == false); + REQUIRE(XmlHasProp(doc.rootNode(), "option123") == false); } SECTION("load3") @@ -72,6 +78,10 @@ TEST_CASE("xml doc") REQUIRE(doc.isValid() == true); REQUIRE(doc.rootNode() != nullptr); REQUIRE(xmlNameEqual(doc.rootNode(), "root") == true); + REQUIRE(xmlNameEqual(doc.rootNode(), "root123") == false); + REQUIRE(xmlTypeEqual(doc.rootNode(), XML_ELEMENT_NODE) == true); + REQUIRE(XmlHasProp(doc.rootNode(), "option1") == false); + REQUIRE(XmlHasProp(doc.rootNode(), "option123") == false); } SECTION("properties") @@ -99,6 +109,7 @@ TEST_CASE("xml doc") break; } REQUIRE(node != nullptr); + REQUIRE(xmlTypeEqual(node, XML_ELEMENT_NODE) == true); REQUIRE(xmlNameEqual(node, "widget") == true); for_each_xml_child_node(optionNode, node) { @@ -107,7 +118,11 @@ TEST_CASE("xml doc") break; } REQUIRE(node != nullptr); + REQUIRE(xmlTypeEqual(node, XML_ELEMENT_NODE) == true); REQUIRE(xmlNameEqual(node, "option") == true); + REQUIRE(XmlHasProp(node, "name") == true); + REQUIRE(XmlHasProp(node, "value") == true); + REQUIRE(XmlHasProp(node, "option123") == false); REQUIRE(XML::getProperty(node, "name", "") == "padding"); REQUIRE(XML::langProperty(node, "name", "") == "padding"); REQUIRE(XML::getProperty(node, "value", 0) == 1); @@ -125,10 +140,15 @@ TEST_CASE("xml doc") const XmlNodePtr rootNode = doc.rootNode(); XmlNodePtr node = XML::findFirstChildByName(rootNode, "widget"); REQUIRE(node != nullptr); + REQUIRE(xmlTypeEqual(node, XML_ELEMENT_NODE) == true); REQUIRE(xmlNameEqual(node, "widget") == true); node = XML::findFirstChildByName(node, "option"); REQUIRE(node != nullptr); + REQUIRE(xmlTypeEqual(node, XML_ELEMENT_NODE) == true); REQUIRE(xmlNameEqual(node, "option") == true); + REQUIRE(XmlHasProp(node, "name") == true); + REQUIRE(XmlHasProp(node, "value") == true); + REQUIRE(XmlHasProp(node, "option123") == false); REQUIRE(XML::getProperty(node, "name", "") == "padding"); REQUIRE(XML::langProperty(node, "name", "") == "padding"); REQUIRE(XML::langProperty(node, "name123", "") == ""); @@ -150,7 +170,10 @@ TEST_CASE("xml doc") const XmlNodePtr rootNode = doc.rootNode(); XmlNodePtr node = XML::findFirstChildByName(rootNode, "data"); REQUIRE(node != nullptr); + REQUIRE(xmlTypeEqual(node, XML_ELEMENT_NODE) == true); REQUIRE(xmlNameEqual(node, "data") == true); + REQUIRE(XmlHasProp(node, "option1") == true); + REQUIRE(XmlHasProp(node, "option123") == false); REQUIRE(XML::getBoolProperty(node, "option1", true) == false); REQUIRE(XML::getBoolProperty(node, "option2", false) == true); const float opt3 = XML::getFloatProperty(node, "option3", 0.0); @@ -168,7 +191,10 @@ TEST_CASE("xml doc") const XmlNodePtr rootNode = doc.rootNode(); XmlNodePtr node = XML::findFirstChildByName(rootNode, "data"); REQUIRE(node != nullptr); + REQUIRE(xmlTypeEqual(node, XML_ELEMENT_NODE) == true); REQUIRE(xmlNameEqual(node, "data") == true); + REQUIRE(XmlHasProp(node, "option1") == true); + REQUIRE(XmlHasProp(node, "option123") == false); REQUIRE(XML::getBoolProperty(node, "option1", true) == false); REQUIRE(XML::getBoolProperty(node, "option2", false) == true); const float opt3 = XML::getFloatProperty(node, "option3", 0.0); |