walterfan / googlemock

Automatically exported from code.google.com/p/googlemock
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

need helpers for printing matcher descriptions #127

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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