OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2015 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 #include <gtest/gtest.h> |
| 18 #include "../../src/plugin/Instances.h" |
| 19 |
| 20 typedef SyncMap<int, int, 0> SyncMapOne; |
| 21 |
| 22 TEST(SyncMap, Instantiate) |
| 23 { |
| 24 SyncMapOne s; |
| 25 } |
| 26 |
| 27 TEST(SyncMap, OrdinaryAdded) |
| 28 { |
| 29 SyncMapOne s; |
| 30 ASSERT_TRUE(s.AddIfAbsent(1, 11)); |
| 31 ASSERT_TRUE(s.Locate(1) == 11); |
| 32 ASSERT_TRUE(s.RemoveAndCheck(1)); |
| 33 } |
| 34 |
| 35 TEST(SyncMap, OrdinaryNotAdded1) |
| 36 { |
| 37 SyncMapOne s; |
| 38 ASSERT_TRUE(s.Locate(1) == 0); |
| 39 } |
| 40 |
| 41 TEST(SyncMap, OrdinaryNotAdded2) |
| 42 { |
| 43 SyncMapOne s; |
| 44 ASSERT_TRUE(s.AddIfAbsent(1, 11)); |
| 45 ASSERT_TRUE(s.AddIfAbsent(2, 22)); |
| 46 ASSERT_TRUE(s.Locate(7) == 0); |
| 47 } |
| 48 |
| 49 TEST(SyncMap, WrongAddedTwice) |
| 50 { |
| 51 SyncMapOne s; |
| 52 ASSERT_TRUE(s.AddIfAbsent(3, 11)); |
| 53 ASSERT_FALSE(s.AddIfAbsent(3, 22)); |
| 54 } |
| 55 |
| 56 TEST(SyncMap, AcceptableAddedRemovedAddedAgain) |
| 57 { |
| 58 SyncMapOne s; |
| 59 ASSERT_TRUE(s.AddIfAbsent(1, 11)); |
| 60 ASSERT_TRUE(s.RemoveAndCheck(1)); |
| 61 ASSERT_TRUE(s.AddIfAbsent(1, 22)); |
| 62 } |
| 63 |
| 64 TEST(SyncMap, WrongRemovedButNotAdded) |
| 65 { |
| 66 SyncMapOne s; |
| 67 ASSERT_FALSE(s.RemoveAndCheck(3)); |
| 68 } |
| 69 |
OLD | NEW |