From 6eb965adcd90f80fefae53b8c07919ad22d87c20 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Mon, 26 Feb 2024 22:32:50 +0100 Subject: [PATCH] test(routing): add star matching test --- test/routing.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/routing.c b/test/routing.c index e18b695..e133f4b 100644 --- a/test/routing.c +++ b/test/routing.c @@ -41,7 +41,20 @@ void test_routing_simple() { 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 = { { "routing simple", test_routing_simple }, + { "routing star", test_routing_star }, { NULL, NULL } };