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

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

Issue 29333107: Issue #1652, #3456 - Replace 's_asyncWebBrowser2' with thread-safe facilities
Left Patch Set: address comments Created Jan. 4, 2016, 5:51 p.m.
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/plugin/PluginClass.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-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
18 #include <gtest/gtest.h> 18 #include <gtest/gtest.h>
19 #include "../../src/plugin/Instances.h" 19 #include "../../src/plugin/Instances.h"
20
21 typedef SyncMap<int, int, 0> SyncMapOne;
22
23 TEST(SyncMap, Instantiate)
24 {
25 SyncMapOne s;
26 }
27
28 TEST(SyncMap, OrdinaryAdded)
29 {
30 SyncMapOne s;
31 ASSERT_TRUE(s.AddIfAbsent(1, 11));
32 ASSERT_TRUE(s.Locate(1) == 11);
33 ASSERT_TRUE(s.RemoveIfPresent(1));
34 }
35
36 TEST(SyncMap, OrdinaryNotAdded1)
37 {
38 SyncMapOne s;
39 ASSERT_TRUE(s.Locate(1) == 0);
40 }
41
42 TEST(SyncMap, OrdinaryNotAdded2)
43 {
44 SyncMapOne s;
45 ASSERT_TRUE(s.AddIfAbsent(1, 11));
46 ASSERT_TRUE(s.AddIfAbsent(2, 22));
47 ASSERT_TRUE(s.Locate(7) == 0);
48 }
49
50 TEST(SyncMap, WrongAddedTwice)
51 {
52 SyncMapOne s;
53 ASSERT_TRUE(s.AddIfAbsent(3, 11));
54 ASSERT_FALSE(s.AddIfAbsent(3, 22));
55 }
56
57 TEST(SyncMap, AcceptableAddedRemovedAddedAgain)
58 {
59 SyncMapOne s;
60 ASSERT_TRUE(s.AddIfAbsent(1, 11));
61 ASSERT_TRUE(s.RemoveIfPresent(1));
62 ASSERT_TRUE(s.AddIfAbsent(1, 22));
63 }
64
65 TEST(SyncMap, WrongRemovedButNotAdded)
66 {
67 SyncMapOne s;
68 ASSERT_FALSE(s.RemoveIfPresent(3));
69 }
20 70
21 typedef SyncSet<int, 0> SyncSetOne; 71 typedef SyncSet<int, 0> SyncSetOne;
22 bool IsFive(int x) 72 bool IsFive(int x)
23 { 73 {
24 return x == 5; 74 return x == 5;
25 } 75 }
26 76
27 TEST(SyncSet, Instantiate) 77 TEST(SyncSet, Instantiate)
28 { 78 {
29 SyncSetOne s; 79 SyncSetOne s;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 ASSERT_TRUE(s.InsertIfAbsent(5)); 115 ASSERT_TRUE(s.InsertIfAbsent(5));
66 ASSERT_TRUE(s.EraseWithCheck(5)); 116 ASSERT_TRUE(s.EraseWithCheck(5));
67 ASSERT_TRUE(s.InsertIfAbsent(5)); 117 ASSERT_TRUE(s.InsertIfAbsent(5));
68 } 118 }
69 119
70 TEST(SyncSet, WrongEraseWithoutInsert) 120 TEST(SyncSet, WrongEraseWithoutInsert)
71 { 121 {
72 SyncSetOne s; 122 SyncSetOne s;
73 ASSERT_FALSE(s.EraseWithCheck(3)); 123 ASSERT_FALSE(s.EraseWithCheck(3));
74 } 124 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld