diff options
author | arseny.kapoulkine@gmail.com <arseny.kapoulkine@gmail.com@99668b35-9821-0410-8761-19e4c4f06640> | 2012-04-03 04:44:54 +0000 |
---|---|---|
committer | arseny.kapoulkine@gmail.com <arseny.kapoulkine@gmail.com@99668b35-9821-0410-8761-19e4c4f06640> | 2012-04-03 04:44:54 +0000 |
commit | a47bd44953e8544572127a2dce527c84aa8e1206 (patch) | |
tree | 58d66437bbd1fcc0aa7e48b265784e887d6da659 /tests/test_dom_traverse.cpp | |
parent | 40777b2ce1fd576fcdc58cb58fc60b81da3bf791 (diff) |
tests: Added tests for as_string and default values in as_*
git-svn-id: http://pugixml.googlecode.com/svn/trunk@894 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test_dom_traverse.cpp')
-rw-r--r-- | tests/test_dom_traverse.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_dom_traverse.cpp b/tests/test_dom_traverse.cpp index 3cbcde4..91fa4f7 100644 --- a/tests/test_dom_traverse.cpp +++ b/tests/test_dom_traverse.cpp @@ -73,6 +73,14 @@ TEST_XML(dom_attr_name_value, "<node attr='1'/>") CHECK_NAME_VALUE(xml_attribute(), STR(""), STR("")); } +TEST_XML(dom_attr_as_string, "<node attr='1'/>") +{ + xml_attribute attr = doc.child(STR("node")).attribute(STR("attr")); + + CHECK_STRING(attr.as_string(), STR("1")); + CHECK_STRING(xml_attribute().as_string(), STR("")); +} + TEST_XML(dom_attr_as_int, "<node attr1='1' attr2='-1' attr3='-2147483648' attr4='2147483647'/>") { xml_node node = doc.child(STR("node")); @@ -135,6 +143,18 @@ TEST_XML(dom_attr_as_bool, "<node attr1='0' attr2='1' attr3='true' attr4='True' CHECK(!node.attribute(STR("attr7")).as_bool()); } +TEST(dom_attr_defaults) +{ + xml_attribute attr; + + CHECK_STRING(attr.as_string(STR("foo")), STR("foo")); + CHECK(attr.as_int(42) == 42); + CHECK(attr.as_uint(42) == 42); + CHECK(attr.as_double(42) == 42); + CHECK(attr.as_float(42) == 42); + CHECK(attr.as_bool(true) == true); +} + TEST_XML(dom_attr_iterator, "<node><node1 attr1='0'/><node2 attr1='0' attr2='1'/><node3/></node>") { xml_node node1 = doc.child(STR("node")).child(STR("node1")); |