add route test for r3_tree_insert_route
This commit is contained in:
parent
5f39b73211
commit
0e476b5a4f
3 changed files with 1029 additions and 1010 deletions
|
@ -22,7 +22,7 @@ END
|
||||||
|
|
||||||
|
|
||||||
arr = ["foo", "bar", "baz", "qux", "quux", "corge", "grault", "garply"]
|
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|
|
paths.each_index do |idx|
|
||||||
path = paths.fetch(idx)
|
path = paths.fetch(idx)
|
||||||
puts " char *data#{idx} = \"#{path}\";"
|
puts " char *data#{idx} = \"#{path}\";"
|
||||||
|
|
2022
tests/check_routes.c
2022
tests/check_routes.c
File diff suppressed because it is too large
Load diff
|
@ -704,11 +704,13 @@ START_TEST(test_insert_route)
|
||||||
{
|
{
|
||||||
int var1 = 22;
|
int var1 = 22;
|
||||||
int var2 = 33;
|
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_GET, "/blog/post", &var1);
|
||||||
r3_tree_insert_route(n, METHOD_POST, "/blog/post", &var2);
|
r3_tree_insert_route(n, METHOD_POST, "/blog/post", &var2);
|
||||||
|
r3_tree_insert_route(n, METHOD_GET, "/", &var3);
|
||||||
|
|
||||||
match_entry * entry;
|
match_entry * entry;
|
||||||
route *r;
|
route *r;
|
||||||
|
@ -730,6 +732,17 @@ START_TEST(test_insert_route)
|
||||||
ck_assert(*((int*)r->data) == 33);
|
ck_assert(*((int*)r->data) == 33);
|
||||||
match_entry_free(entry);
|
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);
|
r3_tree_free(n);
|
||||||
|
|
Loading…
Reference in a new issue