comparison UnitTests/RestApi.cpp @ 332:c51c9ed603e6

fixes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 09 Jan 2013 13:57:58 +0100
parents 78a8eaa5f30b
children
comparison
equal deleted inserted replaced
331:5a96dac27959 332:c51c9ed603e6
13 TEST(RestApi, ParseCookies) 13 TEST(RestApi, ParseCookies)
14 { 14 {
15 HttpHandler::Arguments headers; 15 HttpHandler::Arguments headers;
16 HttpHandler::Arguments cookies; 16 HttpHandler::Arguments cookies;
17 17
18 headers["cookies"] = "a=b;c=d;;;e=f;;g=h;"; 18 headers["cookie"] = "a=b;c=d;;;e=f;;g=h;";
19 HttpHandler::ParseCookies(cookies, headers); 19 HttpHandler::ParseCookies(cookies, headers);
20 ASSERT_EQ(4u, cookies.size()); 20 ASSERT_EQ(4u, cookies.size());
21 ASSERT_EQ("b", cookies["a"]); 21 ASSERT_EQ("b", cookies["a"]);
22 ASSERT_EQ("d", cookies["c"]); 22 ASSERT_EQ("d", cookies["c"]);
23 ASSERT_EQ("f", cookies["e"]); 23 ASSERT_EQ("f", cookies["e"]);
24 ASSERT_EQ("h", cookies["g"]); 24 ASSERT_EQ("h", cookies["g"]);
25 25
26 headers["cookies"] = " name = value ; name2=value2"; 26 headers["cookie"] = " name = value ; name2=value2";
27 HttpHandler::ParseCookies(cookies, headers); 27 HttpHandler::ParseCookies(cookies, headers);
28 ASSERT_EQ(2u, cookies.size()); 28 ASSERT_EQ(2u, cookies.size());
29 ASSERT_EQ("value", cookies["name"]); 29 ASSERT_EQ("value", cookies["name"]);
30 ASSERT_EQ("value2", cookies["name2"]); 30 ASSERT_EQ("value2", cookies["name2"]);
31 31
32 headers["cookies"] = " ;;; "; 32 headers["cookie"] = " ;;; ";
33 HttpHandler::ParseCookies(cookies, headers); 33 HttpHandler::ParseCookies(cookies, headers);
34 ASSERT_EQ(0u, cookies.size()); 34 ASSERT_EQ(0u, cookies.size());
35 35
36 headers["cookies"] = " ; n=v ;; "; 36 headers["cookie"] = " ; n=v ;; ";
37 HttpHandler::ParseCookies(cookies, headers); 37 HttpHandler::ParseCookies(cookies, headers);
38 ASSERT_EQ(1u, cookies.size()); 38 ASSERT_EQ(1u, cookies.size());
39 ASSERT_EQ("v", cookies["n"]); 39 ASSERT_EQ("v", cookies["n"]);
40 } 40 }
41 41