diff options
author | Sam McCall <sam.mccall@gmail.com> | 2018-02-12 10:20:09 +0000 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2018-02-12 10:20:09 +0000 |
commit | 2d8242d60db71f1687beaacfcc252656528ab331 (patch) | |
tree | c3ae6a2363fc5f01487fc0bc648efa0e8e8f08c8 /llvm/utils/unittest/googletest/include/gtest/gtest-printers.h | |
parent | ca4eddee0d8e04fd069232efdf8746fdf6e42b39 (diff) | |
download | bcm5719-llvm-2d8242d60db71f1687beaacfcc252656528ab331.tar.gz bcm5719-llvm-2d8242d60db71f1687beaacfcc252656528ab331.zip |
[gtest] Support raw_ostream printing functions more comprehensively.
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".
Reviewers: ilya-biryukov, chandlerc
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D43091
llvm-svn: 324876
Diffstat (limited to 'llvm/utils/unittest/googletest/include/gtest/gtest-printers.h')
-rw-r--r-- | llvm/utils/unittest/googletest/include/gtest/gtest-printers.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/utils/unittest/googletest/include/gtest/gtest-printers.h b/llvm/utils/unittest/googletest/include/gtest/gtest-printers.h index 8a33164cb38..be793bbb151 100644 --- a/llvm/utils/unittest/googletest/include/gtest/gtest-printers.h +++ b/llvm/utils/unittest/googletest/include/gtest/gtest-printers.h @@ -102,6 +102,7 @@ #include <vector> #include "gtest/internal/gtest-port.h" #include "gtest/internal/gtest-internal.h" +#include "gtest/internal/custom/raw-ostream.h" #if GTEST_HAS_STD_TUPLE_ # include <tuple> @@ -246,7 +247,7 @@ void DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) { // impossible to define #1 (e.g. when foo is ::std, defining // anything in it is undefined behavior unless you are a compiler // vendor.). - *os << value; + *os << ::llvm_gtest::printable(value); } } // namespace testing_internal |