0
0
mirror of https://github.com/zeux/pugixml.git synced 2024-12-27 13:33:17 +08:00

tests: Add coverage tests for new float setters

These only do basic testing to make sure the paths are covered and trivial
values work.
This commit is contained in:
Arseny Kapoulkine 2015-01-16 21:42:35 -08:00
parent f07018f7e7
commit f9ee391233
2 changed files with 21 additions and 9 deletions

View File

@ -21,10 +21,13 @@ TEST_XML(dom_attr_assign, "<node/>")
node.append_attribute(STR("attr6")) = 0.5;
xml_attribute() = 0.5;
node.append_attribute(STR("attr7")) = true;
node.append_attribute(STR("attr7")) = 0.25f;
xml_attribute() = 0.25f;
node.append_attribute(STR("attr8")) = true;
xml_attribute() = true;
CHECK_NODE(node, STR("<node attr1=\"v1\" attr2=\"-2147483647\" attr3=\"-2147483648\" attr4=\"4294967295\" attr5=\"4294967294\" attr6=\"0.5\" attr7=\"true\" />"));
CHECK_NODE(node, STR("<node attr1=\"v1\" attr2=\"-2147483647\" attr3=\"-2147483648\" attr4=\"4294967295\" attr5=\"4294967294\" attr6=\"0.5\" attr7=\"0.25\" attr8=\"true\" />"));
}
TEST_XML(dom_attr_set_name, "<node attr='value' />")
@ -55,10 +58,13 @@ TEST_XML(dom_attr_set_value, "<node/>")
CHECK(node.append_attribute(STR("attr6")).set_value(0.5));
CHECK(!xml_attribute().set_value(0.5));
CHECK(node.append_attribute(STR("attr7")).set_value(true));
CHECK(node.append_attribute(STR("attr7")).set_value(0.25f));
CHECK(!xml_attribute().set_value(0.25f));
CHECK(node.append_attribute(STR("attr8")).set_value(true));
CHECK(!xml_attribute().set_value(true));
CHECK_NODE(node, STR("<node attr1=\"v1\" attr2=\"-2147483647\" attr3=\"-2147483648\" attr4=\"4294967295\" attr5=\"4294967294\" attr6=\"0.5\" attr7=\"true\" />"));
CHECK_NODE(node, STR("<node attr1=\"v1\" attr2=\"-2147483647\" attr3=\"-2147483648\" attr4=\"4294967295\" attr5=\"4294967294\" attr6=\"0.5\" attr7=\"0.25\" attr8=\"true\" />"));
}
#ifdef PUGIXML_HAS_LONG_LONG
@ -753,7 +759,7 @@ TEST_XML(dom_attr_assign_large_number, "<node attr1='' attr2='' />")
node.attribute(STR("attr1")) = std::numeric_limits<float>::max();
node.attribute(STR("attr2")) = std::numeric_limits<double>::max();
CHECK(test_node(node, STR("<node attr1=\"3.40282347e+038\" attr2=\"1.7976931348623157ee+308\" />"), STR(""), pugi::format_raw) ||
CHECK(test_node(node, STR("<node attr1=\"3.40282347e+038\" attr2=\"1.7976931348623157e+308\" />"), STR(""), pugi::format_raw) ||
test_node(node, STR("<node attr1=\"3.40282347e+38\" attr2=\"1.7976931348623157e+308\" />"), STR(""), pugi::format_raw));
}

View File

@ -263,10 +263,13 @@ TEST_XML(dom_text_assign, "<node/>")
node.append_child(STR("text6")).text() = 0.5;
xml_text() = 0.5;
node.append_child(STR("text7")).text() = true;
node.append_child(STR("text7")).text() = 0.25f;
xml_text() = 0.25f;
node.append_child(STR("text8")).text() = true;
xml_text() = true;
CHECK_NODE(node, STR("<node><text1>v1</text1><text2>-2147483647</text2><text3>-2147483648</text3><text4>4294967295</text4><text5>4294967294</text5><text6>0.5</text6><text7>true</text7></node>"));
CHECK_NODE(node, STR("<node><text1>v1</text1><text2>-2147483647</text2><text3>-2147483648</text3><text4>4294967295</text4><text5>4294967294</text5><text6>0.5</text6><text7>0.25</text7><text8>true</text8></node>"));
}
TEST_XML(dom_text_set_value, "<node/>")
@ -287,10 +290,13 @@ TEST_XML(dom_text_set_value, "<node/>")
CHECK(node.append_child(STR("text6")).text().set(0.5));
CHECK(!xml_text().set(0.5));
CHECK(node.append_child(STR("text7")).text().set(true));
CHECK(node.append_child(STR("text7")).text().set(0.25f));
CHECK(!xml_text().set(0.25f));
CHECK(node.append_child(STR("text8")).text().set(true));
CHECK(!xml_text().set(true));
CHECK_NODE(node, STR("<node><text1>v1</text1><text2>-2147483647</text2><text3>-2147483648</text3><text4>4294967295</text4><text5>4294967294</text5><text6>0.5</text6><text7>true</text7></node>"));
CHECK_NODE(node, STR("<node><text1>v1</text1><text2>-2147483647</text2><text3>-2147483648</text3><text4>4294967295</text4><text5>4294967294</text5><text6>0.5</text6><text7>0.25</text7><text8>true</text8></node>"));
}
#ifdef PUGIXML_HAS_LONG_LONG