 Issue 29330403:
  Issue #1467, #3397 - Rewrite the map from threads to tabs  (Closed)
    
  
    Issue 29330403:
  Issue #1467, #3397 - Rewrite the map from threads to tabs  (Closed) 
  | 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-2015 Eyeo GmbH | 
| 
sergei
2016/02/08 13:35:37
2016
 
Eric
2016/02/08 18:45:31
Done.
 | 
| + * | 
| + * 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.RemoveAndCheck(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.RemoveAndCheck(1)); | 
| + ASSERT_TRUE(s.AddIfAbsent(1, 22)); | 
| +} | 
| + | 
| +TEST(SyncMap, WrongRemovedButNotAdded) | 
| +{ | 
| + SyncMapOne s; | 
| + ASSERT_FALSE(s.RemoveAndCheck(3)); | 
| +} | 
| + |