Add test sample for HttpRouter

This commit is contained in:
linhaojun857 2023-11-26 23:49:20 +08:00
parent 1d11558e2c
commit 1137678bba

View File

@ -166,6 +166,26 @@ void HttpRouterTest::onRun() {
OATPP_ASSERT(r.getMatchMap().getTail() == "abc") OATPP_ASSERT(r.getMatchMap().getTail() == "abc")
} }
{
OATPP_LOGI(TAG, "Case 15")
auto r = router.getRoute("GET", "ints/1?q1=1&q2=2");
OATPP_ASSERT(r.isValid())
OATPP_ASSERT(r)
OATPP_ASSERT(r.getEndpoint() == 1)
OATPP_ASSERT(r.getMatchMap().getTail() == "?q1=1&q2=2")
}
{
OATPP_LOGI(TAG, "Case 16")
auto r = router.getRoute("GET", "ints/all/3?q1=1&q2=2");
OATPP_ASSERT(r.isValid())
OATPP_ASSERT(r)
OATPP_ASSERT(r.getEndpoint() == -1)
OATPP_ASSERT(r.getMatchMap().getVariables().size() == 1)
OATPP_ASSERT(r.getMatchMap().getVariable("value") == "3")
OATPP_ASSERT(r.getMatchMap().getTail() == "?q1=1&q2=2")
}
} }
}}}} }}}}