| 54 | ShardingPolicy::SingleShard))); |
| 55 | |
| 56 | TEST_P(CacheInvalidationTest, InvalidateAllEntries) { |
| 57 | constexpr const int kEntriesNum = 1024; |
| 58 | // This scenarios assumes no evictions are done at the cache capacity. |
| 59 | ASSERT_LE(kEntriesNum, cache_size()); |
| 60 | |
| 61 | // Running invalidation on empty cache should yield no invalidated entries. |
| 62 | ASSERT_EQ(0, cache_->Invalidate({})); |
| 63 | for (auto i = 0; i < kEntriesNum; ++i) { |
| 64 | Insert(i, i); |
| 65 | } |
| 66 | // Remove a few entries from the cache (sparse pattern of keys). |
| 67 | constexpr const int kSparseKeys[] = {1, 100, 101, 500, 501, 512, 999, 1001}; |
| 68 | for (const auto key : kSparseKeys) { |
| 69 | Erase(key); |
| 70 | } |
| 71 | ASSERT_EQ(ARRAYSIZE(kSparseKeys), evicted_keys_.size()); |
| 72 | |
| 73 | // All inserted entries, except for the removed one, should be invalidated. |
| 74 | ASSERT_EQ(kEntriesNum - ARRAYSIZE(kSparseKeys), cache_->Invalidate({})); |
| 75 | // In the end, no entries should be left in the cache. |
| 76 | ASSERT_EQ(kEntriesNum, evicted_keys_.size()); |
| 77 | } |
| 78 | |
| 79 | TEST_P(CacheInvalidationTest, InvalidateNoEntries) { |
| 80 | constexpr const int kEntriesNum = 10; |
nothing calls this directly
no test coverage detected