From 2f3bcb711689a03976d65bc6e583792840fe4c6d Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 17 Nov 2015 15:36:29 +0800 Subject: [PATCH] refactoring testcase group --- tests/check_tree.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/tests/check_tree.c b/tests/check_tree.c index 92e47dc..b6b9cd2 100644 --- a/tests/check_tree.c +++ b/tests/check_tree.c @@ -258,7 +258,7 @@ START_TEST (test_compile) r3_tree_insert_path(n, "/{id}", NULL); r3_tree_compile(n, NULL); r3_tree_compile(n, NULL); // test double compile - r3_tree_dump(n, 0); + // r3_tree_dump(n, 0); match_entry * entry; entry = match_entry_createl( "foo" , strlen("/foo") ); @@ -328,7 +328,7 @@ START_TEST (test_incomplete_slug_path) r3_tree_compile(n, &errstr); ck_assert(errstr == NULL); // no error - r3_tree_dump(n, 0); + // r3_tree_dump(n, 0); r3_tree_free(n); } @@ -401,7 +401,7 @@ START_TEST (test_root_match) char *errstr = NULL; r3_tree_compile(n, &errstr); - r3_tree_dump(n, 0); + // r3_tree_dump(n, 0); node *matched; matched = r3_tree_match(n, "/", NULL); ck_assert(matched); @@ -437,7 +437,7 @@ START_TEST (test_pcre_patterns_insert_2) char *errstr = NULL; r3_tree_compile(n, &errstr); - r3_tree_dump(n, 0); + // r3_tree_dump(n, 0); node *matched; matched = r3_tree_match(n, "/post/11/22", NULL); ck_assert((int)matched); @@ -453,11 +453,11 @@ START_TEST (test_pcre_patterns_insert_3) node * n = r3_tree_create(10); printf("Inserting /post/{idx:\\d{2}}/{idy}\n"); r3_tree_insert_path(n, "/post/{idx:\\d{2}}/{idy}", NULL); - r3_tree_dump(n, 0); + // r3_tree_dump(n, 0); printf("Inserting /zoo\n"); r3_tree_insert_path(n, "/zoo", NULL); - r3_tree_dump(n, 0); + // r3_tree_dump(n, 0); r3_tree_insert_path(n, "/foo", NULL); r3_tree_insert_path(n, "/bar", NULL); @@ -465,7 +465,7 @@ START_TEST (test_pcre_patterns_insert_3) char *errstr = NULL; r3_tree_compile(n, &errstr); - r3_tree_dump(n, 0); + // r3_tree_dump(n, 0); node *matched; @@ -551,8 +551,7 @@ START_TEST (test_insert_pathl) char * errstr = NULL; r3_tree_compile(n, &errstr); ck_assert(errstr == NULL); - - r3_tree_dump(n, 0); + // r3_tree_dump(n, 0); r3_tree_free(n); } END_TEST @@ -577,7 +576,7 @@ START_TEST (test_compile_fail) fprintf(stderr, "Compile failed: %s\n", errstr); free(errstr); - r3_tree_dump(n, 0); + // r3_tree_dump(n, 0); r3_tree_free(n); } END_TEST @@ -669,7 +668,7 @@ START_TEST(test_pcre_pattern_more) r3_tree_insert_path(n, "/user3/{id:\\d{3}}", &var3); r3_tree_insert_path(n, "/user", &var0); r3_tree_compile(n, NULL); - r3_tree_dump(n, 0); + // r3_tree_dump(n, 0); node *matched; matched = r3_tree_matchl(n, "/user/123", strlen("/user/123"), entry); @@ -736,25 +735,31 @@ START_TEST(test_insert_route) } END_TEST - Suite* r3_suite (void) { Suite *suite = suite_create("r3 core tests"); - - TCase *tcase = tcase_create("testcase"); - + TCase *tcase = tcase_create("common_prefix_testcase"); tcase_add_test(tcase, test_find_common_prefix); tcase_add_test(tcase, test_find_common_prefix_after); tcase_add_test(tcase, test_find_common_prefix_double_middle); tcase_add_test(tcase, test_find_common_prefix_middle); tcase_add_test(tcase, test_find_common_prefix_same_pattern); tcase_add_test(tcase, test_find_common_prefix_same_pattern2); + suite_add_tcase(suite, tcase); + + tcase = tcase_create("insert_testcase"); tcase_add_test(tcase, test_insert_pathl); tcase_add_test(tcase, test_insert_pathl_fail); tcase_add_test(tcase, test_node_construct_and_free); + suite_add_tcase(suite, tcase); + + tcase = tcase_create("compile_testcase"); tcase_add_test(tcase, test_compile); tcase_add_test(tcase, test_compile_fail); tcase_add_test(tcase, test_route_cmp); tcase_add_test(tcase, test_insert_route); + suite_add_tcase(suite, tcase); + + tcase = tcase_create("pcre_pattern_testcase"); tcase_add_test(tcase, test_pcre_pattern_simple); tcase_add_test(tcase, test_pcre_pattern_more); tcase_add_test(tcase, test_pcre_patterns_insert);