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

Unified 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.
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
« no previous file with comments | « src/plugin/PluginClass.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
===================================================================
--- a/test/plugin/InstancesTest.cpp
+++ b/test/plugin/InstancesTest.cpp
@@ -14,6 +14,7 @@
* 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"
@@ -67,3 +68,57 @@
ASSERT_FALSE(s.RemoveIfPresent(3));
}
+typedef SyncSet<int, 0> SyncSetOne;
+bool IsFive(int x)
+{
+ return x == 5;
+}
+
+TEST(SyncSet, Instantiate)
+{
+ SyncSetOne s;
+}
+
+TEST(SyncSet, OrdinaryInserted)
+{
+ SyncSetOne s;
+ ASSERT_TRUE(s.InsertIfAbsent(5));
+ EXPECT_EQ(5, s.LinearSearch(IsFive));
+ ASSERT_TRUE(s.EraseWithCheck(5));
+ EXPECT_EQ(0, s.LinearSearch(IsFive));
+}
+
+TEST(SyncSet, OrdinaryNotInserted1)
+{
+ SyncSetOne s;
+ ASSERT_EQ(0, s.LinearSearch(IsFive));
+}
+
+TEST(SyncSet, OrdinaryNotInserted2)
+{
+ SyncSetOne s;
+ ASSERT_TRUE(s.InsertIfAbsent(1));
+ ASSERT_TRUE(s.InsertIfAbsent(2));
+ ASSERT_EQ(0, s.LinearSearch(IsFive));
+}
+
+TEST(SyncSet, WrongAddedTwice)
+{
+ SyncSetOne s;
+ ASSERT_TRUE(s.InsertIfAbsent(3));
+ ASSERT_FALSE(s.InsertIfAbsent(3));
+}
+
+TEST(SyncSet, AcceptableAddRemoveAddAgain)
+{
+ SyncSetOne s;
+ ASSERT_TRUE(s.InsertIfAbsent(5));
+ ASSERT_TRUE(s.EraseWithCheck(5));
+ ASSERT_TRUE(s.InsertIfAbsent(5));
+}
+
+TEST(SyncSet, WrongEraseWithoutInsert)
+{
+ SyncSetOne s;
+ ASSERT_FALSE(s.EraseWithCheck(3));
+}
« 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