diff options
Diffstat (limited to 'xbmc/utils/test/TestHttpParser.cpp')
| -rw-r--r-- | xbmc/utils/test/TestHttpParser.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/xbmc/utils/test/TestHttpParser.cpp b/xbmc/utils/test/TestHttpParser.cpp new file mode 100644 index 0000000..1eb2932 --- /dev/null +++ b/xbmc/utils/test/TestHttpParser.cpp | |||
| @@ -0,0 +1,49 @@ | |||
| 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/HttpParser.h" | ||
| 10 | |||
| 11 | #include <gtest/gtest.h> | ||
| 12 | |||
| 13 | TEST(TestHttpParser, General) | ||
| 14 | { | ||
| 15 | HttpParser a; | ||
| 16 | std::string str = "POST /path/script.cgi HTTP/1.0\r\n" | ||
| 17 | "From: amejia@xbmc.org\r\n" | ||
| 18 | "User-Agent: XBMC/snapshot (compatible; MSIE 5.5; Windows NT" | ||
| 19 | " 4.0)\r\n" | ||
| 20 | "Content-Type: application/x-www-form-urlencoded\r\n" | ||
| 21 | "Content-Length: 35\r\n" | ||
| 22 | "\r\n" | ||
| 23 | "home=amejia&favorite+flavor=orange\r\n"; | ||
| 24 | std::string refstr, varstr; | ||
| 25 | |||
| 26 | EXPECT_EQ(a.Done, a.addBytes(str.c_str(), str.length())); | ||
| 27 | |||
| 28 | refstr = "POST"; | ||
| 29 | varstr = a.getMethod(); | ||
| 30 | EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 31 | |||
| 32 | refstr = "/path/script.cgi"; | ||
| 33 | varstr = a.getUri(); | ||
| 34 | EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 35 | |||
| 36 | refstr = ""; | ||
| 37 | varstr = a.getQueryString(); | ||
| 38 | EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 39 | |||
| 40 | refstr = "home=amejia&favorite+flavor=orange\r\n"; | ||
| 41 | varstr = a.getBody(); | ||
| 42 | EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 43 | |||
| 44 | refstr = "application/x-www-form-urlencoded"; | ||
| 45 | varstr = a.getValue("content-type"); | ||
| 46 | EXPECT_STREQ(refstr.c_str(), varstr.c_str()); | ||
| 47 | |||
| 48 | EXPECT_EQ((unsigned)35, a.getContentLength()); | ||
| 49 | } | ||
