diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-04-12 03:05:58 -0700 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-04-12 03:05:58 -0700 |
commit | a19da1c246f244da57197915df3ab70f24bf1502 (patch) | |
tree | 08522294870adb468c37042365095ebbae2c0177 /tests/test_write.cpp | |
parent | e90d2ac8ba44fbcf4d5702643f708f2c86bde42e (diff) | |
parent | a0d065cd22d1d43c417f6d3db88a04bf57b67ed0 (diff) |
Merge branch 'master' into compact
Diffstat (limited to 'tests/test_write.cpp')
-rw-r--r-- | tests/test_write.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_write.cpp b/tests/test_write.cpp index ad6c409..af4acf4 100644 --- a/tests/test_write.cpp +++ b/tests/test_write.cpp @@ -4,6 +4,7 @@ #include <string> #include <sstream> +#include <stdexcept> TEST_XML(write_simple, "<node attr='1'><child>text</child></node>") { @@ -574,3 +575,41 @@ TEST_XML_FLAGS(write_mixed, "<node><child1/><child2>pre<![CDATA[data]]>mid<!--co CHECK_NODE_EX(doc, STR("<node>\n<child1 />\n<child2>pre<![CDATA[data]]>mid<!--comment-->\n<test />post<?pi value?>fin</child2>\n<child3 />\n</node>\n"), STR("\t"), 0); CHECK_NODE_EX(doc, STR("<node>\n\t<child1 />\n\t<child2>pre<![CDATA[data]]>mid<!--comment-->\n\t\t<test />post<?pi value?>fin</child2>\n\t<child3 />\n</node>\n"), STR("\t"), format_indent); } + +#ifndef PUGIXML_NO_EXCEPTIONS +struct throwing_writer: pugi::xml_writer +{ + virtual void write(const void*, size_t) + { + throw std::runtime_error("write failed"); + } +}; + +TEST_XML(write_throw_simple, "<node><child/></node>") +{ + try + { + throwing_writer w; + doc.print(w); + + CHECK_FORCE_FAIL("Expected exception"); + } + catch (std::runtime_error&) + { + } +} + +TEST_XML(write_throw_encoding, "<node><child/></node>") +{ + try + { + throwing_writer w; + doc.print(w, STR("\t"), format_default, encoding_utf32_be); + + CHECK_FORCE_FAIL("Expected exception"); + } + catch (std::runtime_error&) + { + } +} +#endif |