google / google/googletest

Example for "Defining a Custom Matcher Class" does not compile

Open
#3,936 2 comments 0 reactions 1 assignee Claimed by @derekmauro View on GitHub
bug
Dominant language
C++
Stars
39.5k
Forks
10.9k
Avg merge
6d 13h
Merged PRs (30d)
1

Description

**Describe the bug**

Trying out the example from https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#defining-a-custom-matcher-class-custommatcherclass results in `error: could not convert ‘BarPlusBazEqMatcher(expected_sum)’ from ‘BarPlusBazEqMatcher’ to ‘testing::Matcher’`

**Steps to reproduce the bug**

Copy the example (`BarPlusBazEqMatcher`), add `struct Foo { int bar() const; int baz() const; };` to the top of the file), try to compile it.

**Does the bug persist in the most recent commit?**

Yes

**What operating system and version are you using?**

Ubuntu 20.04

**What compiler and version are you using?**

gcc 9.4.0

**What build system are you using?**

Plain command line

**Additional context**

I took a look at the source and found that the solution seems to be to inherit from `testing::MatcherInterface` instead?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.