diff --git a/include/r3_list.h b/include/r3_list.h index 96e878c..d574e8d 100644 --- a/include/r3_list.h +++ b/include/r3_list.h @@ -9,27 +9,27 @@ #define LIST_H #include - + typedef struct _list_item { - void *value; - struct _list_item *prev; - struct _list_item *next; + void *value; + struct _list_item *prev; + struct _list_item *next; } list_item; - + typedef struct { - int count; - list_item *head; - list_item *tail; - pthread_mutex_t mutex; + int count; + list_item *head; + list_item *tail; + pthread_mutex_t mutex; } list; - + list *list_create(); void list_free(list *l); - + list_item *list_add_element(list *l, void *ptr); int list_remove_element(list *l, void *ptr); void list_each_element(list *l, int (*func)(list_item *)); - + #endif /* !LIST_H */ diff --git a/include/str_array.h b/include/str_array.h index 3b37fda..a8b8973 100644 --- a/include/str_array.h +++ b/include/str_array.h @@ -11,9 +11,9 @@ #include "r3_define.h" typedef struct _str_array { - char **tokens; - int len; - int cap; + char **tokens; + int len; + int cap; } str_array; str_array * str_array_create(int cap); diff --git a/main.c b/main.c index f3c4d1a..68d85c7 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,3 @@ - #include #include #include "main.h" @@ -12,6 +11,7 @@ typedef struct _Node { -void compile() { +void compile() +{ } diff --git a/src/edge.c b/src/edge.c index 9b97c72..6202360 100644 --- a/src/edge.c +++ b/src/edge.c @@ -24,7 +24,8 @@ #include "r3.h" #include "str_array.h" -edge * r3_edge_create(char * pattern, int pattern_len, node * child) { +edge * r3_edge_create(char * pattern, int pattern_len, node * child) +{ edge * e = (edge*) malloc( sizeof(edge) ); e->pattern = pattern; e->pattern_len = pattern_len; @@ -43,7 +44,8 @@ edge * r3_edge_create(char * pattern, int pattern_len, node * child) { * A -> [prefix] -> B -> [suffix] -> New Child (Copy Data, Edges from B) * */ -node * r3_edge_branch(edge *e, int dl) { +node * r3_edge_branch(edge *e, int dl) +{ node *new_child; edge *e1; char * s1 = e->pattern + dl; @@ -73,7 +75,7 @@ node * r3_edge_branch(edge *e, int dl) { new_child->data = e->child->data; // copy data pointer e->child->data = NULL; - // truncate the original edge pattern + // truncate the original edge pattern char *op = e->pattern; e->pattern = strndup(e->pattern, dl); e->pattern_len = dl; @@ -81,7 +83,8 @@ node * r3_edge_branch(edge *e, int dl) { return new_child; } -void r3_edge_free(edge * e) { +void r3_edge_free(edge * e) +{ if (e->pattern) { free(e->pattern); } diff --git a/src/gvc.c b/src/gvc.c index 5a9bcca..c8fd010 100644 --- a/src/gvc.c +++ b/src/gvc.c @@ -12,13 +12,15 @@ #include "r3_gvc.h" -char * node_id_str(int id) { +char * node_id_str(int id) +{ char * name = malloc(sizeof(char) * 20); sprintf(name, "#%d", id); return name; } -void r3_tree_build_ag_nodes(Agraph_t * g, Agnode_t * ag_parent_node, node * n, int node_cnt) { +void r3_tree_build_ag_nodes(Agraph_t * g, Agnode_t * ag_parent_node, node * n, int node_cnt) +{ edge * e; Agnode_t *agn_child; Agedge_t *agn_edge; @@ -43,7 +45,7 @@ void r3_tree_build_ag_nodes(Agraph_t * g, Agnode_t * ag_parent_node, node * n, i /** - * Render a tree to tree graph image via graphviz (dot) + * Render a tree to tree graph image via graphviz (dot) */ int r3_tree_render_dot(node * tree) { @@ -71,7 +73,7 @@ int r3_tree_render_dot(node * tree) /** - * Render a tree to tree graph image via graphviz (dot) + * Render a tree to tree graph image via graphviz (dot) */ int r3_tree_render_file(node * tree, char * format, char * filename) { diff --git a/src/list.c b/src/list.c index 4e80695..a2c2f8c 100644 --- a/src/list.c +++ b/src/list.c @@ -6,123 +6,120 @@ */ #include #include "r3_list.h" - + /* Naive linked list implementation */ - + list * list_create() { - list *l = (list *) malloc(sizeof(list)); - l->count = 0; - l->head = NULL; - l->tail = NULL; - pthread_mutex_init(&(l->mutex), NULL); - return l; + list *l = (list *) malloc(sizeof(list)); + l->count = 0; + l->head = NULL; + l->tail = NULL; + pthread_mutex_init(&(l->mutex), NULL); + return l; } - + void list_free(l) - list *l; +list *l; { - list_item *li, *tmp; - - pthread_mutex_lock(&(l->mutex)); - - if (l != NULL) { - li = l->head; - while (li != NULL) { - tmp = li->next; - free(li); - li = tmp; + list_item *li, *tmp; + + pthread_mutex_lock(&(l->mutex)); + + if (l != NULL) { + li = l->head; + while (li != NULL) { + tmp = li->next; + free(li); + li = tmp; + } } - } - - pthread_mutex_unlock(&(l->mutex)); - pthread_mutex_destroy(&(l->mutex)); - free(l); + + pthread_mutex_unlock(&(l->mutex)); + pthread_mutex_destroy(&(l->mutex)); + free(l); } - + list_item * list_add_element(l, ptr) - list *l; - void *ptr; +list *l; +void *ptr; { - list_item *li; - - pthread_mutex_lock(&(l->mutex)); - - li = (list_item *) malloc(sizeof(list_item)); - li->value = ptr; - li->next = NULL; - li->prev = l->tail; - - if (l->tail == NULL) { - l->head = l->tail = li; - } - else { - l->tail = li; - } - l->count++; - - pthread_mutex_unlock(&(l->mutex)); - - return li; + list_item *li; + + pthread_mutex_lock(&(l->mutex)); + + li = (list_item *) malloc(sizeof(list_item)); + li->value = ptr; + li->next = NULL; + li->prev = l->tail; + + if (l->tail == NULL) { + l->head = l->tail = li; + } else { + l->tail = li; + } + l->count++; + + pthread_mutex_unlock(&(l->mutex)); + + return li; } - + int list_remove_element(l, ptr) - list *l; - void *ptr; +list *l; +void *ptr; { - int result = 0; - list_item *li = l->head; - - pthread_mutex_lock(&(l->mutex)); - - while (li != NULL) { - if (li->value == ptr) { - if (li->prev == NULL) { - l->head = li->next; - } - else { - li->prev->next = li->next; - } - - if (li->next == NULL) { - l->tail = li->prev; - } - else { - li->next->prev = li->prev; - } - l->count--; - free(li); - result = 1; - break; + int result = 0; + list_item *li = l->head; + + pthread_mutex_lock(&(l->mutex)); + + while (li != NULL) { + if (li->value == ptr) { + if (li->prev == NULL) { + l->head = li->next; + } else { + li->prev->next = li->next; + } + + if (li->next == NULL) { + l->tail = li->prev; + } else { + li->next->prev = li->prev; + } + l->count--; + free(li); + result = 1; + break; + } + li = li->next; } - li = li->next; - } - - pthread_mutex_unlock(&(l->mutex)); - - return result; + + pthread_mutex_unlock(&(l->mutex)); + + return result; } - + void list_each_element(l, func) - list *l; - int (*func)(list_item *); +list *l; +int (*func)(list_item *); { - list_item *li; - - pthread_mutex_lock(&(l->mutex)); - - li = l->head; - while (li != NULL) { - if (func(li) == 1) { - break; + list_item *li; + + pthread_mutex_lock(&(l->mutex)); + + li = l->head; + while (li != NULL) { + if (func(li) == 1) { + break; + } + li = li->next; } - li = li->next; - } - - pthread_mutex_unlock(&(l->mutex)); + + pthread_mutex_unlock(&(l->mutex)); } diff --git a/src/node.c b/src/node.c index 8d112ed..3aead9f 100644 --- a/src/node.c +++ b/src/node.c @@ -24,7 +24,8 @@ /** * Create a node object */ -node * r3_tree_create(int cap) { +node * r3_tree_create(int cap) +{ node * n = (node*) malloc( sizeof(node) ); n->edges = (edge**) malloc( sizeof(edge*) * 10 ); @@ -39,7 +40,8 @@ node * r3_tree_create(int cap) { return n; } -void r3_tree_free(node * tree) { +void r3_tree_free(node * tree) +{ for (int i = 0 ; i < tree->edge_len ; i++ ) { if (tree->edges[i]) { r3_edge_free(tree->edges[ i ]); @@ -52,7 +54,7 @@ void r3_tree_free(node * tree) { free(tree->pcre_pattern); if (tree->pcre_extra) free(tree->pcre_extra); - if (tree->ov) + if (tree->ov) free(tree->ov); free(tree->edges); // str_array_free(tree->edge_patterns); @@ -63,7 +65,8 @@ void r3_tree_free(node * tree) { /* parent node, edge pattern, child */ -edge * r3_node_add_child(node * n, char * pat , node *child) { +edge * r3_node_add_child(node * n, char * pat , node *child) +{ // find the same sub-pattern, if it does not exist, create one edge * e; @@ -82,7 +85,8 @@ edge * r3_node_add_child(node * n, char * pat , node *child) { -void r3_node_append_edge(node *n, edge *e) { +void r3_node_append_edge(node *n, edge *e) +{ if (!n->edges) { n->edge_cap = 3; n->edges = malloc(sizeof(edge) * n->edge_cap); @@ -94,7 +98,8 @@ void r3_node_append_edge(node *n, edge *e) { n->edges[ n->edge_len++ ] = e; } -edge * r3_node_find_edge(node * n, char * pat) { +edge * r3_node_find_edge(node * n, char * pat) +{ edge * e; for (int i = 0 ; i < n->edge_len ; i++ ) { e = n->edges[i]; @@ -125,7 +130,8 @@ void r3_tree_compile(node *n) * This function combines ['/foo', '/bar', '/{slug}'] into (/foo)|(/bar)|/([^/]+)} * */ -void r3_tree_compile_patterns(node * n) { +void r3_tree_compile_patterns(node * n) +{ char * cpat; char * p; @@ -179,11 +185,11 @@ void r3_tree_compile_patterns(node * n) { // n->pcre_pattern; n->pcre_pattern = pcre_compile( - n->combined_pattern, /* the pattern */ - option_bits, /* default options */ - &error, /* for error message */ - &erroffset, /* for error offset */ - NULL); /* use default character tables */ + n->combined_pattern, /* the pattern */ + option_bits, /* default options */ + &error, /* for error message */ + &erroffset, /* for error offset */ + NULL); /* use default character tables */ if (n->pcre_pattern == NULL) { printf("PCRE compilation failed at offset %d: %s, pattern: %s\n", erroffset, error, n->combined_pattern); return; @@ -196,7 +202,8 @@ void r3_tree_compile_patterns(node * n) { } -match_entry * match_entry_createl(char * path, int path_len) { +match_entry * match_entry_createl(char * path, int path_len) +{ match_entry * entry = malloc(sizeof(match_entry)); if(!entry) return NULL; @@ -207,7 +214,8 @@ match_entry * match_entry_createl(char * path, int path_len) { return entry; } -void match_entry_free(match_entry * entry) { +void match_entry_free(match_entry * entry) +{ str_array_free(entry->vars); free(entry); } @@ -224,7 +232,8 @@ void match_entry_free(match_entry * entry) { * @param int path_len the length of the URL path. * @param match_entry* entry match_entry is used for saving the captured dynamic strings from pcre result. */ -node * r3_tree_matchl(node * n, char * path, int path_len, match_entry * entry) { +node * r3_tree_matchl(node * n, char * path, int path_len, match_entry * entry) +{ info("try matching: %s\n", path); edge *e; @@ -237,34 +246,36 @@ node * r3_tree_matchl(node * n, char * path, int path_len, match_entry * entry) info("pcre matching %s on %s\n", n->combined_pattern, path); rc = pcre_exec( - n->pcre_pattern, /* the compiled pattern */ + n->pcre_pattern, /* the compiled pattern */ - // PCRE Study makes this slow - NULL, // n->pcre_extra, /* no extra data - we didn't study the pattern */ - path, /* the subject string */ - path_len, /* the length of the subject */ - 0, /* start at offset 0 in the subject */ - 0, /* default options */ - n->ov, /* output vector for substring information */ - n->ov_cnt); /* number of elements in the output vector */ + // PCRE Study makes this slow + NULL, // n->pcre_extra, /* no extra data - we didn't study the pattern */ + path, /* the subject string */ + path_len, /* the length of the subject */ + 0, /* start at offset 0 in the subject */ + 0, /* default options */ + n->ov, /* output vector for substring information */ + n->ov_cnt); /* number of elements in the output vector */ // info("rc: %d\n", rc ); if (rc < 0) { - switch(rc) - { - case PCRE_ERROR_NOMATCH: printf("No match\n"); break; - /* - Handle other special cases if you like - */ - default: printf("Matching error %d\n", rc); break; + switch(rc) { + case PCRE_ERROR_NOMATCH: + printf("No match\n"); + break; + /* + Handle other special cases if you like + */ + default: + printf("Matching error %d\n", rc); + break; } // does not match all edges, return NULL; return NULL; } - for (i = 1; i < rc; i++) - { + for (i = 1; i < rc; i++) { char *substring_start = path + n->ov[2*i]; int substring_length = n->ov[2*i+1] - n->ov[2*i]; // info("%2d: %.*s\n", i, substring_length, substring_start); @@ -300,7 +311,8 @@ node * r3_tree_matchl(node * n, char * path, int path_len, match_entry * entry) return NULL; } -route * r3_tree_match_route(node *tree, match_entry * entry) { +route * r3_tree_match_route(node *tree, match_entry * entry) +{ node *n; n = r3_tree_match_entry(tree, entry); if (n->routes && n->route_len > 0) { @@ -314,7 +326,8 @@ route * r3_tree_match_route(node *tree, match_entry * entry) { return NULL; } -inline edge * r3_node_find_edge_str(node * n, char * str, int str_len) { +inline edge * r3_node_find_edge_str(node * n, char * str, int str_len) +{ int i = 0; int matched_idx = 0; @@ -334,7 +347,8 @@ inline edge * r3_node_find_edge_str(node * n, char * str, int str_len) { -node * r3_node_create() { +node * r3_node_create() +{ node * n = (node*) malloc( sizeof(node) ); n->edges = NULL; n->edge_len = 0; @@ -351,15 +365,18 @@ node * r3_node_create() { } -route * r3_route_create(char * path) { +route * r3_route_create(char * path) +{ return r3_route_createl(path, strlen(path)); } -void r3_route_free(route * route) { +void r3_route_free(route * route) +{ free(route); } -route * r3_route_createl(char * path, int path_len) { +route * r3_route_createl(char * path, int path_len) +{ route * info = malloc(sizeof(route)); info->path = path; info->path_len = path_len; @@ -487,13 +504,14 @@ node * _r3_tree_insert_pathl(node *tree, char *path, int path_len, route * route return n; } -bool r3_node_has_slug_edges(node *n) { +bool r3_node_has_slug_edges(node *n) +{ bool found = FALSE; edge *e; for ( int i = 0 ; i < n->edge_len ; i++ ) { e = n->edges[i]; e->has_slug = contains_slug(e->pattern); - if (e->has_slug) + if (e->has_slug) found = TRUE; } return found; @@ -501,7 +519,8 @@ bool r3_node_has_slug_edges(node *n) { -void r3_tree_dump(node * n, int level) { +void r3_tree_dump(node * n, int level) +{ print_indent(level); if ( n->combined_pattern ) { printf(" regexp:%s", n->combined_pattern); @@ -533,7 +552,8 @@ void r3_tree_dump(node * n, int level) { * * -1 == different route */ -int r3_route_cmp(route *r1, match_entry *r2) { +int r3_route_cmp(route *r1, match_entry *r2) +{ if (r1->request_method != 0) { if (0 == (r1->request_method & r2->request_method) ) { return -1; @@ -568,9 +588,10 @@ int r3_route_cmp(route *r1, match_entry *r2) { /** - * + * */ -void r3_node_append_route(node * n, route * route) { +void r3_node_append_route(node * n, route * route) +{ if (!n->routes) { n->route_cap = 3; n->routes = malloc(sizeof(route) * n->route_cap); diff --git a/src/str.c b/src/str.c index 0057dbb..4e8fe8a 100644 --- a/src/str.c +++ b/src/str.c @@ -12,9 +12,10 @@ #include "str_array.h" #include "r3_define.h" -int strndiff(char * d1, char * d2, unsigned int n) { +int strndiff(char * d1, char * d2, unsigned int n) +{ char * o = d1; - while ( *d1 == *d2 && n-- > 0 ) { + while ( *d1 == *d2 && n-- > 0 ) { d1++; d2++; } @@ -22,9 +23,10 @@ int strndiff(char * d1, char * d2, unsigned int n) { } -int strdiff(char * d1, char * d2) { +int strdiff(char * d1, char * d2) +{ char * o = d1; - while( *d1 == *d2 ) { + while( *d1 == *d2 ) { d1++; d2++; } @@ -35,7 +37,8 @@ int strdiff(char * d1, char * d2) { /** * provide a quick way to count slugs, simply search for '{' */ -int count_slug(char * p, int len) { +int count_slug(char * p, int len) +{ int s = 0; int lev = 0; while( len-- ) { @@ -52,11 +55,13 @@ int count_slug(char * p, int len) { return s; } -bool contains_slug(char * str) { +bool contains_slug(char * str) +{ return strchr(str, '{') != NULL ? TRUE : FALSE; } -char * inside_slug(char * needle, int needle_len, char *offset) { +char * inside_slug(char * needle, int needle_len, char *offset) +{ char * s1 = offset; char * s2 = offset; @@ -81,7 +86,8 @@ char * inside_slug(char * needle, int needle_len, char *offset) { return NULL; } -char * find_slug_placeholder(char *s1, int *len) { +char * find_slug_placeholder(char *s1, int *len) +{ char *c; char *s2; int cnt = 0; @@ -113,7 +119,8 @@ char * find_slug_placeholder(char *s1, int *len) { /** * given a slug string, duplicate the pattern string of the slug */ -char * find_slug_pattern(char *s1, int *len) { +char * find_slug_pattern(char *s1, int *len) +{ char *c; char *s2; int cnt = 1; @@ -205,10 +212,8 @@ char** str_split(char* a_str, const char a_delim) delim[1] = 0; /* Count how many elements will be extracted. */ - while (*tmp) - { - if (a_delim == *tmp) - { + while (*tmp) { + if (a_delim == *tmp) { count++; last_comma = tmp; } @@ -224,13 +229,11 @@ char** str_split(char* a_str, const char a_delim) result = malloc(sizeof(char*) * count); - if (result) - { + if (result) { size_t idx = 0; char* token = strtok(a_str, delim); - while (token) - { + while (token) { assert(idx < count); *(result + idx++) = strdup(token); token = strtok(0, delim); @@ -242,13 +245,15 @@ char** str_split(char* a_str, const char a_delim) return result; } -void str_repeat(char *s, char *c, int len) { +void str_repeat(char *s, char *c, int len) +{ while(len--) { s[len - 1] = *c; } } -void print_indent(int level) { +void print_indent(int level) +{ int len = level * 2; while(len--) { printf(" "); @@ -256,7 +261,8 @@ void print_indent(int level) { } #ifndef HAVE_STRDUP -char *strdup(const char *s) { +char *strdup(const char *s) +{ char *out; int count = 0; while( s[count] ) @@ -271,7 +277,8 @@ char *strdup(const char *s) { #endif #ifndef HAVE_STRNDUP -char *strndup(const char *s, int n) { +char *strndup(const char *s, int n) +{ char *out; int count = 0; while( count < n && s[count] ) diff --git a/src/token.c b/src/token.c index 6f2bc27..78710ef 100644 --- a/src/token.c +++ b/src/token.c @@ -12,7 +12,8 @@ #include "r3_str.h" -str_array * str_array_create(int cap) { +str_array * str_array_create(int cap) +{ str_array * list = (str_array*) malloc( sizeof(str_array) ); list->len = 0; list->cap = cap; @@ -20,7 +21,8 @@ str_array * str_array_create(int cap) { return list; } -void str_array_free(str_array *l) { +void str_array_free(str_array *l) +{ for ( int i = 0; i < l->len ; i++ ) { char * t = l->tokens[ i ]; free(t); @@ -28,17 +30,20 @@ void str_array_free(str_array *l) { free(l); } -bool str_array_is_full(str_array * l) { +bool str_array_is_full(str_array * l) +{ return l->len >= l->cap; } -bool str_array_resize(str_array *l, int new_cap) { +bool str_array_resize(str_array *l, int new_cap) +{ l->tokens = realloc(l->tokens, sizeof(char**) * new_cap); l->cap = new_cap; return l->tokens != NULL; } -bool str_array_append(str_array * l, char * token) { +bool str_array_append(str_array * l, char * token) +{ if ( str_array_is_full(l) ) { bool ret = str_array_resize(l, l->cap + 20); if (ret == FALSE ) { @@ -49,7 +54,8 @@ bool str_array_append(str_array * l, char * token) { return TRUE; } -void str_array_dump(str_array *l) { +void str_array_dump(str_array *l) +{ printf("["); for ( int i = 0; i < l->len ; i++ ) { printf("\"%s\"", l->tokens[i] ); diff --git a/tests/bench.c b/tests/bench.c index 494cd1a..ac75680 100644 --- a/tests/bench.c +++ b/tests/bench.c @@ -10,7 +10,8 @@ #include #include -long unixtime() { +long unixtime() +{ struct timeval tp; long sec = 0L; if (gettimeofday((struct timeval *) &tp, (NUL)) == 0) { @@ -19,12 +20,13 @@ long unixtime() { return 0; } -double microtime() { +double microtime() +{ struct timeval tp; long sec = 0L; double msec = 0.0; char ret[100]; - + if (gettimeofday((struct timeval *) &tp, (NUL)) == 0) { msec = (double) (tp.tv_usec / MICRO_IN_SEC); sec = tp.tv_sec; @@ -36,19 +38,23 @@ double microtime() { } -void bench_start(bench *b) { +void bench_start(bench *b) +{ b->start = microtime(); } -void bench_stop(bench *b) { +void bench_stop(bench *b) +{ b->end = microtime(); } -double bench_iteration_speed(bench *b) { +double bench_iteration_speed(bench *b) +{ return b->N / (b->end - b->start); } -void bench_print_summary(bench *b) { +void bench_print_summary(bench *b) +{ printf("%ld runs, ", b->R); printf("%ld iterations each run, ", b->N); printf("finished in %lf seconds\n", b->end - b->start ); diff --git a/tests/check_gvc.c b/tests/check_gvc.c index 69f2a21..7c8a090 100644 --- a/tests/check_gvc.c +++ b/tests/check_gvc.c @@ -56,21 +56,23 @@ START_TEST (test_gvc_render_file) END_TEST -Suite* r3_suite (void) { - Suite *suite = suite_create("gvc test"); - TCase *tcase = tcase_create("test_gvc"); - tcase_add_test(tcase, test_gvc_render_file); - tcase_add_test(tcase, test_gvc_render_dot); - suite_add_tcase(suite, tcase); - return suite; +Suite* r3_suite (void) +{ + Suite *suite = suite_create("gvc test"); + TCase *tcase = tcase_create("test_gvc"); + tcase_add_test(tcase, test_gvc_render_file); + tcase_add_test(tcase, test_gvc_render_dot); + suite_add_tcase(suite, tcase); + return suite; } -int main (int argc, char *argv[]) { - int number_failed; - Suite *suite = r3_suite(); - SRunner *runner = srunner_create(suite); - srunner_run_all(runner, CK_NORMAL); - number_failed = srunner_ntests_failed(runner); - srunner_free(runner); - return number_failed; +int main (int argc, char *argv[]) +{ + int number_failed; + Suite *suite = r3_suite(); + SRunner *runner = srunner_create(suite); + srunner_run_all(runner, CK_NORMAL); + number_failed = srunner_ntests_failed(runner); + srunner_free(runner); + return number_failed; } diff --git a/tests/check_slug.c b/tests/check_slug.c index 2a78431..68302e5 100644 --- a/tests/check_slug.c +++ b/tests/check_slug.c @@ -78,27 +78,29 @@ START_TEST (test_find_slug_placeholder_with_broken_slug) END_TEST -Suite* r3_suite (void) { - Suite *suite = suite_create("slug test"); - TCase *tcase = tcase_create("test_slug"); - tcase_add_test(tcase, test_contains_slug); - tcase_add_test(tcase, test_inside_slug); - tcase_add_test(tcase, test_find_slug_pattern); - tcase_add_test(tcase, test_find_slug_placeholder); - tcase_add_test(tcase, test_find_slug_placeholder_with_broken_slug); - tcase_add_test(tcase, test_count_slug); - tcase_add_test(tcase, test_compile_slug); +Suite* r3_suite (void) +{ + Suite *suite = suite_create("slug test"); + TCase *tcase = tcase_create("test_slug"); + tcase_add_test(tcase, test_contains_slug); + tcase_add_test(tcase, test_inside_slug); + tcase_add_test(tcase, test_find_slug_pattern); + tcase_add_test(tcase, test_find_slug_placeholder); + tcase_add_test(tcase, test_find_slug_placeholder_with_broken_slug); + tcase_add_test(tcase, test_count_slug); + tcase_add_test(tcase, test_compile_slug); - suite_add_tcase(suite, tcase); - return suite; + suite_add_tcase(suite, tcase); + return suite; } -int main (int argc, char *argv[]) { - int number_failed; - Suite *suite = r3_suite(); - SRunner *runner = srunner_create(suite); - srunner_run_all(runner, CK_NORMAL); - number_failed = srunner_ntests_failed(runner); - srunner_free(runner); - return number_failed; +int main (int argc, char *argv[]) +{ + int number_failed; + Suite *suite = r3_suite(); + SRunner *runner = srunner_create(suite); + srunner_run_all(runner, CK_NORMAL); + number_failed = srunner_ntests_failed(runner); + srunner_free(runner); + return number_failed; } diff --git a/tests/check_tree.c b/tests/check_tree.c index 5b10bcb..7777114 100644 --- a/tests/check_tree.c +++ b/tests/check_tree.c @@ -371,342 +371,342 @@ START_TEST(benchmark_str) int route_data = 999; -r3_tree_insert_path(n, "/foo/bar/baz", NULL); -r3_tree_insert_path(n, "/foo/bar/qux", NULL); -r3_tree_insert_path(n, "/foo/bar/quux", NULL); -r3_tree_insert_path(n, "/foo/bar/corge", NULL); -r3_tree_insert_path(n, "/foo/bar/grault", NULL); -r3_tree_insert_path(n, "/foo/bar/garply", NULL); -r3_tree_insert_path(n, "/foo/baz/bar", NULL); -r3_tree_insert_path(n, "/foo/baz/qux", NULL); -r3_tree_insert_path(n, "/foo/baz/quux", NULL); -r3_tree_insert_path(n, "/foo/baz/corge", NULL); -r3_tree_insert_path(n, "/foo/baz/grault", NULL); -r3_tree_insert_path(n, "/foo/baz/garply", NULL); -r3_tree_insert_path(n, "/foo/qux/bar", NULL); -r3_tree_insert_path(n, "/foo/qux/baz", NULL); -r3_tree_insert_path(n, "/foo/qux/quux", NULL); -r3_tree_insert_path(n, "/foo/qux/corge", NULL); -r3_tree_insert_path(n, "/foo/qux/grault", NULL); -r3_tree_insert_path(n, "/foo/qux/garply", NULL); -r3_tree_insert_path(n, "/foo/quux/bar", NULL); -r3_tree_insert_path(n, "/foo/quux/baz", NULL); -r3_tree_insert_path(n, "/foo/quux/qux", NULL); -r3_tree_insert_path(n, "/foo/quux/corge", NULL); -r3_tree_insert_path(n, "/foo/quux/grault", NULL); -r3_tree_insert_path(n, "/foo/quux/garply", NULL); -r3_tree_insert_path(n, "/foo/corge/bar", NULL); -r3_tree_insert_path(n, "/foo/corge/baz", NULL); -r3_tree_insert_path(n, "/foo/corge/qux", NULL); -r3_tree_insert_path(n, "/foo/corge/quux", NULL); -r3_tree_insert_path(n, "/foo/corge/grault", NULL); -r3_tree_insert_path(n, "/foo/corge/garply", NULL); -r3_tree_insert_path(n, "/foo/grault/bar", NULL); -r3_tree_insert_path(n, "/foo/grault/baz", NULL); -r3_tree_insert_path(n, "/foo/grault/qux", NULL); -r3_tree_insert_path(n, "/foo/grault/quux", NULL); -r3_tree_insert_path(n, "/foo/grault/corge", NULL); -r3_tree_insert_path(n, "/foo/grault/garply", NULL); -r3_tree_insert_path(n, "/foo/garply/bar", NULL); -r3_tree_insert_path(n, "/foo/garply/baz", NULL); -r3_tree_insert_path(n, "/foo/garply/qux", NULL); -r3_tree_insert_path(n, "/foo/garply/quux", NULL); -r3_tree_insert_path(n, "/foo/garply/corge", NULL); -r3_tree_insert_path(n, "/foo/garply/grault", NULL); -r3_tree_insert_path(n, "/bar/foo/baz", NULL); -r3_tree_insert_path(n, "/bar/foo/qux", NULL); -r3_tree_insert_path(n, "/bar/foo/quux", NULL); -r3_tree_insert_path(n, "/bar/foo/corge", NULL); -r3_tree_insert_path(n, "/bar/foo/grault", NULL); -r3_tree_insert_path(n, "/bar/foo/garply", NULL); -r3_tree_insert_path(n, "/bar/baz/foo", NULL); -r3_tree_insert_path(n, "/bar/baz/qux", NULL); -r3_tree_insert_path(n, "/bar/baz/quux", NULL); -r3_tree_insert_path(n, "/bar/baz/corge", NULL); -r3_tree_insert_path(n, "/bar/baz/grault", NULL); -r3_tree_insert_path(n, "/bar/baz/garply", NULL); -r3_tree_insert_path(n, "/bar/qux/foo", NULL); -r3_tree_insert_path(n, "/bar/qux/baz", NULL); -r3_tree_insert_path(n, "/bar/qux/quux", NULL); -r3_tree_insert_path(n, "/bar/qux/corge", NULL); -r3_tree_insert_path(n, "/bar/qux/grault", NULL); -r3_tree_insert_path(n, "/bar/qux/garply", NULL); -r3_tree_insert_path(n, "/bar/quux/foo", NULL); -r3_tree_insert_path(n, "/bar/quux/baz", NULL); -r3_tree_insert_path(n, "/bar/quux/qux", NULL); -r3_tree_insert_path(n, "/bar/quux/corge", NULL); -r3_tree_insert_path(n, "/bar/quux/grault", NULL); -r3_tree_insert_path(n, "/bar/quux/garply", NULL); -r3_tree_insert_path(n, "/bar/corge/foo", NULL); -r3_tree_insert_path(n, "/bar/corge/baz", NULL); -r3_tree_insert_path(n, "/bar/corge/qux", NULL); -r3_tree_insert_path(n, "/bar/corge/quux", NULL); -r3_tree_insert_path(n, "/bar/corge/grault", NULL); -r3_tree_insert_path(n, "/bar/corge/garply", NULL); -r3_tree_insert_path(n, "/bar/grault/foo", NULL); -r3_tree_insert_path(n, "/bar/grault/baz", NULL); -r3_tree_insert_path(n, "/bar/grault/qux", NULL); -r3_tree_insert_path(n, "/bar/grault/quux", NULL); -r3_tree_insert_path(n, "/bar/grault/corge", NULL); -r3_tree_insert_path(n, "/bar/grault/garply", NULL); -r3_tree_insert_path(n, "/bar/garply/foo", NULL); -r3_tree_insert_path(n, "/bar/garply/baz", NULL); -r3_tree_insert_path(n, "/bar/garply/qux", NULL); -r3_tree_insert_path(n, "/bar/garply/quux", NULL); -r3_tree_insert_path(n, "/bar/garply/corge", NULL); -r3_tree_insert_path(n, "/bar/garply/grault", NULL); -r3_tree_insert_path(n, "/baz/foo/bar", NULL); -r3_tree_insert_path(n, "/baz/foo/qux", NULL); -r3_tree_insert_path(n, "/baz/foo/quux", NULL); -r3_tree_insert_path(n, "/baz/foo/corge", NULL); -r3_tree_insert_path(n, "/baz/foo/grault", NULL); -r3_tree_insert_path(n, "/baz/foo/garply", NULL); -r3_tree_insert_path(n, "/baz/bar/foo", NULL); -r3_tree_insert_path(n, "/baz/bar/qux", NULL); -r3_tree_insert_path(n, "/baz/bar/quux", NULL); -r3_tree_insert_path(n, "/baz/bar/corge", NULL); -r3_tree_insert_path(n, "/baz/bar/grault", NULL); -r3_tree_insert_path(n, "/baz/bar/garply", NULL); -r3_tree_insert_path(n, "/baz/qux/foo", NULL); -r3_tree_insert_path(n, "/baz/qux/bar", NULL); -r3_tree_insert_path(n, "/baz/qux/quux", NULL); -r3_tree_insert_path(n, "/baz/qux/corge", NULL); -r3_tree_insert_path(n, "/baz/qux/grault", NULL); -r3_tree_insert_path(n, "/baz/qux/garply", NULL); -r3_tree_insert_path(n, "/baz/quux/foo", NULL); -r3_tree_insert_path(n, "/baz/quux/bar", NULL); -r3_tree_insert_path(n, "/baz/quux/qux", NULL); -r3_tree_insert_path(n, "/baz/quux/corge", NULL); -r3_tree_insert_path(n, "/baz/quux/grault", NULL); -r3_tree_insert_path(n, "/baz/quux/garply", NULL); -r3_tree_insert_path(n, "/baz/corge/foo", NULL); -r3_tree_insert_path(n, "/baz/corge/bar", NULL); -r3_tree_insert_path(n, "/baz/corge/qux", NULL); -r3_tree_insert_path(n, "/baz/corge/quux", NULL); -r3_tree_insert_path(n, "/baz/corge/grault", NULL); -r3_tree_insert_path(n, "/baz/corge/garply", NULL); -r3_tree_insert_path(n, "/baz/grault/foo", NULL); -r3_tree_insert_path(n, "/baz/grault/bar", NULL); -r3_tree_insert_path(n, "/baz/grault/qux", NULL); -r3_tree_insert_path(n, "/baz/grault/quux", NULL); -r3_tree_insert_path(n, "/baz/grault/corge", NULL); -r3_tree_insert_path(n, "/baz/grault/garply", NULL); -r3_tree_insert_path(n, "/baz/garply/foo", NULL); -r3_tree_insert_path(n, "/baz/garply/bar", NULL); -r3_tree_insert_path(n, "/baz/garply/qux", NULL); -r3_tree_insert_path(n, "/baz/garply/quux", NULL); -r3_tree_insert_path(n, "/baz/garply/corge", NULL); -r3_tree_insert_path(n, "/baz/garply/grault", NULL); -r3_tree_insert_path(n, "/qux/foo/bar", NULL); -r3_tree_insert_path(n, "/qux/foo/baz", NULL); -r3_tree_insert_path(n, "/qux/foo/quux", NULL); -r3_tree_insert_path(n, "/qux/foo/corge", NULL); -r3_tree_insert_path(n, "/qux/foo/grault", NULL); -r3_tree_insert_path(n, "/qux/foo/garply", NULL); -r3_tree_insert_path(n, "/qux/bar/foo", NULL); -r3_tree_insert_path(n, "/qux/bar/baz", NULL); -r3_tree_insert_path(n, "/qux/bar/quux", NULL); -r3_tree_insert_path(n, "/qux/bar/corge", &route_data); -r3_tree_insert_path(n, "/qux/bar/grault", NULL); -r3_tree_insert_path(n, "/qux/bar/garply", NULL); -r3_tree_insert_path(n, "/qux/baz/foo", NULL); -r3_tree_insert_path(n, "/qux/baz/bar", NULL); -r3_tree_insert_path(n, "/qux/baz/quux", NULL); -r3_tree_insert_path(n, "/qux/baz/corge", NULL); -r3_tree_insert_path(n, "/qux/baz/grault", NULL); -r3_tree_insert_path(n, "/qux/baz/garply", NULL); -r3_tree_insert_path(n, "/qux/quux/foo", NULL); -r3_tree_insert_path(n, "/qux/quux/bar", NULL); -r3_tree_insert_path(n, "/qux/quux/baz", NULL); -r3_tree_insert_path(n, "/qux/quux/corge", NULL); -r3_tree_insert_path(n, "/qux/quux/grault", NULL); -r3_tree_insert_path(n, "/qux/quux/garply", NULL); -r3_tree_insert_path(n, "/qux/corge/foo", NULL); -r3_tree_insert_path(n, "/qux/corge/bar", NULL); -r3_tree_insert_path(n, "/qux/corge/baz", NULL); -r3_tree_insert_path(n, "/qux/corge/quux", NULL); -r3_tree_insert_path(n, "/qux/corge/grault", NULL); -r3_tree_insert_path(n, "/qux/corge/garply", NULL); -r3_tree_insert_path(n, "/qux/grault/foo", NULL); -r3_tree_insert_path(n, "/qux/grault/bar", NULL); -r3_tree_insert_path(n, "/qux/grault/baz", NULL); -r3_tree_insert_path(n, "/qux/grault/quux", NULL); -r3_tree_insert_path(n, "/qux/grault/corge", NULL); -r3_tree_insert_path(n, "/qux/grault/garply", NULL); -r3_tree_insert_path(n, "/qux/garply/foo", NULL); -r3_tree_insert_path(n, "/qux/garply/bar", NULL); -r3_tree_insert_path(n, "/qux/garply/baz", NULL); -r3_tree_insert_path(n, "/qux/garply/quux", NULL); -r3_tree_insert_path(n, "/qux/garply/corge", NULL); -r3_tree_insert_path(n, "/qux/garply/grault", NULL); -r3_tree_insert_path(n, "/quux/foo/bar", NULL); -r3_tree_insert_path(n, "/quux/foo/baz", NULL); -r3_tree_insert_path(n, "/quux/foo/qux", NULL); -r3_tree_insert_path(n, "/quux/foo/corge", NULL); -r3_tree_insert_path(n, "/quux/foo/grault", NULL); -r3_tree_insert_path(n, "/quux/foo/garply", NULL); -r3_tree_insert_path(n, "/quux/bar/foo", NULL); -r3_tree_insert_path(n, "/quux/bar/baz", NULL); -r3_tree_insert_path(n, "/quux/bar/qux", NULL); -r3_tree_insert_path(n, "/quux/bar/corge", NULL); -r3_tree_insert_path(n, "/quux/bar/grault", NULL); -r3_tree_insert_path(n, "/quux/bar/garply", NULL); -r3_tree_insert_path(n, "/quux/baz/foo", NULL); -r3_tree_insert_path(n, "/quux/baz/bar", NULL); -r3_tree_insert_path(n, "/quux/baz/qux", NULL); -r3_tree_insert_path(n, "/quux/baz/corge", NULL); -r3_tree_insert_path(n, "/quux/baz/grault", NULL); -r3_tree_insert_path(n, "/quux/baz/garply", NULL); -r3_tree_insert_path(n, "/quux/qux/foo", NULL); -r3_tree_insert_path(n, "/quux/qux/bar", NULL); -r3_tree_insert_path(n, "/quux/qux/baz", NULL); -r3_tree_insert_path(n, "/quux/qux/corge", NULL); -r3_tree_insert_path(n, "/quux/qux/grault", NULL); -r3_tree_insert_path(n, "/quux/qux/garply", NULL); -r3_tree_insert_path(n, "/quux/corge/foo", NULL); -r3_tree_insert_path(n, "/quux/corge/bar", NULL); -r3_tree_insert_path(n, "/quux/corge/baz", NULL); -r3_tree_insert_path(n, "/quux/corge/qux", NULL); -r3_tree_insert_path(n, "/quux/corge/grault", NULL); -r3_tree_insert_path(n, "/quux/corge/garply", NULL); -r3_tree_insert_path(n, "/quux/grault/foo", NULL); -r3_tree_insert_path(n, "/quux/grault/bar", NULL); -r3_tree_insert_path(n, "/quux/grault/baz", NULL); -r3_tree_insert_path(n, "/quux/grault/qux", NULL); -r3_tree_insert_path(n, "/quux/grault/corge", NULL); -r3_tree_insert_path(n, "/quux/grault/garply", NULL); -r3_tree_insert_path(n, "/quux/garply/foo", NULL); -r3_tree_insert_path(n, "/quux/garply/bar", NULL); -r3_tree_insert_path(n, "/quux/garply/baz", NULL); -r3_tree_insert_path(n, "/quux/garply/qux", NULL); -r3_tree_insert_path(n, "/quux/garply/corge", NULL); -r3_tree_insert_path(n, "/quux/garply/grault", NULL); -r3_tree_insert_path(n, "/corge/foo/bar", NULL); -r3_tree_insert_path(n, "/corge/foo/baz", NULL); -r3_tree_insert_path(n, "/corge/foo/qux", NULL); -r3_tree_insert_path(n, "/corge/foo/quux", NULL); -r3_tree_insert_path(n, "/corge/foo/grault", NULL); -r3_tree_insert_path(n, "/corge/foo/garply", NULL); -r3_tree_insert_path(n, "/corge/bar/foo", NULL); -r3_tree_insert_path(n, "/corge/bar/baz", NULL); -r3_tree_insert_path(n, "/corge/bar/qux", NULL); -r3_tree_insert_path(n, "/corge/bar/quux", NULL); -r3_tree_insert_path(n, "/corge/bar/grault", NULL); -r3_tree_insert_path(n, "/corge/bar/garply", NULL); -r3_tree_insert_path(n, "/corge/baz/foo", NULL); -r3_tree_insert_path(n, "/corge/baz/bar", NULL); -r3_tree_insert_path(n, "/corge/baz/qux", NULL); -r3_tree_insert_path(n, "/corge/baz/quux", NULL); -r3_tree_insert_path(n, "/corge/baz/grault", NULL); -r3_tree_insert_path(n, "/corge/baz/garply", NULL); -r3_tree_insert_path(n, "/corge/qux/foo", NULL); -r3_tree_insert_path(n, "/corge/qux/bar", NULL); -r3_tree_insert_path(n, "/corge/qux/baz", NULL); -r3_tree_insert_path(n, "/corge/qux/quux", NULL); -r3_tree_insert_path(n, "/corge/qux/grault", NULL); -r3_tree_insert_path(n, "/corge/qux/garply", NULL); -r3_tree_insert_path(n, "/corge/quux/foo", NULL); -r3_tree_insert_path(n, "/corge/quux/bar", NULL); -r3_tree_insert_path(n, "/corge/quux/baz", NULL); -r3_tree_insert_path(n, "/corge/quux/qux", NULL); -r3_tree_insert_path(n, "/corge/quux/grault", NULL); -r3_tree_insert_path(n, "/corge/quux/garply", NULL); -r3_tree_insert_path(n, "/corge/grault/foo", NULL); -r3_tree_insert_path(n, "/corge/grault/bar", NULL); -r3_tree_insert_path(n, "/corge/grault/baz", NULL); -r3_tree_insert_path(n, "/corge/grault/qux", NULL); -r3_tree_insert_path(n, "/corge/grault/quux", NULL); -r3_tree_insert_path(n, "/corge/grault/garply", NULL); -r3_tree_insert_path(n, "/corge/garply/foo", NULL); -r3_tree_insert_path(n, "/corge/garply/bar", NULL); -r3_tree_insert_path(n, "/corge/garply/baz", NULL); -r3_tree_insert_path(n, "/corge/garply/qux", NULL); -r3_tree_insert_path(n, "/corge/garply/quux", NULL); -r3_tree_insert_path(n, "/corge/garply/grault", NULL); -r3_tree_insert_path(n, "/grault/foo/bar", NULL); -r3_tree_insert_path(n, "/grault/foo/baz", NULL); -r3_tree_insert_path(n, "/grault/foo/qux", NULL); -r3_tree_insert_path(n, "/grault/foo/quux", NULL); -r3_tree_insert_path(n, "/grault/foo/corge", NULL); -r3_tree_insert_path(n, "/grault/foo/garply", NULL); -r3_tree_insert_path(n, "/grault/bar/foo", NULL); -r3_tree_insert_path(n, "/grault/bar/baz", NULL); -r3_tree_insert_path(n, "/grault/bar/qux", NULL); -r3_tree_insert_path(n, "/grault/bar/quux", NULL); -r3_tree_insert_path(n, "/grault/bar/corge", NULL); -r3_tree_insert_path(n, "/grault/bar/garply", NULL); -r3_tree_insert_path(n, "/grault/baz/foo", NULL); -r3_tree_insert_path(n, "/grault/baz/bar", NULL); -r3_tree_insert_path(n, "/grault/baz/qux", NULL); -r3_tree_insert_path(n, "/grault/baz/quux", NULL); -r3_tree_insert_path(n, "/grault/baz/corge", NULL); -r3_tree_insert_path(n, "/grault/baz/garply", NULL); -r3_tree_insert_path(n, "/grault/qux/foo", NULL); -r3_tree_insert_path(n, "/grault/qux/bar", NULL); -r3_tree_insert_path(n, "/grault/qux/baz", NULL); -r3_tree_insert_path(n, "/grault/qux/quux", NULL); -r3_tree_insert_path(n, "/grault/qux/corge", NULL); -r3_tree_insert_path(n, "/grault/qux/garply", NULL); -r3_tree_insert_path(n, "/grault/quux/foo", NULL); -r3_tree_insert_path(n, "/grault/quux/bar", NULL); -r3_tree_insert_path(n, "/grault/quux/baz", NULL); -r3_tree_insert_path(n, "/grault/quux/qux", NULL); -r3_tree_insert_path(n, "/grault/quux/corge", NULL); -r3_tree_insert_path(n, "/grault/quux/garply", NULL); -r3_tree_insert_path(n, "/grault/corge/foo", NULL); -r3_tree_insert_path(n, "/grault/corge/bar", NULL); -r3_tree_insert_path(n, "/grault/corge/baz", NULL); -r3_tree_insert_path(n, "/grault/corge/qux", NULL); -r3_tree_insert_path(n, "/grault/corge/quux", NULL); -r3_tree_insert_path(n, "/grault/corge/garply", NULL); -r3_tree_insert_path(n, "/grault/garply/foo", NULL); -r3_tree_insert_path(n, "/grault/garply/bar", NULL); -r3_tree_insert_path(n, "/grault/garply/baz", NULL); -r3_tree_insert_path(n, "/grault/garply/qux", NULL); -r3_tree_insert_path(n, "/grault/garply/quux", NULL); -r3_tree_insert_path(n, "/grault/garply/corge", NULL); -r3_tree_insert_path(n, "/garply/foo/bar", NULL); -r3_tree_insert_path(n, "/garply/foo/baz", NULL); -r3_tree_insert_path(n, "/garply/foo/qux", NULL); -r3_tree_insert_path(n, "/garply/foo/quux", NULL); -r3_tree_insert_path(n, "/garply/foo/corge", NULL); -r3_tree_insert_path(n, "/garply/foo/grault", NULL); -r3_tree_insert_path(n, "/garply/bar/foo", NULL); -r3_tree_insert_path(n, "/garply/bar/baz", NULL); -r3_tree_insert_path(n, "/garply/bar/qux", NULL); -r3_tree_insert_path(n, "/garply/bar/quux", NULL); -r3_tree_insert_path(n, "/garply/bar/corge", NULL); -r3_tree_insert_path(n, "/garply/bar/grault", NULL); -r3_tree_insert_path(n, "/garply/baz/foo", NULL); -r3_tree_insert_path(n, "/garply/baz/bar", NULL); -r3_tree_insert_path(n, "/garply/baz/qux", NULL); -r3_tree_insert_path(n, "/garply/baz/quux", NULL); -r3_tree_insert_path(n, "/garply/baz/corge", NULL); -r3_tree_insert_path(n, "/garply/baz/grault", NULL); -r3_tree_insert_path(n, "/garply/qux/foo", NULL); -r3_tree_insert_path(n, "/garply/qux/bar", NULL); -r3_tree_insert_path(n, "/garply/qux/baz", NULL); -r3_tree_insert_path(n, "/garply/qux/quux", NULL); -r3_tree_insert_path(n, "/garply/qux/corge", NULL); -r3_tree_insert_path(n, "/garply/qux/grault", NULL); -r3_tree_insert_path(n, "/garply/quux/foo", NULL); -r3_tree_insert_path(n, "/garply/quux/bar", NULL); -r3_tree_insert_path(n, "/garply/quux/baz", NULL); -r3_tree_insert_path(n, "/garply/quux/qux", NULL); -r3_tree_insert_path(n, "/garply/quux/corge", NULL); -r3_tree_insert_path(n, "/garply/quux/grault", NULL); -r3_tree_insert_path(n, "/garply/corge/foo", NULL); -r3_tree_insert_path(n, "/garply/corge/bar", NULL); -r3_tree_insert_path(n, "/garply/corge/baz", NULL); -r3_tree_insert_path(n, "/garply/corge/qux", NULL); -r3_tree_insert_path(n, "/garply/corge/quux", NULL); -r3_tree_insert_path(n, "/garply/corge/grault", NULL); -r3_tree_insert_path(n, "/garply/grault/foo", NULL); -r3_tree_insert_path(n, "/garply/grault/bar", NULL); -r3_tree_insert_path(n, "/garply/grault/baz", NULL); -r3_tree_insert_path(n, "/garply/grault/qux", NULL); -r3_tree_insert_path(n, "/garply/grault/quux", NULL); -r3_tree_insert_path(n, "/garply/grault/corge", NULL); + r3_tree_insert_path(n, "/foo/bar/baz", NULL); + r3_tree_insert_path(n, "/foo/bar/qux", NULL); + r3_tree_insert_path(n, "/foo/bar/quux", NULL); + r3_tree_insert_path(n, "/foo/bar/corge", NULL); + r3_tree_insert_path(n, "/foo/bar/grault", NULL); + r3_tree_insert_path(n, "/foo/bar/garply", NULL); + r3_tree_insert_path(n, "/foo/baz/bar", NULL); + r3_tree_insert_path(n, "/foo/baz/qux", NULL); + r3_tree_insert_path(n, "/foo/baz/quux", NULL); + r3_tree_insert_path(n, "/foo/baz/corge", NULL); + r3_tree_insert_path(n, "/foo/baz/grault", NULL); + r3_tree_insert_path(n, "/foo/baz/garply", NULL); + r3_tree_insert_path(n, "/foo/qux/bar", NULL); + r3_tree_insert_path(n, "/foo/qux/baz", NULL); + r3_tree_insert_path(n, "/foo/qux/quux", NULL); + r3_tree_insert_path(n, "/foo/qux/corge", NULL); + r3_tree_insert_path(n, "/foo/qux/grault", NULL); + r3_tree_insert_path(n, "/foo/qux/garply", NULL); + r3_tree_insert_path(n, "/foo/quux/bar", NULL); + r3_tree_insert_path(n, "/foo/quux/baz", NULL); + r3_tree_insert_path(n, "/foo/quux/qux", NULL); + r3_tree_insert_path(n, "/foo/quux/corge", NULL); + r3_tree_insert_path(n, "/foo/quux/grault", NULL); + r3_tree_insert_path(n, "/foo/quux/garply", NULL); + r3_tree_insert_path(n, "/foo/corge/bar", NULL); + r3_tree_insert_path(n, "/foo/corge/baz", NULL); + r3_tree_insert_path(n, "/foo/corge/qux", NULL); + r3_tree_insert_path(n, "/foo/corge/quux", NULL); + r3_tree_insert_path(n, "/foo/corge/grault", NULL); + r3_tree_insert_path(n, "/foo/corge/garply", NULL); + r3_tree_insert_path(n, "/foo/grault/bar", NULL); + r3_tree_insert_path(n, "/foo/grault/baz", NULL); + r3_tree_insert_path(n, "/foo/grault/qux", NULL); + r3_tree_insert_path(n, "/foo/grault/quux", NULL); + r3_tree_insert_path(n, "/foo/grault/corge", NULL); + r3_tree_insert_path(n, "/foo/grault/garply", NULL); + r3_tree_insert_path(n, "/foo/garply/bar", NULL); + r3_tree_insert_path(n, "/foo/garply/baz", NULL); + r3_tree_insert_path(n, "/foo/garply/qux", NULL); + r3_tree_insert_path(n, "/foo/garply/quux", NULL); + r3_tree_insert_path(n, "/foo/garply/corge", NULL); + r3_tree_insert_path(n, "/foo/garply/grault", NULL); + r3_tree_insert_path(n, "/bar/foo/baz", NULL); + r3_tree_insert_path(n, "/bar/foo/qux", NULL); + r3_tree_insert_path(n, "/bar/foo/quux", NULL); + r3_tree_insert_path(n, "/bar/foo/corge", NULL); + r3_tree_insert_path(n, "/bar/foo/grault", NULL); + r3_tree_insert_path(n, "/bar/foo/garply", NULL); + r3_tree_insert_path(n, "/bar/baz/foo", NULL); + r3_tree_insert_path(n, "/bar/baz/qux", NULL); + r3_tree_insert_path(n, "/bar/baz/quux", NULL); + r3_tree_insert_path(n, "/bar/baz/corge", NULL); + r3_tree_insert_path(n, "/bar/baz/grault", NULL); + r3_tree_insert_path(n, "/bar/baz/garply", NULL); + r3_tree_insert_path(n, "/bar/qux/foo", NULL); + r3_tree_insert_path(n, "/bar/qux/baz", NULL); + r3_tree_insert_path(n, "/bar/qux/quux", NULL); + r3_tree_insert_path(n, "/bar/qux/corge", NULL); + r3_tree_insert_path(n, "/bar/qux/grault", NULL); + r3_tree_insert_path(n, "/bar/qux/garply", NULL); + r3_tree_insert_path(n, "/bar/quux/foo", NULL); + r3_tree_insert_path(n, "/bar/quux/baz", NULL); + r3_tree_insert_path(n, "/bar/quux/qux", NULL); + r3_tree_insert_path(n, "/bar/quux/corge", NULL); + r3_tree_insert_path(n, "/bar/quux/grault", NULL); + r3_tree_insert_path(n, "/bar/quux/garply", NULL); + r3_tree_insert_path(n, "/bar/corge/foo", NULL); + r3_tree_insert_path(n, "/bar/corge/baz", NULL); + r3_tree_insert_path(n, "/bar/corge/qux", NULL); + r3_tree_insert_path(n, "/bar/corge/quux", NULL); + r3_tree_insert_path(n, "/bar/corge/grault", NULL); + r3_tree_insert_path(n, "/bar/corge/garply", NULL); + r3_tree_insert_path(n, "/bar/grault/foo", NULL); + r3_tree_insert_path(n, "/bar/grault/baz", NULL); + r3_tree_insert_path(n, "/bar/grault/qux", NULL); + r3_tree_insert_path(n, "/bar/grault/quux", NULL); + r3_tree_insert_path(n, "/bar/grault/corge", NULL); + r3_tree_insert_path(n, "/bar/grault/garply", NULL); + r3_tree_insert_path(n, "/bar/garply/foo", NULL); + r3_tree_insert_path(n, "/bar/garply/baz", NULL); + r3_tree_insert_path(n, "/bar/garply/qux", NULL); + r3_tree_insert_path(n, "/bar/garply/quux", NULL); + r3_tree_insert_path(n, "/bar/garply/corge", NULL); + r3_tree_insert_path(n, "/bar/garply/grault", NULL); + r3_tree_insert_path(n, "/baz/foo/bar", NULL); + r3_tree_insert_path(n, "/baz/foo/qux", NULL); + r3_tree_insert_path(n, "/baz/foo/quux", NULL); + r3_tree_insert_path(n, "/baz/foo/corge", NULL); + r3_tree_insert_path(n, "/baz/foo/grault", NULL); + r3_tree_insert_path(n, "/baz/foo/garply", NULL); + r3_tree_insert_path(n, "/baz/bar/foo", NULL); + r3_tree_insert_path(n, "/baz/bar/qux", NULL); + r3_tree_insert_path(n, "/baz/bar/quux", NULL); + r3_tree_insert_path(n, "/baz/bar/corge", NULL); + r3_tree_insert_path(n, "/baz/bar/grault", NULL); + r3_tree_insert_path(n, "/baz/bar/garply", NULL); + r3_tree_insert_path(n, "/baz/qux/foo", NULL); + r3_tree_insert_path(n, "/baz/qux/bar", NULL); + r3_tree_insert_path(n, "/baz/qux/quux", NULL); + r3_tree_insert_path(n, "/baz/qux/corge", NULL); + r3_tree_insert_path(n, "/baz/qux/grault", NULL); + r3_tree_insert_path(n, "/baz/qux/garply", NULL); + r3_tree_insert_path(n, "/baz/quux/foo", NULL); + r3_tree_insert_path(n, "/baz/quux/bar", NULL); + r3_tree_insert_path(n, "/baz/quux/qux", NULL); + r3_tree_insert_path(n, "/baz/quux/corge", NULL); + r3_tree_insert_path(n, "/baz/quux/grault", NULL); + r3_tree_insert_path(n, "/baz/quux/garply", NULL); + r3_tree_insert_path(n, "/baz/corge/foo", NULL); + r3_tree_insert_path(n, "/baz/corge/bar", NULL); + r3_tree_insert_path(n, "/baz/corge/qux", NULL); + r3_tree_insert_path(n, "/baz/corge/quux", NULL); + r3_tree_insert_path(n, "/baz/corge/grault", NULL); + r3_tree_insert_path(n, "/baz/corge/garply", NULL); + r3_tree_insert_path(n, "/baz/grault/foo", NULL); + r3_tree_insert_path(n, "/baz/grault/bar", NULL); + r3_tree_insert_path(n, "/baz/grault/qux", NULL); + r3_tree_insert_path(n, "/baz/grault/quux", NULL); + r3_tree_insert_path(n, "/baz/grault/corge", NULL); + r3_tree_insert_path(n, "/baz/grault/garply", NULL); + r3_tree_insert_path(n, "/baz/garply/foo", NULL); + r3_tree_insert_path(n, "/baz/garply/bar", NULL); + r3_tree_insert_path(n, "/baz/garply/qux", NULL); + r3_tree_insert_path(n, "/baz/garply/quux", NULL); + r3_tree_insert_path(n, "/baz/garply/corge", NULL); + r3_tree_insert_path(n, "/baz/garply/grault", NULL); + r3_tree_insert_path(n, "/qux/foo/bar", NULL); + r3_tree_insert_path(n, "/qux/foo/baz", NULL); + r3_tree_insert_path(n, "/qux/foo/quux", NULL); + r3_tree_insert_path(n, "/qux/foo/corge", NULL); + r3_tree_insert_path(n, "/qux/foo/grault", NULL); + r3_tree_insert_path(n, "/qux/foo/garply", NULL); + r3_tree_insert_path(n, "/qux/bar/foo", NULL); + r3_tree_insert_path(n, "/qux/bar/baz", NULL); + r3_tree_insert_path(n, "/qux/bar/quux", NULL); + r3_tree_insert_path(n, "/qux/bar/corge", &route_data); + r3_tree_insert_path(n, "/qux/bar/grault", NULL); + r3_tree_insert_path(n, "/qux/bar/garply", NULL); + r3_tree_insert_path(n, "/qux/baz/foo", NULL); + r3_tree_insert_path(n, "/qux/baz/bar", NULL); + r3_tree_insert_path(n, "/qux/baz/quux", NULL); + r3_tree_insert_path(n, "/qux/baz/corge", NULL); + r3_tree_insert_path(n, "/qux/baz/grault", NULL); + r3_tree_insert_path(n, "/qux/baz/garply", NULL); + r3_tree_insert_path(n, "/qux/quux/foo", NULL); + r3_tree_insert_path(n, "/qux/quux/bar", NULL); + r3_tree_insert_path(n, "/qux/quux/baz", NULL); + r3_tree_insert_path(n, "/qux/quux/corge", NULL); + r3_tree_insert_path(n, "/qux/quux/grault", NULL); + r3_tree_insert_path(n, "/qux/quux/garply", NULL); + r3_tree_insert_path(n, "/qux/corge/foo", NULL); + r3_tree_insert_path(n, "/qux/corge/bar", NULL); + r3_tree_insert_path(n, "/qux/corge/baz", NULL); + r3_tree_insert_path(n, "/qux/corge/quux", NULL); + r3_tree_insert_path(n, "/qux/corge/grault", NULL); + r3_tree_insert_path(n, "/qux/corge/garply", NULL); + r3_tree_insert_path(n, "/qux/grault/foo", NULL); + r3_tree_insert_path(n, "/qux/grault/bar", NULL); + r3_tree_insert_path(n, "/qux/grault/baz", NULL); + r3_tree_insert_path(n, "/qux/grault/quux", NULL); + r3_tree_insert_path(n, "/qux/grault/corge", NULL); + r3_tree_insert_path(n, "/qux/grault/garply", NULL); + r3_tree_insert_path(n, "/qux/garply/foo", NULL); + r3_tree_insert_path(n, "/qux/garply/bar", NULL); + r3_tree_insert_path(n, "/qux/garply/baz", NULL); + r3_tree_insert_path(n, "/qux/garply/quux", NULL); + r3_tree_insert_path(n, "/qux/garply/corge", NULL); + r3_tree_insert_path(n, "/qux/garply/grault", NULL); + r3_tree_insert_path(n, "/quux/foo/bar", NULL); + r3_tree_insert_path(n, "/quux/foo/baz", NULL); + r3_tree_insert_path(n, "/quux/foo/qux", NULL); + r3_tree_insert_path(n, "/quux/foo/corge", NULL); + r3_tree_insert_path(n, "/quux/foo/grault", NULL); + r3_tree_insert_path(n, "/quux/foo/garply", NULL); + r3_tree_insert_path(n, "/quux/bar/foo", NULL); + r3_tree_insert_path(n, "/quux/bar/baz", NULL); + r3_tree_insert_path(n, "/quux/bar/qux", NULL); + r3_tree_insert_path(n, "/quux/bar/corge", NULL); + r3_tree_insert_path(n, "/quux/bar/grault", NULL); + r3_tree_insert_path(n, "/quux/bar/garply", NULL); + r3_tree_insert_path(n, "/quux/baz/foo", NULL); + r3_tree_insert_path(n, "/quux/baz/bar", NULL); + r3_tree_insert_path(n, "/quux/baz/qux", NULL); + r3_tree_insert_path(n, "/quux/baz/corge", NULL); + r3_tree_insert_path(n, "/quux/baz/grault", NULL); + r3_tree_insert_path(n, "/quux/baz/garply", NULL); + r3_tree_insert_path(n, "/quux/qux/foo", NULL); + r3_tree_insert_path(n, "/quux/qux/bar", NULL); + r3_tree_insert_path(n, "/quux/qux/baz", NULL); + r3_tree_insert_path(n, "/quux/qux/corge", NULL); + r3_tree_insert_path(n, "/quux/qux/grault", NULL); + r3_tree_insert_path(n, "/quux/qux/garply", NULL); + r3_tree_insert_path(n, "/quux/corge/foo", NULL); + r3_tree_insert_path(n, "/quux/corge/bar", NULL); + r3_tree_insert_path(n, "/quux/corge/baz", NULL); + r3_tree_insert_path(n, "/quux/corge/qux", NULL); + r3_tree_insert_path(n, "/quux/corge/grault", NULL); + r3_tree_insert_path(n, "/quux/corge/garply", NULL); + r3_tree_insert_path(n, "/quux/grault/foo", NULL); + r3_tree_insert_path(n, "/quux/grault/bar", NULL); + r3_tree_insert_path(n, "/quux/grault/baz", NULL); + r3_tree_insert_path(n, "/quux/grault/qux", NULL); + r3_tree_insert_path(n, "/quux/grault/corge", NULL); + r3_tree_insert_path(n, "/quux/grault/garply", NULL); + r3_tree_insert_path(n, "/quux/garply/foo", NULL); + r3_tree_insert_path(n, "/quux/garply/bar", NULL); + r3_tree_insert_path(n, "/quux/garply/baz", NULL); + r3_tree_insert_path(n, "/quux/garply/qux", NULL); + r3_tree_insert_path(n, "/quux/garply/corge", NULL); + r3_tree_insert_path(n, "/quux/garply/grault", NULL); + r3_tree_insert_path(n, "/corge/foo/bar", NULL); + r3_tree_insert_path(n, "/corge/foo/baz", NULL); + r3_tree_insert_path(n, "/corge/foo/qux", NULL); + r3_tree_insert_path(n, "/corge/foo/quux", NULL); + r3_tree_insert_path(n, "/corge/foo/grault", NULL); + r3_tree_insert_path(n, "/corge/foo/garply", NULL); + r3_tree_insert_path(n, "/corge/bar/foo", NULL); + r3_tree_insert_path(n, "/corge/bar/baz", NULL); + r3_tree_insert_path(n, "/corge/bar/qux", NULL); + r3_tree_insert_path(n, "/corge/bar/quux", NULL); + r3_tree_insert_path(n, "/corge/bar/grault", NULL); + r3_tree_insert_path(n, "/corge/bar/garply", NULL); + r3_tree_insert_path(n, "/corge/baz/foo", NULL); + r3_tree_insert_path(n, "/corge/baz/bar", NULL); + r3_tree_insert_path(n, "/corge/baz/qux", NULL); + r3_tree_insert_path(n, "/corge/baz/quux", NULL); + r3_tree_insert_path(n, "/corge/baz/grault", NULL); + r3_tree_insert_path(n, "/corge/baz/garply", NULL); + r3_tree_insert_path(n, "/corge/qux/foo", NULL); + r3_tree_insert_path(n, "/corge/qux/bar", NULL); + r3_tree_insert_path(n, "/corge/qux/baz", NULL); + r3_tree_insert_path(n, "/corge/qux/quux", NULL); + r3_tree_insert_path(n, "/corge/qux/grault", NULL); + r3_tree_insert_path(n, "/corge/qux/garply", NULL); + r3_tree_insert_path(n, "/corge/quux/foo", NULL); + r3_tree_insert_path(n, "/corge/quux/bar", NULL); + r3_tree_insert_path(n, "/corge/quux/baz", NULL); + r3_tree_insert_path(n, "/corge/quux/qux", NULL); + r3_tree_insert_path(n, "/corge/quux/grault", NULL); + r3_tree_insert_path(n, "/corge/quux/garply", NULL); + r3_tree_insert_path(n, "/corge/grault/foo", NULL); + r3_tree_insert_path(n, "/corge/grault/bar", NULL); + r3_tree_insert_path(n, "/corge/grault/baz", NULL); + r3_tree_insert_path(n, "/corge/grault/qux", NULL); + r3_tree_insert_path(n, "/corge/grault/quux", NULL); + r3_tree_insert_path(n, "/corge/grault/garply", NULL); + r3_tree_insert_path(n, "/corge/garply/foo", NULL); + r3_tree_insert_path(n, "/corge/garply/bar", NULL); + r3_tree_insert_path(n, "/corge/garply/baz", NULL); + r3_tree_insert_path(n, "/corge/garply/qux", NULL); + r3_tree_insert_path(n, "/corge/garply/quux", NULL); + r3_tree_insert_path(n, "/corge/garply/grault", NULL); + r3_tree_insert_path(n, "/grault/foo/bar", NULL); + r3_tree_insert_path(n, "/grault/foo/baz", NULL); + r3_tree_insert_path(n, "/grault/foo/qux", NULL); + r3_tree_insert_path(n, "/grault/foo/quux", NULL); + r3_tree_insert_path(n, "/grault/foo/corge", NULL); + r3_tree_insert_path(n, "/grault/foo/garply", NULL); + r3_tree_insert_path(n, "/grault/bar/foo", NULL); + r3_tree_insert_path(n, "/grault/bar/baz", NULL); + r3_tree_insert_path(n, "/grault/bar/qux", NULL); + r3_tree_insert_path(n, "/grault/bar/quux", NULL); + r3_tree_insert_path(n, "/grault/bar/corge", NULL); + r3_tree_insert_path(n, "/grault/bar/garply", NULL); + r3_tree_insert_path(n, "/grault/baz/foo", NULL); + r3_tree_insert_path(n, "/grault/baz/bar", NULL); + r3_tree_insert_path(n, "/grault/baz/qux", NULL); + r3_tree_insert_path(n, "/grault/baz/quux", NULL); + r3_tree_insert_path(n, "/grault/baz/corge", NULL); + r3_tree_insert_path(n, "/grault/baz/garply", NULL); + r3_tree_insert_path(n, "/grault/qux/foo", NULL); + r3_tree_insert_path(n, "/grault/qux/bar", NULL); + r3_tree_insert_path(n, "/grault/qux/baz", NULL); + r3_tree_insert_path(n, "/grault/qux/quux", NULL); + r3_tree_insert_path(n, "/grault/qux/corge", NULL); + r3_tree_insert_path(n, "/grault/qux/garply", NULL); + r3_tree_insert_path(n, "/grault/quux/foo", NULL); + r3_tree_insert_path(n, "/grault/quux/bar", NULL); + r3_tree_insert_path(n, "/grault/quux/baz", NULL); + r3_tree_insert_path(n, "/grault/quux/qux", NULL); + r3_tree_insert_path(n, "/grault/quux/corge", NULL); + r3_tree_insert_path(n, "/grault/quux/garply", NULL); + r3_tree_insert_path(n, "/grault/corge/foo", NULL); + r3_tree_insert_path(n, "/grault/corge/bar", NULL); + r3_tree_insert_path(n, "/grault/corge/baz", NULL); + r3_tree_insert_path(n, "/grault/corge/qux", NULL); + r3_tree_insert_path(n, "/grault/corge/quux", NULL); + r3_tree_insert_path(n, "/grault/corge/garply", NULL); + r3_tree_insert_path(n, "/grault/garply/foo", NULL); + r3_tree_insert_path(n, "/grault/garply/bar", NULL); + r3_tree_insert_path(n, "/grault/garply/baz", NULL); + r3_tree_insert_path(n, "/grault/garply/qux", NULL); + r3_tree_insert_path(n, "/grault/garply/quux", NULL); + r3_tree_insert_path(n, "/grault/garply/corge", NULL); + r3_tree_insert_path(n, "/garply/foo/bar", NULL); + r3_tree_insert_path(n, "/garply/foo/baz", NULL); + r3_tree_insert_path(n, "/garply/foo/qux", NULL); + r3_tree_insert_path(n, "/garply/foo/quux", NULL); + r3_tree_insert_path(n, "/garply/foo/corge", NULL); + r3_tree_insert_path(n, "/garply/foo/grault", NULL); + r3_tree_insert_path(n, "/garply/bar/foo", NULL); + r3_tree_insert_path(n, "/garply/bar/baz", NULL); + r3_tree_insert_path(n, "/garply/bar/qux", NULL); + r3_tree_insert_path(n, "/garply/bar/quux", NULL); + r3_tree_insert_path(n, "/garply/bar/corge", NULL); + r3_tree_insert_path(n, "/garply/bar/grault", NULL); + r3_tree_insert_path(n, "/garply/baz/foo", NULL); + r3_tree_insert_path(n, "/garply/baz/bar", NULL); + r3_tree_insert_path(n, "/garply/baz/qux", NULL); + r3_tree_insert_path(n, "/garply/baz/quux", NULL); + r3_tree_insert_path(n, "/garply/baz/corge", NULL); + r3_tree_insert_path(n, "/garply/baz/grault", NULL); + r3_tree_insert_path(n, "/garply/qux/foo", NULL); + r3_tree_insert_path(n, "/garply/qux/bar", NULL); + r3_tree_insert_path(n, "/garply/qux/baz", NULL); + r3_tree_insert_path(n, "/garply/qux/quux", NULL); + r3_tree_insert_path(n, "/garply/qux/corge", NULL); + r3_tree_insert_path(n, "/garply/qux/grault", NULL); + r3_tree_insert_path(n, "/garply/quux/foo", NULL); + r3_tree_insert_path(n, "/garply/quux/bar", NULL); + r3_tree_insert_path(n, "/garply/quux/baz", NULL); + r3_tree_insert_path(n, "/garply/quux/qux", NULL); + r3_tree_insert_path(n, "/garply/quux/corge", NULL); + r3_tree_insert_path(n, "/garply/quux/grault", NULL); + r3_tree_insert_path(n, "/garply/corge/foo", NULL); + r3_tree_insert_path(n, "/garply/corge/bar", NULL); + r3_tree_insert_path(n, "/garply/corge/baz", NULL); + r3_tree_insert_path(n, "/garply/corge/qux", NULL); + r3_tree_insert_path(n, "/garply/corge/quux", NULL); + r3_tree_insert_path(n, "/garply/corge/grault", NULL); + r3_tree_insert_path(n, "/garply/grault/foo", NULL); + r3_tree_insert_path(n, "/garply/grault/bar", NULL); + r3_tree_insert_path(n, "/garply/grault/baz", NULL); + r3_tree_insert_path(n, "/garply/grault/qux", NULL); + r3_tree_insert_path(n, "/garply/grault/quux", NULL); + r3_tree_insert_path(n, "/garply/grault/corge", NULL); r3_tree_compile(n); @@ -735,35 +735,37 @@ r3_tree_insert_path(n, "/garply/grault/corge", NULL); END_TEST -Suite* r3_suite (void) { - Suite *suite = suite_create("blah"); +Suite* r3_suite (void) +{ + Suite *suite = suite_create("blah"); - TCase *tcase = tcase_create("testcase"); - tcase_add_test(tcase, test_str_array); - tcase_add_test(tcase, test_ltrim_slash); - tcase_add_test(tcase, test_r3_node_construct_uniq); - tcase_add_test(tcase, test_r3_node_find_edge); - tcase_add_test(tcase, test_r3_tree_insert_pathl); - tcase_add_test(tcase, test_compile_slug); - tcase_add_test(tcase, test_compile); - tcase_add_test(tcase, test_route_cmp); - tcase_add_test(tcase, test_insert_route); - tcase_add_test(tcase, test_pcre_pattern_simple); - tcase_add_test(tcase, test_pcre_pattern_more); - tcase_add_test(tcase, test_pcre_patterns_insert); - tcase_add_test(tcase, benchmark_str); + TCase *tcase = tcase_create("testcase"); + tcase_add_test(tcase, test_str_array); + tcase_add_test(tcase, test_ltrim_slash); + tcase_add_test(tcase, test_r3_node_construct_uniq); + tcase_add_test(tcase, test_r3_node_find_edge); + tcase_add_test(tcase, test_r3_tree_insert_pathl); + tcase_add_test(tcase, test_compile_slug); + tcase_add_test(tcase, test_compile); + tcase_add_test(tcase, test_route_cmp); + tcase_add_test(tcase, test_insert_route); + tcase_add_test(tcase, test_pcre_pattern_simple); + tcase_add_test(tcase, test_pcre_pattern_more); + tcase_add_test(tcase, test_pcre_patterns_insert); + tcase_add_test(tcase, benchmark_str); - suite_add_tcase(suite, tcase); + suite_add_tcase(suite, tcase); - return suite; + return suite; } -int main (int argc, char *argv[]) { - int number_failed; - Suite *suite = r3_suite(); - SRunner *runner = srunner_create(suite); - srunner_run_all(runner, CK_NORMAL); - number_failed = srunner_ntests_failed(runner); - srunner_free(runner); - return number_failed; +int main (int argc, char *argv[]) +{ + int number_failed; + Suite *suite = r3_suite(); + SRunner *runner = srunner_create(suite); + srunner_run_all(runner, CK_NORMAL); + number_failed = srunner_ntests_failed(runner); + srunner_free(runner); + return number_failed; }