From 87d4f03187c66181c47696f879542b5bf911e8c4 Mon Sep 17 00:00:00 2001
From: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Date: Tue, 14 Oct 2014 04:11:26 +0000
Subject: [PATCH] tests: Add a test for printing comments that contain --

git-svn-id: https://pugixml.googlecode.com/svn/trunk@1059 99668b35-9821-0410-8761-19e4c4f06640
---
 tests/test_write.cpp | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tests/test_write.cpp b/tests/test_write.cpp
index 0c20e26f..98650ac5 100644
--- a/tests/test_write.cpp
+++ b/tests/test_write.cpp
@@ -57,6 +57,29 @@ TEST_XML_FLAGS(write_comment, "<!--text-->", parse_comments | parse_fragment)
 	CHECK_NODE_EX(doc, STR("<!--text-->\n"), STR(""), 0);
 }
 
+TEST(write_comment_invalid)
+{
+	xml_document doc;
+	xml_node child = doc.append_child(node_comment);
+
+	CHECK_NODE(doc, STR("<!---->"));
+
+	child.set_value(STR("-"));
+	CHECK_NODE(doc, STR("<!--- -->"));
+
+	child.set_value(STR("--"));
+	CHECK_NODE(doc, STR("<!--- - -->"));
+
+	child.set_value(STR("---"));
+	CHECK_NODE(doc, STR("<!--- - - -->"));
+
+	child.set_value(STR("-->"));
+	CHECK_NODE(doc, STR("<!--- ->-->"));
+
+	child.set_value(STR("-->-"));
+	CHECK_NODE(doc, STR("<!--- ->- -->"));
+}
+
 TEST_XML_FLAGS(write_pi, "<?name value?>", parse_pi | parse_fragment)
 {
 	CHECK_NODE(doc, STR("<?name value?>"));
-- 
GitLab