LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 #include <gtest/gtest.h> | 18 #include <gtest/gtest.h> |
19 #include "../src/shared/Utils.h" | 19 #include "../src/shared/Utils.h" |
20 | 20 |
21 TEST(GetQueryStringTest, SimpleUrl) | 21 // Tests are in the following order |
| 22 // x ? x # x |
| 23 // 1 0 0 0 0 |
| 24 // 1 0 0 0 1 - the same as 10000 |
| 25 // 1 0 0 1 0 |
| 26 // 1 0 0 1 1 |
| 27 // 1 0 1 0 0 - the same as 10000 |
| 28 // 1 0 1 0 1 - the same as 10000 |
| 29 // 1 0 1 1 0 - the same as 10010 |
| 30 // 1 0 1 1 1 - the same as 10011 |
| 31 // 1 1 0 0 0 |
| 32 // 1 1 0 0 1 - the same as 11100 |
| 33 // 1 1 0 1 0 |
| 34 // 1 1 0 1 1 |
| 35 // 1 1 1 0 0 |
| 36 // 1 1 1 0 1 - the same as 11100 |
| 37 // 1 1 1 1 0 |
| 38 // 1 1 1 1 1 |
| 39 |
| 40 TEST(GetQueryStringTest, URL_10000) |
22 { | 41 { |
23 EXPECT_EQ(L"", GetQueryString(L"schema://host/path1/path2")); | 42 EXPECT_EQ(L"", GetQueryString(L"schema://host/path1/path2")); |
24 } | 43 } |
25 | 44 |
26 TEST(GetQueryStringTest, EmptyQueryString) | 45 TEST(GetQueryStringTest, URL_10010) |
| 46 { |
| 47 EXPECT_EQ(L"", GetQueryString(L"schema://host/path1/path2#")); |
| 48 } |
| 49 |
| 50 TEST(GetQueryStringTest, URL_10011) |
| 51 { |
| 52 EXPECT_EQ(L"", GetQueryString(L"schema://host/path1/path2#fragment")); |
| 53 } |
| 54 |
| 55 TEST(GetQueryStringTest, URL_11000) |
27 { | 56 { |
28 EXPECT_EQ(L"", GetQueryString(L"schema://host/path1/path2?")); | 57 EXPECT_EQ(L"", GetQueryString(L"schema://host/path1/path2?")); |
29 } | 58 } |
30 | 59 |
31 TEST(GetQueryStringTest, UrlWithQueryString) | 60 TEST(GetQueryStringTest, URL_11010) |
| 61 { |
| 62 EXPECT_EQ(L"", GetQueryString(L"schema://host/path1/path2?#")); |
| 63 } |
| 64 |
| 65 TEST(GetQueryStringTest, URL_11011) |
| 66 { |
| 67 EXPECT_EQ(L"", GetQueryString(L"schema://host/path1/path2?#fragment")); |
| 68 } |
| 69 |
| 70 TEST(GetQueryStringTest, URL_11100) |
32 { | 71 { |
33 EXPECT_EQ(L"queryString", GetQueryString(L"schema://host/path1/path2?queryStri
ng")); | 72 EXPECT_EQ(L"queryString", GetQueryString(L"schema://host/path1/path2?queryStri
ng")); |
34 } | 73 } |
35 | 74 |
36 TEST(GetQueryStringTest, UrlWithQueryStringAndHash) | 75 TEST(GetQueryStringTest, URL_11110) |
37 { | 76 { |
38 EXPECT_EQ(L"queryString=value", GetQueryString(L"schema://host/path1/path2?que
ryString=value#")); | 77 EXPECT_EQ(L"queryString=value", GetQueryString(L"schema://host/path1/path2?que
ryString=value#")); |
39 } | 78 } |
40 | 79 |
41 TEST(GetQueryStringTest, UrlWithoutQuestionSign) | 80 TEST(GetQueryStringTest, URL_11111) |
42 { | 81 { |
43 EXPECT_EQ(L"", GetQueryString(L"schema://host/path1/path2#")); | 82 EXPECT_EQ(L"queryString=value", GetQueryString(L"schema://host/path1/path2?que
ryString=value#fragment")); |
44 } | 83 } |
45 | 84 |
46 TEST(GetQueryStringTest, UrlWithEmptyQueryStringAndWithHash) | |
47 { | |
48 EXPECT_EQ(L"", GetQueryString(L"schema://host/path1/path2?#")); | |
49 } | |
50 | |
LEFT | RIGHT |