refactor(routing): simply key segment api

This commit is contained in:
Jef Roosens 2024-02-23 11:38:52 +01:00
parent 9dbdb0b089
commit d739157fb1
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
3 changed files with 15 additions and 19 deletions

View file

@ -29,12 +29,12 @@ void test_routing_simple() {
TEST_CHECK(match.key_segments[1].start == 15);
TEST_CHECK(match.key_segments[1].len == 9);
lnm_http_route_match_segment *segment;
TEST_CHECK(lnm_http_route_match_get(&segment, &match, "second") == lnm_err_ok);
const lnm_http_route_match_segment *segment;
TEST_CHECK((segment = lnm_http_route_match_get(&match, "second")) != NULL);
TEST_CHECK(segment->start == 15);
TEST_CHECK(segment->len == 9);
TEST_CHECK(lnm_http_route_match_get(&segment, &match, "yuhh") == lnm_err_not_found);
TEST_CHECK(lnm_http_route_match_get(&segment, &match, "hello") == lnm_err_ok);
TEST_CHECK((segment = lnm_http_route_match_get(&match, "yuhh")) == NULL);
TEST_CHECK((segment = lnm_http_route_match_get(&match, "hello")) != NULL);
TEST_CHECK(segment->start == 6);
TEST_CHECK(segment->len == 8);
}