This is an archive of the discontinued LLVM Phabricator instance.

[gtest] Support raw_ostream printing functions more comprehensively.
ClosedPublic

Authored by sammccall on Feb 8 2018, 2:41 PM.

Details

Summary

These are functions like operator<<(raw_ostream&, Foo).

Previously these were only supported for messages. In the assertion

EXPECT_EQ(A, B) << C;

the local modifications would explicitly try to use raw_ostream printing for C.
However A and B would look for a std::ostream printing function, and often fall
back to gtest's default "168 byte object <00 01 FE 42 ...>".

This patch pulls out the raw_ostream support into a new header under custom/.

I changed the mechanism: instead of a convertible stream, we wrap the printed
value in a proxy object to allow it to be sent to a std::ostream.
I think the new way is clearer.

I also changed the policy: we prefer raw_ostream printers over std::ostream
ones. This is because the fallback printers are defined using std::ostream,
while all the raw_ostream printers should be "good".

Diff Detail

Repository
rL LLVM

Event Timeline

sammccall created this revision.Feb 8 2018, 2:41 PM
labath added a subscriber: labath.Feb 9 2018, 1:59 AM
ilya-biryukov accepted this revision.Feb 12 2018, 1:49 AM
This revision is now accepted and ready to land.Feb 12 2018, 1:49 AM
This revision was automatically updated to reflect the committed changes.