mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-24 12:14:26 +00:00
Improve allocator test
This commit is contained in:
parent
13bbb0db7a
commit
49222dc0c7
@ -468,14 +468,16 @@ TEST(WriterTest, MoveAssignment) {
|
|||||||
#endif // FMT_USE_RVALUE_REFERENCES
|
#endif // FMT_USE_RVALUE_REFERENCES
|
||||||
|
|
||||||
TEST(WriterTest, Allocator) {
|
TEST(WriterTest, Allocator) {
|
||||||
typedef AllocatorRef< MockAllocator<char> > TestAllocator;
|
typedef testing::StrictMock< MockAllocator<char> > MockAllocator;
|
||||||
MockAllocator<char> alloc;
|
typedef AllocatorRef<MockAllocator> TestAllocator;
|
||||||
|
MockAllocator alloc;
|
||||||
BasicWriter<char, TestAllocator> w((TestAllocator(&alloc)));
|
BasicWriter<char, TestAllocator> w((TestAllocator(&alloc)));
|
||||||
std::size_t size = 1.5 * fmt::internal::INLINE_BUFFER_SIZE;
|
std::size_t size = 1.5 * fmt::internal::INLINE_BUFFER_SIZE;
|
||||||
std::vector<char> mem(size);
|
std::vector<char> mem(size);
|
||||||
EXPECT_CALL(alloc, allocate(size)).WillOnce(Return(&mem[0]));
|
EXPECT_CALL(alloc, allocate(size)).WillOnce(Return(&mem[0]));
|
||||||
for (int i = 0; i < fmt::internal::INLINE_BUFFER_SIZE + 1; ++i)
|
for (int i = 0; i < fmt::internal::INLINE_BUFFER_SIZE + 1; ++i)
|
||||||
w << '*';
|
w << '*';
|
||||||
|
EXPECT_CALL(alloc, deallocate(&mem[0], size));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(WriterTest, Data) {
|
TEST(WriterTest, Data) {
|
||||||
|
Loading…
Reference in New Issue
Block a user