[llvm] r326092 - [gtest] Add PrintTo overload for StringRef.
Ilya Biryukov via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 26 07:19:27 PST 2018
Author: ibiryukov
Date: Mon Feb 26 07:19:26 2018
New Revision: 326092
URL: http://llvm.org/viewvc/llvm-project?rev=326092&view=rev
Log:
[gtest] Add PrintTo overload for StringRef.
Summary:
It was printed using code for generic containers before, resulting in
unreadable output.
Reviewers: sammccall, labath
Reviewed By: sammccall, labath
Subscribers: labath, zturner, llvm-commits
Differential Revision: https://reviews.llvm.org/D43330
Modified:
llvm/trunk/utils/unittest/googletest/include/gtest/internal/custom/gtest-printers.h
Modified: llvm/trunk/utils/unittest/googletest/include/gtest/internal/custom/gtest-printers.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/unittest/googletest/include/gtest/internal/custom/gtest-printers.h?rev=326092&r1=326091&r2=326092&view=diff
==============================================================================
--- llvm/trunk/utils/unittest/googletest/include/gtest/internal/custom/gtest-printers.h (original)
+++ llvm/trunk/utils/unittest/googletest/include/gtest/internal/custom/gtest-printers.h Mon Feb 26 07:19:26 2018
@@ -39,4 +39,17 @@
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_os_ostream.h"
+#include <cassert>
+
+namespace llvm {
+// Without this overload StringRef will be printed as a generic container.
+inline void PrintTo(const llvm::StringRef &Val, std::ostream *S) {
+ assert(S);
+ llvm::raw_os_ostream OS(*S);
+ OS << Val;
+}
+} // namespace llvm
+
#endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_
More information about the llvm-commits
mailing list