add route test for r3_tree_insert_route

This commit is contained in:
Coney Wu 2015-10-18 14:57:55 +08:00
parent 5f39b73211
commit 0e476b5a4f
3 changed files with 1029 additions and 1010 deletions

View file

@ -22,7 +22,7 @@ END
arr = ["foo", "bar", "baz", "qux", "quux", "corge", "grault", "garply"]
paths = arr.permutation(3).map { |a| "/#{a.join '/'}" }
paths = ["/"] + arr.permutation(3).map { |a| "/#{a.join '/'}" }
paths.each_index do |idx|
path = paths.fetch(idx)
puts " char *data#{idx} = \"#{path}\";"

File diff suppressed because it is too large Load diff

View file

@ -704,11 +704,13 @@ START_TEST(test_insert_route)
{
int var1 = 22;
int var2 = 33;
int var3 = 44;
node * n = r3_tree_create(2);
node * n = r3_tree_create(3);
r3_tree_insert_route(n, METHOD_GET, "/blog/post", &var1);
r3_tree_insert_route(n, METHOD_POST, "/blog/post", &var2);
r3_tree_insert_route(n, METHOD_GET, "/", &var3);
match_entry * entry;
route *r;
@ -730,6 +732,17 @@ START_TEST(test_insert_route)
ck_assert(*((int*)r->data) == 33);
match_entry_free(entry);
entry = match_entry_create("/");
entry->request_method = METHOD_GET;
r = r3_tree_match_route(n, entry);
ck_assert(r != NULL);
ck_assert(r->request_method & METHOD_GET );
ck_assert(*((int*)r->data) == 44);
match_entry_free(entry);
r3_tree_free(n);