diff --git a/include/r3_str.h b/include/r3_str.h index 8da66fa..4aeced1 100644 --- a/include/r3_str.h +++ b/include/r3_str.h @@ -12,7 +12,7 @@ int slug_count(char * p, int len); -char * compile_slug(char * str, int len); +char * slug_compile(char * str, int len); bool contains_slug(char * str); diff --git a/src/node.c b/src/node.c index e278e1f..9bd4b29 100644 --- a/src/node.c +++ b/src/node.c @@ -170,7 +170,7 @@ void r3_tree_compile_patterns(node * n) { for ( int i = 0 ; i < n->edge_len ; i++ ) { e = n->edges[i]; if ( e->has_slug ) { - char * slug_pat = compile_slug(e->pattern, e->pattern_len); + char * slug_pat = slug_compile(e->pattern, e->pattern_len); strcat(p, slug_pat); } else { strncat(p++,"(", 1); diff --git a/src/str.c b/src/str.c index 814a012..73b2c80 100644 --- a/src/str.c +++ b/src/str.c @@ -122,7 +122,7 @@ char * find_slug_pattern(char *s1, int *len) { /** * @param char * sep separator */ -char * compile_slug(char * str, int len) +char * slug_compile(char * str, int len) { char *s1 = NULL, *o = NULL; char *pat = NULL; diff --git a/tests/bench_str.csv b/tests/bench_str.csv index f06c833..c76d5e1 100644 --- a/tests/bench_str.csv +++ b/tests/bench_str.csv @@ -385,3 +385,4 @@ 1400593210,13568445.16 1400593219,13704926.07 1400599508,13991454.07 +1400599553,13826120.84 diff --git a/tests/check_slug.c b/tests/check_slug.c index 31125f9..22fe635 100644 --- a/tests/check_slug.c +++ b/tests/check_slug.c @@ -12,19 +12,19 @@ #include "r3_str.h" #include "str_array.h" -START_TEST (test_compile_slug) +START_TEST (test_slug_compile) { char * path = "/user/{id}"; - ck_assert_str_eq( compile_slug(path, strlen(path) ) , "/user/([^/]+)" ); + ck_assert_str_eq( slug_compile(path, strlen(path) ) , "/user/([^/]+)" ); char * path2 = "/what/{id}-foo"; - ck_assert_str_eq( compile_slug(path2, strlen(path2) ) , "/what/([^/]+)-foo" ); + ck_assert_str_eq( slug_compile(path2, strlen(path2) ) , "/what/([^/]+)-foo" ); char * path3 = "-{id}"; - ck_assert_str_eq(compile_slug(path3, strlen(path3)), "-([^/]+)" ); + ck_assert_str_eq(slug_compile(path3, strlen(path3)), "-([^/]+)" ); char * path4 = "-{idx:\\d{3}}"; - ck_assert_str_eq(compile_slug(path4, strlen(path4)), "-(\\d{3})" ); + ck_assert_str_eq(slug_compile(path4, strlen(path4)), "-(\\d{3})" ); } END_TEST @@ -98,7 +98,7 @@ Suite* r3_suite (void) { tcase_add_test(tcase, test_find_slug_placeholder); tcase_add_test(tcase, test_find_slug_placeholder_with_broken_slug); tcase_add_test(tcase, test_slug_count); - tcase_add_test(tcase, test_compile_slug); + tcase_add_test(tcase, test_slug_compile); suite_add_tcase(suite, tcase); return suite;