mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-23 01:52:48 +03:00
reader: Add tests for content accessors
This commit is contained in:
36
testparser.c
36
testparser.c
@@ -209,6 +209,41 @@ testReaderEncoding(void) {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
testReaderContent(void) {
|
||||||
|
xmlTextReader *reader;
|
||||||
|
const xmlChar *xml = BAD_CAST "<d>x<e>y</e><f>z</f></d>";
|
||||||
|
xmlChar *string;
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
|
reader = xmlReaderForDoc(xml, NULL, NULL, 0);
|
||||||
|
xmlTextReaderRead(reader);
|
||||||
|
|
||||||
|
string = xmlTextReaderReadOuterXml(reader);
|
||||||
|
if (!xmlStrEqual(string, xml)) {
|
||||||
|
fprintf(stderr, "xmlTextReaderReadOuterXml failed\n");
|
||||||
|
err = 1;
|
||||||
|
}
|
||||||
|
xmlFree(string);
|
||||||
|
|
||||||
|
string = xmlTextReaderReadInnerXml(reader);
|
||||||
|
if (!xmlStrEqual(string, BAD_CAST "x<e>y</e><f>z</f>")) {
|
||||||
|
fprintf(stderr, "xmlTextReaderReadInnerXml failed\n");
|
||||||
|
err = 1;
|
||||||
|
}
|
||||||
|
xmlFree(string);
|
||||||
|
|
||||||
|
string = xmlTextReaderReadString(reader);
|
||||||
|
if (!xmlStrEqual(string, BAD_CAST "xyz")) {
|
||||||
|
fprintf(stderr, "xmlTextReaderReadString failed\n");
|
||||||
|
err = 1;
|
||||||
|
}
|
||||||
|
xmlFree(string);
|
||||||
|
|
||||||
|
xmlFreeTextReader(reader);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *message;
|
char *message;
|
||||||
@@ -350,6 +385,7 @@ main(void) {
|
|||||||
#endif
|
#endif
|
||||||
#ifdef LIBXML_READER_ENABLED
|
#ifdef LIBXML_READER_ENABLED
|
||||||
err |= testReaderEncoding();
|
err |= testReaderEncoding();
|
||||||
|
err |= testReaderContent();
|
||||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||||
err |= testReaderXIncludeError();
|
err |= testReaderXIncludeError();
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user