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

Side by Side Diff: test/plugin/InstancesTest.cpp

Issue 29333107: Issue #1652, #3456 - Replace 's_asyncWebBrowser2' with thread-safe facilities
Patch Set: rebase only Created July 27, 2016, 10:26 p.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/plugin/PluginClass.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
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-2016 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
17 #include <gtest/gtest.h> 18 #include <gtest/gtest.h>
18 #include "../../src/plugin/Instances.h" 19 #include "../../src/plugin/Instances.h"
19 20
20 typedef SyncMap<int, int, 0> SyncMapOne; 21 typedef SyncMap<int, int, 0> SyncMapOne;
21 22
22 TEST(SyncMap, Instantiate) 23 TEST(SyncMap, Instantiate)
23 { 24 {
24 SyncMapOne s; 25 SyncMapOne s;
25 } 26 }
26 27
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 ASSERT_TRUE(s.RemoveIfPresent(1)); 61 ASSERT_TRUE(s.RemoveIfPresent(1));
61 ASSERT_TRUE(s.AddIfAbsent(1, 22)); 62 ASSERT_TRUE(s.AddIfAbsent(1, 22));
62 } 63 }
63 64
64 TEST(SyncMap, WrongRemovedButNotAdded) 65 TEST(SyncMap, WrongRemovedButNotAdded)
65 { 66 {
66 SyncMapOne s; 67 SyncMapOne s;
67 ASSERT_FALSE(s.RemoveIfPresent(3)); 68 ASSERT_FALSE(s.RemoveIfPresent(3));
68 } 69 }
69 70
71 typedef SyncSet<int, 0> SyncSetOne;
72 bool IsFive(int x)
73 {
74 return x == 5;
75 }
76
77 TEST(SyncSet, Instantiate)
78 {
79 SyncSetOne s;
80 }
81
82 TEST(SyncSet, OrdinaryInserted)
83 {
84 SyncSetOne s;
85 ASSERT_TRUE(s.InsertIfAbsent(5));
86 EXPECT_EQ(5, s.LinearSearch(IsFive));
87 ASSERT_TRUE(s.EraseWithCheck(5));
88 EXPECT_EQ(0, s.LinearSearch(IsFive));
89 }
90
91 TEST(SyncSet, OrdinaryNotInserted1)
92 {
93 SyncSetOne s;
94 ASSERT_EQ(0, s.LinearSearch(IsFive));
95 }
96
97 TEST(SyncSet, OrdinaryNotInserted2)
98 {
99 SyncSetOne s;
100 ASSERT_TRUE(s.InsertIfAbsent(1));
101 ASSERT_TRUE(s.InsertIfAbsent(2));
102 ASSERT_EQ(0, s.LinearSearch(IsFive));
103 }
104
105 TEST(SyncSet, WrongAddedTwice)
106 {
107 SyncSetOne s;
108 ASSERT_TRUE(s.InsertIfAbsent(3));
109 ASSERT_FALSE(s.InsertIfAbsent(3));
110 }
111
112 TEST(SyncSet, AcceptableAddRemoveAddAgain)
113 {
114 SyncSetOne s;
115 ASSERT_TRUE(s.InsertIfAbsent(5));
116 ASSERT_TRUE(s.EraseWithCheck(5));
117 ASSERT_TRUE(s.InsertIfAbsent(5));
118 }
119
120 TEST(SyncSet, WrongEraseWithoutInsert)
121 {
122 SyncSetOne s;
123 ASSERT_FALSE(s.EraseWithCheck(3));
124 }
OLDNEW
« no previous file with comments | « src/plugin/PluginClass.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld