diff options
author | Jaeseung Ha <ipknhama@gmail.com> | 2015-01-19 19:03:06 +0900 |
---|---|---|
committer | Jaeseung Ha <ipknhama@gmail.com> | 2015-01-19 19:03:06 +0900 |
commit | 07042b55fdeaab1170cd5ad244939b5ed1f486a9 (patch) | |
tree | 232855d6eda941c94dfaeeb9eb2b030038d63b08 /tests | |
parent | b5942c4dda628e1b697a7bddd153e0988b253367 (diff) | |
download | crow-07042b55fdeaab1170cd5ad244939b5ed1f486a9.tar.gz crow-07042b55fdeaab1170cd5ad244939b5ed1f486a9.zip |
fix #27 : handling routes with trailing slash
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittest.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
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::S<uint64_t, double, int64_t>, 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; |