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

Unified Diff: test/plugin/InstancesTest.cpp

Issue 29330403: Issue #1467, #3397 - Rewrite the map from threads to tabs (Closed)
Patch Set: add comment; new function body Created July 17, 2016, 4:01 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/plugin/Instances.h ('K') | « src/plugin/PluginWbPassThrough.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/plugin/InstancesTest.cpp
===================================================================
new file mode 100644
--- /dev/null
+++ b/test/plugin/InstancesTest.cpp
@@ -0,0 +1,69 @@
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
+ * Copyright (C) 2006-2016 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include <gtest/gtest.h>
+#include "../../src/plugin/Instances.h"
+
+typedef SyncMap<int, int, 0> SyncMapOne;
+
+TEST(SyncMap, Instantiate)
+{
+ SyncMapOne s;
+}
+
+TEST(SyncMap, OrdinaryAdded)
+{
+ SyncMapOne s;
+ ASSERT_TRUE(s.AddIfAbsent(1, 11));
+ ASSERT_TRUE(s.Locate(1) == 11);
+ ASSERT_TRUE(s.RemoveIfPresent(1));
+}
+
+TEST(SyncMap, OrdinaryNotAdded1)
+{
+ SyncMapOne s;
+ ASSERT_TRUE(s.Locate(1) == 0);
+}
+
+TEST(SyncMap, OrdinaryNotAdded2)
+{
+ SyncMapOne s;
+ ASSERT_TRUE(s.AddIfAbsent(1, 11));
+ ASSERT_TRUE(s.AddIfAbsent(2, 22));
+ ASSERT_TRUE(s.Locate(7) == 0);
+}
+
+TEST(SyncMap, WrongAddedTwice)
+{
+ SyncMapOne s;
+ ASSERT_TRUE(s.AddIfAbsent(3, 11));
+ ASSERT_FALSE(s.AddIfAbsent(3, 22));
+}
+
+TEST(SyncMap, AcceptableAddedRemovedAddedAgain)
+{
+ SyncMapOne s;
+ ASSERT_TRUE(s.AddIfAbsent(1, 11));
+ ASSERT_TRUE(s.RemoveIfPresent(1));
+ ASSERT_TRUE(s.AddIfAbsent(1, 22));
+}
+
+TEST(SyncMap, WrongRemovedButNotAdded)
+{
+ SyncMapOne s;
+ ASSERT_FALSE(s.RemoveIfPresent(3));
+}
+
« src/plugin/Instances.h ('K') | « src/plugin/PluginWbPassThrough.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld