]> granicus.if.org Git - libexpat/commitdiff
Extend coverage of byte information function tests
authorRhodri James <rhodri@kynesim.co.uk>
Wed, 8 Feb 2017 13:54:59 +0000 (13:54 +0000)
committerSebastian Pipping <sebastian@pipping.org>
Mon, 13 Mar 2017 14:39:38 +0000 (15:39 +0100)
expat/tests/runtests.c

index 15bd505c98937421c597c55ab28f3f4bd6a0e130..fa07d5a70edf84509f3450075e80270cc57311eb 100644 (file)
@@ -2224,6 +2224,21 @@ START_TEST(test_byte_info_at_end)
 }
 END_TEST
 
+/* Test position information from errors */
+START_TEST(test_byte_info_at_error)
+{
+    const char *text = "<doc></wombat></doc>";
+
+    if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
+                                XML_TRUE) == XML_STATUS_OK)
+        fail("Syntax error not faulted");
+    if (XML_GetCurrentByteCount(parser) != 0)
+        fail("Error byte count incorrect");
+    if (XML_GetCurrentByteIndex(parser) != 7)
+        fail("Error byte index incorrect");
+}
+END_TEST
+
 
 /*
  * Namespaces tests.
@@ -3302,6 +3317,7 @@ make_suite(void)
     tcase_add_test(tc_basic, test_get_buffer_1);
     tcase_add_test(tc_basic, test_get_buffer_2);
     tcase_add_test(tc_basic, test_byte_info_at_end);
+    tcase_add_test(tc_basic, test_byte_info_at_error);
 
     suite_add_tcase(s, tc_namespace);
     tcase_add_checked_fixture(tc_namespace,