diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/main.cpp | 12 | ||||
-rw-r--r-- | tests/test.hpp | 2 | ||||
-rw-r--r-- | tests/test_document.cpp | 4 | ||||
-rw-r--r-- | tests/test_dom_modify.cpp | 76 | ||||
-rw-r--r-- | tests/test_dom_text.cpp | 6 | ||||
-rw-r--r-- | tests/test_dom_traverse.cpp | 26 | ||||
-rw-r--r-- | tests/test_memory.cpp | 2 | ||||
-rw-r--r-- | tests/test_parse.cpp | 8 | ||||
-rw-r--r-- | tests/test_xpath.cpp | 4 | ||||
-rw-r--r-- | tests/test_xpath_api.cpp | 10 | ||||
-rw-r--r-- | tests/test_xpath_functions.cpp | 58 | ||||
-rw-r--r-- | tests/test_xpath_operators.cpp | 6 | ||||
-rw-r--r-- | tests/test_xpath_variables.cpp | 2 | ||||
-rw-r--r-- | tests/test_xpath_xalan_1.cpp | 2 | ||||
-rw-r--r-- | tests/writer_string.hpp | 2 |
15 files changed, 110 insertions, 110 deletions
diff --git a/tests/main.cpp b/tests/main.cpp index 00016a6..8eb55ed 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -45,7 +45,7 @@ static void* custom_allocate(size_t size) g_memory_total_size += memory_size(ptr); g_memory_total_count++; - + return ptr; } } @@ -68,7 +68,7 @@ static void custom_deallocate(void* ptr) g_memory_total_size -= memory_size(ptr); g_memory_total_count--; - + memory_deallocate(ptr); } @@ -105,9 +105,9 @@ static bool run_test(test_runner* test, const char* test_name, pugi::allocation_ g_memory_fail_triggered = false; test_runner::_memory_fail_threshold = 0; test_runner::_memory_fail_triggered = false; - + pugi::set_memory_management_functions(allocate, custom_deallocate); - + #ifdef _MSC_VER # pragma warning(push) # pragma warning(disable: 4611) // interaction between _setjmp and C++ object destruction is non-portable @@ -115,7 +115,7 @@ static bool run_test(test_runner* test, const char* test_name, pugi::allocation_ #endif volatile int result = setjmp(test_runner::_failure_buffer); - + #ifdef _MSC_VER # pragma warning(pop) #endif @@ -177,7 +177,7 @@ int main(int, char** argv) temp.erase((slash != std::string::npos) ? slash + 1 : 0); test_runner::_temp_path = temp.c_str(); - + replace_memory_management(); unsigned int total = 0; diff --git a/tests/test.hpp b/tests/test.hpp index fad555d..e700826 100644 --- a/tests/test.hpp +++ b/tests/test.hpp @@ -157,7 +157,7 @@ struct dummy_fixture {}; #if (defined(_MSC_VER) && _MSC_VER == 1200) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER == 800) || defined(__BORLANDC__) // NaN comparison on MSVC6 is incorrect, see http://www.nabble.com/assertDoubleEquals,-NaN---Microsoft-Visual-Studio-6-td9137859.html // IC8 and BCC are also affected by the same bug -# define MSVC6_NAN_BUG +# define MSVC6_NAN_BUG #endif inline wchar_t wchar_cast(unsigned int value) diff --git a/tests/test_document.cpp b/tests/test_document.cpp index 8573ce3..eba2fd4 100644 --- a/tests/test_document.cpp +++ b/tests/test_document.cpp @@ -109,7 +109,7 @@ TEST(document_load_stream_error) std::ifstream fs("filedoesnotexist"); CHECK(doc.load(fs).status == status_io_error); - + std::istringstream iss("<node/>"); test_runner::_memory_fail_threshold = 1; CHECK_ALLOC_FAIL(CHECK(doc.load(iss).status == status_out_of_memory)); @@ -499,7 +499,7 @@ TEST_XML(document_save_declaration_latin1, "<node/>") struct temp_file { char path[512]; - + temp_file() { static int index = 0; diff --git a/tests/test_dom_modify.cpp b/tests/test_dom_modify.cpp index e84f098..67d550b 100644 --- a/tests/test_dom_modify.cpp +++ b/tests/test_dom_modify.cpp @@ -74,7 +74,7 @@ TEST_XML(dom_attr_set_value, "<node/>") TEST_XML(dom_attr_assign_llong, "<node/>") { xml_node node = doc.child(STR("node")); - + node.append_attribute(STR("attr1")) = -9223372036854775807ll; node.append_attribute(STR("attr2")) = -9223372036854775807ll - 1; xml_attribute() = -9223372036854775807ll - 1; @@ -89,7 +89,7 @@ TEST_XML(dom_attr_assign_llong, "<node/>") TEST_XML(dom_attr_set_value_llong, "<node/>") { xml_node node = doc.child(STR("node")); - + CHECK(node.append_attribute(STR("attr1")).set_value(-9223372036854775807ll)); CHECK(node.append_attribute(STR("attr2")).set_value(-9223372036854775807ll - 1)); CHECK(!xml_attribute().set_value(-9223372036854775807ll - 1)); @@ -158,7 +158,7 @@ TEST_XML(dom_node_prepend_attribute, "<node><child/></node>") { CHECK(xml_node().prepend_attribute(STR("a")) == xml_attribute()); CHECK(doc.prepend_attribute(STR("a")) == xml_attribute()); - + xml_attribute a1 = doc.child(STR("node")).prepend_attribute(STR("a1")); CHECK(a1); a1 = STR("v1"); @@ -178,7 +178,7 @@ TEST_XML(dom_node_append_attribute, "<node><child/></node>") { CHECK(xml_node().append_attribute(STR("a")) == xml_attribute()); CHECK(doc.append_attribute(STR("a")) == xml_attribute()); - + xml_attribute a1 = doc.child(STR("node")).append_attribute(STR("a1")); CHECK(a1); a1 = STR("v1"); @@ -206,7 +206,7 @@ TEST_XML(dom_node_insert_attribute_after, "<node a1='v1'><child a2='v2'/></node> CHECK(node.insert_attribute_after(STR("a"), xml_attribute()) == xml_attribute()); CHECK(node.insert_attribute_after(STR("a"), a2) == xml_attribute()); - + xml_attribute a3 = node.insert_attribute_after(STR("a3"), a1); CHECK(a3 && a3 != a2 && a3 != a1); a3 = STR("v3"); @@ -236,7 +236,7 @@ TEST_XML(dom_node_insert_attribute_before, "<node a1='v1'><child a2='v2'/></node CHECK(node.insert_attribute_before(STR("a"), xml_attribute()) == xml_attribute()); CHECK(node.insert_attribute_before(STR("a"), a2) == xml_attribute()); - + xml_attribute a3 = node.insert_attribute_before(STR("a3"), a1); CHECK(a3 && a3 != a2 && a3 != a1); a3 = STR("v3"); @@ -260,7 +260,7 @@ TEST_XML(dom_node_prepend_copy_attribute, "<node a1='v1'><child a2='v2'/><child/ CHECK(xml_node().prepend_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute()); CHECK(doc.prepend_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute()); CHECK(doc.child(STR("node")).prepend_copy(xml_attribute()) == xml_attribute()); - + xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); @@ -280,13 +280,13 @@ TEST_XML(dom_node_prepend_copy_attribute, "<node a1='v1'><child a2='v2'/><child/ a3.set_name(STR("a3")); a3 = STR("v3"); - + a4.set_name(STR("a4")); a4 = STR("v4"); - + a5.set_name(STR("a5")); a5 = STR("v5"); - + CHECK_NODE(doc, STR("<node a4=\"v4\" a3=\"v3\" a1=\"v1\"><child a2=\"v2\" /><child a5=\"v5\" /></node>")); } @@ -296,7 +296,7 @@ TEST_XML(dom_node_append_copy_attribute, "<node a1='v1'><child a2='v2'/><child/> CHECK(xml_node().append_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute()); CHECK(doc.append_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute()); CHECK(doc.child(STR("node")).append_copy(xml_attribute()) == xml_attribute()); - + xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); @@ -316,13 +316,13 @@ TEST_XML(dom_node_append_copy_attribute, "<node a1='v1'><child a2='v2'/><child/> a3.set_name(STR("a3")); a3 = STR("v3"); - + a4.set_name(STR("a4")); a4 = STR("v4"); - + a5.set_name(STR("a5")); a5 = STR("v5"); - + CHECK_NODE(doc, STR("<node a1=\"v1\" a3=\"v3\" a4=\"v4\"><child a2=\"v2\" /><child a5=\"v5\" /></node>")); } @@ -339,7 +339,7 @@ TEST_XML(dom_node_insert_copy_after_attribute, "<node a1='v1'><child a2='v2'/></ CHECK(node.insert_copy_after(a1, xml_attribute()) == xml_attribute()); CHECK(node.insert_copy_after(xml_attribute(), a1) == xml_attribute()); CHECK(node.insert_copy_after(a2, a2) == xml_attribute()); - + xml_attribute a3 = node.insert_copy_after(a1, a1); CHECK(a3 && a3 != a2 && a3 != a1); @@ -355,13 +355,13 @@ TEST_XML(dom_node_insert_copy_after_attribute, "<node a1='v1'><child a2='v2'/></ a3.set_name(STR("a3")); a3 = STR("v3"); - + a4.set_name(STR("a4")); a4 = STR("v4"); - + a5.set_name(STR("a5")); a5 = STR("v5"); - + CHECK_NODE(doc, STR("<node a1=\"v1\" a5=\"v5\" a4=\"v4\" a3=\"v3\"><child a2=\"v2\" /></node>")); } @@ -378,7 +378,7 @@ TEST_XML(dom_node_insert_copy_before_attribute, "<node a1='v1'><child a2='v2'/>< CHECK(node.insert_copy_before(a1, xml_attribute()) == xml_attribute()); CHECK(node.insert_copy_before(xml_attribute(), a1) == xml_attribute()); CHECK(node.insert_copy_before(a2, a2) == xml_attribute()); - + xml_attribute a3 = node.insert_copy_before(a1, a1); CHECK(a3 && a3 != a2 && a3 != a1); @@ -394,13 +394,13 @@ TEST_XML(dom_node_insert_copy_before_attribute, "<node a1='v1'><child a2='v2'/>< a3.set_name(STR("a3")); a3 = STR("v3"); - + a4.set_name(STR("a4")); a4 = STR("v4"); - + a5.set_name(STR("a5")); a5 = STR("v5"); - + CHECK_NODE(doc, STR("<node a3=\"v3\" a4=\"v4\" a5=\"v5\" a1=\"v1\"><child a2=\"v2\" /></node>")); } @@ -408,7 +408,7 @@ TEST_XML(dom_node_remove_attribute, "<node a1='v1' a2='v2' a3='v3'><child a4='v4 { CHECK(!xml_node().remove_attribute(STR("a"))); CHECK(!xml_node().remove_attribute(xml_attribute())); - + xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); @@ -431,7 +431,7 @@ TEST_XML(dom_node_prepend_child, "<node>foo<child/></node>") CHECK(doc.child(STR("node")).first_child().prepend_child() == xml_node()); CHECK(doc.prepend_child(node_document) == xml_node()); CHECK(doc.prepend_child(node_null) == xml_node()); - + xml_node n1 = doc.child(STR("node")).prepend_child(); CHECK(n1); CHECK(n1.set_name(STR("n1"))); @@ -443,7 +443,7 @@ TEST_XML(dom_node_prepend_child, "<node>foo<child/></node>") xml_node n3 = doc.child(STR("node")).child(STR("child")).prepend_child(node_pcdata); CHECK(n3 && n1 != n3 && n2 != n3); CHECK(n3.set_value(STR("n3"))); - + xml_node n4 = doc.prepend_child(node_comment); CHECK(n4 && n1 != n4 && n2 != n4 && n3 != n4); CHECK(n4.set_value(STR("n4"))); @@ -457,7 +457,7 @@ TEST_XML(dom_node_append_child, "<node>foo<child/></node>") CHECK(doc.child(STR("node")).first_child().append_child() == xml_node()); CHECK(doc.append_child(node_document) == xml_node()); CHECK(doc.append_child(node_null) == xml_node()); - + xml_node n1 = doc.child(STR("node")).append_child(); CHECK(n1); CHECK(n1.set_name(STR("n1"))); @@ -469,7 +469,7 @@ TEST_XML(dom_node_append_child, "<node>foo<child/></node>") xml_node n3 = doc.child(STR("node")).child(STR("child")).append_child(node_pcdata); CHECK(n3 && n1 != n3 && n2 != n3); CHECK(n3.set_value(STR("n3"))); - + xml_node n4 = doc.append_child(node_comment); CHECK(n4 && n1 != n4 && n2 != n4 && n3 != n4); CHECK(n4.set_value(STR("n4"))); @@ -489,7 +489,7 @@ TEST_XML(dom_node_insert_child_after, "<node>foo<child/></node>") CHECK(node.insert_child_after(node_element, node) == xml_node()); CHECK(child.insert_child_after(node_element, node) == xml_node()); - + xml_node n1 = node.insert_child_after(node_element, child); CHECK(n1 && n1 != node && n1 != child); CHECK(n1.set_name(STR("n1"))); @@ -523,7 +523,7 @@ TEST_XML(dom_node_insert_child_before, "<node>foo<child/></node>") CHECK(node.insert_child_before(node_element, node) == xml_node()); CHECK(child.insert_child_before(node_element, node) == xml_node()); - + xml_node n1 = node.insert_child_before(node_element, child); CHECK(n1 && n1 != node && n1 != child); CHECK(n1.set_name(STR("n1"))); @@ -549,7 +549,7 @@ TEST_XML(dom_node_prepend_child_name, "<node>foo<child/></node>") { CHECK(xml_node().prepend_child(STR("")) == xml_node()); CHECK(doc.child(STR("node")).first_child().prepend_child(STR("")) == xml_node()); - + xml_node n1 = doc.child(STR("node")).prepend_child(STR("n1")); CHECK(n1); @@ -563,7 +563,7 @@ TEST_XML(dom_node_append_child_name, "<node>foo<child/></node>") { CHECK(xml_node().append_child(STR("")) == xml_node()); CHECK(doc.child(STR("node")).first_child().append_child(STR("")) == xml_node()); - + xml_node n1 = doc.child(STR("node")).append_child(STR("n1")); CHECK(n1); @@ -583,7 +583,7 @@ TEST_XML(dom_node_insert_child_after_name, "<node>foo<child/></node>") CHECK(node.insert_child_after(STR(""), node) == xml_node()); CHECK(child.insert_child_after(STR(""), node) == xml_node()); - + xml_node n1 = node.insert_child_after(STR("n1"), child); CHECK(n1 && n1 != node && n1 != child); @@ -605,7 +605,7 @@ TEST_XML(dom_node_insert_child_before_name, "<node>foo<child/></node>") CHECK(node.insert_child_before(STR(""), node) == xml_node()); CHECK(child.insert_child_before(STR(""), node) == xml_node()); - + xml_node n1 = node.insert_child_before(STR("n1"), child); CHECK(n1 && n1 != node && n1 != child); @@ -621,7 +621,7 @@ TEST_XML(dom_node_remove_child, "<node><n1/><n2/><n3/><child><n4/></child></node { CHECK(!xml_node().remove_child(STR("a"))); CHECK(!xml_node().remove_child(xml_node())); - + xml_node node = doc.child(STR("node")); xml_node child = node.child(STR("child")); @@ -665,7 +665,7 @@ TEST_XML(dom_node_prepend_copy, "<node>foo<child/></node>") CHECK(doc.child(STR("node")).first_child().prepend_copy(doc.child(STR("node"))) == xml_node()); CHECK(doc.prepend_copy(doc) == xml_node()); CHECK(doc.prepend_copy(xml_node()) == xml_node()); - + xml_node n1 = doc.child(STR("node")).prepend_copy(doc.child(STR("node")).first_child()); CHECK(n1); CHECK_STRING(n1.value(), STR("foo")); @@ -688,7 +688,7 @@ TEST_XML(dom_node_append_copy, "<node>foo<child/></node>") CHECK(doc.child(STR("node")).first_child().append_copy(doc.child(STR("node"))) == xml_node()); CHECK(doc.append_copy(doc) == xml_node()); CHECK(doc.append_copy(xml_node()) == xml_node()); - + xml_node n1 = doc.child(STR("node")).append_copy(doc.child(STR("node")).first_child()); CHECK(n1); CHECK_STRING(n1.value(), STR("foo")); @@ -712,7 +712,7 @@ TEST_XML(dom_node_insert_copy_after, "<node>foo<child/></node>") CHECK(doc.insert_copy_after(doc, doc) == xml_node()); CHECK(doc.insert_copy_after(xml_node(), doc.child(STR("node"))) == xml_node()); CHECK(doc.insert_copy_after(doc.child(STR("node")), xml_node()) == xml_node()); - + xml_node n1 = doc.child(STR("node")).insert_copy_after(doc.child(STR("node")).child(STR("child")), doc.child(STR("node")).first_child()); CHECK(n1); CHECK_STRING(n1.name(), STR("child")); @@ -736,7 +736,7 @@ TEST_XML(dom_node_insert_copy_before, "<node>foo<child/></node>") CHECK(doc.insert_copy_before(doc, doc) == xml_node()); CHECK(doc.insert_copy_before(xml_node(), doc.child(STR("node"))) == xml_node()); CHECK(doc.insert_copy_before(doc.child(STR("node")), xml_node()) == xml_node()); - + xml_node n1 = doc.child(STR("node")).insert_copy_before(doc.child(STR("node")).child(STR("child")), doc.child(STR("node")).first_child()); CHECK(n1); CHECK_STRING(n1.name(), STR("child")); diff --git a/tests/test_dom_text.cpp b/tests/test_dom_text.cpp index 01c815c..4d91452 100644 --- a/tests/test_dom_text.cpp +++ b/tests/test_dom_text.cpp @@ -303,7 +303,7 @@ TEST_XML(dom_text_set_value, "<node/>") TEST_XML(dom_text_assign_llong, "<node/>") { xml_node node = doc.child(STR("node")); - + node.append_child(STR("text1")).text() = -9223372036854775807ll; node.append_child(STR("text2")).text() = -9223372036854775807ll - 1; xml_text() = -9223372036854775807ll - 1; @@ -311,14 +311,14 @@ TEST_XML(dom_text_assign_llong, "<node/>") node.append_child(STR("text3")).text() = 18446744073709551615ull; node.append_child(STR("text4")).text() = 18446744073709551614ull; xml_text() = 18446744073709551615ull; - + CHECK_NODE(node, STR("<node><text1>-9223372036854775807</text1><text2>-9223372036854775808</text2><text3>18446744073709551615</text3><text4>18446744073709551614</text4></node>")); } TEST_XML(dom_text_set_value_llong, "<node/>") { xml_node node = doc.child(STR("node")); - + CHECK(node.append_child(STR("text1")).text().set(-9223372036854775807ll)); CHECK(node.append_child(STR("text2")).text().set(-9223372036854775807ll - 1)); CHECK(!xml_text().set(-9223372036854775807ll - 1)); diff --git a/tests/test_dom_traverse.cpp b/tests/test_dom_traverse.cpp index 5c7579a..25774a5 100644 --- a/tests/test_dom_traverse.cpp +++ b/tests/test_dom_traverse.cpp @@ -57,10 +57,10 @@ TEST_XML(dom_attr_next_previous_attribute, "<node attr1='1' attr2='2' />") CHECK(attr1.next_attribute() == attr2); CHECK(attr2.next_attribute() == xml_attribute()); - + CHECK(attr1.previous_attribute() == xml_attribute()); CHECK(attr2.previous_attribute() == attr1); - + CHECK(xml_attribute().next_attribute() == xml_attribute()); CHECK(xml_attribute().previous_attribute() == xml_attribute()); } @@ -497,7 +497,7 @@ TEST_XML_FLAGS(dom_node_type, "<?xml?><!DOCTYPE><?pi?><!--comment--><node>pcdata CHECK((it++)->type() == node_element); xml_node_iterator cit = doc.child(STR("node")).begin(); - + CHECK((cit++)->type() == node_pcdata); CHECK((cit++)->type() == node_cdata); } @@ -516,7 +516,7 @@ TEST_XML_FLAGS(dom_node_name_value, "<?xml?><!DOCTYPE id><?pi?><!--comment--><no CHECK_NAME_VALUE(*it++, STR("node"), STR("")); xml_node_iterator cit = doc.child(STR("node")).begin(); - + CHECK_NAME_VALUE(*cit++, STR(""), STR("pcdata")); CHECK_NAME_VALUE(*cit++, STR(""), STR("cdata")); } @@ -555,10 +555,10 @@ TEST_XML(dom_node_next_previous_sibling, "<node><child1/><child2/><child3/></nod CHECK(child1.next_sibling() == child2); CHECK(child3.next_sibling() == xml_node()); - + CHECK(child1.previous_sibling() == xml_node()); CHECK(child3.previous_sibling() == child2); - + CHECK(child1.next_sibling(STR("child3")) == child3); CHECK(child1.next_sibling(STR("child")) == xml_node()); @@ -728,13 +728,13 @@ TEST_XML(dom_node_find_node, "<node><child1/><child2/></node>") TEST_XML(dom_node_path, "<node><child1>text<child2/></child1></node>") { CHECK(xml_node().path() == STR("")); - + CHECK(doc.path() == STR("")); CHECK(doc.child(STR("node")).path() == STR("/node")); CHECK(doc.child(STR("node")).child(STR("child1")).path() == STR("/node/child1")); CHECK(doc.child(STR("node")).child(STR("child1")).child(STR("child2")).path() == STR("/node/child1/child2")); CHECK(doc.child(STR("node")).child(STR("child1")).first_child().path() == STR("/node/child1/")); - + CHECK(doc.child(STR("node")).child(STR("child1")).path('\\') == STR("\\node\\child1")); } #endif @@ -743,7 +743,7 @@ TEST_XML(dom_node_first_element_by_path, "<node><child1>text<child2/></child1></ { CHECK(xml_node().first_element_by_path(STR("/")) == xml_node()); CHECK(xml_node().first_element_by_path(STR("a")) == xml_node()); - + CHECK(doc.first_element_by_path(STR("")) == doc); CHECK(doc.first_element_by_path(STR("/")) == doc); @@ -757,7 +757,7 @@ TEST_XML(dom_node_first_element_by_path, "<node><child1>text<child2/></child1></ #endif CHECK(doc.first_element_by_path(STR("/node/child2")) == xml_node()); - + CHECK(doc.first_element_by_path(STR("\\node\\child1"), '\\') == doc.child(STR("node")).child(STR("child1"))); CHECK(doc.child(STR("node")).first_element_by_path(STR("..")) == doc); @@ -919,7 +919,7 @@ TEST_XML_FLAGS(dom_offset_debug, "<?xml?><!DOCTYPE><?pi?><!--comment--><node>pcd CHECK((it++)->offset_debug() == 38); xml_node_iterator cit = doc.child(STR("node")).begin(); - + CHECK((cit++)->offset_debug() == 43); CHECK((cit++)->offset_debug() == 58); } @@ -966,7 +966,7 @@ TEST_XML(dom_internal_object, "<node attr='value'>value</node>") xml_node node = doc.child(STR("node")); xml_attribute attr = node.first_attribute(); xml_node value = node.first_child(); - + CHECK(xml_node().internal_object() == 0); CHECK(xml_attribute().internal_object() == 0); @@ -988,7 +988,7 @@ TEST_XML(dom_hash_value, "<node attr='value'>value</node>") xml_node node = doc.child(STR("node")); xml_attribute attr = node.first_attribute(); xml_node value = node.first_child(); - + CHECK(xml_node().hash_value() == 0); CHECK(xml_attribute().hash_value() == 0); diff --git a/tests/test_memory.cpp b/tests/test_memory.cpp index 85d6e86..14c9aff 100644 --- a/tests/test_memory.cpp +++ b/tests/test_memory.cpp @@ -48,7 +48,7 @@ TEST(memory_custom_memory_management) CHECK(page_allocs == 0 && page_deallocs == 0); CHECK(doc.load_string(STR("<node />"))); - + CHECK(page_allocs == 1 && page_deallocs == 0); // modify document (no new page) diff --git a/tests/test_parse.cpp b/tests/test_parse.cpp index 47f774e..68fd217 100644 --- a/tests/test_parse.cpp +++ b/tests/test_parse.cpp @@ -82,7 +82,7 @@ TEST(parse_pi_error) CHECK(doc.load_string(STR("<?name&"), flags).status == status_bad_pi); CHECK(doc.load_string(STR("<?name&?"), flags).status == status_bad_pi); } - + CHECK(doc.load_string(STR("<?xx#?>"), parse_fragment | parse_pi).status == status_bad_pi); CHECK(doc.load_string(STR("<?name&?>"), parse_fragment | parse_pi).status == status_bad_pi); CHECK(doc.load_string(STR("<?name& x?>"), parse_fragment | parse_pi).status == status_bad_pi); @@ -235,9 +235,9 @@ TEST(parse_ws_pcdata_skip) CHECK(!doc.first_child()); CHECK(doc.load_string(STR("<root> <node> </node> </root>"), parse_minimal)); - + xml_node root = doc.child(STR("root")); - + CHECK(root.first_child() == root.last_child()); CHECK(!root.first_child().first_child()); } @@ -855,7 +855,7 @@ TEST(parse_declaration_error) CHECK(doc.load_string(STR("<?xml>"), flags).status == status_bad_pi); CHECK(doc.load_string(STR("<?xml version='1>"), flags).status == status_bad_pi); } - + CHECK(doc.load_string(STR("<?xml version='1?>"), parse_fragment | parse_declaration).status == status_bad_attribute); CHECK(doc.load_string(STR("<foo><?xml version='1'?></foo>"), parse_fragment | parse_declaration).status == status_bad_pi); } diff --git a/tests/test_xpath.cpp b/tests/test_xpath.cpp index 57fa95b..33c1696 100644 --- a/tests/test_xpath.cpp +++ b/tests/test_xpath.cpp @@ -196,7 +196,7 @@ TEST(xpath_long_numbers_parse) { const pugi::char_t* str_flt_max = STR("340282346638528860000000000000000000000"); const pugi::char_t* str_flt_max_dec = STR("340282346638528860000000000000000000000.000000"); - + const pugi::char_t* str_dbl_max = STR("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); const pugi::char_t* str_dbl_max_dec = STR("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000"); @@ -225,7 +225,7 @@ TEST(xpath_long_numbers_stringize) { const pugi::char_t* str_flt_max = STR("340282346638528860000000000000000000000"); const pugi::char_t* str_flt_max_dec = STR("340282346638528860000000000000000000000.000000"); - + const pugi::char_t* str_dbl_max = STR("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); const pugi::char_t* str_dbl_max_dec = STR("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000"); diff --git a/tests/test_xpath_api.cpp b/tests/test_xpath_api.cpp index e53c25a..ef7d4b2 100644 --- a/tests/test_xpath_api.cpp +++ b/tests/test_xpath_api.cpp @@ -31,12 +31,12 @@ TEST_XML(xpath_api_select_node, "<node><head/><foo id='1'/><foo/><tail/></node>" CHECK(n2.node().attribute(STR("id")).as_int() == 1); xpath_node n3 = doc.select_node(STR("node/bar")); - + CHECK(!n3); xpath_node n4 = doc.select_node(STR("node/head/following-sibling::foo")); xpath_node n5 = doc.select_node(STR("node/tail/preceding-sibling::foo")); - + CHECK(n4.node().attribute(STR("id")).as_int() == 1); CHECK(n5.node().attribute(STR("id")).as_int() == 1); } @@ -258,7 +258,7 @@ TEST(xpath_api_evaluate_string) // test for just enough space std::basic_string<char_t> s1 = base; CHECK(q.evaluate_string(&s1[0], 11, xml_node()) == 11 && memcmp(&s1[0], STR("0123456789\0xxxxx"), 16 * sizeof(char_t)) == 0); - + // test for just not enough space std::basic_string<char_t> s2 = base; CHECK(q.evaluate_string(&s2[0], 10, xml_node()) == 11 && memcmp(&s2[0], STR("012345678\0xxxxxx"), 16 * sizeof(char_t)) == 0); @@ -292,7 +292,7 @@ TEST(xpath_api_return_type) TEST(xpath_api_query_bool) { xpath_query q(STR("node")); - + CHECK(q); CHECK((!q) == false); } @@ -301,7 +301,7 @@ TEST(xpath_api_query_bool) TEST(xpath_api_query_bool_fail) { xpath_query q(STR("")); - + CHECK((q ? true : false) == false); CHECK((!q) == true); } diff --git a/tests/test_xpath_functions.cpp b/tests/test_xpath_functions.cpp index eb43bb5..211dbfb 100644 --- a/tests/test_xpath_functions.cpp +++ b/tests/test_xpath_functions.cpp @@ -6,7 +6,7 @@ TEST_XML(xpath_number_number, "<node>123</node>") { xml_node c; xml_node n = doc.child(STR("node")).first_child(); - + // number with 0 arguments CHECK_XPATH_NUMBER_NAN(c, STR("number()")); CHECK_XPATH_NUMBER(n, STR("number()"), 123); @@ -35,7 +35,7 @@ TEST_XML(xpath_number_number, "<node>123</node>") // number with 1 number argument CHECK_XPATH_NUMBER(c, STR("number(1)"), 1); - + // number with 2 arguments CHECK_XPATH_FAIL(STR("number(1, 2)")); } @@ -44,21 +44,21 @@ TEST_XML(xpath_number_sum, "<node>123<child>789</child></node><node/>") { xml_node c; xml_node n = doc.child(STR("node")); - + // sum with 0 arguments CHECK_XPATH_FAIL(STR("sum()")); // sum with 1 argument CHECK_XPATH_NUMBER(c, STR("sum(.)"), 0); CHECK_XPATH_NUMBER(n, STR("sum(.)"), 123789); // 123 .. 789 - + CHECK_XPATH_NUMBER(n, STR("sum(./descendant-or-self::node())"), 125490); // node + 123 + child + 789 = 123789 + 123 + 789 + 789 = 125490 CHECK_XPATH_NUMBER(n, STR("sum(.//node())"), 1701); // 123 + child + 789 = 123 + 789 + 789 CHECK_XPATH_NUMBER_NAN(doc.last_child(), STR("sum(.)")); // sum with 2 arguments CHECK_XPATH_FAIL(STR("sum(1, 2)")); - + // sum with 1 non-node-set argument CHECK_XPATH_FAIL(STR("sum(1)")); } @@ -155,7 +155,7 @@ TEST(xpath_number_round) TEST_XML(xpath_boolean_boolean, "<node />") { xml_node c; - + // boolean with 0 arguments CHECK_XPATH_FAIL(STR("boolean()")); @@ -182,14 +182,14 @@ TEST_XML(xpath_boolean_boolean, "<node />") TEST(xpath_boolean_not) { xml_node c; - + // not with 0 arguments CHECK_XPATH_FAIL(STR("not()")); // not with 1 argument CHECK_XPATH_BOOLEAN(c, STR("not(true())"), false); CHECK_XPATH_BOOLEAN(c, STR("not(false())"), true); - + // boolean with 2 arguments CHECK_XPATH_FAIL(STR("not(1, 2)")); } @@ -197,7 +197,7 @@ TEST(xpath_boolean_not) TEST(xpath_boolean_true) { xml_node c; - + // true with 0 arguments CHECK_XPATH_BOOLEAN(c, STR("true()"), true); @@ -208,7 +208,7 @@ TEST(xpath_boolean_true) TEST(xpath_boolean_false) { xml_node c; - + // false with 0 arguments CHECK_XPATH_BOOLEAN(c, STR("false()"), false); @@ -219,7 +219,7 @@ TEST(xpath_boolean_false) TEST_XML(xpath_boolean_lang, "<node xml:lang='en'><child xml:lang='zh-UK'><subchild attr=''/></child></node><foo><bar/></foo>") { xml_node c; - + // lang with 0 arguments CHECK_XPATH_FAIL(STR("lang()")); @@ -228,7 +228,7 @@ TEST_XML(xpath_boolean_lang, "<node xml:lang='en'><child xml:lang='zh-UK'><subch CHECK_XPATH_BOOLEAN(doc.child(STR("foo")), STR("lang('en')"), false); CHECK_XPATH_BOOLEAN(doc.child(STR("foo")), STR("lang('')"), false); CHECK_XPATH_BOOLEAN(doc.child(STR("foo")).child(STR("bar")), STR("lang('en')"), false); - + // lang with 1 argument, same language/prefix CHECK_XPATH_BOOLEAN(doc.child(STR("node")), STR("lang('en')"), true); CHECK_XPATH_BOOLEAN(doc.child(STR("node")).child(STR("child")), STR("lang('zh-uk')"), true); @@ -373,7 +373,7 @@ TEST(xpath_string_substring_before) // substring-before with 1 argument CHECK_XPATH_FAIL(STR("substring-before('a')")); - + // substring-before with 2 arguments CHECK_XPATH_STRING(c, STR("substring-before('abc', 'abc')"), STR("")); CHECK_XPATH_STRING(c, STR("substring-before('abc', 'a')"), STR("")); @@ -382,7 +382,7 @@ TEST(xpath_string_substring_before) CHECK_XPATH_STRING(c, STR("substring-before('abc', 'c')"), STR("ab")); CHECK_XPATH_STRING(c, STR("substring-before('abc', '')"), STR("")); CHECK_XPATH_STRING(c, STR("substring-before('', '')"), STR("")); - + // substring-before with 2 arguments, from W3C standard CHECK_XPATH_STRING(c, STR("substring-before(\"1999/04/01\",\"/\")"), STR("1999")); @@ -399,7 +399,7 @@ TEST(xpath_string_substring_after) // substring-after with 1 argument CHECK_XPATH_FAIL(STR("substring-after('a')")); - + // substring-after with 2 arguments CHECK_XPATH_STRING(c, STR("substring-after('abc', 'abc')"), STR("")); CHECK_XPATH_STRING(c, STR("substring-after('abc', 'a')"), STR("bc")); @@ -430,10 +430,10 @@ TEST(xpath_string_substring) // substring with 0 arguments CHECK_XPATH_FAIL(STR("substring()")); - + // substring with 1 argument CHECK_XPATH_FAIL(STR("substring('')")); - + // substring with 2 arguments CHECK_XPATH_STRING(c, STR("substring('abcd', 2)"), STR("bcd")); CHECK_XPATH_STRING(c, STR("substring('abcd', 1)"), STR("abcd")); @@ -517,7 +517,7 @@ TEST_XML_FLAGS(xpath_string_normalize_space, "<node> \t\r\rval1 \rval2\r\nval3\ // normalize-space with 0 arguments CHECK_XPATH_STRING(c, STR("normalize-space()"), STR("")); CHECK_XPATH_STRING(n, STR("normalize-space()"), STR("val1 val2 val3 val4")); - + // normalize-space with 1 argument CHECK_XPATH_STRING(c, STR("normalize-space('')"), STR("")); CHECK_XPATH_STRING(c, STR("normalize-space('abcd')"), STR("abcd")); @@ -526,7 +526,7 @@ TEST_XML_FLAGS(xpath_string_normalize_space, "<node> \t\r\rval1 \rval2\r\nval3\ CHECK_XPATH_STRING(c, STR("normalize-space('ab\r\n\tcd')"), STR("ab cd")); CHECK_XPATH_STRING(c, STR("normalize-space('ab cd')"), STR("ab cd")); CHECK_XPATH_STRING(c, STR("normalize-space('\07')"), STR("\07")); - + // normalize-space with 2 arguments CHECK_XPATH_FAIL(STR("normalize-space(1, 2)")); } @@ -537,13 +537,13 @@ TEST(xpath_string_translate) // translate with 0 arguments CHECK_XPATH_FAIL(STR("translate()")); - + // translate with 1 argument CHECK_XPATH_FAIL(STR("translate('a')")); // translate with 2 arguments CHECK_XPATH_FAIL(STR("translate('a', 'b')")); - + // translate with 3 arguments CHECK_XPATH_STRING(c, STR("translate('abc', '', '')"), STR("abc")); CHECK_XPATH_STRING(c, STR("translate('abc', '', 'foo')"), STR("abc")); @@ -604,7 +604,7 @@ TEST_XML(xpath_nodeset_position, "<node><c1/><c1/><c2/><c3/><c3/><c3/><c3/></nod CHECK_XPATH_NODESET(n, STR("c1[position() = 3]")); CHECK_XPATH_NODESET(n, STR("c2/preceding-sibling::node()[position() = 1]")) % 4; CHECK_XPATH_NODESET(n, STR("c2/preceding-sibling::node()[position() = 2]")) % 3; - + // position with 1 argument CHECK_XPATH_FAIL(STR("position(c)")); } @@ -640,7 +640,7 @@ TEST_XML(xpath_nodeset_id, "<node id='foo'/>") // id with 0 arguments CHECK_XPATH_FAIL(STR("id()")); - + // id with 1 argument - no DTD => no id CHECK_XPATH_NODESET(n, STR("id('foo')")); @@ -656,7 +656,7 @@ TEST_XML_FLAGS(xpath_nodeset_local_name, "<node xmlns:foo='http://foo'><c1>text< // local-name with 0 arguments CHECK_XPATH_STRING(c, STR("local-name()"), STR("")); CHECK_XPATH_STRING(n, STR("local-name()"), STR("node")); - + // local-name with 1 non-node-set argument CHECK_XPATH_FAIL(STR("local-name(1)")); @@ -681,7 +681,7 @@ TEST_XML_FLAGS(xpath_nodeset_namespace_uri, "<node xmlns:foo='http://foo'><c1>te // namespace-uri with 0 arguments CHECK_XPATH_STRING(c, STR("namespace-uri()"), STR("")); CHECK_XPATH_STRING(n.child(STR("c2")).child(STR("foo:child")), STR("namespace-uri()"), STR("http://foo2")); - + // namespace-uri with 1 non-node-set argument CHECK_XPATH_FAIL(STR("namespace-uri(1)")); @@ -710,7 +710,7 @@ TEST_XML_FLAGS(xpath_nodeset_name, "<node xmlns:foo='http://foo'><c1>text</c1><c // name with 0 arguments CHECK_XPATH_STRING(c, STR("name()"), STR("")); CHECK_XPATH_STRING(n, STR("name()"), STR("node")); - + // name with 1 non-node-set argument CHECK_XPATH_FAIL(STR("name(1)")); @@ -733,7 +733,7 @@ TEST(xpath_function_arguments) // conversion to string CHECK_XPATH_NUMBER(c, STR("string-length(12)"), 2); - + // conversion to number CHECK_XPATH_NUMBER(c, STR("round('1.2')"), 1); CHECK_XPATH_NUMBER(c, STR("round('1.7')"), 2); @@ -741,13 +741,13 @@ TEST(xpath_function_arguments) // conversion to boolean CHECK_XPATH_BOOLEAN(c, STR("not('1')"), false); CHECK_XPATH_BOOLEAN(c, STR("not('')"), true); - + // conversion to node set CHECK_XPATH_FAIL(STR("sum(1)")); // expression evaluation CHECK_XPATH_NUMBER(c, STR("round((2 + 2 * 2) div 4)"), 2); - + // empty expressions CHECK_XPATH_FAIL(STR("round(,)")); CHECK_XPATH_FAIL(STR("substring(,)")); diff --git a/tests/test_xpath_operators.cpp b/tests/test_xpath_operators.cpp index 450af5d..1a97c7d 100644 --- a/tests/test_xpath_operators.cpp +++ b/tests/test_xpath_operators.cpp @@ -63,7 +63,7 @@ TEST(xpath_operators_arithmetic_specials) CHECK_XPATH_STRING(c, STR("1 div 0 + 100"), STR("Infinity")); CHECK_XPATH_STRING(c, STR("-1 div 0 + 100"), STR("-Infinity")); CHECK_XPATH_STRING(c, STR("0 div 0 + 100"), STR("NaN")); - + // unary - and multiplication clarifications from recommendations errata CHECK_XPATH_STRING(c, STR("1 div -0"), STR("-Infinity")); CHECK_XPATH_STRING(c, STR("-1 div -0"), STR("Infinity")); @@ -99,7 +99,7 @@ TEST(xpath_operators_logical) CHECK_XPATH_BOOLEAN(c, STR("true() and false()"), false); CHECK_XPATH_BOOLEAN(c, STR("false() and false()"), false); CHECK_XPATH_BOOLEAN(c, STR("false() and true()"), false); - + // boolean conversion CHECK_XPATH_BOOLEAN(c, STR("1 or ''"), true); CHECK_XPATH_BOOLEAN(c, STR("1 and ''"), false); @@ -225,7 +225,7 @@ TEST_XML(xpath_operators_equality_node_set_primitive, "<node><c1><v>1</v><v>-1</ CHECK_XPATH_BOOLEAN(n, STR("c2/v != 1"), true); CHECK_XPATH_BOOLEAN(n, STR("1 != c2/v"), true); #endif - + // node set vs string CHECK_XPATH_BOOLEAN(c, STR("x = '1'"), false); CHECK_XPATH_BOOLEAN(c, STR("x != '1'"), false); diff --git a/tests/test_xpath_variables.cpp b/tests/test_xpath_variables.cpp index fec1386..d9603ce 100644 --- a/tests/test_xpath_variables.cpp +++ b/tests/test_xpath_variables.cpp @@ -261,7 +261,7 @@ TEST(xpath_variables_multiple_documents) CHECK(ns.size() == 3); CHECK(ns[0] != ns[1] && ns[0] != ns[2]); - + xml_node n0 = doc.child(STR("node")), n1 = doc1.child(STR("node")), n2 = doc2.child(STR("node")); CHECK(n0 == ns[0].node() || n0 == ns[1].node() || n0 == ns[2].node()); diff --git a/tests/test_xpath_xalan_1.cpp b/tests/test_xpath_xalan_1.cpp index 28db218..7f87c52 100644 --- a/tests/test_xpath_xalan_1.cpp +++ b/tests/test_xpath_xalan_1.cpp @@ -363,7 +363,7 @@ TEST_XML(xpath_xalan_math_8, "<k>0.0004</k>") CHECK_XPATH_NUMBER(doc, STR("number(4 div 10000)"), 0.0004); // +0 works around extended precision in div on x86 (this is needed for some configurations in MinGW 3.4) - CHECK_XPATH_BOOLEAN(doc, STR("(number(k) = (4 div 10000 + 0))"), true); + CHECK_XPATH_BOOLEAN(doc, STR("(number(k) = (4 div 10000 + 0))"), true); CHECK_XPATH_NUMBER(doc, STR("number(0.0001 * 4)"), 0.0004); CHECK_XPATH_BOOLEAN(doc, STR("(number(k) = (0.0001 * 4))"), true); } diff --git a/tests/writer_string.hpp b/tests/writer_string.hpp index 6bffc32..0c1089d 100644 --- a/tests/writer_string.hpp +++ b/tests/writer_string.hpp @@ -8,7 +8,7 @@ struct xml_writer_string: public pugi::xml_writer { std::string contents; - + virtual void write(const void* data, size_t size); std::string as_narrow() const; |