diff options
Diffstat (limited to 'xbmc/utils/test/TestHttpResponse.cpp')
| -rw-r--r-- | xbmc/utils/test/TestHttpResponse.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/xbmc/utils/test/TestHttpResponse.cpp b/xbmc/utils/test/TestHttpResponse.cpp new file mode 100644 index 0000000..1f66285 --- /dev/null +++ b/xbmc/utils/test/TestHttpResponse.cpp | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #include "utils/HttpResponse.h" | ||
| 10 | |||
| 11 | #include <gtest/gtest.h> | ||
| 12 | |||
| 13 | TEST(TestHttpResponse, General) | ||
| 14 | { | ||
| 15 | CHttpResponse a(HTTP::POST, HTTP::OK); | ||
| 16 | std::string response, content, refstr; | ||
| 17 | |||
| 18 | a.AddHeader("date", "Sun, 01 Jul 2012 00:00:00 -0400"); | ||
| 19 | a.AddHeader("content-type", "text/html"); | ||
| 20 | content = "<html>\r\n" | ||
| 21 | " <body>\r\n" | ||
| 22 | " <h1>XBMC TestHttpResponse Page</h1>\r\n" | ||
| 23 | " <p>blah blah blah</p>\r\n" | ||
| 24 | " </body>\r\n" | ||
| 25 | "</html>\r\n"; | ||
| 26 | a.SetContent(content.c_str(), content.length()); | ||
| 27 | |||
| 28 | response = a.Create();; | ||
| 29 | EXPECT_EQ((unsigned int)210, response.size()); | ||
| 30 | |||
| 31 | refstr = "HTTP/1.1 200 OK\r\n" | ||
| 32 | "date: Sun, 01 Jul 2012 00:00:00 -0400\r\n" | ||
| 33 | "content-type: text/html\r\n" | ||
| 34 | "Content-Length: 106\r\n" | ||
| 35 | "\r\n" | ||
| 36 | "<html>\r\n" | ||
| 37 | " <body>\r\n" | ||
| 38 | " <h1>XBMC TestHttpResponse Page</h1>\r\n" | ||
| 39 | " <p>blah blah blah</p>\r\n" | ||
| 40 | " </body>\r\n" | ||
| 41 | "</html>\r\n"; | ||
| 42 | EXPECT_STREQ(refstr.c_str(), response.c_str()); | ||
| 43 | } | ||
