]> granicus.if.org Git - libexpat/commitdiff
Test a bad encoding is rejected at initialisation time
authorRhodri James <rhodri@kynesim.co.uk>
Tue, 28 Feb 2017 15:33:55 +0000 (15:33 +0000)
committerSebastian Pipping <sebastian@pipping.org>
Sat, 22 Jul 2017 19:25:49 +0000 (21:25 +0200)
expat/tests/runtests.c

index 9ad3b0736eafb8dec2bbe9263482c40ee309d9b9..12542724943dab8ae493991722b2591b70ef4e0f 100644 (file)
@@ -681,6 +681,19 @@ START_TEST(test_not_utf16)
 }
 END_TEST
 
+/* Test that an unknown encoding is rejected */
+START_TEST(test_bad_encoding)
+{
+    const char *text = "<doc>Hi</doc>";
+
+    if (!XML_SetEncoding(parser, "unknown-encoding"))
+        fail("XML_SetEncoding failed");
+    expect_failure(text,
+                   XML_ERROR_UNKNOWN_ENCODING,
+                   "Unknown encoding not faulted");
+}
+END_TEST
+
 /* Regression test for SF bug #481609, #774028. */
 START_TEST(test_latin1_umlauts)
 {
@@ -5865,6 +5878,7 @@ make_suite(void)
     tcase_add_test(tc_basic, test_utf16);
     tcase_add_test(tc_basic, test_utf16_le_epilog_newline);
     tcase_add_test(tc_basic, test_not_utf16);
+    tcase_add_test(tc_basic, test_bad_encoding);
     tcase_add_test(tc_basic, test_latin1_umlauts);
     /* Regression test for SF bug #491986. */
     tcase_add_test(tc_basic, test_danish_latin1);