From 4226a8f63becd0ce5d281d6822a917101c736a0c Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 20 Nov 2009 15:40:55 +0100 Subject: [PATCH] add tests for should_keep_alive() --- test.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test.c b/test.c index 8658235..2d392c5 100644 --- a/test.c +++ b/test.c @@ -631,6 +631,7 @@ headers_complete_cb (http_parser *parser) messages[num_messages].http_major = parser->http_major; messages[num_messages].http_minor = parser->http_minor; messages[num_messages].headers_complete_cb_called = TRUE; + messages[num_messages].should_keep_alive = http_should_keep_alive(parser); return 0; } @@ -638,6 +639,14 @@ int message_complete_cb (http_parser *parser) { assert(parser); + if (messages[num_messages].should_keep_alive != http_should_keep_alive(parser)) + { + fprintf(stderr, "\n\n *** Error http_should_keep_alive() should have same " + "value in both on_message_complete and on_headers_complete " + "but it doesn't! ***\n\n"); + assert(0); + exit(1); + } messages[num_messages].message_complete_cb_called = TRUE; num_messages++; return 0; @@ -714,6 +723,8 @@ message_eq (int index, const struct message *expected) MESSAGE_CHECK_NUM_EQ(expected, m, status_code); } + MESSAGE_CHECK_NUM_EQ(expected, m, should_keep_alive); + assert(m->message_begin_cb_called); assert(m->headers_complete_cb_called); assert(m->message_complete_cb_called);