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: Created Dec. 29, 2015, 5:54 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
« src/plugin/PluginClass.cpp ('K') | « 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
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 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 <gtest/gtest.h>
19 #include "../../src/plugin/Instances.h"
20
21 typedef SyncSet<int, 0> SyncSetOne;
22 bool IsFive(int x)
23 {
24 return x == 5;
25 }
26
27 TEST(SyncSet, Instantiate)
28 {
29 SyncSetOne s;
30 }
31
32 TEST(SyncSet, OrdinaryInserted)
33 {
34 SyncSetOne s;
35 ASSERT_TRUE(s.InsertIfAbsent(5));
36 EXPECT_EQ(5, s.LinearSearch(IsFive));
37 ASSERT_TRUE(s.EraseWithCheck(5));
38 EXPECT_EQ(0, s.LinearSearch(IsFive));
39 }
40
41 TEST(SyncSet, OrdinaryNotInserted1)
42 {
43 SyncSetOne s;
44 ASSERT_EQ(0, s.LinearSearch(IsFive));
45 }
46
47 TEST(SyncSet, OrdinaryNotInserted2)
48 {
49 SyncSetOne s;
50 ASSERT_TRUE(s.InsertIfAbsent(1));
51 ASSERT_TRUE(s.InsertIfAbsent(2));
52 ASSERT_EQ(0, s.LinearSearch(IsFive));
53 }
54
55 TEST(SyncSet, WrongAddedTwice)
56 {
57 SyncSetOne s;
58 ASSERT_TRUE(s.InsertIfAbsent(3));
59 ASSERT_FALSE(s.InsertIfAbsent(3));
60 }
61
62 TEST(SyncSet, AcceptableAddRemoveAddAgain)
63 {
64 SyncSetOne s;
65 ASSERT_TRUE(s.InsertIfAbsent(5));
66 ASSERT_TRUE(s.EraseWithCheck(5));
67 ASSERT_TRUE(s.InsertIfAbsent(5));
68 }
69
70 TEST(SyncSet, WrongEraseWithoutInsert)
71 {
72 SyncSetOne s;
73 ASSERT_FALSE(s.EraseWithCheck(3));
74 }
OLDNEW
« src/plugin/PluginClass.cpp ('K') | « src/plugin/PluginClass.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld