Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need helpers for printing matcher descriptions #127

Open
GoogleCodeExporter opened this issue Apr 2, 2015 · 0 comments
Open

need helpers for printing matcher descriptions #127

GoogleCodeExporter opened this issue Apr 2, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

When using MATCHER_P*() to define custom matchers, often we have parameters 
that themselves are matchers, e.g.

  MATCHER_P(HasAddress, matcher, ...) { ... }

Here the description of the HasProperty(matcher) matcher depends on the 
description of the matcher.  We should provide a function template:

  template <typename Arg, class MatcherType>
  string DescribeMatcher(const MatcherType& m, bool negation);

such that the user can write:

  MATCHER_P(HasAddress, matcher,
            "has an address that " +
            DescribeMatcher<remove_reference<arg_type>::type *>(matcher, negation)) { ... }

where arg_type is the type of the value being matched, as inferred by the 
compiler.

For example, HasAddress(IsNotNull()) will have a description:

 has an address that is not NULL

Original issue reported on code.google.com by w...@google.com on 28 Sep 2010 at 5:24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant