expat/tests runtests.c,1.42,1.43

"Fred L. Drake" <[email protected]>
Newsgroups gmane.text.xml.expat.cvs
Message-ID <[email protected]>
Update of /cvsroot/expat/expat/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv9871

Modified Files:
	runtests.c 
Log Message:
Fix test case regarding reporting of undefined entities and
non-validating parsers (see section 5.1 of the XML 1.0 specification).


Index: runtests.c
===================================================================
RCS file: /cvsroot/expat/expat/tests/runtests.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- runtests.c	20 Jan 2003 14:49:44 -0000	1.42
+++ runtests.c	21 Jan 2003 05:41:24 -0000	1.43
@@ -827,11 +827,11 @@
 }
 
 /* Test that an error is reported for unknown entities if we have read
-   an external subset.
+   an external subset, and standalone is true.
 */
-START_TEST(test_wfc_undeclared_entity_with_external_subset) {
+START_TEST(test_wfc_undeclared_entity_with_external_subset_standalone) {
     char *text =
-        "<?xml version='1.0' encoding='us-ascii'?>\n"
+        "<?xml version='1.0' encoding='us-ascii' standalone='yes'?>\n"
         "<!DOCTYPE doc SYSTEM 'foo'>\n"
         "<doc>&entity;</doc>";
     char *foo_text =
@@ -846,6 +846,25 @@
 }
 END_TEST
 
+/* Test that no error is reported for unknown entities if we have read
+   an external subset, and standalone is false.
+*/
+START_TEST(test_wfc_undeclared_entity_with_external_subset) {
+    char *text =
+        "<?xml version='1.0' encoding='us-ascii'?>\n"
+        "<!DOCTYPE doc SYSTEM 'foo'>\n"
+        "<doc>&entity;</doc>";
+    char *foo_text =
+        "<!ELEMENT doc (#PCDATA)*>";
+
+    XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
+    XML_SetUserData(parser, foo_text);
+    XML_SetExternalEntityRefHandler(parser, external_entity_loader);
+    if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+        xml_failure(parser);
+}
+END_TEST
+
 START_TEST(test_wfc_no_recursive_entity_refs)
 {
     char *text =
@@ -1165,6 +1184,8 @@
     tcase_add_test(tc_basic, test_wfc_undeclared_entity_no_external_subset);
     tcase_add_test(tc_basic, test_wfc_undeclared_entity_standalone);
     tcase_add_test(tc_basic, test_wfc_undeclared_entity_with_external_subset);
+    tcase_add_test(tc_basic,
+                   test_wfc_undeclared_entity_with_external_subset_standalone);
     tcase_add_test(tc_basic, test_wfc_no_recursive_entity_refs);
     tcase_add_test(tc_basic, test_ext_entity_set_encoding);
     tcase_add_test(tc_basic, test_dtd_default_handling);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.