From 80cac4a7800f377707ac18aaa8b50a508f005a37 Mon Sep 17 00:00:00 2001 From: "Fred L. Drake, Jr." Date: Fri, 23 Aug 2002 03:14:01 +0000 Subject: [PATCH] Renamed the last test added to be more clear about the condition being tested. Added a couple of additional tests checking for proper response to the same well-formedness constraint. No bugs to fix there, just trying to improve the coverage of the test suite. --- expat/tests/runtests.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index 0d513759..fdfcd5a8 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -511,7 +511,7 @@ END_TEST /* Test that no error is reported for unknown entities if we don't read an external subset. This was fixed in Expat 1.95.5. */ -START_TEST(test_wfc_declared_entity_unread_external_subset) { +START_TEST(test_wfc_undeclared_entity_unread_external_subset) { char *text = "\n" "&entity;"; @@ -521,6 +521,35 @@ START_TEST(test_wfc_declared_entity_unread_external_subset) { } END_TEST +/* Test that an error is reported for unknown entities if we don't + have an external subset. +*/ +START_TEST(test_wfc_undeclared_entity_no_external_subset) { + char *text = "&entity;"; + + if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_OK) + fail("Parser did not report error on undefined entity w/out a DTD."); + if (XML_GetErrorCode(parser) != XML_ERROR_UNDEFINED_ENTITY) + xml_failure(parser); +} +END_TEST + +/* Test that an error is reported for unknown entities if we don't + read an external subset, but have been declared standalone. +*/ +START_TEST(test_wfc_undeclared_entity_standalone) { + char *text = + "\n" + "\n" + "&entity;"; + + if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_OK) + fail("Parser did not report error on undefined entity (standalone)."); + if (XML_GetErrorCode(parser) != XML_ERROR_UNDEFINED_ENTITY) + xml_failure(parser); +} +END_TEST + /* * Namespaces tests. @@ -703,7 +732,10 @@ make_basic_suite(void) tcase_add_test(tc_basic, test_attr_whitespace_normalization); tcase_add_test(tc_basic, test_xmldecl_misplaced); tcase_add_test(tc_basic, test_unknown_encoding_internal_entity); - tcase_add_test(tc_basic, test_wfc_declared_entity_unread_external_subset); + tcase_add_test(tc_basic, + test_wfc_undeclared_entity_unread_external_subset); + tcase_add_test(tc_basic, test_wfc_undeclared_entity_no_external_subset); + tcase_add_test(tc_basic, test_wfc_undeclared_entity_standalone); suite_add_tcase(s, tc_namespace); tcase_add_checked_fixture(tc_namespace, -- 2.40.0