| 14 | |
| 15 | Y_UNIT_TEST_SUITE(TCacheTest) { |
| 16 | Y_UNIT_TEST(LRUListTest) { |
| 17 | typedef TLRUList<int, TString> TListType; |
| 18 | TListType list(2); |
| 19 | |
| 20 | TListType::TItem x1(1, "ttt"); |
| 21 | list.Insert(&x1); |
| 22 | UNIT_ASSERT_EQUAL(list.GetTotalSize(), 1); |
| 23 | UNIT_ASSERT_EQUAL(list.GetSize(), 1); |
| 24 | UNIT_ASSERT_EQUAL(list.GetOldest()->Key, 1); |
| 25 | |
| 26 | TListType::TItem x2(2, "yyy"); |
| 27 | list.Insert(&x2); |
| 28 | UNIT_ASSERT_EQUAL(list.GetTotalSize(), 2); |
| 29 | UNIT_ASSERT_EQUAL(list.GetSize(), 2); |
| 30 | UNIT_ASSERT_EQUAL(list.GetOldest()->Key, 1); |
| 31 | |
| 32 | list.Promote(list.GetOldest()); |
| 33 | UNIT_ASSERT_EQUAL(list.GetOldest()->Key, 2); |
| 34 | |
| 35 | TListType::TItem x3(3, "zzz"); |
| 36 | list.Insert(&x3); |
| 37 | UNIT_ASSERT_EQUAL(list.GetTotalSize(), 2); |
| 38 | UNIT_ASSERT_EQUAL(list.GetSize(), 2); |
| 39 | UNIT_ASSERT_EQUAL(list.GetOldest()->Key, 1); |
| 40 | } |
| 41 | |
| 42 | Y_UNIT_TEST(LRUListWeightedTest) { |
| 43 | typedef TLRUList<int, TString, size_t (*)(const TString&)> TListType; |
nothing calls this directly
no test coverage detected