This tests a very simple case: insert entries, then flush the cache and verify entries are evicted in the appropriate order.
| 96 | // This tests a very simple case: insert entries, then flush the cache and verify |
| 97 | // entries are evicted in the appropriate order. |
| 98 | TEST_F(LIRSCacheTest, BasicEvictionOrdering) { |
| 99 | FillCache(); |
| 100 | FlushCache(); |
| 101 | |
| 102 | // There were 5 unprotected elements (95-99). They should be the first to be evicted. |
| 103 | for (int i = 0; i < 5; ++i) { |
| 104 | ASSERT_EQ(evicted_keys_[i], 95+i); |
| 105 | ASSERT_EQ(evicted_values_[i], 95+i); |
| 106 | } |
| 107 | // There were 95 protected elements (0-94). They should be evicted in order. |
| 108 | for (int i = 5; i < 100; ++i) { |
| 109 | ASSERT_EQ(evicted_keys_[i], i-5); |
| 110 | ASSERT_EQ(evicted_values_[i], i-5); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | // Lookup operations can be tagged as NO_UPDATE, in which case, nothing should change |
| 115 | // priority. Verify that adding NO_UPDATE Lookups to the basic case does not change |