mirror of
https://github.com/google/googletest.git
synced 2025-12-04 14:57:29 +08:00
Ability to optionally depend on Abseil plus upstream of 183716547
This commit is contained in:
@@ -46,6 +46,10 @@
|
||||
// 2. operator<<(ostream&, const T&) defined in either foo or the
|
||||
// global namespace.
|
||||
//
|
||||
// However if T is an STL-style container then it is printed element-wise
|
||||
// unless foo::PrintTo(const T&, ostream*) is defined. Note that
|
||||
// operator<<() is ignored for container types.
|
||||
//
|
||||
// If none of the above is defined, it will print the debug string of
|
||||
// the value if it is a protocol buffer, or print the raw bytes in the
|
||||
// value otherwise.
|
||||
@@ -107,6 +111,10 @@
|
||||
# include <tuple>
|
||||
#endif
|
||||
|
||||
#if GTEST_HAS_ABSL
|
||||
#include "absl/types/optional.h"
|
||||
#endif // GTEST_HAS_ABSL
|
||||
|
||||
namespace testing {
|
||||
|
||||
// Definitions in the 'internal' and 'internal2' name spaces are
|
||||
@@ -722,6 +730,26 @@ class UniversalPrinter {
|
||||
GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||
};
|
||||
|
||||
#if GTEST_HAS_ABSL
|
||||
|
||||
// Printer for absl::optional
|
||||
|
||||
template <typename T>
|
||||
class UniversalPrinter<::absl::optional<T>> {
|
||||
public:
|
||||
static void Print(const ::absl::optional<T>& value, ::std::ostream* os) {
|
||||
*os << '(';
|
||||
if (!value) {
|
||||
*os << "nullopt";
|
||||
} else {
|
||||
UniversalPrint(*value, os);
|
||||
}
|
||||
*os << ')';
|
||||
}
|
||||
};
|
||||
|
||||
#endif // GTEST_HAS_ABSL
|
||||
|
||||
// UniversalPrintArray(begin, len, os) prints an array of 'len'
|
||||
// elements, starting at address 'begin'.
|
||||
template <typename T>
|
||||
|
||||
Reference in New Issue
Block a user