| 22 | namespace { |
| 23 | |
| 24 | TEST(SimpleMemoryArenaTest, BasicArenaOperations) { |
| 25 | TfLiteContext context; |
| 26 | SimpleMemoryArena arena(64); |
| 27 | ArenaAlloc allocs[6]; |
| 28 | |
| 29 | arena.Allocate(&context, 32, 2047, &allocs[0]); |
| 30 | arena.Allocate(&context, 32, 2047, &allocs[1]); |
| 31 | arena.Allocate(&context, 32, 2047, &allocs[2]); |
| 32 | arena.Deallocate(&context, allocs[0]); |
| 33 | arena.Allocate(&context, 32, 1023, &allocs[3]); |
| 34 | arena.Allocate(&context, 32, 2047, &allocs[4]); |
| 35 | arena.Deallocate(&context, allocs[1]); |
| 36 | arena.Allocate(&context, 32, 1023, &allocs[5]); |
| 37 | |
| 38 | EXPECT_EQ(allocs[0].offset, 0); |
| 39 | EXPECT_EQ(allocs[1].offset, 2048); |
| 40 | EXPECT_EQ(allocs[2].offset, 4096); |
| 41 | EXPECT_EQ(allocs[3].offset, 0); |
| 42 | EXPECT_EQ(allocs[4].offset, 6144); |
| 43 | EXPECT_EQ(allocs[5].offset, 1024); |
| 44 | } |
| 45 | |
| 46 | TEST(SimpleMemoryArenaTest, BasicZeroAlloc) { |
| 47 | TfLiteContext context; |
nothing calls this directly
no test coverage detected