| 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)); |
| +} |