Formatted the project using AStyle.

This commit is contained in:
Omer Katz 2014-05-19 13:54:13 +03:00
parent 6ea4405ddf
commit 8fc6333de5
13 changed files with 645 additions and 597 deletions

View file

@ -9,27 +9,27 @@
#define LIST_H #define LIST_H
#include <pthread.h> #include <pthread.h>
typedef struct _list_item { typedef struct _list_item {
void *value; void *value;
struct _list_item *prev; struct _list_item *prev;
struct _list_item *next; struct _list_item *next;
} list_item; } list_item;
typedef struct { typedef struct {
int count; int count;
list_item *head; list_item *head;
list_item *tail; list_item *tail;
pthread_mutex_t mutex; pthread_mutex_t mutex;
} list; } list;
list *list_create(); list *list_create();
void list_free(list *l); void list_free(list *l);
list_item *list_add_element(list *l, void *ptr); list_item *list_add_element(list *l, void *ptr);
int list_remove_element(list *l, void *ptr); int list_remove_element(list *l, void *ptr);
void list_each_element(list *l, int (*func)(list_item *)); void list_each_element(list *l, int (*func)(list_item *));
#endif /* !LIST_H */ #endif /* !LIST_H */

View file

@ -11,9 +11,9 @@
#include "r3_define.h" #include "r3_define.h"
typedef struct _str_array { typedef struct _str_array {
char **tokens; char **tokens;
int len; int len;
int cap; int cap;
} str_array; } str_array;
str_array * str_array_create(int cap); str_array * str_array_create(int cap);

4
main.c
View file

@ -1,4 +1,3 @@
#include <stdlib.h> #include <stdlib.h>
#include <pcre.h> #include <pcre.h>
#include "main.h" #include "main.h"
@ -12,6 +11,7 @@ typedef struct _Node {
void compile() { void compile()
{
} }

View file

@ -24,7 +24,8 @@
#include "r3.h" #include "r3.h"
#include "str_array.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) ); edge * e = (edge*) malloc( sizeof(edge) );
e->pattern = pattern; e->pattern = pattern;
e->pattern_len = pattern_len; 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) * 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; node *new_child;
edge *e1; edge *e1;
char * s1 = e->pattern + dl; 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 new_child->data = e->child->data; // copy data pointer
e->child->data = NULL; e->child->data = NULL;
// truncate the original edge pattern // truncate the original edge pattern
char *op = e->pattern; char *op = e->pattern;
e->pattern = strndup(e->pattern, dl); e->pattern = strndup(e->pattern, dl);
e->pattern_len = dl; e->pattern_len = dl;
@ -81,7 +83,8 @@ node * r3_edge_branch(edge *e, int dl) {
return new_child; return new_child;
} }
void r3_edge_free(edge * e) { void r3_edge_free(edge * e)
{
if (e->pattern) { if (e->pattern) {
free(e->pattern); free(e->pattern);
} }

View file

@ -12,13 +12,15 @@
#include "r3_gvc.h" #include "r3_gvc.h"
char * node_id_str(int id) { char * node_id_str(int id)
{
char * name = malloc(sizeof(char) * 20); char * name = malloc(sizeof(char) * 20);
sprintf(name, "#%d", id); sprintf(name, "#%d", id);
return name; 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; edge * e;
Agnode_t *agn_child; Agnode_t *agn_child;
Agedge_t *agn_edge; 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) 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) int r3_tree_render_file(node * tree, char * format, char * filename)
{ {

View file

@ -6,123 +6,120 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include "r3_list.h" #include "r3_list.h"
/* Naive linked list implementation */ /* Naive linked list implementation */
list * list *
list_create() list_create()
{ {
list *l = (list *) malloc(sizeof(list)); list *l = (list *) malloc(sizeof(list));
l->count = 0; l->count = 0;
l->head = NULL; l->head = NULL;
l->tail = NULL; l->tail = NULL;
pthread_mutex_init(&(l->mutex), NULL); pthread_mutex_init(&(l->mutex), NULL);
return l; return l;
} }
void void
list_free(l) list_free(l)
list *l; list *l;
{ {
list_item *li, *tmp; list_item *li, *tmp;
pthread_mutex_lock(&(l->mutex)); pthread_mutex_lock(&(l->mutex));
if (l != NULL) { if (l != NULL) {
li = l->head; li = l->head;
while (li != NULL) { while (li != NULL) {
tmp = li->next; tmp = li->next;
free(li); free(li);
li = tmp; li = tmp;
}
} }
}
pthread_mutex_unlock(&(l->mutex));
pthread_mutex_unlock(&(l->mutex)); pthread_mutex_destroy(&(l->mutex));
pthread_mutex_destroy(&(l->mutex)); free(l);
free(l);
} }
list_item * list_item *
list_add_element(l, ptr) list_add_element(l, ptr)
list *l; list *l;
void *ptr; void *ptr;
{ {
list_item *li; list_item *li;
pthread_mutex_lock(&(l->mutex)); pthread_mutex_lock(&(l->mutex));
li = (list_item *) malloc(sizeof(list_item)); li = (list_item *) malloc(sizeof(list_item));
li->value = ptr; li->value = ptr;
li->next = NULL; li->next = NULL;
li->prev = l->tail; li->prev = l->tail;
if (l->tail == NULL) { if (l->tail == NULL) {
l->head = l->tail = li; l->head = l->tail = li;
} } else {
else { l->tail = li;
l->tail = li; }
} l->count++;
l->count++;
pthread_mutex_unlock(&(l->mutex));
pthread_mutex_unlock(&(l->mutex));
return li;
return li;
} }
int int
list_remove_element(l, ptr) list_remove_element(l, ptr)
list *l; list *l;
void *ptr; void *ptr;
{ {
int result = 0; int result = 0;
list_item *li = l->head; list_item *li = l->head;
pthread_mutex_lock(&(l->mutex)); pthread_mutex_lock(&(l->mutex));
while (li != NULL) { while (li != NULL) {
if (li->value == ptr) { if (li->value == ptr) {
if (li->prev == NULL) { if (li->prev == NULL) {
l->head = li->next; l->head = li->next;
} } else {
else { li->prev->next = li->next;
li->prev->next = li->next; }
}
if (li->next == NULL) {
if (li->next == NULL) { l->tail = li->prev;
l->tail = li->prev; } else {
} li->next->prev = li->prev;
else { }
li->next->prev = li->prev; l->count--;
} free(li);
l->count--; result = 1;
free(li); break;
result = 1; }
break; li = li->next;
} }
li = li->next;
} pthread_mutex_unlock(&(l->mutex));
pthread_mutex_unlock(&(l->mutex)); return result;
return result;
} }
void void
list_each_element(l, func) list_each_element(l, func)
list *l; list *l;
int (*func)(list_item *); int (*func)(list_item *);
{ {
list_item *li; list_item *li;
pthread_mutex_lock(&(l->mutex)); pthread_mutex_lock(&(l->mutex));
li = l->head; li = l->head;
while (li != NULL) { while (li != NULL) {
if (func(li) == 1) { if (func(li) == 1) {
break; break;
}
li = li->next;
} }
li = li->next;
} pthread_mutex_unlock(&(l->mutex));
pthread_mutex_unlock(&(l->mutex));
} }

View file

@ -24,7 +24,8 @@
/** /**
* Create a node object * Create a node object
*/ */
node * r3_tree_create(int cap) { node * r3_tree_create(int cap)
{
node * n = (node*) malloc( sizeof(node) ); node * n = (node*) malloc( sizeof(node) );
n->edges = (edge**) malloc( sizeof(edge*) * 10 ); n->edges = (edge**) malloc( sizeof(edge*) * 10 );
@ -39,7 +40,8 @@ node * r3_tree_create(int cap) {
return n; return n;
} }
void r3_tree_free(node * tree) { void r3_tree_free(node * tree)
{
for (int i = 0 ; i < tree->edge_len ; i++ ) { for (int i = 0 ; i < tree->edge_len ; i++ ) {
if (tree->edges[i]) { if (tree->edges[i]) {
r3_edge_free(tree->edges[ i ]); r3_edge_free(tree->edges[ i ]);
@ -52,7 +54,7 @@ void r3_tree_free(node * tree) {
free(tree->pcre_pattern); free(tree->pcre_pattern);
if (tree->pcre_extra) if (tree->pcre_extra)
free(tree->pcre_extra); free(tree->pcre_extra);
if (tree->ov) if (tree->ov)
free(tree->ov); free(tree->ov);
free(tree->edges); free(tree->edges);
// str_array_free(tree->edge_patterns); // str_array_free(tree->edge_patterns);
@ -63,7 +65,8 @@ void r3_tree_free(node * tree) {
/* parent node, edge pattern, child */ /* 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 // find the same sub-pattern, if it does not exist, create one
edge * e; 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) { if (!n->edges) {
n->edge_cap = 3; n->edge_cap = 3;
n->edges = malloc(sizeof(edge) * n->edge_cap); 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; 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; edge * e;
for (int i = 0 ; i < n->edge_len ; i++ ) { for (int i = 0 ; i < n->edge_len ; i++ ) {
e = n->edges[i]; e = n->edges[i];
@ -125,7 +130,8 @@ void r3_tree_compile(node *n)
* This function combines ['/foo', '/bar', '/{slug}'] into (/foo)|(/bar)|/([^/]+)} * 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 * cpat;
char * p; char * p;
@ -179,11 +185,11 @@ void r3_tree_compile_patterns(node * n) {
// n->pcre_pattern; // n->pcre_pattern;
n->pcre_pattern = pcre_compile( n->pcre_pattern = pcre_compile(
n->combined_pattern, /* the pattern */ n->combined_pattern, /* the pattern */
option_bits, /* default options */ option_bits, /* default options */
&error, /* for error message */ &error, /* for error message */
&erroffset, /* for error offset */ &erroffset, /* for error offset */
NULL); /* use default character tables */ NULL); /* use default character tables */
if (n->pcre_pattern == NULL) { if (n->pcre_pattern == NULL) {
printf("PCRE compilation failed at offset %d: %s, pattern: %s\n", erroffset, error, n->combined_pattern); printf("PCRE compilation failed at offset %d: %s, pattern: %s\n", erroffset, error, n->combined_pattern);
return; 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)); match_entry * entry = malloc(sizeof(match_entry));
if(!entry) if(!entry)
return NULL; return NULL;
@ -207,7 +214,8 @@ match_entry * match_entry_createl(char * path, int path_len) {
return entry; return entry;
} }
void match_entry_free(match_entry * entry) { void match_entry_free(match_entry * entry)
{
str_array_free(entry->vars); str_array_free(entry->vars);
free(entry); free(entry);
} }
@ -224,7 +232,8 @@ void match_entry_free(match_entry * entry) {
* @param int path_len the length of the URL path. * @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. * @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); info("try matching: %s\n", path);
edge *e; 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); info("pcre matching %s on %s\n", n->combined_pattern, path);
rc = pcre_exec( rc = pcre_exec(
n->pcre_pattern, /* the compiled pattern */ n->pcre_pattern, /* the compiled pattern */
// PCRE Study makes this slow // PCRE Study makes this slow
NULL, // n->pcre_extra, /* no extra data - we didn't study the pattern */ NULL, // n->pcre_extra, /* no extra data - we didn't study the pattern */
path, /* the subject string */ path, /* the subject string */
path_len, /* the length of the subject */ path_len, /* the length of the subject */
0, /* start at offset 0 in the subject */ 0, /* start at offset 0 in the subject */
0, /* default options */ 0, /* default options */
n->ov, /* output vector for substring information */ n->ov, /* output vector for substring information */
n->ov_cnt); /* number of elements in the output vector */ n->ov_cnt); /* number of elements in the output vector */
// info("rc: %d\n", rc ); // info("rc: %d\n", rc );
if (rc < 0) { if (rc < 0) {
switch(rc) switch(rc) {
{ case PCRE_ERROR_NOMATCH:
case PCRE_ERROR_NOMATCH: printf("No match\n"); break; printf("No match\n");
/* break;
Handle other special cases if you like /*
*/ Handle other special cases if you like
default: printf("Matching error %d\n", rc); break; */
default:
printf("Matching error %d\n", rc);
break;
} }
// does not match all edges, return NULL; // does not match all edges, return NULL;
return NULL; return NULL;
} }
for (i = 1; i < rc; i++) for (i = 1; i < rc; i++) {
{
char *substring_start = path + n->ov[2*i]; char *substring_start = path + n->ov[2*i];
int substring_length = n->ov[2*i+1] - 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); // 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; return NULL;
} }
route * r3_tree_match_route(node *tree, match_entry * entry) { route * r3_tree_match_route(node *tree, match_entry * entry)
{
node *n; node *n;
n = r3_tree_match_entry(tree, entry); n = r3_tree_match_entry(tree, entry);
if (n->routes && n->route_len > 0) { if (n->routes && n->route_len > 0) {
@ -314,7 +326,8 @@ route * r3_tree_match_route(node *tree, match_entry * entry) {
return NULL; 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 i = 0;
int matched_idx = 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) ); node * n = (node*) malloc( sizeof(node) );
n->edges = NULL; n->edges = NULL;
n->edge_len = 0; 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)); return r3_route_createl(path, strlen(path));
} }
void r3_route_free(route * route) { void r3_route_free(route * route)
{
free(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)); route * info = malloc(sizeof(route));
info->path = path; info->path = path;
info->path_len = path_len; 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; return n;
} }
bool r3_node_has_slug_edges(node *n) { bool r3_node_has_slug_edges(node *n)
{
bool found = FALSE; bool found = FALSE;
edge *e; edge *e;
for ( int i = 0 ; i < n->edge_len ; i++ ) { for ( int i = 0 ; i < n->edge_len ; i++ ) {
e = n->edges[i]; e = n->edges[i];
e->has_slug = contains_slug(e->pattern); e->has_slug = contains_slug(e->pattern);
if (e->has_slug) if (e->has_slug)
found = TRUE; found = TRUE;
} }
return found; 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); print_indent(level);
if ( n->combined_pattern ) { if ( n->combined_pattern ) {
printf(" regexp:%s", n->combined_pattern); printf(" regexp:%s", n->combined_pattern);
@ -533,7 +552,8 @@ void r3_tree_dump(node * n, int level) {
* *
* -1 == different route * -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 (r1->request_method != 0) {
if (0 == (r1->request_method & r2->request_method) ) { if (0 == (r1->request_method & r2->request_method) ) {
return -1; 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) { if (!n->routes) {
n->route_cap = 3; n->route_cap = 3;
n->routes = malloc(sizeof(route) * n->route_cap); n->routes = malloc(sizeof(route) * n->route_cap);

View file

@ -12,9 +12,10 @@
#include "str_array.h" #include "str_array.h"
#include "r3_define.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; char * o = d1;
while ( *d1 == *d2 && n-- > 0 ) { while ( *d1 == *d2 && n-- > 0 ) {
d1++; d1++;
d2++; 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; char * o = d1;
while( *d1 == *d2 ) { while( *d1 == *d2 ) {
d1++; d1++;
d2++; d2++;
} }
@ -35,7 +37,8 @@ int strdiff(char * d1, char * d2) {
/** /**
* provide a quick way to count slugs, simply search for '{' * 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 s = 0;
int lev = 0; int lev = 0;
while( len-- ) { while( len-- ) {
@ -52,11 +55,13 @@ int count_slug(char * p, int len) {
return s; return s;
} }
bool contains_slug(char * str) { bool contains_slug(char * str)
{
return strchr(str, '{') != NULL ? TRUE : FALSE; 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 * s1 = offset;
char * s2 = offset; char * s2 = offset;
@ -81,7 +86,8 @@ char * inside_slug(char * needle, int needle_len, char *offset) {
return NULL; return NULL;
} }
char * find_slug_placeholder(char *s1, int *len) { char * find_slug_placeholder(char *s1, int *len)
{
char *c; char *c;
char *s2; char *s2;
int cnt = 0; 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 * 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 *c;
char *s2; char *s2;
int cnt = 1; int cnt = 1;
@ -205,10 +212,8 @@ char** str_split(char* a_str, const char a_delim)
delim[1] = 0; delim[1] = 0;
/* Count how many elements will be extracted. */ /* Count how many elements will be extracted. */
while (*tmp) while (*tmp) {
{ if (a_delim == *tmp) {
if (a_delim == *tmp)
{
count++; count++;
last_comma = tmp; last_comma = tmp;
} }
@ -224,13 +229,11 @@ char** str_split(char* a_str, const char a_delim)
result = malloc(sizeof(char*) * count); result = malloc(sizeof(char*) * count);
if (result) if (result) {
{
size_t idx = 0; size_t idx = 0;
char* token = strtok(a_str, delim); char* token = strtok(a_str, delim);
while (token) while (token) {
{
assert(idx < count); assert(idx < count);
*(result + idx++) = strdup(token); *(result + idx++) = strdup(token);
token = strtok(0, delim); token = strtok(0, delim);
@ -242,13 +245,15 @@ char** str_split(char* a_str, const char a_delim)
return result; return result;
} }
void str_repeat(char *s, char *c, int len) { void str_repeat(char *s, char *c, int len)
{
while(len--) { while(len--) {
s[len - 1] = *c; s[len - 1] = *c;
} }
} }
void print_indent(int level) { void print_indent(int level)
{
int len = level * 2; int len = level * 2;
while(len--) { while(len--) {
printf(" "); printf(" ");
@ -256,7 +261,8 @@ void print_indent(int level) {
} }
#ifndef HAVE_STRDUP #ifndef HAVE_STRDUP
char *strdup(const char *s) { char *strdup(const char *s)
{
char *out; char *out;
int count = 0; int count = 0;
while( s[count] ) while( s[count] )
@ -271,7 +277,8 @@ char *strdup(const char *s) {
#endif #endif
#ifndef HAVE_STRNDUP #ifndef HAVE_STRNDUP
char *strndup(const char *s, int n) { char *strndup(const char *s, int n)
{
char *out; char *out;
int count = 0; int count = 0;
while( count < n && s[count] ) while( count < n && s[count] )

View file

@ -12,7 +12,8 @@
#include "r3_str.h" #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) ); str_array * list = (str_array*) malloc( sizeof(str_array) );
list->len = 0; list->len = 0;
list->cap = cap; list->cap = cap;
@ -20,7 +21,8 @@ str_array * str_array_create(int cap) {
return list; return list;
} }
void str_array_free(str_array *l) { void str_array_free(str_array *l)
{
for ( int i = 0; i < l->len ; i++ ) { for ( int i = 0; i < l->len ; i++ ) {
char * t = l->tokens[ i ]; char * t = l->tokens[ i ];
free(t); free(t);
@ -28,17 +30,20 @@ void str_array_free(str_array *l) {
free(l); free(l);
} }
bool str_array_is_full(str_array * l) { bool str_array_is_full(str_array * l)
{
return l->len >= l->cap; 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->tokens = realloc(l->tokens, sizeof(char**) * new_cap);
l->cap = new_cap; l->cap = new_cap;
return l->tokens != NULL; 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) ) { if ( str_array_is_full(l) ) {
bool ret = str_array_resize(l, l->cap + 20); bool ret = str_array_resize(l, l->cap + 20);
if (ret == FALSE ) { if (ret == FALSE ) {
@ -49,7 +54,8 @@ bool str_array_append(str_array * l, char * token) {
return TRUE; return TRUE;
} }
void str_array_dump(str_array *l) { void str_array_dump(str_array *l)
{
printf("["); printf("[");
for ( int i = 0; i < l->len ; i++ ) { for ( int i = 0; i < l->len ; i++ ) {
printf("\"%s\"", l->tokens[i] ); printf("\"%s\"", l->tokens[i] );

View file

@ -10,7 +10,8 @@
#include <stdio.h> #include <stdio.h>
#include <sys/time.h> #include <sys/time.h>
long unixtime() { long unixtime()
{
struct timeval tp; struct timeval tp;
long sec = 0L; long sec = 0L;
if (gettimeofday((struct timeval *) &tp, (NUL)) == 0) { if (gettimeofday((struct timeval *) &tp, (NUL)) == 0) {
@ -19,12 +20,13 @@ long unixtime() {
return 0; return 0;
} }
double microtime() { double microtime()
{
struct timeval tp; struct timeval tp;
long sec = 0L; long sec = 0L;
double msec = 0.0; double msec = 0.0;
char ret[100]; char ret[100];
if (gettimeofday((struct timeval *) &tp, (NUL)) == 0) { if (gettimeofday((struct timeval *) &tp, (NUL)) == 0) {
msec = (double) (tp.tv_usec / MICRO_IN_SEC); msec = (double) (tp.tv_usec / MICRO_IN_SEC);
sec = tp.tv_sec; sec = tp.tv_sec;
@ -36,19 +38,23 @@ double microtime() {
} }
void bench_start(bench *b) { void bench_start(bench *b)
{
b->start = microtime(); b->start = microtime();
} }
void bench_stop(bench *b) { void bench_stop(bench *b)
{
b->end = microtime(); b->end = microtime();
} }
double bench_iteration_speed(bench *b) { double bench_iteration_speed(bench *b)
{
return b->N / (b->end - b->start); 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 runs, ", b->R);
printf("%ld iterations each run, ", b->N); printf("%ld iterations each run, ", b->N);
printf("finished in %lf seconds\n", b->end - b->start ); printf("finished in %lf seconds\n", b->end - b->start );

View file

@ -56,21 +56,23 @@ START_TEST (test_gvc_render_file)
END_TEST END_TEST
Suite* r3_suite (void) { Suite* r3_suite (void)
Suite *suite = suite_create("gvc test"); {
TCase *tcase = tcase_create("test_gvc"); Suite *suite = suite_create("gvc test");
tcase_add_test(tcase, test_gvc_render_file); TCase *tcase = tcase_create("test_gvc");
tcase_add_test(tcase, test_gvc_render_dot); tcase_add_test(tcase, test_gvc_render_file);
suite_add_tcase(suite, tcase); tcase_add_test(tcase, test_gvc_render_dot);
return suite; suite_add_tcase(suite, tcase);
return suite;
} }
int main (int argc, char *argv[]) { int main (int argc, char *argv[])
int number_failed; {
Suite *suite = r3_suite(); int number_failed;
SRunner *runner = srunner_create(suite); Suite *suite = r3_suite();
srunner_run_all(runner, CK_NORMAL); SRunner *runner = srunner_create(suite);
number_failed = srunner_ntests_failed(runner); srunner_run_all(runner, CK_NORMAL);
srunner_free(runner); number_failed = srunner_ntests_failed(runner);
return number_failed; srunner_free(runner);
return number_failed;
} }

View file

@ -78,27 +78,29 @@ START_TEST (test_find_slug_placeholder_with_broken_slug)
END_TEST END_TEST
Suite* r3_suite (void) { Suite* r3_suite (void)
Suite *suite = suite_create("slug test"); {
TCase *tcase = tcase_create("test_slug"); Suite *suite = suite_create("slug test");
tcase_add_test(tcase, test_contains_slug); TCase *tcase = tcase_create("test_slug");
tcase_add_test(tcase, test_inside_slug); tcase_add_test(tcase, test_contains_slug);
tcase_add_test(tcase, test_find_slug_pattern); tcase_add_test(tcase, test_inside_slug);
tcase_add_test(tcase, test_find_slug_placeholder); tcase_add_test(tcase, test_find_slug_pattern);
tcase_add_test(tcase, test_find_slug_placeholder_with_broken_slug); tcase_add_test(tcase, test_find_slug_placeholder);
tcase_add_test(tcase, test_count_slug); tcase_add_test(tcase, test_find_slug_placeholder_with_broken_slug);
tcase_add_test(tcase, test_compile_slug); tcase_add_test(tcase, test_count_slug);
tcase_add_test(tcase, test_compile_slug);
suite_add_tcase(suite, tcase); suite_add_tcase(suite, tcase);
return suite; return suite;
} }
int main (int argc, char *argv[]) { int main (int argc, char *argv[])
int number_failed; {
Suite *suite = r3_suite(); int number_failed;
SRunner *runner = srunner_create(suite); Suite *suite = r3_suite();
srunner_run_all(runner, CK_NORMAL); SRunner *runner = srunner_create(suite);
number_failed = srunner_ntests_failed(runner); srunner_run_all(runner, CK_NORMAL);
srunner_free(runner); number_failed = srunner_ntests_failed(runner);
return number_failed; srunner_free(runner);
return number_failed;
} }

View file

@ -371,342 +371,342 @@ START_TEST(benchmark_str)
int route_data = 999; int route_data = 999;
r3_tree_insert_path(n, "/foo/bar/baz", 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/qux", NULL);
r3_tree_insert_path(n, "/foo/bar/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/foo/bar/grault", 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/bar/garply", NULL);
r3_tree_insert_path(n, "/foo/baz/bar", 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/qux", NULL);
r3_tree_insert_path(n, "/foo/baz/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/foo/baz/grault", 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/baz/garply", NULL);
r3_tree_insert_path(n, "/foo/qux/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/foo/qux/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/foo/qux/grault", 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/qux/garply", NULL);
r3_tree_insert_path(n, "/foo/quux/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/foo/quux/qux", 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/corge", NULL);
r3_tree_insert_path(n, "/foo/quux/grault", 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/quux/garply", NULL);
r3_tree_insert_path(n, "/foo/corge/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/foo/corge/qux", 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/quux", NULL);
r3_tree_insert_path(n, "/foo/corge/grault", 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/corge/garply", NULL);
r3_tree_insert_path(n, "/foo/grault/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/foo/grault/qux", 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/quux", NULL);
r3_tree_insert_path(n, "/foo/grault/corge", 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/grault/garply", NULL);
r3_tree_insert_path(n, "/foo/garply/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/foo/garply/qux", 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/quux", NULL);
r3_tree_insert_path(n, "/foo/garply/corge", NULL); r3_tree_insert_path(n, "/foo/garply/corge", NULL);
r3_tree_insert_path(n, "/foo/garply/grault", 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/baz", NULL);
r3_tree_insert_path(n, "/bar/foo/qux", 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/quux", NULL);
r3_tree_insert_path(n, "/bar/foo/corge", 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/grault", NULL);
r3_tree_insert_path(n, "/bar/foo/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/bar/baz/qux", 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/quux", NULL);
r3_tree_insert_path(n, "/bar/baz/corge", 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/grault", NULL);
r3_tree_insert_path(n, "/bar/baz/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/bar/qux/baz", 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/quux", NULL);
r3_tree_insert_path(n, "/bar/qux/corge", 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/grault", NULL);
r3_tree_insert_path(n, "/bar/qux/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/bar/quux/baz", 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/qux", NULL);
r3_tree_insert_path(n, "/bar/quux/corge", 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/grault", NULL);
r3_tree_insert_path(n, "/bar/quux/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/bar/corge/baz", 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/qux", NULL);
r3_tree_insert_path(n, "/bar/corge/quux", 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/grault", NULL);
r3_tree_insert_path(n, "/bar/corge/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/bar/grault/baz", 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/qux", NULL);
r3_tree_insert_path(n, "/bar/grault/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/bar/grault/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/bar/garply/baz", 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/qux", NULL);
r3_tree_insert_path(n, "/bar/garply/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/bar/garply/grault", 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/bar", NULL);
r3_tree_insert_path(n, "/baz/foo/qux", 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/quux", NULL);
r3_tree_insert_path(n, "/baz/foo/corge", 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/grault", NULL);
r3_tree_insert_path(n, "/baz/foo/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/baz/bar/qux", 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/quux", NULL);
r3_tree_insert_path(n, "/baz/bar/corge", 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/grault", NULL);
r3_tree_insert_path(n, "/baz/bar/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/baz/qux/bar", 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/quux", NULL);
r3_tree_insert_path(n, "/baz/qux/corge", 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/grault", NULL);
r3_tree_insert_path(n, "/baz/qux/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/baz/quux/bar", 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/qux", NULL);
r3_tree_insert_path(n, "/baz/quux/corge", 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/grault", NULL);
r3_tree_insert_path(n, "/baz/quux/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/baz/corge/bar", 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/qux", NULL);
r3_tree_insert_path(n, "/baz/corge/quux", 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/grault", NULL);
r3_tree_insert_path(n, "/baz/corge/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/baz/grault/bar", 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/qux", NULL);
r3_tree_insert_path(n, "/baz/grault/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/baz/grault/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/baz/garply/bar", 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/qux", NULL);
r3_tree_insert_path(n, "/baz/garply/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/baz/garply/grault", 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/bar", NULL);
r3_tree_insert_path(n, "/qux/foo/baz", 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/quux", NULL);
r3_tree_insert_path(n, "/qux/foo/corge", 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/grault", NULL);
r3_tree_insert_path(n, "/qux/foo/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/qux/bar/baz", 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/quux", NULL);
r3_tree_insert_path(n, "/qux/bar/corge", &route_data); 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/grault", NULL);
r3_tree_insert_path(n, "/qux/bar/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/qux/baz/bar", 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/quux", NULL);
r3_tree_insert_path(n, "/qux/baz/corge", 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/grault", NULL);
r3_tree_insert_path(n, "/qux/baz/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/qux/quux/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/qux/quux/corge", 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/grault", NULL);
r3_tree_insert_path(n, "/qux/quux/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/qux/corge/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/qux/corge/quux", 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/grault", NULL);
r3_tree_insert_path(n, "/qux/corge/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/qux/grault/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/qux/grault/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/qux/grault/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/qux/garply/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/qux/garply/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/qux/garply/grault", 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/bar", NULL);
r3_tree_insert_path(n, "/quux/foo/baz", 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/qux", NULL);
r3_tree_insert_path(n, "/quux/foo/corge", 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/grault", NULL);
r3_tree_insert_path(n, "/quux/foo/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/quux/bar/baz", 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/qux", NULL);
r3_tree_insert_path(n, "/quux/bar/corge", 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/grault", NULL);
r3_tree_insert_path(n, "/quux/bar/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/quux/baz/bar", 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/qux", NULL);
r3_tree_insert_path(n, "/quux/baz/corge", 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/grault", NULL);
r3_tree_insert_path(n, "/quux/baz/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/quux/qux/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/quux/qux/corge", 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/grault", NULL);
r3_tree_insert_path(n, "/quux/qux/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/quux/corge/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/quux/corge/qux", 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/grault", NULL);
r3_tree_insert_path(n, "/quux/corge/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/quux/grault/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/quux/grault/qux", 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/corge", NULL);
r3_tree_insert_path(n, "/quux/grault/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/quux/garply/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/quux/garply/qux", 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/corge", NULL);
r3_tree_insert_path(n, "/quux/garply/grault", 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/bar", NULL);
r3_tree_insert_path(n, "/corge/foo/baz", 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/qux", NULL);
r3_tree_insert_path(n, "/corge/foo/quux", 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/grault", NULL);
r3_tree_insert_path(n, "/corge/foo/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/corge/bar/baz", 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/qux", NULL);
r3_tree_insert_path(n, "/corge/bar/quux", 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/grault", NULL);
r3_tree_insert_path(n, "/corge/bar/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/corge/baz/bar", 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/qux", NULL);
r3_tree_insert_path(n, "/corge/baz/quux", 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/grault", NULL);
r3_tree_insert_path(n, "/corge/baz/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/corge/qux/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/corge/qux/quux", 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/grault", NULL);
r3_tree_insert_path(n, "/corge/qux/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/corge/quux/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/corge/quux/qux", 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/grault", NULL);
r3_tree_insert_path(n, "/corge/quux/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/corge/grault/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/corge/grault/qux", 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/quux", NULL);
r3_tree_insert_path(n, "/corge/grault/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/corge/garply/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/corge/garply/qux", 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/quux", NULL);
r3_tree_insert_path(n, "/corge/garply/grault", 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/bar", NULL);
r3_tree_insert_path(n, "/grault/foo/baz", 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/qux", NULL);
r3_tree_insert_path(n, "/grault/foo/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/grault/foo/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/grault/bar/baz", 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/qux", NULL);
r3_tree_insert_path(n, "/grault/bar/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/grault/bar/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/grault/baz/bar", 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/qux", NULL);
r3_tree_insert_path(n, "/grault/baz/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/grault/baz/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/grault/qux/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/grault/qux/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/grault/qux/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/grault/quux/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/grault/quux/qux", 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/corge", NULL);
r3_tree_insert_path(n, "/grault/quux/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/grault/corge/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/grault/corge/qux", 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/quux", NULL);
r3_tree_insert_path(n, "/grault/corge/garply", 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/foo", NULL);
r3_tree_insert_path(n, "/grault/garply/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/grault/garply/qux", 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/quux", NULL);
r3_tree_insert_path(n, "/grault/garply/corge", 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/bar", NULL);
r3_tree_insert_path(n, "/garply/foo/baz", 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/qux", NULL);
r3_tree_insert_path(n, "/garply/foo/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/garply/foo/grault", 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/foo", NULL);
r3_tree_insert_path(n, "/garply/bar/baz", 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/qux", NULL);
r3_tree_insert_path(n, "/garply/bar/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/garply/bar/grault", 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/foo", NULL);
r3_tree_insert_path(n, "/garply/baz/bar", 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/qux", NULL);
r3_tree_insert_path(n, "/garply/baz/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/garply/baz/grault", 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/foo", NULL);
r3_tree_insert_path(n, "/garply/qux/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/garply/qux/quux", 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/corge", NULL);
r3_tree_insert_path(n, "/garply/qux/grault", 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/foo", NULL);
r3_tree_insert_path(n, "/garply/quux/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/garply/quux/qux", 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/corge", NULL);
r3_tree_insert_path(n, "/garply/quux/grault", 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/foo", NULL);
r3_tree_insert_path(n, "/garply/corge/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/garply/corge/qux", 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/quux", NULL);
r3_tree_insert_path(n, "/garply/corge/grault", 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/foo", NULL);
r3_tree_insert_path(n, "/garply/grault/bar", 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/baz", NULL);
r3_tree_insert_path(n, "/garply/grault/qux", 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/quux", NULL);
r3_tree_insert_path(n, "/garply/grault/corge", NULL); r3_tree_insert_path(n, "/garply/grault/corge", NULL);
r3_tree_compile(n); r3_tree_compile(n);
@ -735,35 +735,37 @@ r3_tree_insert_path(n, "/garply/grault/corge", NULL);
END_TEST END_TEST
Suite* r3_suite (void) { Suite* r3_suite (void)
Suite *suite = suite_create("blah"); {
Suite *suite = suite_create("blah");
TCase *tcase = tcase_create("testcase"); TCase *tcase = tcase_create("testcase");
tcase_add_test(tcase, test_str_array); tcase_add_test(tcase, test_str_array);
tcase_add_test(tcase, test_ltrim_slash); tcase_add_test(tcase, test_ltrim_slash);
tcase_add_test(tcase, test_r3_node_construct_uniq); tcase_add_test(tcase, test_r3_node_construct_uniq);
tcase_add_test(tcase, test_r3_node_find_edge); tcase_add_test(tcase, test_r3_node_find_edge);
tcase_add_test(tcase, test_r3_tree_insert_pathl); tcase_add_test(tcase, test_r3_tree_insert_pathl);
tcase_add_test(tcase, test_compile_slug); tcase_add_test(tcase, test_compile_slug);
tcase_add_test(tcase, test_compile); tcase_add_test(tcase, test_compile);
tcase_add_test(tcase, test_route_cmp); tcase_add_test(tcase, test_route_cmp);
tcase_add_test(tcase, test_insert_route); tcase_add_test(tcase, test_insert_route);
tcase_add_test(tcase, test_pcre_pattern_simple); tcase_add_test(tcase, test_pcre_pattern_simple);
tcase_add_test(tcase, test_pcre_pattern_more); tcase_add_test(tcase, test_pcre_pattern_more);
tcase_add_test(tcase, test_pcre_patterns_insert); tcase_add_test(tcase, test_pcre_patterns_insert);
tcase_add_test(tcase, benchmark_str); 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 main (int argc, char *argv[])
int number_failed; {
Suite *suite = r3_suite(); int number_failed;
SRunner *runner = srunner_create(suite); Suite *suite = r3_suite();
srunner_run_all(runner, CK_NORMAL); SRunner *runner = srunner_create(suite);
number_failed = srunner_ntests_failed(runner); srunner_run_all(runner, CK_NORMAL);
srunner_free(runner); number_failed = srunner_ntests_failed(runner);
return number_failed; srunner_free(runner);
return number_failed;
} }