From a4378fdaf296f2c1f7ec94fe2042a9354027b237 Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 22 May 2014 17:07:02 +0800 Subject: [PATCH] Add test_feedback --- include/r3.h | 2 ++ src/node.c | 5 +++++ tests/bench_str.csv | 2 ++ tests/check_tree.c | 17 +++++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/include/r3.h b/include/r3.h index cda6f0e..f69d2ab 100644 --- a/include/r3.h +++ b/include/r3.h @@ -181,6 +181,8 @@ void r3_route_free(route * route); route * r3_tree_match_route(const node *n, match_entry * entry); +void r3_tree_feedback(node *tree, node *end); + #define METHOD_GET 2 #define METHOD_POST 2<<1 #define METHOD_PUT 2<<1 diff --git a/src/node.c b/src/node.c index 16fa41e..7082c4b 100644 --- a/src/node.c +++ b/src/node.c @@ -115,7 +115,12 @@ edge * r3_node_add_child(node * n, char * pat , node *child) { return e; } +void r3_tree_feedback(node *tree, node *end) { + edge * e; + while( (e = end->parent_edge) != NULL ) { + } +} void r3_node_append_edge(node *n, edge *e) { if (n->edges == NULL) { diff --git a/tests/bench_str.csv b/tests/bench_str.csv index 27997c7..2d98f6a 100644 --- a/tests/bench_str.csv +++ b/tests/bench_str.csv @@ -451,3 +451,5 @@ 1400749175,13518288.33 1400749320,13445606.30 1400749326,13242705.99 +1400749599,13245418.70 +1400749614,12494314.81 diff --git a/tests/check_tree.c b/tests/check_tree.c index 673857f..15fe542 100644 --- a/tests/check_tree.c +++ b/tests/check_tree.c @@ -729,6 +729,23 @@ r3_tree_insert_path(n, "/garply/grault/corge", NULL); } END_TEST +START_TEST(test_feedback) +{ + node * t = r3_tree_create(1); + r3_tree_insert_path(t, "/foo/bar/baz", NULL); + r3_tree_insert_path(t, "/foo/grault/bar", NULL); + r3_tree_insert_path(t, "/garply/corge/grault", NULL); + r3_tree_compile(t); + + node * m = r3_tree_match(t, "/foo/grault/bar", NULL); + ck_assert(m != NULL); + + r3_tree_feedback(t, m); + + r3_tree_free(t); +} +END_TEST + Suite* r3_suite (void) { Suite *suite = suite_create("blah");