summaryrefslogtreecommitdiff
path: root/test/xml.c
diff options
context:
space:
mode:
authorjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2004-10-17 13:06:00 +0000
committerjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2004-10-17 13:06:00 +0000
commitd01dd904918f1628e2708b5dc7595089cc688bc0 (patch)
tree5f055655de6ec0f568c5b5f4769a62e7cb9e6b03 /test/xml.c
parent3aa536fc208b12a335be934350b2d5c7b17a6d22 (diff)
downloadneon-d01dd904918f1628e2708b5dc7595089cc688bc0.tar.gz
* src/ne_xml.h (ne_xml_parse): Returns an error if parsing fails.
(ne_xml_failed): Redefine in terms of ne_xml_parse return value. * src/ne_xml.c (ne_xml_parse): Return p->failure. (ne_xml_parse_v): Pass through return value from ne_xml_parse. * test/xml.c (parse_match): Check ne_xml_parse() return value; handle match_chunked test mode. (matches): Test for UTF-8 BOM handling in chunked mode. git-svn-id: http://svn.webdav.org/repos/projects/neon/trunk@315 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845
Diffstat (limited to 'test/xml.c')
-rw-r--r--test/xml.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/test/xml.c b/test/xml.c
index b949455..ad9ab9a 100644
--- a/test/xml.c
+++ b/test/xml.c
@@ -156,17 +156,20 @@ static int endelm_abort(void *buf, int state,
return 0;
}
+/* Test mode for parse_match: */
enum match_type {
- match_valid = 0,
- match_invalid,
- match_nohands,
- match_encoding
+ match_valid = 0, /* test that the parse succeeds */
+ match_invalid, /* test that the parse fails */
+ match_nohands, /* test with no handlers registered */
+ match_encoding, /* test whether the encoding is equal to the result string */.
+ match_chunked /* parse the document one byte at a time */
};
static int parse_match(const char *doc, const char *result, enum match_type t)
{
ne_xml_parser *p = ne_xml_create();
ne_buffer *buf = ne_buffer_create();
+ int ret;
if (t == match_invalid)
ne_xml_push_handler(p, startelm_abort, chardata, endelm_abort, buf);
@@ -176,15 +179,26 @@ static int parse_match(const char *doc, const char *result, enum match_type t)
ne_xml_push_handler(p, startelm_xform, chardata, endelm_xform, buf);
}
- ne_xml_parse(p, doc, strlen(doc));
- ne_xml_parse(p, "", 0);
-
+ if (t == match_chunked) {
+ do {
+ ret = ne_xml_parse(p, doc++, 1);
+ } while (ret == 0 && *doc);
+ } else {
+ ret = ne_xml_parse(p, doc, strlen(doc));
+ }
+
+ if (ret == 0) {
+ ne_xml_parse(p, "", 0);
+ }
+
+ ONV(ret != ne_xml_failed(p),
+ ("ne_xml_failed gave %d not %d", ne_xml_failed(p), ret));
+
if (t == match_invalid)
- ONV(ne_xml_failed(p) != ABORT,
- ("parse got %d not abort failure: %s",
- ne_xml_failed(p), buf->data));
+ ONV(ret != ABORT,
+ ("parse got %d not abort failure: %s", ret, buf->data));
else
- ONV(ne_xml_failed(p), ("parse failed: %s", ne_xml_get_error(p)));
+ ONV(ret, ("parse failed: %s", ne_xml_get_error(p)));
if (t == match_encoding) {
const char *enc = ne_xml_doc_encoding(p);
@@ -221,6 +235,8 @@ static int matches(void)
/* UTF-8 XML Byte Order Mark */
{ "\xEF\xBB\xBF" PFX "<hello/>", "<{}hello></{}hello>" },
+ /* UTF-8 XML Byte Order Mark */
+ { "\xEF\xBB\xBF" PFX "<hello/>", "<{}hello></{}hello>", match_chunked },
/*** Tests for namespace handling. ***/
#define NSA "xmlns:foo='bar'"