[Expat-checkins] CVS: expat/tests runtests.c,1.1,1.2
Fred L. Drake
fdrake@users.sourceforge.net
Mon Nov 12 20:50:02 2001
Update of /cvsroot/expat/expat/tests
In directory usw-pr-cvs1:/tmp/cvs-serv4714/tests
Modified Files:
runtests.c
Log Message:
Added a test that ensures the parser reports an out-of-place XML declaration.
(Originally written to attempt to tickle a different bug, but useful as a
regression test even though Expat has been doing the right thing.)
Index: runtests.c
===================================================================
RCS file: /cvsroot/expat/expat/tests/runtests.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** runtests.c 2001/08/17 19:16:41 1.1
--- runtests.c 2001/11/13 04:49:52 1.2
***************
*** 55,58 ****
--- 55,79 ----
+ START_TEST(test_xmldecl_misplaced)
+ {
+ char *text =
+ "\n"
+ "<?xml version='1.0'?>\n"
+ "<a>&eee;</a>";
+
+ if (parser == NULL)
+ fail("Parser not created.");
+
+ if (!XML_Parse(parser, text, strlen(text), 1)) {
+ fail_unless(XML_GetErrorCode(parser) == XML_ERROR_MISPLACED_XML_PI,
+ "wrong error when XML declaration is misplaced");
+ }
+ else {
+ fail("expected XML_ERROR_MISPLACED_XML_PI with misplaced XML decl");
+ }
+ }
+ END_TEST
+
+
static Suite *
make_basic_suite(void)
***************
*** 60,63 ****
--- 81,85 ----
Suite *s = suite_create("basic");
TCase *tc_nulls = tcase_create("null characters");
+ TCase *tc_xmldecl = tcase_create("XML declaration");
suite_add_tcase(s, tc_nulls);
***************
*** 65,68 ****
--- 87,94 ----
tcase_add_test(tc_nulls, test_nul_byte);
tcase_add_test(tc_nulls, test_u0000_char);
+
+ suite_add_tcase(s, tc_xmldecl);
+ tcase_set_fixture(tc_xmldecl, basic_setup, basic_teardown);
+ tcase_add_test(tc_xmldecl, test_xmldecl_misplaced);
return s;