diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2017-02-01 21:07:46 -0800 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2017-02-01 21:07:46 -0800 |
commit | f9f1c867166d9d07ebe2b370b7951d68c1f5c3ff (patch) | |
tree | 63372994cbb83605ec2990d4cfb3e9b26933dc5d /tests | |
parent | 0e3ccc73965b10c078fba31967c5d5500dade767 (diff) |
tests: Improve parsing coverage
Add tests for PI erroring exactly at the buffer boundary with
non-zero-terminated buffers (so we have to clear the last character
which changes the parsing flow slightly) and a test that makes sure
parse_embed_pcdata works properly with XML fragments where PCDATA can be
at the root level but can't be embedded into the document node.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_parse.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_parse.cpp b/tests/test_parse.cpp index efc3ca6..94e6f24 100644 --- a/tests/test_parse.cpp +++ b/tests/test_parse.cpp @@ -88,6 +88,16 @@ TEST(parse_pi_error) CHECK(doc.load_string(STR("<?name& x?>"), parse_fragment | parse_pi).status == status_bad_pi); } +TEST(parse_pi_error_buffer_boundary) +{ + char buf1[] = "<?name?>"; + char buf2[] = "<?name?x"; + + xml_document doc; + CHECK(doc.load_buffer_inplace(buf1, 8, parse_fragment | parse_pi)); + CHECK(doc.load_buffer_inplace(buf2, 8, parse_fragment | parse_pi).status == status_bad_pi); +} + TEST(parse_comments_skip) { xml_document doc; @@ -1213,6 +1223,13 @@ TEST(parse_embed_pcdata) } } +TEST_XML_FLAGS(parse_embed_pcdata_fragment, "text", parse_fragment | parse_embed_pcdata) +{ + CHECK_NODE(doc, STR("text")); + CHECK(doc.first_child().type() == node_pcdata); + CHECK_STRING(doc.first_child().value(), STR("text")); +} + TEST(parse_encoding_detect) { char test[] = "<?xml version='1.0' encoding='utf-8'?><n/>"; |