| 45 | namespace facebook::cachelib { |
| 46 | |
| 47 | TEST_F(AllocationClassTest, Basic) { |
| 48 | // create a dummy allocator to instantiate the AllocationClass. |
| 49 | const auto slabAlloc = createSlabAllocator(2); |
| 50 | const ClassId cid = 5; |
| 51 | // test with a size not more than the slab size. |
| 52 | const size_t allocSize = getRandomAllocSize(); |
| 53 | AllocationClass ac(cid, 0, allocSize, *slabAlloc); |
| 54 | ASSERT_EQ(ac.getId(), cid); |
| 55 | ASSERT_EQ(ac.getAllocSize(), allocSize); |
| 56 | |
| 57 | // trying to allocate without adding any slabs should fail. |
| 58 | ASSERT_EQ(ac.allocate(), nullptr); |
| 59 | ASSERT_GT(ac.getAllocsPerSlab(), 0); |
| 60 | |
| 61 | ASSERT_LE(ac.getAllocsPerSlab(), Slab::kSize); |
| 62 | } |
| 63 | |
| 64 | TEST_F(AllocationClassTest, AllocFree) { |
| 65 | // allocator with ~100 slabs. |
nothing calls this directly
no test coverage detected