r3_tree_insert_pathn to r3_tree_insert_pathl
This commit is contained in:
parent
08a059465e
commit
4efd1b9702
5 changed files with 19 additions and 18 deletions
|
@ -37,10 +37,10 @@ n = r3_tree_create(10);
|
||||||
int route_data = 3;
|
int route_data = 3;
|
||||||
|
|
||||||
// insert the route path into the router tree
|
// insert the route path into the router tree
|
||||||
r3_tree_insert_pathn(n , "/zoo" , strlen("/zoo") , &route_data );
|
r3_tree_insert_pathl(n , "/zoo" , strlen("/zoo") , &route_data );
|
||||||
r3_tree_insert_pathn(n , "/foo/bar" , strlen("/foo/bar") , &route_data );
|
r3_tree_insert_pathl(n , "/foo/bar" , strlen("/foo/bar") , &route_data );
|
||||||
r3_tree_insert_pathn(n , "/bar" , strlen("/bar") , &route_data );
|
r3_tree_insert_pathl(n , "/bar" , strlen("/bar") , &route_data );
|
||||||
r3_tree_insert_pathn(n , "/post/{id}" , strlen("/post/{id}") , &route_data );
|
r3_tree_insert_pathl(n , "/post/{id}" , strlen("/post/{id}") , &route_data );
|
||||||
|
|
||||||
// let's compile the tree!
|
// let's compile the tree!
|
||||||
r3_tree_compile(n);
|
r3_tree_compile(n);
|
||||||
|
|
|
@ -102,7 +102,7 @@ void r3_tree_append_edge(node *n, edge *child);
|
||||||
|
|
||||||
node * r3_tree_insert_path(node *tree, char *path, route * route, void * data);
|
node * r3_tree_insert_path(node *tree, char *path, route * route, void * data);
|
||||||
|
|
||||||
node * r3_tree_insert_pathn(node *tree, char *path, int path_len, route * route, void * data);
|
node * r3_tree_insert_pathl(node *tree, char *path, int path_len, route * route, void * data);
|
||||||
|
|
||||||
void r3_tree_dump(node * n, int level);
|
void r3_tree_dump(node * n, int level);
|
||||||
|
|
||||||
|
|
|
@ -366,10 +366,10 @@ node * r3_node_create() {
|
||||||
|
|
||||||
node * r3_tree_insert_path(node *tree, char *path, route * route, void * data)
|
node * r3_tree_insert_path(node *tree, char *path, route * route, void * data)
|
||||||
{
|
{
|
||||||
return r3_tree_insert_pathn(tree, path, strlen(path) , route , data);
|
return r3_tree_insert_pathl(tree, path, strlen(path) , route , data);
|
||||||
}
|
}
|
||||||
|
|
||||||
node * r3_tree_insert_pathn(node *tree, char *path, int path_len, route * route, void * data)
|
node * r3_tree_insert_pathl(node *tree, char *path, int path_len, route * route, void * data)
|
||||||
{
|
{
|
||||||
node * n = tree;
|
node * n = tree;
|
||||||
edge * e = NULL;
|
edge * e = NULL;
|
||||||
|
@ -413,7 +413,7 @@ node * r3_tree_insert_pathn(node *tree, char *path, int path_len, route * route,
|
||||||
|
|
||||||
// there are something more we can insert
|
// there are something more we can insert
|
||||||
if ( subroute_len > 0 ) {
|
if ( subroute_len > 0 ) {
|
||||||
return r3_tree_insert_pathn(e->child, subroute, subroute_len, route, data);
|
return r3_tree_insert_pathl(e->child, subroute, subroute_len, route, data);
|
||||||
} else {
|
} else {
|
||||||
// no more,
|
// no more,
|
||||||
e->child->endpoint++; // make it as an endpoint, TODO: put the path value
|
e->child->endpoint++; // make it as an endpoint, TODO: put the path value
|
||||||
|
|
|
@ -92,3 +92,4 @@
|
||||||
1400382578,13521992.76
|
1400382578,13521992.76
|
||||||
1400382591,12607054.51
|
1400382591,12607054.51
|
||||||
1400382780,12319337.31
|
1400382780,12319337.31
|
||||||
|
1400382819,12453653.04
|
||||||
|
|
|
|
@ -55,9 +55,9 @@ START_TEST (test_compile)
|
||||||
node *m;
|
node *m;
|
||||||
edge *e ;
|
edge *e ;
|
||||||
|
|
||||||
r3_tree_insert_pathn(n, "/zoo", strlen("/zoo"), NULL, NULL);
|
r3_tree_insert_pathl(n, "/zoo", strlen("/zoo"), NULL, NULL);
|
||||||
r3_tree_insert_pathn(n, "/foo", strlen("/foo"), NULL, NULL);
|
r3_tree_insert_pathl(n, "/foo", strlen("/foo"), NULL, NULL);
|
||||||
r3_tree_insert_pathn(n, "/bar", strlen("/bar"), NULL, NULL);
|
r3_tree_insert_pathl(n, "/bar", strlen("/bar"), NULL, NULL);
|
||||||
r3_tree_compile(n);
|
r3_tree_compile(n);
|
||||||
fail_if( n->combined_pattern );
|
fail_if( n->combined_pattern );
|
||||||
fail_if( NULL == r3_node_find_edge_str(n, "/", strlen("/") ) );
|
fail_if( NULL == r3_node_find_edge_str(n, "/", strlen("/") ) );
|
||||||
|
@ -66,8 +66,8 @@ START_TEST (test_compile)
|
||||||
r3_tree_dump(n, 0);
|
r3_tree_dump(n, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
r3_tree_insert_pathn(n, "/foo/{id}", strlen("/foo/{id}"), NULL, NULL);
|
r3_tree_insert_pathl(n, "/foo/{id}", strlen("/foo/{id}"), NULL, NULL);
|
||||||
r3_tree_insert_pathn(n, "/{id}", strlen("/{id}"), NULL, NULL);
|
r3_tree_insert_pathl(n, "/{id}", strlen("/{id}"), NULL, NULL);
|
||||||
r3_tree_compile(n);
|
r3_tree_compile(n);
|
||||||
r3_tree_compile(n); // test double compile
|
r3_tree_compile(n); // test double compile
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -160,7 +160,7 @@ START_TEST (test_compile_slug)
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
|
||||||
START_TEST (test_r3_tree_insert_pathn)
|
START_TEST (test_r3_tree_insert_pathl)
|
||||||
{
|
{
|
||||||
node * n = r3_tree_create(10);
|
node * n = r3_tree_create(10);
|
||||||
|
|
||||||
|
@ -177,15 +177,15 @@ START_TEST (test_r3_tree_insert_pathn)
|
||||||
// r3_tree_dump(n, 0);
|
// r3_tree_dump(n, 0);
|
||||||
|
|
||||||
info("Inserting /post/{id}\n");
|
info("Inserting /post/{id}\n");
|
||||||
r3_tree_insert_pathn(n, "/post/{id}", strlen("/post/{id}"), NULL, NULL);
|
r3_tree_insert_pathl(n, "/post/{id}", strlen("/post/{id}"), NULL, NULL);
|
||||||
// r3_tree_dump(n, 0);
|
// r3_tree_dump(n, 0);
|
||||||
|
|
||||||
info("Inserting /post/{handle}\n");
|
info("Inserting /post/{handle}\n");
|
||||||
r3_tree_insert_pathn(n, "/post/{handle}", strlen("/post/{handle}"), NULL, NULL);
|
r3_tree_insert_pathl(n, "/post/{handle}", strlen("/post/{handle}"), NULL, NULL);
|
||||||
// r3_tree_dump(n, 0);
|
// r3_tree_dump(n, 0);
|
||||||
|
|
||||||
info("Inserting /post/{handle}-{id}\n");
|
info("Inserting /post/{handle}-{id}\n");
|
||||||
r3_tree_insert_pathn(n, "/post/{handle}-{id}", strlen("/post/{handle}-{id}"), NULL, NULL);
|
r3_tree_insert_pathl(n, "/post/{handle}-{id}", strlen("/post/{handle}-{id}"), NULL, NULL);
|
||||||
r3_tree_compile(n);
|
r3_tree_compile(n);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -655,7 +655,7 @@ Suite* r3_suite (void) {
|
||||||
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_pathn);
|
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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue