diff options
Diffstat (limited to 'tdutils/test/WaitFreeHashSet.cpp')
| -rw-r--r-- | tdutils/test/WaitFreeHashSet.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tdutils/test/WaitFreeHashSet.cpp b/tdutils/test/WaitFreeHashSet.cpp index d14d4c49f..4c6c03698 100644 --- a/tdutils/test/WaitFreeHashSet.cpp +++ b/tdutils/test/WaitFreeHashSet.cpp @@ -71,3 +71,22 @@ TEST(WaitFreeHashSet, stress_test) { } } } + +TEST(WaitFreeHashSet, remove_if) { + td::WaitFreeHashSet<td::uint64> set; + bool is_removed; + for (td::uint64 i = 0; i < 10000; i++) { + set.insert(2 * i + 1); + set.insert(2 * i + 2); + is_removed = set.remove_if([i](const auto &num) { return num <= i; }); + CHECK(!is_removed); + CHECK(set.calc_size() == i + 2); + is_removed = set.remove_if([i](const auto &num) { return num <= i + 1; }); + CHECK(is_removed); + CHECK(set.calc_size() == i + 1); + } + is_removed = set.remove_if([](const auto &num) { return num <= 19999; }); + CHECK(set.calc_size() == 1); + is_removed = set.remove_if([](const auto &num) { return num <= 20000; }); + CHECK(set.calc_size() == 0); +} |
