Skip to content

Commit

Permalink
fixed 'Uninteresting mock function call'
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Nov 2, 2016
1 parent f9de1ec commit 0addfaa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ TEST(WriterTest, Allocator) {
for (int i = 0; i < fmt::internal::INLINE_BUFFER_SIZE + 1; ++i)
w << '*';
EXPECT_CALL(alloc, deallocate(&mem[0], size));

EXPECT_CALL(alloc, allocate(size, 0)).WillOnce(testing::Return(&mem[0]));
EXPECT_CALL(alloc, deallocate(&mem[0], size));
}

TEST(WriterTest, Data) {
Expand Down
21 changes: 21 additions & 0 deletions test/util-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ void CheckForwarding(
ref.allocate(42);
EXPECT_CALL(alloc, deallocate(ptr, 42));
ref.deallocate(ptr, 42);

EXPECT_CALL(alloc, allocate(42, 0)).WillOnce(Return(ptr));
ref.allocate(42, 0);
EXPECT_CALL(alloc, deallocate(ptr, 42));
ref.deallocate(ptr, 42);
}

TEST(AllocatorTest, AllocatorRef) {
Expand Down Expand Up @@ -366,6 +371,22 @@ TEST(MemoryBufferTest, Allocator) {
}
}

TEST(MemoryBufferTest, Allocator2) {
typedef AllocatorRef< MockAllocator<char> > TestAllocator;
MemoryBuffer<char, 10, TestAllocator> buffer;
EXPECT_EQ(0, buffer.get_allocator().get());
StrictMock< MockAllocator<char> > alloc;
char mem;
{
MemoryBuffer<char, 10, TestAllocator> buffer2((TestAllocator(&alloc)));
EXPECT_EQ(&alloc, buffer2.get_allocator().get());
std::size_t size = 2 * fmt::internal::INLINE_BUFFER_SIZE;
EXPECT_CALL(alloc, allocate(size, 0)).WillOnce(Return(&mem));
buffer2.reserve(size);
EXPECT_CALL(alloc, deallocate(&mem, size));
}
}

TEST(MemoryBufferTest, ExceptionInDeallocate) {
typedef AllocatorRef< MockAllocator<char> > TestAllocator;
StrictMock< MockAllocator<char> > alloc;
Expand Down

0 comments on commit 0addfaa

Please sign in to comment.