From 07042b55fdeaab1170cd5ad244939b5ed1f486a9 Mon Sep 17 00:00:00 2001 From: Jaeseung Ha Date: Mon, 19 Jan 2015 19:03:06 +0900 Subject: fix #27 : handling routes with trailing slash --- tests/unittest.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'tests') diff --git a/tests/unittest.cpp b/tests/unittest.cpp index 3a48f20..4aded66 100644 --- a/tests/unittest.cpp +++ b/tests/unittest.cpp @@ -116,6 +116,59 @@ TEST(ParameterTagging) static_assert(std::is_same, black_magic::arguments<6*6+6*3+2>::type>::value, "tag to type container"); } +TEST(PathRouting) +{ + SimpleApp app; + + CROW_ROUTE(app, "/file") + ([]{ + return "file"; + }); + + CROW_ROUTE(app, "/path/") + ([]{ + return "path"; + }); + + { + request req; + response res; + + req.url = "/file"; + + app.handle(req, res); + + ASSERT_EQUAL(200, res.code); + } + { + request req; + response res; + + req.url = "/file/"; + + app.handle(req, res); + ASSERT_EQUAL(404, res.code); + } + { + request req; + response res; + + req.url = "/path"; + + app.handle(req, res); + ASSERT_NOTEQUAL(404, res.code); + } + { + request req; + response res; + + req.url = "/path/"; + + app.handle(req, res); + ASSERT_EQUAL(200, res.code); + } +} + TEST(RoutingTest) { SimpleApp app; -- cgit v1.2.3-54-g00ecf