Skip to content

Commit

Permalink
Update tests to use recommended MOCK_METHOD (#3395)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhwang committed Apr 20, 2023
1 parent 18e7a25 commit e7d6eb6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions test/core-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ TEST(buffer_test, indestructible) {
}

template <typename T> struct mock_buffer final : buffer<T> {
MOCK_METHOD1(do_grow, size_t(size_t capacity));
MOCK_METHOD(size_t, do_grow, (size_t));

void grow(size_t capacity) override {
this->set(this->data(), do_grow(capacity));
Expand Down Expand Up @@ -327,8 +327,8 @@ template <typename T> struct mock_visitor {
ON_CALL(*this, visit(_)).WillByDefault(Return(test_result()));
}

MOCK_METHOD1_T(visit, test_result(T value));
MOCK_METHOD0_T(unexpected, void());
MOCK_METHOD(test_result, visit, (T));
MOCK_METHOD(void, unexpected, ());

auto operator()(T value) -> test_result { return visit(value); }

Expand Down
4 changes: 2 additions & 2 deletions test/mock-allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ template <typename T> class mock_allocator {
mock_allocator() {}
mock_allocator(const mock_allocator&) {}
using value_type = T;
MOCK_METHOD1_T(allocate, T*(size_t n));
MOCK_METHOD2_T(deallocate, void(T* p, size_t n));
MOCK_METHOD(T*, allocate, (size_t));
MOCK_METHOD(void, deallocate, (T*, size_t));
};

template <typename Allocator> class allocator_ref {
Expand Down
2 changes: 1 addition & 1 deletion test/ostream-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ TEST(ostream_test, write_to_ostream_max_size) {
} buffer(max_size);

struct mock_streambuf : std::streambuf {
MOCK_METHOD2(xsputn, std::streamsize(const void* s, std::streamsize n));
MOCK_METHOD(std::streamsize, xsputn, (const void*, std::streamsize));
auto xsputn(const char* s, std::streamsize n) -> std::streamsize override {
const void* v = s;
return xsputn(v, n);
Expand Down

0 comments on commit e7d6eb6

Please sign in to comment.