aboutsummaryrefslogtreecommitdiffstats
path: root/unittest.cpp
diff options
context:
space:
mode:
authoripknHama <ipknhama@gmail.com>2014-08-06 03:54:38 +0900
committeripknHama <ipknhama@gmail.com>2014-08-06 04:07:46 +0900
commita0c93f5b84cc11b30bc6320ac26127832ef8bf7a (patch)
treedc3a51f019b99bf4b4c62201bf6c183a9fb9fa38 /unittest.cpp
parent88cc6079cb2ba9790a2d8bb9a5955006bfcc7a16 (diff)
downloadcrow-a0c93f5b84cc11b30bc6320ac26127832ef8bf7a.tar.gz
crow-a0c93f5b84cc11b30bc6320ac26127832ef8bf7a.zip
long polling implementation complete
change `res handle(req)' into `void handle(req, res)' connnection::handle is divide into two part: before and after user handler
Diffstat (limited to 'unittest.cpp')
-rw-r--r--unittest.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/unittest.cpp b/unittest.cpp
index e4f8105..918d027 100644
--- a/unittest.cpp
+++ b/unittest.cpp
@@ -72,9 +72,11 @@ TEST(Rule)
r.validate();
+ response res;
+
// executing handler
ASSERT_EQUAL(0, x);
- r.handle(request(), routing_params());
+ r.handle(request(), res, routing_params());
ASSERT_EQUAL(1, x);
// registering handler with request argument
@@ -84,7 +86,7 @@ TEST(Rule)
// executing handler
ASSERT_EQUAL(1, x);
- r.handle(request(), routing_params());
+ r.handle(request(), res, routing_params());
ASSERT_EQUAL(2, x);
}
@@ -143,13 +145,24 @@ TEST(RoutingTest)
app.validate();
//app.debug_print();
+ {
+ request req;
+ response res;
+
+ req.url = "/-1";
+
+ app.handle(req, res);
+
+ ASSERT_EQUAL(404, res.code);
+ }
{
request req;
+ response res;
req.url = "/0/1001999";
- auto res = app.handle(req);
+ app.handle(req, res);
ASSERT_EQUAL(200, res.code);
@@ -158,10 +171,11 @@ TEST(RoutingTest)
{
request req;
+ response res;
req.url = "/1/-100/1999";
- auto res = app.handle(req);
+ app.handle(req, res);
ASSERT_EQUAL(200, res.code);
@@ -170,11 +184,12 @@ TEST(RoutingTest)
}
{
request req;
+ response res;
req.url = "/4/5000/3/-2.71828/hellhere";
req.headers["TestHeader"] = "Value";
- auto res = app.handle(req);
+ app.handle(req, res);
ASSERT_EQUAL(200, res.code);
@@ -185,11 +200,12 @@ TEST(RoutingTest)
}
{
request req;
+ response res;
req.url = "/5/-5/999/3.141592/hello_there/a/b/c/d";
req.headers["TestHeader"] = "Value";
- auto res = app.handle(req);
+ app.handle(req, res);
ASSERT_EQUAL(200, res.code);