Improve allocator test

This commit is contained in:
Victor Zverovich 2014-09-23 07:58:23 -07:00
parent 13bbb0db7a
commit 49222dc0c7

View File

@ -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) {