diff options
Diffstat (limited to 'tests/unittest.cpp')
-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; |