summaryrefslogtreecommitdiff
path: root/tests/test_write.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_write.cpp')
-rw-r--r--tests/test_write.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_write.cpp b/tests/test_write.cpp
index 5cd92a5..be77aa8 100644
--- a/tests/test_write.cpp
+++ b/tests/test_write.cpp
@@ -639,6 +639,33 @@ TEST_XML_FLAGS(write_roundtrip, "<node><child1 attr1='value1' attr2='value2'/><c
}
}
+TEST(write_flush_coverage)
+{
+ xml_document doc;
+
+ // this creates a node that uses short sequences of lengths 1-6 for output
+ xml_node n = doc.append_child(STR("n"));
+
+ xml_attribute a = n.append_attribute(STR("a"));
+
+ xml_attribute b = n.append_attribute(STR("b"));
+ b.set_value(STR("<&\""));
+
+ n.append_child(node_comment);
+
+ size_t basel = save_narrow(doc, format_raw, encoding_auto).size();
+ size_t bufl = 2048;
+
+ for (size_t l = 0; l <= basel; ++l)
+ {
+ std::basic_string<pugi::char_t> pad(bufl - l, STR('v'));
+ a.set_value(pad.c_str());
+
+ std::string s = save_narrow(doc, format_raw, encoding_auto);
+ CHECK(s.size() == basel + bufl - l);
+ }
+}
+
#ifndef PUGIXML_NO_EXCEPTIONS
struct throwing_writer: pugi::xml_writer
{