Fix keymap.
[vuplus_xbmc] / xbmc / test / TestURL.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 "URL.h"
22
23 #include "gtest/gtest.h"
24
25 using ::testing::Test;
26 using ::testing::WithParamInterface;
27 using ::testing::ValuesIn;
28
29 struct TestURLGetWithoutUserDetailsData
30 {
31   std::string input;
32   std::string expected;
33   bool redact;
34 };
35
36 std::ostream& operator<<(std::ostream& os,
37                        const TestURLGetWithoutUserDetailsData& rhs)
38 {
39   return os << "(Input: " << rhs.input <<
40     "; Redact: " << (rhs.redact?"true":"false") <<
41     "; Expected: " << rhs.expected << ")";
42 }
43
44 class TestURLGetWithoutUserDetails : public Test,
45                                      public WithParamInterface<TestURLGetWithoutUserDetailsData>
46 {
47 };
48
49 TEST_P(TestURLGetWithoutUserDetails, GetWithoutUserDetails)
50 {
51   CURL input(GetParam().input);
52   std::string result = input.GetWithoutUserDetails(GetParam().redact);
53   EXPECT_EQ(result, GetParam().expected);
54 }
55
56 const TestURLGetWithoutUserDetailsData values[] = {
57   { std::string("smb://example.com/example"), std::string("smb://example.com/example"), false },
58   { std::string("smb://example.com/example"), std::string("smb://example.com/example"), true },
59   { std::string("smb://god:universe@example.com/example"), std::string("smb://example.com/example"), false },
60   { std::string("smb://god@example.com/example"), std::string("smb://USERNAME@example.com/example"), true },
61   { std::string("smb://god:universe@example.com/example"), std::string("smb://USERNAME:PASSWORD@example.com/example"), true },
62   { std::string("http://god:universe@example.com:8448/example|auth=digest"), std::string("http://USERNAME:PASSWORD@example.com:8448/example|auth=digest"), true }
63   };
64
65 INSTANTIATE_TEST_CASE_P(URL, TestURLGetWithoutUserDetails, ValuesIn(values));