Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: test/ReferrerMapping.cpp

Issue 6307944991817728: Issue 984 - port referrer mapping from Android (Closed)
Patch Set: Created July 16, 2014, 10:32 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ReferrerMapping.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
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/>.
16 */
17
18 #include <AdblockPlus.h>
19 #include <gtest/gtest.h>
20
21 TEST(ReferrerMappingTest, EmptyReferrerChain)
22 {
23 AdblockPlus::ReferrerMapping referrerMapping;
24 std::vector<std::string> referrerChain =
25 referrerMapping.BuildReferrerChain("first");
26 ASSERT_EQ(1, referrerChain.size());
27 ASSERT_EQ("first", referrerChain[0]);
28 }
29
30 TEST(ReferrerMappingTest, TwoElementReferrerChain)
31 {
32 AdblockPlus::ReferrerMapping referrerMapping;
33 referrerMapping.Add("second", "first");
34 std::vector<std::string> referrerChain =
35 referrerMapping.BuildReferrerChain("second");
36 ASSERT_EQ(2, referrerChain.size());
37 ASSERT_EQ("first", referrerChain[0]);
38 ASSERT_EQ("second", referrerChain[1]);
39 }
40
41 TEST(ReferrerMappingTest, TenElementReferrerChain)
42 {
43 AdblockPlus::ReferrerMapping referrerMapping;
44 referrerMapping.Add("second", "first");
45 referrerMapping.Add("third", "second");
46 referrerMapping.Add("fourth", "third");
47 referrerMapping.Add("fifth", "fourth");
48 referrerMapping.Add("sixth", "fifth");
49 referrerMapping.Add("seventh", "sixth");
50 referrerMapping.Add("eighth", "seventh");
51 referrerMapping.Add("ninth", "eighth");
52 referrerMapping.Add("tenth", "ninth");
53 std::vector<std::string> referrerChain =
54 referrerMapping.BuildReferrerChain("tenth");
55 ASSERT_EQ(10, referrerChain.size());
56 ASSERT_EQ("first", referrerChain[0]);
57 ASSERT_EQ("second", referrerChain[1]);
58 ASSERT_EQ("third", referrerChain[2]);
59 ASSERT_EQ("fourth", referrerChain[3]);
60 ASSERT_EQ("fifth", referrerChain[4]);
61 ASSERT_EQ("sixth", referrerChain[5]);
62 ASSERT_EQ("seventh", referrerChain[6]);
63 ASSERT_EQ("eighth", referrerChain[7]);
64 ASSERT_EQ("ninth", referrerChain[8]);
65 ASSERT_EQ("tenth", referrerChain[9]);
66 }
67
68 TEST(ReferrerMappingTest, CacheOnlyFiveUrls)
69 {
70 AdblockPlus::ReferrerMapping referrerMapping(5);
71 referrerMapping.Add("second", "first");
72 referrerMapping.Add("third", "second");
73 referrerMapping.Add("fourth", "third");
74 referrerMapping.Add("fifth", "fourth");
75 referrerMapping.Add("sixth", "fifth");
76 referrerMapping.Add("seventh", "sixth");
77 std::vector<std::string> referrerChain =
78 referrerMapping.BuildReferrerChain("seventh");
79 ASSERT_EQ(6, referrerChain.size());
80 ASSERT_EQ("second", referrerChain[0]);
81 ASSERT_EQ("third", referrerChain[1]);
82 ASSERT_EQ("fourth", referrerChain[2]);
83 ASSERT_EQ("fifth", referrerChain[3]);
84 ASSERT_EQ("sixth", referrerChain[4]);
85 ASSERT_EQ("seventh", referrerChain[5]);
86 }
OLDNEW
« no previous file with comments | « src/ReferrerMapping.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld