diff options
Diffstat (limited to 'tests/continue-test.c')
-rw-r--r-- | tests/continue-test.c | 107 |
1 files changed, 82 insertions, 25 deletions
diff --git a/tests/continue-test.c b/tests/continue-test.c index fa9ef809..b6a5805f 100644 --- a/tests/continue-test.c +++ b/tests/continue-test.c @@ -59,13 +59,6 @@ do_message (const char *path, gboolean long_body, const char *expected_event; char *actual_event; int expected_status, actual_status; - static int count = 1; - - debug_printf (1, "%d. /%s, %s body, %sExpect, %s password\n", - count++, path, - long_body ? "long" : "short", - expect_continue ? "" : "no ", - auth ? "with" : "without"); uri = g_strdup_printf ("http://%s127.0.0.1:%d/%s", auth ? "user:pass@" : "", @@ -106,17 +99,13 @@ do_message (const char *path, gboolean long_body, while ((expected_event = va_arg (ap, const char *))) { if (!events) { - actual_event = g_strdup (""); - debug_printf (1, " Expected '%s', got end of list\n", - expected_event); - errors++; + soup_test_assert (events != NULL, + "Expected '%s', got end of list", + expected_event); + continue; } else { actual_event = events->data; - if (strcmp (expected_event, actual_event) != 0) { - debug_printf (1, " Expected '%s', got '%s'\n", - expected_event, actual_event); - errors++; - } + g_assert_cmpstr (expected_event, ==, actual_event); events = g_slist_delete_link (events, events); } @@ -134,10 +123,10 @@ do_message (const char *path, gboolean long_body, if (expected_status != -1 && actual_status != -1 && expected_status != actual_status) { - debug_printf (1, " Expected status '%s', got '%s'\n", - soup_status_get_phrase (expected_status), - soup_status_get_phrase (actual_status)); - errors++; + soup_test_assert (expected_status == actual_status, + "Expected status '%s', got '%s'", + soup_status_get_phrase (expected_status), + soup_status_get_phrase (actual_status)); } g_free (actual_event); @@ -145,8 +134,8 @@ do_message (const char *path, gboolean long_body, va_end (ap); while (events) { actual_event = events->data; - debug_printf (1, " Expected to be done, got '%s'\n", actual_event); - errors++; + soup_test_assert (events == NULL, + "Expected to be done, got '%s'", actual_event); events = g_slist_delete_link (events, events); if (!strcmp (actual_event, "server-wrote_headers") || @@ -157,7 +146,7 @@ do_message (const char *path, gboolean long_body, } static void -run_tests (void) +do_test_unauth_short_noexpect_nopass (void) { do_message ("unauth", FALSE, FALSE, FALSE, "client-wrote_headers", @@ -171,6 +160,11 @@ run_tests (void) "client-got_body", "client-finished", NULL); +} + +static void +do_test_unauth_long_noexpect_nopass (void) +{ do_message ("unauth", TRUE, FALSE, FALSE, "client-wrote_headers", "client-wrote_body", @@ -183,6 +177,11 @@ run_tests (void) "client-got_body", "client-finished", NULL); +} + +static void +do_test_unauth_short_expect_nopass (void) +{ do_message ("unauth", FALSE, TRUE, FALSE, "client-wrote_headers", "server-got_headers", @@ -197,6 +196,11 @@ run_tests (void) "client-got_body", "client-finished", NULL); +} + +static void +do_test_unauth_long_expect_nopass (void) +{ do_message ("unauth", TRUE, TRUE, FALSE, "client-wrote_headers", "server-got_headers", @@ -207,7 +211,11 @@ run_tests (void) "client-got_body", "client-finished", NULL); +} +static void +do_test_auth_short_noexpect_nopass (void) +{ do_message ("auth", FALSE, FALSE, FALSE, "client-wrote_headers", "client-wrote_body", @@ -220,6 +228,11 @@ run_tests (void) "client-got_body", "client-finished", NULL); +} + +static void +do_test_auth_long_noexpect_nopass (void) +{ do_message ("auth", TRUE, FALSE, FALSE, "client-wrote_headers", "client-wrote_body", @@ -232,6 +245,11 @@ run_tests (void) "client-got_body", "client-finished", NULL); +} + +static void +do_test_auth_short_expect_nopass (void) +{ do_message ("auth", FALSE, TRUE, FALSE, "client-wrote_headers", "server-got_headers", @@ -242,6 +260,11 @@ run_tests (void) "client-got_body", "client-finished", NULL); +} + +static void +do_test_auth_long_expect_nopass (void) +{ do_message ("auth", TRUE, TRUE, FALSE, "client-wrote_headers", "server-got_headers", @@ -252,7 +275,11 @@ run_tests (void) "client-got_body", "client-finished", NULL); +} +static void +do_test_auth_short_noexpect_pass (void) +{ do_message ("auth", FALSE, FALSE, TRUE, "client-wrote_headers", "client-wrote_body", @@ -274,6 +301,11 @@ run_tests (void) "client-got_body", "client-finished", NULL); +} + +static void +do_test_auth_long_noexpect_pass (void) +{ do_message ("auth", TRUE, FALSE, TRUE, "client-wrote_headers", "client-wrote_body", @@ -295,6 +327,11 @@ run_tests (void) "client-got_body", "client-finished", NULL); +} + +static void +do_test_auth_short_expect_pass (void) +{ do_message ("auth", FALSE, TRUE, TRUE, "client-wrote_headers", "server-got_headers", @@ -316,6 +353,11 @@ run_tests (void) "client-got_body", "client-finished", NULL); +} + +static void +do_test_auth_long_expect_pass (void) +{ do_message ("auth", TRUE, TRUE, TRUE, "client-wrote_headers", "server-got_headers", @@ -434,15 +476,30 @@ int main (int argc, char **argv) { SoupServer *server; + int ret; test_init (argc, argv, NULL); server = setup_server (); port = soup_server_get_port (server); - run_tests (); + g_test_add_func ("/continue/unauth_short_noexpect_nopass", do_test_unauth_short_noexpect_nopass); + g_test_add_func ("/continue/unauth_long_noexpect_nopass", do_test_unauth_long_noexpect_nopass); + g_test_add_func ("/continue/unauth_short_expect_nopass", do_test_unauth_short_expect_nopass); + g_test_add_func ("/continue/unauth_long_expect_nopass", do_test_unauth_long_expect_nopass); + g_test_add_func ("/continue/auth_short_noexpect_nopass", do_test_auth_short_noexpect_nopass); + g_test_add_func ("/continue/auth_long_noexpect_nopass", do_test_auth_long_noexpect_nopass); + g_test_add_func ("/continue/auth_short_expect_nopass", do_test_auth_short_expect_nopass); + g_test_add_func ("/continue/auth_long_expect_nopass", do_test_auth_long_expect_nopass); + g_test_add_func ("/continue/auth_short_noexpect_pass", do_test_auth_short_noexpect_pass); + g_test_add_func ("/continue/auth_long_noexpect_pass", do_test_auth_long_noexpect_pass); + g_test_add_func ("/continue/auth_short_expect_pass", do_test_auth_short_expect_pass); + g_test_add_func ("/continue/auth_long_expect_pass", do_test_auth_long_expect_pass); + + ret = g_test_run (); soup_test_server_quit_unref (server); test_cleanup (); - return errors != 0; + + return ret; } |