[PATCH] D43091: [gtest] Support raw_ostream printing functions more comprehensively.

Sam McCall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 8 14:43:47 PST 2018


sammccall created this revision.
sammccall added reviewers: ilya-biryukov, chandlerc.
Herald added a subscriber: llvm-commits.

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".


Repository:
  rL LLVM

https://reviews.llvm.org/D43091

Files:
  utils/unittest/googletest/include/gtest/gtest-message.h
  utils/unittest/googletest/include/gtest/gtest-printers.h
  utils/unittest/googletest/include/gtest/internal/custom/raw-ostream.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43091.133493.patch
Type: text/x-patch
Size: 6370 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180208/d3996328/attachment.bin>


More information about the llvm-commits mailing list