DVDCodecs: Amlogic: Handle conditions in which amcodec should be opened during Open()
[vuplus_xbmc] / xbmc / utils / test / TestHttpHeader.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "utils/HttpHeader.h"
22 #include "gtest/gtest.h"
23
24 TEST(TestHttpHeader, General)
25 {
26   CHttpHeader a;
27   std::string str = "Host: xbmc.org\r\n"
28                    "Accept: text/*, text/html, text/html;level=1, */*\r\n"
29                    "Accept-Language: en\r\n"
30                    "Accept-Encoding: gzip, deflate\r\n"
31                    "Content-Type: text/html; charset=ISO-8859-4\r\n"
32                    "User-Agent: XBMC/snapshot (compatible; MSIE 5.5; Windows NT"
33                      " 4.0)\r\n"
34                    "Connection: Keep-Alive\r\n";
35   std::string refstr, varstr;
36
37   a.Parse(str);
38
39   /* Should be in the same order as above */
40   refstr = "\n"
41            "host: xbmc.org\n"
42            "accept: text/*, text/html, text/html;level=1, */*\n"
43            "accept-language: en\n"
44            "accept-encoding: gzip, deflate\n"
45            "content-type: text/html; charset=ISO-8859-4\n"
46            "user-agent: XBMC/snapshot (compatible; MSIE 5.5; Windows NT 4.0)\n"
47            "connection: Keep-Alive\n"
48            "\n";
49   varstr.clear();
50   varstr = a.GetHeader();
51   EXPECT_STREQ(refstr.c_str(), varstr.c_str());
52
53   refstr = "XBMC/snapshot (compatible; MSIE 5.5; Windows NT 4.0)";
54   varstr = a.GetValue("User-Agent");
55   EXPECT_STREQ(refstr.c_str(), varstr.c_str());
56
57   /* No charset should be here */
58   refstr = "text/html";
59   varstr = a.GetMimeType();
60   EXPECT_STREQ(refstr.c_str(), varstr.c_str());
61
62   refstr = "";
63   varstr = a.GetProtoLine();
64   EXPECT_STREQ(refstr.c_str(), varstr.c_str());
65
66   a.Clear();
67   refstr = "";
68   varstr = a.GetMimeType();
69   EXPECT_STREQ(refstr.c_str(), varstr.c_str());
70 }