diff options
| author | levlam <levlam@telegram.org> | 2025-06-23 01:54:42 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2025-06-23 01:54:42 +0300 |
| commit | 6614c148781db9cdc492c7c428ce685fa3f49abe (patch) | |
| tree | d2ffa658d7ff3751707ea39c53bc367dc057eefe /tdutils/test | |
| parent | 3c8bbc53c34bd0ef8ffdc406c9c8d8b71db73465 (diff) | |
Add WaitFreeHashSet::remove_if.
Diffstat (limited to 'tdutils/test')
| -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); +} |
