From 1bc717dc54b9964e7c62082b34d2d74e3daaa6a6 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 28 Aug 2016 00:20:02 -0400 Subject: add te parser (not working) --- test.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'test.c') diff --git a/test.c b/test.c index fc209b9..98e09d3 100644 --- a/test.c +++ b/test.c @@ -145,12 +145,54 @@ test_percent(void) { } } +/******************/ +/* te parser test */ +/******************/ + +static const char * +te_parser_tests[] = { + "gzip", + "deflate", + "gzip,deflate,chunked", + "gzip, deflate, chunked", + "deflate , gzip , chunked ", + " deflate , gzip , chunked ", + NULL +}; + +static void +test_te_parser(void) { + for (size_t i = 0; te_parser_tests[i]; i++) { + fhp_err_t err; + + // get test string + const char *s = te_parser_tests[i]; + + // init parser + fhp_te_parser_t p; + fhp_te_parser_init(&p); + + // parse data + if ((err = fhp_te_parser_push(&p, s, strlen(s))) != FHP_OK) { + die("test_te_parser", "fhp_te_parser_push", err); + } + + // finish parsing + if ((err = fhp_te_parser_done(&p)) != FHP_OK) { + die("test_te_parser", "fhp_te_parser_push", err); + } + + fprintf(stderr, "te test: \"%s\", p->num_tes = %u\n", s, p.num_tes); + } +} + int main(int argc, char *argv[]) { UNUSED(argc); UNUSED(argv); test_basic(); test_percent(); + test_te_parser(); return EXIT_SUCCESS; } -- cgit v1.2.3