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

Delta Between Two Patch Sets: test/plugin/InstancesTest.cpp

Issue 29330403: Issue #1467, #3397 - Rewrite the map from threads to tabs (Closed)
Left Patch Set: rebase only Created Dec. 8, 2015, 7:43 p.m.
Right Patch Set: add comment; new function body Created July 17, 2016, 4:01 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« src/plugin/Instances.h ('K') | « src/plugin/PluginWbPassThrough.cpp ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2016 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 #include <gtest/gtest.h> 17 #include <gtest/gtest.h>
18 #include "../../src/plugin/Instances.h" 18 #include "../../src/plugin/Instances.h"
19 19
20 typedef SyncMap<int, int, 0> SyncMapOne; 20 typedef SyncMap<int, int, 0> SyncMapOne;
sergei 2016/02/01 15:50:43 What does "One" mean?
Eric 2016/02/03 17:17:05 It means its the first 'SyncMap' for testing. If w
sergei 2016/02/08 13:35:36 Let's solve the problem of name collision when it
Eric 2016/02/08 18:45:30 Bikeshedding.
21 21
22 TEST(SyncMap, Instantiate) 22 TEST(SyncMap, Instantiate)
sergei 2016/02/08 13:35:36 Where is the test "Destroy"? I'm not sure that we
Eric 2016/02/08 18:45:30 This test also calls the destructor.
23 { 23 {
24 SyncMapOne s; 24 SyncMapOne s;
25 } 25 }
26 26
27 TEST(SyncMap, OrdinaryAdded) 27 TEST(SyncMap, OrdinaryAdded)
28 { 28 {
29 SyncMapOne s; 29 SyncMapOne s;
30 ASSERT_TRUE(s.AddIfAbsent(1, 11)); 30 ASSERT_TRUE(s.AddIfAbsent(1, 11));
sergei 2016/02/08 13:35:36 I still think that we should use EXPECT_ instead o
Eric 2016/02/08 18:45:30 'EXPECT' is inferior here, and it isn't just perso
31 ASSERT_TRUE(s.Locate(1) == 11); 31 ASSERT_TRUE(s.Locate(1) == 11);
32 ASSERT_TRUE(s.RemoveAndCheck(1)); 32 ASSERT_TRUE(s.RemoveIfPresent(1));
33 } 33 }
34 34
35 TEST(SyncMap, OrdinaryNotAdded1) 35 TEST(SyncMap, OrdinaryNotAdded1)
36 { 36 {
37 SyncMapOne s; 37 SyncMapOne s;
38 ASSERT_TRUE(s.Locate(1) == 0); 38 ASSERT_TRUE(s.Locate(1) == 0);
39 } 39 }
40 40
41 TEST(SyncMap, OrdinaryNotAdded2) 41 TEST(SyncMap, OrdinaryNotAdded2)
42 { 42 {
43 SyncMapOne s; 43 SyncMapOne s;
44 ASSERT_TRUE(s.AddIfAbsent(1, 11)); 44 ASSERT_TRUE(s.AddIfAbsent(1, 11));
45 ASSERT_TRUE(s.AddIfAbsent(2, 22)); 45 ASSERT_TRUE(s.AddIfAbsent(2, 22));
46 ASSERT_TRUE(s.Locate(7) == 0); 46 ASSERT_TRUE(s.Locate(7) == 0);
47 } 47 }
48 48
49 TEST(SyncMap, WrongAddedTwice) 49 TEST(SyncMap, WrongAddedTwice)
50 { 50 {
51 SyncMapOne s; 51 SyncMapOne s;
52 ASSERT_TRUE(s.AddIfAbsent(3, 11)); 52 ASSERT_TRUE(s.AddIfAbsent(3, 11));
53 ASSERT_FALSE(s.AddIfAbsent(3, 22)); 53 ASSERT_FALSE(s.AddIfAbsent(3, 22));
54 } 54 }
55 55
56 TEST(SyncMap, AcceptableAddedRemovedAddedAgain) 56 TEST(SyncMap, AcceptableAddedRemovedAddedAgain)
57 { 57 {
58 SyncMapOne s; 58 SyncMapOne s;
59 ASSERT_TRUE(s.AddIfAbsent(1, 11)); 59 ASSERT_TRUE(s.AddIfAbsent(1, 11));
60 ASSERT_TRUE(s.RemoveAndCheck(1)); 60 ASSERT_TRUE(s.RemoveIfPresent(1));
61 ASSERT_TRUE(s.AddIfAbsent(1, 22)); 61 ASSERT_TRUE(s.AddIfAbsent(1, 22));
62 } 62 }
63 63
64 TEST(SyncMap, WrongRemovedButNotAdded) 64 TEST(SyncMap, WrongRemovedButNotAdded)
65 { 65 {
66 SyncMapOne s; 66 SyncMapOne s;
67 ASSERT_FALSE(s.RemoveAndCheck(3)); 67 ASSERT_FALSE(s.RemoveIfPresent(3));
68 } 68 }
69 69
LEFTRIGHT

Powered by Google App Engine
This is Rietveld