Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Commit

Permalink
test: Check that message_begin, message_complete, headers_complete al…
Browse files Browse the repository at this point in the history
…ways called
  • Loading branch information
ry committed Jun 9, 2009
1 parent 9367b74 commit 88049b0
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ struct message {
enum { NONE=0, FIELD, VALUE } last_header_element;
char headers [MAX_HEADERS][2][MAX_ELEMENT_SIZE];
int should_keep_alive;

int message_begin_cb_called;
int headers_complete_cb_called;
int message_complete_cb_called;
};

static struct message messages[5];
Expand Down Expand Up @@ -422,13 +426,23 @@ message_complete_cb (http_parser *parser)
messages[num_messages].method = parser->method;
messages[num_messages].status_code = parser->status_code;

messages[num_messages].message_complete_cb_called = TRUE;

num_messages++;
return 0;
}

int
message_begin_cb (http_parser *_)
{
messages[num_messages].message_begin_cb_called = TRUE;
return 0;
}

int
headers_complete_cb (http_parser *_)
{
messages[num_messages].headers_complete_cb_called = TRUE;
return 0;
}

Expand All @@ -449,7 +463,7 @@ parser_init (enum http_parser_type type)
parser.on_fragment = fragment_cb;
parser.on_query_string = query_string_cb;
parser.on_body = body_cb;
parser.on_headers_complete = NULL;
parser.on_headers_complete = headers_complete_cb;
parser.on_message_complete = message_complete_cb;
}

Expand All @@ -462,6 +476,10 @@ message_eq (int index, const struct message *expected)
assert(m->method == expected->method);
assert(m->status_code == expected->status_code);

assert(m->message_begin_cb_called);
assert(m->headers_complete_cb_called);
assert(m->message_complete_cb_called);

assert(0 == strcmp(m->body, expected->body));
assert(0 == strcmp(m->fragment, expected->fragment));
assert(0 == strcmp(m->query_string, expected->query_string));
Expand Down

0 comments on commit 88049b0

Please sign in to comment.