This is an archive of the discontinued LLVM Phabricator instance.

[gmock] (WIP) Teach gmock ElementsAre and BeginEndDistanceIs matchers to handle generic ranges by using std::begin and std::end rather than requiring things to look exactly like an STL container.
ClosedPublic

Authored by chandlerc on Jan 4 2017, 5:12 AM.

Details

Summary

Much of the credit for this goes to Dave Blaikie who helped me figure
out the right incantations.

This will probably be re-designed when I send this to the maintainers of
gmock, so I've instead structured it to change is little as possible
while it is a local patch. That makes it somewhat ugly, but I think a focused
change is better for getting this to work for LLVM today and letting the
upstream maintainers figure out the correct long-term pattern.

Note that I'm not looking to submit this, mostly to show all the patches
necessary in some examples of what using GoogleMock might look like in LLVM. So
just sending this out so folks can patch it in and play with it. There will be
an llvm-dev thread to discuss the larger issue of using gmock, and this will
only be seriously proposed for submission if the community decides to do that.

Depends on D28156.

Diff Detail

Repository
rL LLVM

Event Timeline

chandlerc updated this revision to Diff 83035.Jan 4 2017, 5:12 AM
chandlerc retitled this revision from to [gmock] (WIP) Teach gmock ElementsAre and BeginEndDistanceIs matchers to handle generic ranges by using std::begin and std::end rather than requiring things to look exactly like an STL container..
chandlerc updated this object.
chandlerc added a subscriber: llvm-commits.
chandlerc updated this revision to Diff 83517.Jan 6 2017, 11:09 PM

This is also now ready for review. Rebased and updated description.

chandlerc updated this revision to Diff 83664.Jan 9 2017, 12:11 PM

Rebase and ping.

dblaikie accepted this revision.Jan 9 2017, 12:42 PM
dblaikie edited edge metadata.
dblaikie added inline comments.
utils/unittest/googlemock/include/gmock/gmock-matchers.h
2465–2472 ↗(On Diff #83664)

This one you use iterator_traits for - the others you use declval/decltype. What's the reason there?

(I guess it's closer to the original code?)

This revision is now accepted and ready to land.Jan 9 2017, 12:42 PM
chandlerc added inline comments.Jan 10 2017, 4:20 PM
utils/unittest/googlemock/include/gmock/gmock-matchers.h
2465–2472 ↗(On Diff #83664)

Well, this is the only place where we're computing difference_type, so I'll leave it as a trait for now.

If you'd like to change though, happy to do that in a follow-up.

This revision was automatically updated to reflect the committed changes.