From f9bbc39bd9a14124c1cba696c99d051a39e34b60 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Sat, 8 Feb 2014 20:36:09 +0000 Subject: Implement long long support if PUGIXML_HAS_LONG_LONG is defined (autodetection is not implemented yet) git-svn-id: http://pugixml.googlecode.com/svn/trunk@962 99668b35-9821-0410-8761-19e4c4f06640 --- tests/test_dom_traverse.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'tests/test_dom_traverse.cpp') diff --git a/tests/test_dom_traverse.cpp b/tests/test_dom_traverse.cpp index 9c7c9ec..43fec80 100644 --- a/tests/test_dom_traverse.cpp +++ b/tests/test_dom_traverse.cpp @@ -179,6 +179,56 @@ TEST_XML(dom_attr_as_bool, "") +{ + xml_node node = doc.child(STR("node")); + + CHECK(xml_attribute().as_llong() == 0); + CHECK(node.attribute(STR("attr1")).as_llong() == 1); + CHECK(node.attribute(STR("attr2")).as_llong() == -1); + CHECK(node.attribute(STR("attr3")).as_llong() == -9223372036854775807ll - 1); + CHECK(node.attribute(STR("attr4")).as_llong() == 9223372036854775807ll); + CHECK(node.attribute(STR("attr5")).as_llong() == 0); +} + +TEST_XML(dom_attr_as_llong_hex, "") +{ + xml_node node = doc.child(STR("node")); + + CHECK(node.attribute(STR("attr1")).as_llong() == 777); // no octal support! intentional + CHECK(node.attribute(STR("attr2")).as_llong() == 1451); + CHECK(node.attribute(STR("attr3")).as_llong() == 255); + CHECK(node.attribute(STR("attr4")).as_llong() == -32); + CHECK(node.attribute(STR("attr5")).as_llong() == -9223372036854775807ll - 1); + CHECK(node.attribute(STR("attr6")).as_llong() == 0); +} + +TEST_XML(dom_attr_as_ullong, "") +{ + xml_node node = doc.child(STR("node")); + + CHECK(xml_attribute().as_ullong() == 0); + CHECK(node.attribute(STR("attr1")).as_ullong() == 0); + CHECK(node.attribute(STR("attr2")).as_ullong() == 1); + CHECK(node.attribute(STR("attr3")).as_ullong() == 9223372036854775807ull); + CHECK(node.attribute(STR("attr4")).as_ullong() == 18446744073709551615ull); + CHECK(node.attribute(STR("attr5")).as_ullong() == 0); +} + +TEST_XML(dom_attr_as_ullong_hex, "") +{ + xml_node node = doc.child(STR("node")); + + CHECK(node.attribute(STR("attr1")).as_ullong() == 777); // no octal support! intentional + CHECK(node.attribute(STR("attr2")).as_ullong() == 1451); + CHECK(node.attribute(STR("attr3")).as_ullong() == 255); + CHECK(node.attribute(STR("attr4")).as_ullong() == 32); + CHECK(node.attribute(STR("attr5")).as_ullong() == 18446744073709551615ull); + CHECK(node.attribute(STR("attr6")).as_ullong() == 0); +} +#endif + TEST(dom_attr_defaults) { xml_attribute attr; @@ -189,6 +239,11 @@ TEST(dom_attr_defaults) CHECK(attr.as_double(42) == 42); CHECK(attr.as_float(42) == 42); CHECK(attr.as_bool(true) == true); + +#ifdef PUGIXML_HAS_LONG_LONG + CHECK(attr.as_llong(42) == 42); + CHECK(attr.as_ullong(42) == 42); +#endif } TEST_XML(dom_attr_iterator, "") -- cgit v1.2.3