diff options
Diffstat (limited to 'tests/test_dom_modify.cpp')
-rw-r--r-- | tests/test_dom_modify.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/test_dom_modify.cpp b/tests/test_dom_modify.cpp index 67d550b..4c944e9 100644 --- a/tests/test_dom_modify.cpp +++ b/tests/test_dom_modify.cpp @@ -5,6 +5,7 @@ #include <math.h> #include <string.h> +#include <limits.h> TEST_XML(dom_attr_assign, "<node/>") { @@ -70,6 +71,68 @@ TEST_XML(dom_attr_set_value, "<node/>") CHECK_NODE(node, STR("<node attr1=\"v1\" attr2=\"-2147483647\" attr3=\"-2147483648\" attr4=\"4294967295\" attr5=\"4294967294\" attr6=\"0.5\" attr7=\"0.25\" attr8=\"true\" />")); } +#if LONG_MAX > 2147483647 +TEST_XML(dom_attr_assign_long, "<node/>") +{ + xml_node node = doc.child(STR("node")); + + node.append_attribute(STR("attr1")) = -9223372036854775807l; + node.append_attribute(STR("attr2")) = -9223372036854775807l - 1; + xml_attribute() = -9223372036854775807l - 1; + + node.append_attribute(STR("attr3")) = 18446744073709551615ul; + node.append_attribute(STR("attr4")) = 18446744073709551614ul; + xml_attribute() = 18446744073709551615ul; + + CHECK_NODE(node, STR("<node attr1=\"-9223372036854775807\" attr2=\"-9223372036854775808\" attr3=\"18446744073709551615\" attr4=\"18446744073709551614\" />")); +} + +TEST_XML(dom_attr_set_value_long, "<node/>") +{ + xml_node node = doc.child(STR("node")); + + CHECK(node.append_attribute(STR("attr1")).set_value(-9223372036854775807l)); + CHECK(node.append_attribute(STR("attr2")).set_value(-9223372036854775807l - 1)); + CHECK(!xml_attribute().set_value(-9223372036854775807l - 1)); + + CHECK(node.append_attribute(STR("attr3")).set_value(18446744073709551615ul)); + CHECK(node.append_attribute(STR("attr4")).set_value(18446744073709551614ul)); + CHECK(!xml_attribute().set_value(18446744073709551615ul)); + + CHECK_NODE(node, STR("<node attr1=\"-9223372036854775807\" attr2=\"-9223372036854775808\" attr3=\"18446744073709551615\" attr4=\"18446744073709551614\" />")); +} +#else +TEST_XML(dom_attr_assign_long, "<node/>") +{ + xml_node node = doc.child(STR("node")); + + node.append_attribute(STR("attr1")) = -2147483647l; + node.append_attribute(STR("attr2")) = -2147483647l - 1; + xml_attribute() = -2147483647l - 1; + + node.append_attribute(STR("attr3")) = 4294967295ul; + node.append_attribute(STR("attr4")) = 4294967294ul; + xml_attribute() = 4294967295ul; + + CHECK_NODE(node, STR("<node attr1=\"-2147483647\" attr2=\"-2147483648\" attr3=\"4294967295\" attr4=\"4294967294\" />")); +} + +TEST_XML(dom_attr_set_value_long, "<node/>") +{ + xml_node node = doc.child(STR("node")); + + CHECK(node.append_attribute(STR("attr1")).set_value(-2147483647l)); + CHECK(node.append_attribute(STR("attr2")).set_value(-2147483647l - 1)); + CHECK(!xml_attribute().set_value(-2147483647l - 1)); + + CHECK(node.append_attribute(STR("attr3")).set_value(4294967295ul)); + CHECK(node.append_attribute(STR("attr4")).set_value(4294967294ul)); + CHECK(!xml_attribute().set_value(4294967295ul)); + + CHECK_NODE(node, STR("<node attr1=\"-2147483647\" attr2=\"-2147483648\" attr3=\"4294967295\" attr4=\"4294967294\" />")); +} +#endif + #ifdef PUGIXML_HAS_LONG_LONG TEST_XML(dom_attr_assign_llong, "<node/>") { |