This is an archive of the discontinued LLVM Phabricator instance.

[Testing/Support] Make the HasValue matcher composable
ClosedPublic

Authored by labath on Dec 11 2017, 4:43 AM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

labath created this revision.Dec 11 2017, 4:43 AM
zturner accepted this revision.Dec 12 2017, 12:30 PM

Very nice, thanks!

This revision is now accepted and ready to land.Dec 12 2017, 12:30 PM
This revision was automatically updated to reflect the committed changes.