aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoripknHama <ipknhama@gmail.com>2015-02-19 00:57:01 +0900
committeripknHama <ipknhama@gmail.com>2015-02-19 00:57:01 +0900
commitd564d486b550d8c2717e51e09c20314ca322fd67 (patch)
tree4caeb801fc73957f7ad81260b5ffe0c61e29d7b8 /tests
parent07042b55fdeaab1170cd5ad244939b5ed1f486a9 (diff)
downloadcrow-d564d486b550d8c2717e51e09c20314ca322fd67.tar.gz
crow-d564d486b550d8c2717e51e09c20314ca322fd67.zip
added route_dynamic
Diffstat (limited to 'tests')
-rw-r--r--tests/unittest.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/unittest.cpp b/tests/unittest.cpp
index 4aded66..a133bce 100644
--- a/tests/unittest.cpp
+++ b/tests/unittest.cpp
@@ -1039,6 +1039,65 @@ TEST(simple_url_params)
server.stop();
}
+TEST(route_dynamic)
+{
+ SimpleApp app;
+ int x = 1;
+ app.route_dynamic("/")
+ ([&]{
+ x = 2;
+ return "";
+ });
+
+ app.route_dynamic("/set4")
+ ([&](const request& req){
+ x = 4;
+ return "";
+ });
+ app.route_dynamic("/set5")
+ ([&](const request& req, response& res){
+ x = 5;
+ res.end();
+ });
+
+
+
+ app.route_dynamic("/set_int/<int>")
+ ([&](int y){
+ x = y;
+ return "";
+ });
+
+ {
+ request req;
+ response res;
+ req.url = "/";
+ app.handle(req, res);
+ ASSERT_EQUAL(x, 2);
+ }
+ {
+ request req;
+ response res;
+ req.url = "/set_int/42";
+ app.handle(req, res);
+ ASSERT_EQUAL(x, 42);
+ }
+ {
+ request req;
+ response res;
+ req.url = "/set5";
+ app.handle(req, res);
+ ASSERT_EQUAL(x, 5);
+ }
+ {
+ request req;
+ response res;
+ req.url = "/set4";
+ app.handle(req, res);
+ ASSERT_EQUAL(x, 4);
+ }
+}
+
int main()
{
return testmain();