diff options
author | Oleg Morozenkov <omorozenkov@gmail.com> | 2015-08-11 22:13:23 +0300 |
---|---|---|
committer | Oleg Morozenkov <omorozenkov@gmail.com> | 2015-08-11 22:13:23 +0300 |
commit | 376b88ec09ef8cf71dd823467406c58204485fcc (patch) | |
tree | 9ca599b854d18006c65b26003ce7dbdd416fdf18 /test/tgbot/net/HttpParser.cpp | |
parent | d7fbf7149d0e0c1c30972dab68d510ef6ac377dd (diff) |
Fixed compiler's errors in TgTypeParser + fixed indentation + some other fixes
Diffstat (limited to 'test/tgbot/net/HttpParser.cpp')
-rw-r--r-- | test/tgbot/net/HttpParser.cpp | 168 |
1 files changed, 84 insertions, 84 deletions
diff --git a/test/tgbot/net/HttpParser.cpp b/test/tgbot/net/HttpParser.cpp index 57ba187..362a13f 100644 --- a/test/tgbot/net/HttpParser.cpp +++ b/test/tgbot/net/HttpParser.cpp @@ -32,105 +32,105 @@ using namespace TgBot; BOOST_AUTO_TEST_SUITE(tHttpParser) BOOST_AUTO_TEST_CASE(generateRequest) { - vector<HttpReqArg> args = { HttpReqArg("email", "test@example.com"), HttpReqArg("text", "Hello, world!") }; - string t = HttpParser::getInstance().generateRequest(Url("http://example.com/index.html"), args, true); - string e = "" - "POST /index.html HTTP/1.1\r\n" - "Host: example.com\r\n" - "Connection: keep-alive\r\n" - "Content-Type: application/x-www-form-urlencoded\r\n" - "Content-Length: 49\r\n" - "\r\n" - "email=test%40example.com&text=Hello%2c%20world%21"; - BOOST_CHECK_MESSAGE(t == e, diff(t, e)); + vector<HttpReqArg> args = { HttpReqArg("email", "test@example.com"), HttpReqArg("text", "Hello, world!") }; + string t = HttpParser::getInstance().generateRequest(Url("http://example.com/index.html"), args, true); + string e = "" + "POST /index.html HTTP/1.1\r\n" + "Host: example.com\r\n" + "Connection: keep-alive\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Length: 49\r\n" + "\r\n" + "email=test%40example.com&text=Hello%2c%20world%21"; + BOOST_CHECK_MESSAGE(t == e, diff(t, e)); } BOOST_AUTO_TEST_CASE(generateMultipartFormData) { - vector<HttpReqArg> args = { HttpReqArg("email", "test@example.com"), HttpReqArg("text", "Hello, world!", true) }; - string boundary = HttpParser::getInstance().generateMultipartBoundary(args); - string t = HttpParser::getInstance().generateMultipartFormData(args, boundary); - string e = "" - "--" + boundary + "\r\n" - "Content-Disposition: form-data; name=\"email\"\r\n" - "\r\n" - "test@example.com\r\n" - "--" + boundary + "\r\n" - "Content-Disposition: form-data; name=\"text\"\r\n" - "Content-Type: text/plain\r\n" - "\r\n" - "Hello, world!\r\n"; - BOOST_CHECK_MESSAGE(t == e, diff(t, e)); + vector<HttpReqArg> args = { HttpReqArg("email", "test@example.com"), HttpReqArg("text", "Hello, world!", true) }; + string boundary = HttpParser::getInstance().generateMultipartBoundary(args); + string t = HttpParser::getInstance().generateMultipartFormData(args, boundary); + string e = "" + "--" + boundary + "\r\n" + "Content-Disposition: form-data; name=\"email\"\r\n" + "\r\n" + "test@example.com\r\n" + "--" + boundary + "\r\n" + "Content-Disposition: form-data; name=\"text\"\r\n" + "Content-Type: text/plain\r\n" + "\r\n" + "Hello, world!\r\n"; + BOOST_CHECK_MESSAGE(t == e, diff(t, e)); } BOOST_AUTO_TEST_CASE(generateWwwFormUrlencoded) { - vector<HttpReqArg> args = { HttpReqArg("email", "test@example.com"), HttpReqArg("text", "Hello, world!") }; - string t = HttpParser::getInstance().generateWwwFormUrlencoded(args); - string e = "email=test%40example.com&text=Hello%2c%20world%21"; - BOOST_CHECK_MESSAGE(t == e, diff(t, e)); + vector<HttpReqArg> args = { HttpReqArg("email", "test@example.com"), HttpReqArg("text", "Hello, world!") }; + string t = HttpParser::getInstance().generateWwwFormUrlencoded(args); + string e = "email=test%40example.com&text=Hello%2c%20world%21"; + BOOST_CHECK_MESSAGE(t == e, diff(t, e)); } BOOST_AUTO_TEST_CASE(generateResponse) { - string t = HttpParser::getInstance().generateResponse("testdata"); - string e = "" - "HTTP/1.1 200 OK\r\n" - "Content-Type: text/plain\r\n" - "Content-Length: 8\r\n" - "\r\n" - "testdata"; - BOOST_CHECK_MESSAGE(t == e, diff(t, e)); + string t = HttpParser::getInstance().generateResponse("testdata"); + string e = "" + "HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain\r\n" + "Content-Length: 8\r\n" + "\r\n" + "testdata"; + BOOST_CHECK_MESSAGE(t == e, diff(t, e)); } BOOST_AUTO_TEST_CASE(parseRequest) { - string data = "" - "POST /index.html HTTP/1.1\r\n" - "Host: example.com\r\n" - "Connection: keep-alive\r\n" - "Content-Type: text/plain\r\n" - "Content-Length: 8\r\n" - "\r\n" - "testdata"; - - map<string, string> tHeaders; - string t = HttpParser::getInstance().parseRequest(data, tHeaders); - - map<string, string> eHeaders = { - { "method", "POST" }, - { "path", "/index.html" }, - { "host", "example.com" }, - { "connection", "keep-alive" }, - { "content-type", "text/plain" }, - { "content-length", "8" } - }; - string e = "testdata"; - - BOOST_CHECK_MESSAGE(t == e, diff(t, e)); - BOOST_CHECK_MESSAGE(tHeaders == eHeaders, diff(tHeaders, eHeaders, [](const pair<const string, string>& item) -> string { - return item.first + '=' + item.second; - })); + string data = "" + "POST /index.html HTTP/1.1\r\n" + "Host: example.com\r\n" + "Connection: keep-alive\r\n" + "Content-Type: text/plain\r\n" + "Content-Length: 8\r\n" + "\r\n" + "testdata"; + + map<string, string> tHeaders; + string t = HttpParser::getInstance().parseRequest(data, tHeaders); + + map<string, string> eHeaders = { + { "method", "POST" }, + { "path", "/index.html" }, + { "host", "example.com" }, + { "connection", "keep-alive" }, + { "content-type", "text/plain" }, + { "content-length", "8" } + }; + string e = "testdata"; + + BOOST_CHECK_MESSAGE(t == e, diff(t, e)); + BOOST_CHECK_MESSAGE(tHeaders == eHeaders, diff(tHeaders, eHeaders, [](const pair<const string, string>& item) -> string { + return item.first + '=' + item.second; + })); } BOOST_AUTO_TEST_CASE(parseResponse) { - string data = "" - "HTTP/1.1 200 OK\r\n" - "Content-Type: text/plain\r\n" - "Content-Length: 8\r\n" - "\r\n" - "testdata"; - - map<string, string> tHeaders; - string t = HttpParser::getInstance().parseResponse(data, tHeaders); - - map<string, string> eHeaders = { - { "status", "200" }, - { "content-type", "text/plain" }, - { "content-length", "8" } - }; - string e = "testdata"; - - BOOST_CHECK_MESSAGE(t == e, diff(t, e)); - BOOST_CHECK_MESSAGE(tHeaders == eHeaders, diff(tHeaders, eHeaders, [](const pair<const string, string>& item) -> string { - return item.first + '=' + item.second; - })); + string data = "" + "HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain\r\n" + "Content-Length: 8\r\n" + "\r\n" + "testdata"; + + map<string, string> tHeaders; + string t = HttpParser::getInstance().parseResponse(data, tHeaders); + + map<string, string> eHeaders = { + { "status", "200" }, + { "content-type", "text/plain" }, + { "content-length", "8" } + }; + string e = "testdata"; + + BOOST_CHECK_MESSAGE(t == e, diff(t, e)); + BOOST_CHECK_MESSAGE(tHeaders == eHeaders, diff(tHeaders, eHeaders, [](const pair<const string, string>& item) -> string { + return item.first + '=' + item.second; + })); } BOOST_AUTO_TEST_SUITE_END() |