MCPcopy Create free account
hub / github.com/facebook/CacheLib / TEST_F

Function TEST_F

cachelib/allocator/memory/tests/AllocationClassTest.cpp:47–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45namespace facebook::cachelib {
46
47TEST_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
64TEST_F(AllocationClassTest, AllocFree) {
65 // allocator with ~100 slabs.

Callers

nothing calls this directly

Calls 15

getAllocsPerSlabMethod · 0.80
getNumUsableSlabsMethod · 0.80
makeNewSlabMethod · 0.80
addSlabMethod · 0.80
isMemoryInSlabMethod · 0.80
isFullMethod · 0.80
eraseMethod · 0.80
getClassIdMethod · 0.80
isReleasedMethod · 0.80
totalSlabsMethod · 0.80
getSlabMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected