From 5d66ae9fb952a0954df5ae35df93191e7c73feac Mon Sep 17 00:00:00 2001 From: halex2005 Date: Tue, 14 Apr 2015 00:56:42 +0500 Subject: add tests for aligning each attribute on next line --- tests/test_write.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests/test_write.cpp') diff --git a/tests/test_write.cpp b/tests/test_write.cpp index af4acf4..d280840 100644 --- a/tests/test_write.cpp +++ b/tests/test_write.cpp @@ -21,6 +21,21 @@ TEST_XML(write_indent, "text") CHECK_NODE_EX(doc, STR("\n\t\n\t\ttext\n\t\n\n"), STR("\t"), format_indent); } +TEST_XML(write_indent_attribute, "text") +{ + CHECK_NODE_EX(doc, STR("\n\t\n\t\ttext\n\t\n\n"), STR("\t"), format_indent_attributes); +} + +TEST_XML(write_indent_attribute_empty_tag, "") +{ + CHECK_NODE_EX(doc, STR("\n"), STR("\t"), format_indent_attributes); +} + +TEST_XML_FLAGS(write_indent_attribute_on_declaration, "", pugi::parse_full) +{ + CHECK_NODE_EX(doc, STR("\n\n"), STR("\t"), format_indent_attributes); +} + TEST_XML(write_pcdata, "text") { CHECK_NODE_EX(doc, STR("\n\t\n\t\ttext\n\n"), STR("\t"), format_indent); @@ -360,7 +375,7 @@ TEST(write_encoding_huge_invalid) TEST(write_unicode_escape) { char s_utf8[] = "<\xE2\x82\xAC \xC2\xA2='\"\xF0\xA4\xAD\xA2 \"'>&\x14\xF0\xA4\xAD\xA2<"; - + xml_document doc; CHECK(doc.load_buffer(s_utf8, sizeof(s_utf8), parse_default, encoding_utf8)); -- cgit v1.2.3 From 2a3435274f0d7d0e3ccb4417e143e5957e820332 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Mon, 13 Apr 2015 21:21:26 -0700 Subject: Refactor format_indent_attributes implementation Fix code style and revert redundant parameters/whitespace changes. Also remove format_each_attribute_on_new_line - we're only introducing one extra formatting flag. The flag implies format_indent but does not include its bitmask. Also add a few more tests. Fixes #14. --- tests/test_write.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'tests/test_write.cpp') diff --git a/tests/test_write.cpp b/tests/test_write.cpp index d280840..df7b0b1 100644 --- a/tests/test_write.cpp +++ b/tests/test_write.cpp @@ -21,21 +21,31 @@ TEST_XML(write_indent, "text") CHECK_NODE_EX(doc, STR("\n\t\n\t\ttext\n\t\n\n"), STR("\t"), format_indent); } -TEST_XML(write_indent_attribute, "text") +TEST_XML(write_indent_attributes, "text") { CHECK_NODE_EX(doc, STR("\n\t\n\t\ttext\n\t\n\n"), STR("\t"), format_indent_attributes); } -TEST_XML(write_indent_attribute_empty_tag, "") +TEST_XML(write_indent_attributes_empty_element, "") { CHECK_NODE_EX(doc, STR("\n"), STR("\t"), format_indent_attributes); } -TEST_XML_FLAGS(write_indent_attribute_on_declaration, "", pugi::parse_full) +TEST_XML_FLAGS(write_indent_attributes_declaration, "", parse_full) { CHECK_NODE_EX(doc, STR("\n\n"), STR("\t"), format_indent_attributes); } +TEST_XML(write_indent_attributes_raw, "text") +{ + CHECK_NODE_EX(doc, STR("text"), STR("\t"), format_indent_attributes | format_raw); +} + +TEST_XML(write_indent_attributes_empty_indent, "text") +{ + CHECK_NODE_EX(doc, STR("\n\ntext\n\n\n"), STR(""), format_indent_attributes); +} + TEST_XML(write_pcdata, "text") { CHECK_NODE_EX(doc, STR("\n\t\n\t\ttext\n\n"), STR("\t"), format_indent); -- cgit v1.2.3