[Expat-checkins] CVS: expat/tests runtests.c,1.3,1.4
Fred L. Drake
fdrake@users.sourceforge.net
Tue Nov 13 09:32:08 2001
Update of /cvsroot/expat/expat/tests
In directory usw-pr-cvs1:/tmp/cvs-serv1219/tests
Modified Files:
runtests.c
Log Message:
Added tests that some basic encodings are recognized and the corresponding
BOM marks do not cause core dumps. The UTF-8 BOM bug was fixed a while ago,
but a regression test is always a good idea.
Index: runtests.c
===================================================================
RCS file: /cvsroot/expat/expat/tests/runtests.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** runtests.c 2001/11/13 05:04:02 1.3
--- runtests.c 2001/11/13 17:31:53 1.4
***************
*** 68,83 ****
END_TEST
static Suite *
make_basic_suite(void)
{
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);
! tcase_add_checked_fixture(tc_nulls, basic_setup, basic_teardown);
! tcase_add_test(tc_nulls, test_nul_byte);
! tcase_add_test(tc_nulls, test_u0000_char);
suite_add_tcase(s, tc_xmldecl);
--- 68,113 ----
END_TEST
+ START_TEST(test_bom_utf8)
+ {
+ /* This test is really just making sure we don't core on a UTF-8 BOM. */
+ char *text = "\357\273\277<e/>";
+ if (!XML_Parse(parser, text, strlen(text), 1))
+ fail("false error reported for UTF-8 BOM");
+ }
+ END_TEST
+
+ START_TEST(test_bom_utf16_be)
+ {
+ char text[] = "\376\377\0<\0e\0/\0>";
+
+ if (!XML_Parse(parser, text, sizeof(text) - 1, 1))
+ fail("false error reported for UTF-16-BE BOM");
+ }
+ END_TEST
+
+ START_TEST(test_bom_utf16_le)
+ {
+ char text[] = "\377\376<\0e\0/\0>\0";
+
+ if (!XML_Parse(parser, text, sizeof(text) - 1, 1))
+ fail("false error reported for UTF-16-LE BOM");
+ }
+ END_TEST
+
static Suite *
make_basic_suite(void)
{
Suite *s = suite_create("basic");
! TCase *tc_chars = tcase_create("character tests");
TCase *tc_xmldecl = tcase_create("XML declaration");
! suite_add_tcase(s, tc_chars);
! tcase_add_checked_fixture(tc_chars, basic_setup, basic_teardown);
! tcase_add_test(tc_chars, test_nul_byte);
! tcase_add_test(tc_chars, test_u0000_char);
! tcase_add_test(tc_chars, test_bom_utf8);
! tcase_add_test(tc_chars, test_bom_utf16_be);
! tcase_add_test(tc_chars, test_bom_utf16_le);
suite_add_tcase(s, tc_xmldecl);
***************
*** 92,107 ****
main(int argc, char *argv[])
{
! int nf;
int verbosity = CK_NORMAL;
Suite *s = make_basic_suite();
SRunner *sr = srunner_create(s);
! if (argc >= 2) {
! char *opt = argv[1];
if (strcmp(opt, "-v") == 0 || strcmp(opt, "--verbose") == 0)
verbosity = CK_VERBOSE;
else if (strcmp(opt, "-q") == 0 || strcmp(opt, "--quiet") == 0)
verbosity = CK_SILENT;
}
srunner_run_all(sr, verbosity);
nf = srunner_ntests_failed(sr);
--- 122,148 ----
main(int argc, char *argv[])
{
! int i, nf;
! int forking = 0, forking_set = 0;
int verbosity = CK_NORMAL;
Suite *s = make_basic_suite();
SRunner *sr = srunner_create(s);
! for (i = 1; i < argc; ++i) {
! char *opt = argv[i];
if (strcmp(opt, "-v") == 0 || strcmp(opt, "--verbose") == 0)
verbosity = CK_VERBOSE;
else if (strcmp(opt, "-q") == 0 || strcmp(opt, "--quiet") == 0)
verbosity = CK_SILENT;
+ else if (strcmp(opt, "-f") == 0 || strcmp(opt, "--fork") == 0) {
+ forking = 1;
+ forking_set = 1;
+ }
+ else if (strcmp(opt, "-n") == 0 || strcmp(opt, "--no-fork") == 0) {
+ forking = 0;
+ forking_set = 1;
+ }
}
+ if (forking_set)
+ srunner_set_fork_status(sr, forking ? CK_FORK : CK_NOFORK);
srunner_run_all(sr, verbosity);
nf = srunner_ntests_failed(sr);