本文整理汇总了C++中Arena::ReserveBytes方法的典型用法代码示例。如果您正苦于以下问题:C++ Arena::ReserveBytes方法的具体用法?C++ Arena::ReserveBytes怎么用?C++ Arena::ReserveBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arena
的用法示例。
在下文中一共展示了Arena::ReserveBytes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(ArenaTest, ReserveBytes) {
Arena arena;
char* ptr;
ptr = arena.ReserveBytes(kMinBlockSize / 2);
EXPECT_EQ(ptr, arena.remained_buffer());
EXPECT_EQ(kMinBlockSize, arena.remained_buffer_size());
EXPECT_EQ(kMinBlockSize, arena.total_reserved_bytes());
ptr = arena.ReserveBytes(kMinBlockSize + 1);
EXPECT_EQ(ptr, arena.remained_buffer());
EXPECT_EQ(2 * kMinBlockSize, arena.remained_buffer_size());
EXPECT_EQ(2 * kMinBlockSize, arena.total_reserved_bytes());
ptr = arena.ReserveBytes(kMaxBlockSize / 2);
EXPECT_EQ(ptr, arena.remained_buffer());
EXPECT_EQ(kMaxBlockSize / 2, arena.remained_buffer_size());
EXPECT_EQ(kMaxBlockSize / 2, arena.total_reserved_bytes());
ptr = arena.ReserveBytes(kMaxBlockSize - 1);
EXPECT_EQ(ptr, arena.remained_buffer());
EXPECT_EQ(kMaxBlockSize, arena.remained_buffer_size());
EXPECT_EQ(kMaxBlockSize, arena.total_reserved_bytes());
ptr = arena.ReserveBytes(kMaxBlockSize + 1);
EXPECT_EQ(ptr, arena.remained_buffer());
EXPECT_EQ(kMaxBlockSize + kMinBlockSize, arena.remained_buffer_size());
EXPECT_EQ(kMaxBlockSize + kMinBlockSize, arena.total_reserved_bytes());
}