aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJaeseung Ha <ipknhama@gmail.com>2015-01-19 19:03:06 +0900
committerJaeseung Ha <ipknhama@gmail.com>2015-01-19 19:03:06 +0900
commit07042b55fdeaab1170cd5ad244939b5ed1f486a9 (patch)
tree232855d6eda941c94dfaeeb9eb2b030038d63b08 /tests
parentb5942c4dda628e1b697a7bddd153e0988b253367 (diff)
downloadcrow-07042b55fdeaab1170cd5ad244939b5ed1f486a9.tar.gz
crow-07042b55fdeaab1170cd5ad244939b5ed1f486a9.zip
fix #27 : handling routes with trailing slash
Diffstat (limited to 'tests')
-rw-r--r--tests/unittest.cpp53
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;