[PATCH] D41065: [Testing/Support] Make the HasValue matcher composable

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 11 04:43:02 PST 2017


labath created this revision.

This makes it possible to run an arbitrary matcher on the value
contained within the Expected<T> object.

To do this, I've needed to fully spell out the matcher, instead of using
the shorthand MATCHER_P macro.

The slight gotcha here is that standard template deduction will fail if
one tries to match HasValue(47) against an Expected<int &> -- the
workaround is to use HasValue(testing::Eq(47)).

The explanations produced by this matcher have changed a bit, since now
we delegate to the nested matcher to print the value. Since these don't
put quotes around the value, I've changed our PrintTo methods to match.


https://reviews.llvm.org/D41065

Files:
  include/llvm/Testing/Support/Error.h
  include/llvm/Testing/Support/SupportHelpers.h
  unittests/Support/ErrorTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41065.126341.patch
Type: text/x-patch
Size: 5095 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171211/1d23675d/attachment.bin>


More information about the llvm-commits mailing list