summaryrefslogtreecommitdiffstats
path: root/xbmc/utils/test/TestHttpParser.cpp
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
committermanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
commitbe933ef2241d79558f91796cc5b3a161f72ebf9c (patch)
treefe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/utils/test/TestHttpParser.cpp
parent5f8335c1e49ce108ef3481863833c98efa00411b (diff)
downloadkodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip
sync with upstream
Diffstat (limited to 'xbmc/utils/test/TestHttpParser.cpp')
-rw-r--r--xbmc/utils/test/TestHttpParser.cpp49
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
13TEST(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}