From 2e0ed8284b7488f9664bf8dba9aae90688862cc3 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Thu, 14 Apr 2016 00:30:24 -0700 Subject: Remove extra space in an empty tag for format_raw When using format_raw the space in the empty tag () is the only character that does not have to be there; so format_raw almost results in a minimal XML but not quite. It's pretty unlikely that this is crucial for any users - the formatting change should be benign, and it's better to improve format_raw than to add yet another flag. Fixes #87. --- tests/test_document.cpp | 70 +++++++++--------- tests/test_dom_modify.cpp | 170 +++++++++++++++++++++---------------------- tests/test_dom_text.cpp | 6 +- tests/test_parse.cpp | 64 ++++++++-------- tests/test_parse_doctype.cpp | 6 +- tests/test_write.cpp | 12 +-- 6 files changed, 164 insertions(+), 164 deletions(-) (limited to 'tests') diff --git a/tests/test_document.cpp b/tests/test_document.cpp index eba2fd4..b442126 100644 --- a/tests/test_document.cpp +++ b/tests/test_document.cpp @@ -68,7 +68,7 @@ TEST(document_create) { pugi::xml_document doc; doc.append_child().set_name(STR("node")); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } #ifndef PUGIXML_NO_STL @@ -78,7 +78,7 @@ TEST(document_load_stream) std::istringstream iss(""); CHECK(doc.load(iss)); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(document_load_stream_offset) @@ -91,7 +91,7 @@ TEST(document_load_stream_offset) iss >> s; CHECK(doc.load(iss)); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(document_load_stream_text) @@ -100,7 +100,7 @@ TEST(document_load_stream_text) std::ifstream iss("tests/data/multiline.xml"); CHECK(doc.load(iss)); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(document_load_stream_error) @@ -130,7 +130,7 @@ TEST(document_load_stream_wide) std::basic_istringstream iss(L""); CHECK(doc.load(iss)); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } #ifndef PUGIXML_NO_EXCEPTIONS @@ -201,7 +201,7 @@ TEST(document_load_stream_nonseekable) pugi::xml_document doc; CHECK(doc.load(in)); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(document_load_stream_wide_nonseekable) @@ -212,14 +212,14 @@ TEST(document_load_stream_wide_nonseekable) pugi::xml_document doc; CHECK(doc.load(in)); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(document_load_stream_nonseekable_large) { std::basic_string str; str += STR(""); - for (int i = 0; i < 10000; ++i) str += STR(""); + for (int i = 0; i < 10000; ++i) str += STR(""); str += STR(""); char_array_buffer buffer(&str[0], &str[0] + str.length()); @@ -264,7 +264,7 @@ TEST(document_load_string) pugi::xml_document doc; CHECK(doc.load_string(STR(""))); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(document_load_file) @@ -272,7 +272,7 @@ TEST(document_load_file) pugi::xml_document doc; CHECK(doc.load_file("tests/data/small.xml")); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(document_load_file_empty) @@ -291,7 +291,7 @@ TEST(document_load_file_large) std::basic_string str; str += STR(""); - for (int i = 0; i < 10000; ++i) str += STR(""); + for (int i = 0; i < 10000; ++i) str += STR(""); str += STR(""); CHECK_NODE(doc, str.c_str()); @@ -324,7 +324,7 @@ TEST(document_load_file_out_of_memory_file_leak) test_runner::_memory_fail_threshold = 0; CHECK(doc.load_file("tests/data/small.xml")); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(document_load_file_wide_out_of_memory_file_leak) @@ -339,7 +339,7 @@ TEST(document_load_file_wide_out_of_memory_file_leak) test_runner::_memory_fail_threshold = 0; CHECK(doc.load_file(L"tests/data/small.xml")); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(document_load_file_error_previous) @@ -357,7 +357,7 @@ TEST(document_load_file_wide_ascii) pugi::xml_document doc; CHECK(doc.load_file(L"tests/data/small.xml")); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } #if !defined(__DMC__) && !defined(__MWERKS__) && !(defined(__MINGW32__) && defined(__STRICT_ANSI__) && !defined(__MINGW64_VERSION_MAJOR)) && !defined(__BORLANDC__) @@ -366,7 +366,7 @@ TEST(document_load_file_wide_unicode) pugi::xml_document doc; CHECK(doc.load_file(L"tests/data/\x0442\x0435\x0441\x0442.xml")); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } #endif @@ -389,7 +389,7 @@ TEST_XML(document_save, "") doc.save(writer, STR(""), pugi::format_no_declaration | pugi::format_raw, get_native_encoding()); - CHECK(writer.as_string() == STR("")); + CHECK(writer.as_string() == STR("")); } #ifndef PUGIXML_NO_STL @@ -399,7 +399,7 @@ TEST_XML(document_save_stream, "") doc.save(oss, STR(""), pugi::format_no_declaration | pugi::format_raw); - CHECK(oss.str() == ""); + CHECK(oss.str() == ""); } TEST_XML(document_save_stream_wide, "") @@ -408,7 +408,7 @@ TEST_XML(document_save_stream_wide, "") doc.save(oss, STR(""), pugi::format_no_declaration | pugi::format_raw); - CHECK(oss.str() == L""); + CHECK(oss.str() == L""); } #endif @@ -417,12 +417,12 @@ TEST_XML(document_save_bom, "") unsigned int flags = format_no_declaration | format_raw | format_write_bom; // specific encodings - CHECK(test_save_narrow(doc, flags, encoding_utf8, "\xef\xbb\xbf", 8)); - CHECK(test_save_narrow(doc, flags, encoding_utf16_be, "\xfe\xff\x00<\x00n\x00 \x00/\x00>", 12)); - CHECK(test_save_narrow(doc, flags, encoding_utf16_le, "\xff\xfe<\x00n\x00 \x00/\x00>\x00", 12)); - CHECK(test_save_narrow(doc, flags, encoding_utf32_be, "\x00\x00\xfe\xff\x00\x00\x00<\x00\x00\x00n\x00\x00\x00 \x00\x00\x00/\x00\x00\x00>", 24)); - CHECK(test_save_narrow(doc, flags, encoding_utf32_le, "\xff\xfe\x00\x00<\x00\x00\x00n\x00\x00\x00 \x00\x00\x00/\x00\x00\x00>\x00\x00\x00", 24)); - CHECK(test_save_narrow(doc, flags, encoding_latin1, "", 5)); + CHECK(test_save_narrow(doc, flags, encoding_utf8, "\xef\xbb\xbf", 7)); + CHECK(test_save_narrow(doc, flags, encoding_utf16_be, "\xfe\xff\x00<\x00n\x00/\x00>", 10)); + CHECK(test_save_narrow(doc, flags, encoding_utf16_le, "\xff\xfe<\x00n\x00/\x00>\x00", 10)); + CHECK(test_save_narrow(doc, flags, encoding_utf32_be, "\x00\x00\xfe\xff\x00\x00\x00<\x00\x00\x00n\x00\x00\x00/\x00\x00\x00>", 20)); + CHECK(test_save_narrow(doc, flags, encoding_utf32_le, "\xff\xfe\x00\x00<\x00\x00\x00n\x00\x00\x00/\x00\x00\x00>\x00\x00\x00", 20)); + CHECK(test_save_narrow(doc, flags, encoding_latin1, "", 4)); // encodings synonyms CHECK(save_narrow(doc, flags, encoding_utf16) == save_narrow(doc, flags, (is_little_endian() ? encoding_utf16_le : encoding_utf16_be))); @@ -521,7 +521,7 @@ TEST_XML(document_save_file, "") CHECK(doc.save_file(f.path)); CHECK(doc.load_file(f.path, pugi::parse_default | pugi::parse_declaration)); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST_XML(document_save_file_wide, "") @@ -535,7 +535,7 @@ TEST_XML(document_save_file_wide, "") CHECK(doc.save_file(wpath)); CHECK(doc.load_file(f.path, pugi::parse_default | pugi::parse_declaration)); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST_XML(document_save_file_error, "") @@ -596,7 +596,7 @@ TEST(document_load_buffer) pugi::xml_document doc; CHECK(doc.load_buffer(text, sizeof(text))); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(document_load_buffer_inplace) @@ -606,7 +606,7 @@ TEST(document_load_buffer_inplace) pugi::xml_document doc; CHECK(doc.load_buffer_inplace(text, sizeof(text))); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(document_load_buffer_inplace_own) @@ -623,7 +623,7 @@ TEST(document_load_buffer_inplace_own) pugi::xml_document doc; CHECK(doc.load_buffer_inplace_own(text, size)); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(document_parse_result_bool) @@ -1196,7 +1196,7 @@ TEST_XML(document_reset, "") CHECK(doc.load_string(STR(""))); CHECK(doc.first_child()); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); doc.reset(); CHECK(!doc.first_child()); @@ -1220,12 +1220,12 @@ TEST_XML(document_reset_copy, "") doc2.reset(doc); - CHECK_NODE(doc2, STR("")); + CHECK_NODE(doc2, STR("")); CHECK(doc.first_child() != doc2.first_child()); doc.reset(doc2); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); CHECK(doc.first_child() != doc2.first_child()); CHECK(doc.first_child().offset_debug() == -1); @@ -1233,7 +1233,7 @@ TEST_XML(document_reset_copy, "") TEST_XML(document_reset_copy_self, "") { - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); doc.reset(doc); @@ -1349,7 +1349,7 @@ TEST(document_alignment) xml_document* doc = new (buf + offset) xml_document; CHECK(doc->load_string(STR(""))); - CHECK_NODE(*doc, STR("")); + CHECK_NODE(*doc, STR("")); doc->~xml_document(); } @@ -1393,5 +1393,5 @@ TEST(document_deprecated_load) { xml_document doc; CHECK(doc.load(STR(""))); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } diff --git a/tests/test_dom_modify.cpp b/tests/test_dom_modify.cpp index 4c944e9..f2d7ea8 100644 --- a/tests/test_dom_modify.cpp +++ b/tests/test_dom_modify.cpp @@ -31,7 +31,7 @@ TEST_XML(dom_attr_assign, "") node.append_attribute(STR("attr8")) = true; xml_attribute() = true; - CHECK_NODE(node, STR("")); + CHECK_NODE(node, STR("")); } TEST_XML(dom_attr_set_name, "") @@ -41,7 +41,7 @@ TEST_XML(dom_attr_set_name, "") CHECK(attr.set_name(STR("n"))); CHECK(!xml_attribute().set_name(STR("n"))); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST_XML(dom_attr_set_value, "") @@ -68,7 +68,7 @@ TEST_XML(dom_attr_set_value, "") CHECK(node.append_attribute(STR("attr8")).set_value(true)); CHECK(!xml_attribute().set_value(true)); - CHECK_NODE(node, STR("")); + CHECK_NODE(node, STR("")); } #if LONG_MAX > 2147483647 @@ -84,7 +84,7 @@ TEST_XML(dom_attr_assign_long, "") node.append_attribute(STR("attr4")) = 18446744073709551614ul; xml_attribute() = 18446744073709551615ul; - CHECK_NODE(node, STR("")); + CHECK_NODE(node, STR("")); } TEST_XML(dom_attr_set_value_long, "") @@ -99,7 +99,7 @@ TEST_XML(dom_attr_set_value_long, "") CHECK(node.append_attribute(STR("attr4")).set_value(18446744073709551614ul)); CHECK(!xml_attribute().set_value(18446744073709551615ul)); - CHECK_NODE(node, STR("")); + CHECK_NODE(node, STR("")); } #else TEST_XML(dom_attr_assign_long, "") @@ -114,7 +114,7 @@ TEST_XML(dom_attr_assign_long, "") node.append_attribute(STR("attr4")) = 4294967294ul; xml_attribute() = 4294967295ul; - CHECK_NODE(node, STR("")); + CHECK_NODE(node, STR("")); } TEST_XML(dom_attr_set_value_long, "") @@ -129,7 +129,7 @@ TEST_XML(dom_attr_set_value_long, "") CHECK(node.append_attribute(STR("attr4")).set_value(4294967294ul)); CHECK(!xml_attribute().set_value(4294967295ul)); - CHECK_NODE(node, STR("")); + CHECK_NODE(node, STR("")); } #endif @@ -146,7 +146,7 @@ TEST_XML(dom_attr_assign_llong, "") node.append_attribute(STR("attr4")) = 18446744073709551614ull; xml_attribute() = 18446744073709551615ull; - CHECK_NODE(node, STR("")); + CHECK_NODE(node, STR("")); } TEST_XML(dom_attr_set_value_llong, "") @@ -161,7 +161,7 @@ TEST_XML(dom_attr_set_value_llong, "") CHECK(node.append_attribute(STR("attr4")).set_value(18446744073709551614ull)); CHECK(!xml_attribute().set_value(18446744073709551615ull)); - CHECK_NODE(node, STR("")); + CHECK_NODE(node, STR("")); } #endif @@ -171,8 +171,8 @@ TEST_XML(dom_attr_assign_large_number_float, "") node.attribute(STR("attr")) = std::numeric_limits::max(); - CHECK(test_node(node, STR(""), STR(""), pugi::format_raw) || - test_node(node, STR(""), STR(""), pugi::format_raw)); + CHECK(test_node(node, STR(""), STR(""), pugi::format_raw) || + test_node(node, STR(""), STR(""), pugi::format_raw)); } TEST_XML(dom_attr_assign_large_number_double, "") @@ -183,9 +183,9 @@ TEST_XML(dom_attr_assign_large_number_double, "") // Borland C does not print double values with enough precision #ifdef __BORLANDC__ - CHECK_NODE(node, STR("")); + CHECK_NODE(node, STR("")); #else - CHECK_NODE(node, STR("")); + CHECK_NODE(node, STR("")); #endif } @@ -234,7 +234,7 @@ TEST_XML(dom_node_prepend_attribute, "") CHECK(a3 && a1 != a3 && a2 != a3); a3 = STR("v3"); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST_XML(dom_node_append_attribute, "") @@ -254,7 +254,7 @@ TEST_XML(dom_node_append_attribute, "") CHECK(a3 && a1 != a3 && a2 != a3); a3 = STR("v3"); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST_XML(dom_node_insert_attribute_after, "") @@ -284,7 +284,7 @@ TEST_XML(dom_node_insert_attribute_after, " CHECK(child.insert_attribute_after(STR("a"), a4) == xml_attribute()); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST_XML(dom_node_insert_attribute_before, "") @@ -314,7 +314,7 @@ TEST_XML(dom_node_insert_attribute_before, "")); + CHECK_NODE(doc, STR("")); } TEST_XML(dom_node_prepend_copy_attribute, "") @@ -339,7 +339,7 @@ TEST_XML(dom_node_prepend_copy_attribute, "")); + CHECK_NODE(doc, STR("")); a3.set_name(STR("a3")); a3 = STR("v3"); @@ -350,7 +350,7 @@ TEST_XML(dom_node_prepend_copy_attribute, "")); + CHECK_NODE(doc, STR("")); } TEST_XML(dom_node_append_copy_attribute, "") @@ -375,7 +375,7 @@ TEST_XML(dom_node_append_copy_attribute, " xml_attribute a5 = node.last_child().append_copy(a1); CHECK(a5 && a5 != a4 && a5 != a3 && a5 != a2 && a5 != a1); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); a3.set_name(STR("a3")); a3 = STR("v3"); @@ -386,7 +386,7 @@ TEST_XML(dom_node_append_copy_attribute, " a5.set_name(STR("a5")); a5 = STR("v5"); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST_XML(dom_node_insert_copy_after_attribute, "") @@ -414,7 +414,7 @@ TEST_XML(dom_node_insert_copy_after_attribute, "")); + CHECK_NODE(doc, STR("")); a3.set_name(STR("a3")); a3 = STR("v3"); @@ -425,7 +425,7 @@ TEST_XML(dom_node_insert_copy_after_attribute, "")); + CHECK_NODE(doc, STR("")); } TEST_XML(dom_node_insert_copy_before_attribute, "") @@ -453,7 +453,7 @@ TEST_XML(dom_node_insert_copy_before_attribute, "< CHECK(child.insert_copy_before(a4, a4) == xml_attribute()); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); a3.set_name(STR("a3")); a3 = STR("v3"); @@ -464,7 +464,7 @@ TEST_XML(dom_node_insert_copy_before_attribute, "< a5.set_name(STR("a5")); a5 = STR("v5"); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST_XML(dom_node_remove_attribute, "") @@ -479,13 +479,13 @@ TEST_XML(dom_node_remove_attribute, "") { CHECK(doc.child(STR("node")).remove_child(STR("n1"))); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); CHECK(doc.remove_child(STR("node"))); @@ -732,17 +732,17 @@ TEST_XML(dom_node_prepend_copy, "foo") xml_node n1 = doc.child(STR("node")).prepend_copy(doc.child(STR("node")).first_child()); CHECK(n1); CHECK_STRING(n1.value(), STR("foo")); - CHECK_NODE(doc, STR("foofoo")); + CHECK_NODE(doc, STR("foofoo")); xml_node n2 = doc.child(STR("node")).prepend_copy(doc.child(STR("node")).child(STR("child"))); CHECK(n2 && n2 != n1); CHECK_STRING(n2.name(), STR("child")); - CHECK_NODE(doc, STR("foofoo")); + CHECK_NODE(doc, STR("foofoo")); xml_node n3 = doc.child(STR("node")).child(STR("child")).prepend_copy(doc.child(STR("node")).first_child().next_sibling()); CHECK(n3 && n3 != n1 && n3 != n2); CHECK_STRING(n3.value(), STR("foo")); - CHECK_NODE(doc, STR("foofoofoo")); + CHECK_NODE(doc, STR("foofoofoo")); } TEST_XML(dom_node_append_copy, "foo") @@ -755,17 +755,17 @@ TEST_XML(dom_node_append_copy, "foo") xml_node n1 = doc.child(STR("node")).append_copy(doc.child(STR("node")).first_child()); CHECK(n1); CHECK_STRING(n1.value(), STR("foo")); - CHECK_NODE(doc, STR("foofoo")); + CHECK_NODE(doc, STR("foofoo")); xml_node n2 = doc.child(STR("node")).append_copy(doc.child(STR("node")).child(STR("child"))); CHECK(n2 && n2 != n1); CHECK_STRING(n2.name(), STR("child")); - CHECK_NODE(doc, STR("foofoo")); + CHECK_NODE(doc, STR("foofoo")); xml_node n3 = doc.child(STR("node")).child(STR("child")).append_copy(doc.child(STR("node")).first_child()); CHECK(n3 && n3 != n1 && n3 != n2); CHECK_STRING(n3.value(), STR("foo")); - CHECK_NODE(doc, STR("foofoofoo")); + CHECK_NODE(doc, STR("foofoofoo")); } TEST_XML(dom_node_insert_copy_after, "foo") @@ -779,17 +779,17 @@ TEST_XML(dom_node_insert_copy_after, "foo") 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")); - CHECK_NODE(doc, STR("foo")); + CHECK_NODE(doc, STR("foo")); xml_node n2 = doc.child(STR("node")).insert_copy_after(doc.child(STR("node")).first_child(), doc.child(STR("node")).last_child()); CHECK(n2 && n2 != n1); CHECK_STRING(n2.value(), STR("foo")); - CHECK_NODE(doc, STR("foofoo")); + CHECK_NODE(doc, STR("foofoo")); xml_node n3 = doc.child(STR("node")).insert_copy_after(doc.child(STR("node")).first_child(), doc.child(STR("node")).first_child()); CHECK(n3 && n3 != n1 && n3 != n2); CHECK_STRING(n3.value(), STR("foo")); - CHECK_NODE(doc, STR("foofoofoo")); + CHECK_NODE(doc, STR("foofoofoo")); } TEST_XML(dom_node_insert_copy_before, "foo") @@ -803,39 +803,39 @@ TEST_XML(dom_node_insert_copy_before, "foo") 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")); - CHECK_NODE(doc, STR("foo")); + CHECK_NODE(doc, STR("foo")); xml_node n2 = doc.child(STR("node")).insert_copy_before(doc.child(STR("node")).first_child(), doc.child(STR("node")).last_child()); CHECK(n2 && n2 != n1); CHECK_STRING(n2.name(), STR("child")); - CHECK_NODE(doc, STR("foo")); + CHECK_NODE(doc, STR("foo")); xml_node n3 = doc.child(STR("node")).insert_copy_before(doc.child(STR("node")).first_child().next_sibling(), doc.child(STR("node")).first_child()); CHECK(n3 && n3 != n1 && n3 != n2); CHECK_STRING(n3.value(), STR("foo")); - CHECK_NODE(doc, STR("foofoo")); + CHECK_NODE(doc, STR("foofoo")); } TEST_XML(dom_node_copy_recursive, "foo") { doc.child(STR("node")).append_copy(doc.child(STR("node"))); - CHECK_NODE(doc, STR("foofoo")); + CHECK_NODE(doc, STR("foofoo")); } TEST_XML(dom_node_copy_crossdoc, "") { xml_document newdoc; newdoc.append_copy(doc.child(STR("node"))); - CHECK_NODE(doc, STR("")); - CHECK_NODE(newdoc, STR("")); + CHECK_NODE(doc, STR("")); + CHECK_NODE(newdoc, STR("")); } TEST_XML(dom_node_copy_crossdoc_attribute, "") { xml_document newdoc; newdoc.append_child(STR("copy")).append_copy(doc.child(STR("node")).attribute(STR("attr"))); - CHECK_NODE(doc, STR("")); - CHECK_NODE(newdoc, STR("")); + CHECK_NODE(doc, STR("")); + CHECK_NODE(newdoc, STR("")); } TEST_XML_FLAGS(dom_node_copy_types, "pcdata", parse_full) @@ -906,7 +906,7 @@ TEST(dom_node_declaration_copy) doc.last_child().append_copy(doc.first_child()); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(dom_string_out_of_memory) @@ -1056,7 +1056,7 @@ TEST(dom_node_doctype_copy) doc.last_child().append_copy(doc.first_child()); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(dom_node_doctype_value) @@ -1085,7 +1085,7 @@ TEST_XML(dom_node_append_buffer_native, "test") CHECK(node.append_buffer(data2, sizeof(data2))); CHECK(node.append_buffer(data2, sizeof(data2))); - CHECK_NODE(doc, STR("testtexttext")); + CHECK_NODE(doc, STR("testtexttext")); } TEST_XML(dom_node_append_buffer_convert, "test") @@ -1097,7 +1097,7 @@ TEST_XML(dom_node_append_buffer_convert, "test") CHECK(node.append_buffer(data, sizeof(data))); CHECK(node.append_buffer(data, sizeof(data), parse_default, encoding_utf32_be)); - CHECK_NODE(doc, STR("test")); + CHECK_NODE(doc, STR("test")); } @@ -1113,15 +1113,15 @@ TEST_XML(dom_node_append_buffer_remove, "test") CHECK(node.append_buffer(data1, sizeof(data1))); CHECK(node.append_buffer(data2, sizeof(data2))); - CHECK_NODE(doc, STR("testtexttext")); + CHECK_NODE(doc, STR("testtexttext")); while (node.remove_child(STR("child2"))) {} - CHECK_NODE(doc, STR("test")); + CHECK_NODE(doc, STR("test")); while (node.remove_child(STR("child1"))) {} - CHECK_NODE(doc, STR("test")); + CHECK_NODE(doc, STR("test")); while (node.remove_child(STR("child3"))) {} @@ -1140,7 +1140,7 @@ TEST(dom_node_append_buffer_empty_document) doc.append_buffer(data, sizeof(data)); - CHECK_NODE(doc, STR("text")); + CHECK_NODE(doc, STR("text")); } TEST_XML(dom_node_append_buffer_invalid_type, "test") @@ -1158,10 +1158,10 @@ TEST_XML(dom_node_append_buffer_close_external, "") const char data[] = ""; CHECK(node.append_buffer(data, sizeof(data)).status == status_end_element_mismatch); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); CHECK(node.append_buffer(data, sizeof(data)).status == status_end_element_mismatch); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(dom_node_append_buffer_out_of_memory_extra) @@ -1252,7 +1252,7 @@ TEST_XML(dom_node_append_buffer_empty, "") CHECK(node.append_buffer(0, 0).status == status_no_document_element); CHECK(node.append_buffer(0, 0, parse_fragment).status == status_ok); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST_XML(dom_node_prepend_move, "foo") @@ -1267,12 +1267,12 @@ TEST_XML(dom_node_prepend_move, "foo") xml_node n1 = doc.child(STR("node")).prepend_move(doc.child(STR("node")).first_child()); CHECK(n1 && n1 == doc.child(STR("node")).first_child()); CHECK_STRING(n1.value(), STR("foo")); - CHECK_NODE(doc, STR("foo")); + CHECK_NODE(doc, STR("foo")); xml_node n2 = doc.child(STR("node")).prepend_move(doc.child(STR("node")).child(STR("child"))); CHECK(n2 && n2 != n1 && n2 == child); CHECK_STRING(n2.name(), STR("child")); - CHECK_NODE(doc, STR("foo")); + CHECK_NODE(doc, STR("foo")); xml_node n3 = doc.child(STR("node")).child(STR("child")).prepend_move(doc.child(STR("node")).first_child().next_sibling()); CHECK(n3 && n3 == n1 && n3 != n2); @@ -1292,12 +1292,12 @@ TEST_XML(dom_node_append_move, "foo") xml_node n1 = doc.child(STR("node")).append_move(doc.child(STR("node")).first_child()); CHECK(n1 && n1 == doc.child(STR("node")).last_child()); CHECK_STRING(n1.value(), STR("foo")); - CHECK_NODE(doc, STR("foo")); + CHECK_NODE(doc, STR("foo")); xml_node n2 = doc.child(STR("node")).append_move(doc.child(STR("node")).last_child()); CHECK(n2 && n2 == n1); CHECK_STRING(n2.value(), STR("foo")); - CHECK_NODE(doc, STR("foo")); + CHECK_NODE(doc, STR("foo")); xml_node n3 = doc.child(STR("node")).child(STR("child")).append_move(doc.child(STR("node")).last_child()); CHECK(n3 && n3 == n1 && n3 == n2); @@ -1378,7 +1378,7 @@ TEST_XML(dom_node_move_recursive, "foo") CHECK(child.append_move(node) == xml_node()); - CHECK_NODE(doc, STR("foo")); + CHECK_NODE(doc, STR("foo")); } TEST_XML(dom_node_move_marker, "") @@ -1388,7 +1388,7 @@ TEST_XML(dom_node_move_marker, "") CHECK(doc.insert_move_before(node, node) == xml_node()); CHECK(doc.insert_move_after(node, node) == xml_node()); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST_XML(dom_node_move_crossdoc, "") @@ -1418,7 +1418,7 @@ TEST_XML(dom_node_move_tree, "t1t2< // n2 n4 n1 + n3 CHECK(n3 == doc.insert_move_after(n3, root)); - CHECK_NODE(doc, STR("t2t4t1t3")); + CHECK_NODE(doc, STR("t2t4t1t3")); CHECK(n1 == root.child(STR("n1"))); CHECK(n2 == root.child(STR("n2"))); @@ -1454,7 +1454,7 @@ TEST(dom_node_copy_copyless) data += STR(""); for (int i = 0; i < 10000; ++i) data += STR("pcdata"); - data += STR(""); + data += STR(""); std::basic_string datacopy = data; @@ -1500,7 +1500,7 @@ TEST(dom_node_copy_copyless_mix) std::basic_string dataxml; dataxml += STR(""); dataxml += data; - dataxml += STR(""); + dataxml += STR(""); CHECK_NODE(copy, dataxml.c_str()); CHECK_NODE(copy2, dataxml.c_str()); @@ -1511,23 +1511,23 @@ TEST_XML(dom_node_copy_copyless_taint, "") xml_node node = doc.child(STR("node")); xml_node copy = doc.append_copy(node); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); node.set_name(STR("nod1")); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); xml_node copy2 = doc.append_copy(copy); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); copy.attribute(STR("attr")).set_value(STR("valu2")); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); copy2.attribute(STR("attr")).set_name(STR("att3")); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(dom_node_copy_attribute_copyless) @@ -1536,7 +1536,7 @@ TEST(dom_node_copy_attribute_copyless) data += STR(""); + data += STR("\"/>"); std::basic_string datacopy = data; @@ -1571,21 +1571,21 @@ TEST_XML(dom_node_copy_attribute_copyless_taint, "") xml_node copy2 = doc.append_child(STR("copy2")); xml_node copy3 = doc.append_child(STR("copy3")); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); copy1.append_copy(attr); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); attr.set_name(STR("att1")); copy2.append_copy(attr); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); copy1.first_attribute().set_value(STR("valu2")); copy3.append_copy(copy1.first_attribute()); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST_XML(dom_node_copy_out_of_memory_node, "text1text2") diff --git a/tests/test_dom_text.cpp b/tests/test_dom_text.cpp index 7582460..8f62e49 100644 --- a/tests/test_dom_text.cpp +++ b/tests/test_dom_text.cpp @@ -403,16 +403,16 @@ TEST_XML(dom_text_middle, "notthisonetext") CHECK_STRING(t.get(), STR("text")); t.set(STR("notext")); - CHECK_NODE(node, STR("notthisonenotext")); + CHECK_NODE(node, STR("notthisonenotext")); CHECK(node.remove_child(t.data())); CHECK(!t); - CHECK_NODE(node, STR("notthisone")); + CHECK_NODE(node, STR("notthisone")); t.set(STR("yestext")); CHECK(t); - CHECK_NODE(node, STR("notthisoneyestext")); + CHECK_NODE(node, STR("notthisoneyestext")); CHECK(t.data() == node.last_child()); } diff --git a/tests/test_parse.cpp b/tests/test_parse.cpp index bc40815..dc709a2 100644 --- a/tests/test_parse.cpp +++ b/tests/test_parse.cpp @@ -288,38 +288,38 @@ TEST(parse_ws_pcdata_permutations) test_data_t test_data[] = { // external pcdata should be discarded (whitespace or not) - {7, STR("ext1"), STR(""), 2}, - {7, STR("ext1ext2"), STR(""), 2}, - {7, STR(" "), STR(""), 2}, - {7, STR(" "), STR(""), 2}, - {7, STR(" "), STR(""), 2}, + {7, STR("ext1"), STR(""), 2}, + {7, STR("ext1ext2"), STR(""), 2}, + {7, STR(" "), STR(""), 2}, + {7, STR(" "), STR(""), 2}, + {7, STR(" "), STR(""), 2}, // inner pcdata should be preserved {7, STR("inner"), STR("inner"), 3}, - {7, STR("inner1inner2"), STR("inner1inner2"), 5}, + {7, STR("inner1inner2"), STR("inner1inner2"), 5}, {7, STR("inner1deepinner2"), STR("inner1deepinner2"), 6}, // empty pcdata nodes should never be created - {7, STR("inner1inner2"), STR("inner1inner2"), 5}, - {7, STR("inner2"), STR("inner2"), 4}, - {7, STR("inner1"), STR("inner1"), 4}, - {7, STR(""), STR(""), 3}, + {7, STR("inner1inner2"), STR("inner1inner2"), 5}, + {7, STR("inner2"), STR("inner2"), 4}, + {7, STR("inner1"), STR("inner1"), 4}, + {7, STR(""), STR(""), 3}, // comments, pi or other nodes should not cause pcdata creation either - {7, STR(""), STR(""), 4}, + {7, STR(""), STR(""), 4}, // leading/trailing pcdata whitespace should be preserved (note: this will change if parse_ws_pcdata_trim is introduced) {7, STR("\t \tinner1 deep \t\ninner2\n\t"), STR("\t \tinner1 deep \t\ninner2\n\t"), 6}, // whitespace-only pcdata preservation depends on the parsing mode - {1, STR("\n\t \n\t \n\t\n\t"), STR(""), 5}, + {1, STR("\n\t \n\t \n\t\n\t"), STR(""), 5}, {2, STR("\n\t \n\t \n\t\n\t"), STR("\n\t \n\t \n\t\n\t"), 13}, {4, STR("\n\t \n\t \n\t\n\t"), STR(" "), 7}, // current implementation of parse_ws_pcdata_single has an unfortunate bug; reproduce it here {4, STR("\t\t\n\n"), STR("\n\n"), 3}, // error case: terminate PCDATA in the middle {7, STR("abcdef"), STR("abcdef"), -3}, - {5, STR(" "), STR(""), -2}, + {5, STR(" "), STR(""), -2}, {2, STR(" "), STR(" "), -3}, // error case: terminate PCDATA as early as possible - {7, STR(""), STR(""), -2}, + {7, STR(""), STR(""), -2}, {7, STR("a"), STR("a"), -3}, - {5, STR(" "), STR(""), -2}, + {5, STR(" "), STR(""), -2}, {2, STR(" "), STR(" "), -3}, }; @@ -360,18 +360,18 @@ TEST(parse_ws_pcdata_fragment_permutations) {7, STR("ext1"), STR("ext1"), 2}, {5, STR(" "), STR(""), 1}, {2, STR(" "), STR(" "), 2}, - {7, STR("ext1"), STR("ext1"), 3}, - {7, STR("ext2"), STR("ext2"), 3}, - {7, STR("ext1ext2"), STR("ext1ext2"), 4}, - {7, STR("ext1ext2ext3"), STR("ext1ext2ext3"), 6}, - {5, STR(" "), STR(""), 2}, - {2, STR(" "), STR(" "), 3}, - {5, STR(" "), STR(""), 2}, - {2, STR(" "), STR(" "), 3}, - {5, STR(" "), STR(""), 2}, - {2, STR(" "), STR(" "), 4}, - {5, STR(" "), STR(""), 3}, - {2, STR(" "), STR(" "), 6}, + {7, STR("ext1"), STR("ext1"), 3}, + {7, STR("ext2"), STR("ext2"), 3}, + {7, STR("ext1ext2"), STR("ext1ext2"), 4}, + {7, STR("ext1ext2ext3"), STR("ext1ext2ext3"), 6}, + {5, STR(" "), STR(""), 2}, + {2, STR(" "), STR(" "), 3}, + {5, STR(" "), STR(""), 2}, + {2, STR(" "), STR(" "), 3}, + {5, STR(" "), STR(""), 2}, + {2, STR(" "), STR(" "), 4}, + {5, STR(" "), STR(""), 3}, + {2, STR(" "), STR(" "), 6}, }; for (size_t i = 0; i < sizeof(test_data) / sizeof(test_data[0]); ++i) @@ -750,14 +750,14 @@ TEST(parse_tag_single) { xml_document doc; CHECK(doc.load_string(STR(""), parse_minimal)); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(parse_tag_hierarchy) { xml_document doc; CHECK(doc.load_string(STR(""), parse_minimal)); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(parse_tag_error) @@ -894,7 +894,7 @@ TEST(parse_out_of_memory_halfway_node) xml_document doc; CHECK_ALLOC_FAIL(CHECK(doc.load_buffer_inplace(text, count * 4).status == status_out_of_memory)); - CHECK_NODE(doc.first_child(), STR("")); + CHECK_NODE(doc.first_child(), STR("")); } TEST(parse_out_of_memory_halfway_attr) @@ -952,7 +952,7 @@ TEST(parse_out_of_memory_allocator_state_sync) xml_document doc; CHECK_ALLOC_FAIL(CHECK(doc.load_buffer_inplace(text, count * 4).status == status_out_of_memory)); - CHECK_NODE(doc.first_child(), STR("")); + CHECK_NODE(doc.first_child(), STR("")); test_runner::_memory_fail_threshold = 0; @@ -1177,7 +1177,7 @@ TEST(parse_embed_pcdata) CHECK_XPATH_NUMBER(doc, STR("count(node/child/*[starts-with(., 'value')])"), 2); #endif - CHECK_NODE(doc, STR("valuevalue1value2outertext")); + CHECK_NODE(doc, STR("valuevalue1value2outertext")); CHECK_NODE_EX(doc, STR("\nvalue\n\nvalue1\nvalue2outer\ntext\n\n\n"), STR("\t"), 0); CHECK_NODE_EX(doc, STR("\n\tvalue\n\t\n\t\tvalue1\n\t\tvalue2outer\n\ttext\n\t\n\n"), STR("\t"), format_indent); } diff --git a/tests/test_parse_doctype.cpp b/tests/test_parse_doctype.cpp index 901890c..e32af8e 100644 --- a/tests/test_parse_doctype.cpp +++ b/tests/test_parse_doctype.cpp @@ -36,9 +36,9 @@ static bool test_doctype_wf(const char_t* decl) if (!load_concat(doc, STR("a"), decl, STR("b")) || !test_node(doc, STR("ab"), STR(""), format_raw)) return false; // node pre/postfix - if (!load_concat(doc, STR(""), decl) || !test_node(doc, STR(""), STR(""), format_raw)) return false; - if (!load_concat(doc, decl, STR("")) || !test_node(doc, STR(""), STR(""), format_raw)) return false; - if (!load_concat(doc, STR(""), decl, STR("")) || !test_node(doc, STR(""), STR(""), format_raw)) return false; + if (!load_concat(doc, STR(""), decl) || !test_node(doc, STR(""), STR(""), format_raw)) return false; + if (!load_concat(doc, decl, STR("")) || !test_node(doc, STR(""), STR(""), format_raw)) return false; + if (!load_concat(doc, STR(""), decl, STR("")) || !test_node(doc, STR(""), STR(""), format_raw)) return false; // check load-store contents preservation CHECK(doc.load_string(decl, parse_doctype | parse_fragment)); diff --git a/tests/test_write.cpp b/tests/test_write.cpp index df7b0b1..341a4f0 100644 --- a/tests/test_write.cpp +++ b/tests/test_write.cpp @@ -192,12 +192,12 @@ TEST_XML(write_escape_unicode, "") { #ifdef PUGIXML_WCHAR_MODE #ifdef U_LITERALS - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); #else - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); #endif #else - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); #endif } @@ -473,7 +473,7 @@ TEST(write_no_name_element) root.append_child(); root.append_child().append_child(node_pcdata).set_value(STR("text")); - CHECK_NODE(doc, STR("<:anonymous><:anonymous /><:anonymous>text")); + CHECK_NODE(doc, STR("<:anonymous><:anonymous/><:anonymous>text")); CHECK_NODE_EX(doc, STR("<:anonymous>\n\t<:anonymous />\n\t<:anonymous>text\n\n"), STR("\t"), format_default); } @@ -491,7 +491,7 @@ TEST(write_no_name_attribute) doc.append_child().set_name(STR("root")); doc.child(STR("root")).append_attribute(STR("")); - CHECK_NODE(doc, STR("")); + CHECK_NODE(doc, STR("")); } TEST(write_print_empty) @@ -596,7 +596,7 @@ TEST(write_pcdata_whitespace_fixedpoint) TEST_XML_FLAGS(write_mixed, "premidpostfin", parse_full) { - CHECK_NODE(doc, STR("premidpostfin")); + CHECK_NODE(doc, STR("premidpostfin")); CHECK_NODE_EX(doc, STR("\n\npremid\npostfin\n\n\n"), STR("\t"), 0); CHECK_NODE_EX(doc, STR("\n\t\n\tpremid\n\t\tpostfin\n\t\n\n"), STR("\t"), format_indent); } -- cgit v1.2.3