From b249a2f69f1516c760babf65def1e5affc110f9f Mon Sep 17 00:00:00 2001 From: bel Date: Wed, 29 Jul 2015 23:55:55 +0200 Subject: [PATCH] More unit tests --- test/public.c | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/test/public.c b/test/public.c index 4720ac9f..ba77e2f0 100644 --- a/test/public.c +++ b/test/public.c @@ -432,7 +432,8 @@ START_TEST(test_mg_start_stop_https_server) "listening_ports", "8080,8443s", "ssl_certificate", - "resources/ssl_cert.pem", // TODO: check working path of CI test system + "../resources/ssl_cert.pem", // TODO: check working path of CI test + // system NULL, }; size_t ports_cnt; @@ -446,11 +447,13 @@ START_TEST(test_mg_start_stop_https_server) ck_assert(ctx != NULL); ports_cnt = mg_get_ports(ctx, 16, ports, ssl); - ck_assert_uint_eq(ports_cnt, 1); + ck_assert_uint_eq(ports_cnt, 2); ck_assert_int_eq(ports[0], 8080); ck_assert_int_eq(ssl[0], 0); - ck_assert_int_eq(ports[1], 0); - ck_assert_int_eq(ssl[1], 0); + ck_assert_int_eq(ports[1], 8443); + ck_assert_int_eq(ssl[1], 1); + ck_assert_int_eq(ports[2], 0); + ck_assert_int_eq(ssl[2], 0); mg_Sleep(1); mg_stop(ctx); @@ -488,7 +491,7 @@ static int request_test_handler(struct mg_connection *conn, void *cbdata) "Content-Type: text/plain\r\n\r\n"); for (i = 1; i <= 10; i++) { - mg_printf(conn, "%u\r\n", i); + mg_printf(conn, "%x\r\n", i); mg_write(conn, chunk_data, (unsigned)i); mg_printf(conn, "\r\n"); } @@ -579,7 +582,6 @@ START_TEST(test_request_handlers) } END_TEST - Suite *make_public_suite(void) { @@ -627,3 +629,31 @@ Suite *make_public_suite(void) return suite; } + +#if 0 +/* Used to debug test cases without using the check framework */ +void main(void) +{ + test_mg_start_stop_http_server(0); + test_mg_start_stop_https_server(0); + test_request_handlers(0); +} + +void _ck_assert_failed(const char *file, int line, const char *expr, ...) +{ + fprintf(stderr, "error!\n"); +} + +void _mark_point(const char *file, int line) {} +void tcase_fn_start(const char *fname, const char *file, int line) {} +void suite_add_tcase(Suite *s, TCase *tc){}; +void _tcase_add_test(TCase *tc, + TFun tf, + const char *fname, + int _signal, + int allowed_exit_value, + int start, + int end){}; +TCase *tcase_create(const char *name) { return NULL; }; +Suite *suite_create(const char *name) { return NULL; }; +#endif \ No newline at end of file