test(routing): add star matching test

routing
Jef Roosens 2024-02-26 22:32:50 +01:00
parent 115bf74456
commit 6eb965adcd
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 13 additions and 0 deletions

View File

@ -41,7 +41,20 @@ void test_routing_simple() {
lnm_http_router_free(router); lnm_http_router_free(router);
} }
void test_routing_star() {
lnm_http_router *router;
TEST_CHECK(lnm_http_router_init(&router) == lnm_err_ok);
TEST_CHECK(lnm_http_router_add(NULL, router, lnm_http_method_get, "/*key") == lnm_err_ok);
lnm_http_route_match match;
TEST_CHECK(lnm_http_router_route(&match, router, lnm_http_method_get, "/hello/world") == lnm_http_route_err_match);
TEST_CHECK(match.key_segments[0].start == 1);
TEST_CHECK(match.key_segments[0].len == 11);
}
TEST_LIST = { TEST_LIST = {
{ "routing simple", test_routing_simple }, { "routing simple", test_routing_simple },
{ "routing star", test_routing_star },
{ NULL, NULL } { NULL, NULL }
}; };