Googletest export
googletest: Add printer for {std,absl}::nullopt.
PiperOrigin-RevId: 399928554
			
			
This commit is contained in:
		@@ -742,6 +742,14 @@ class UniversalPrinter<Optional<T>> {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <>
 | 
				
			||||||
 | 
					class UniversalPrinter<decltype(Nullopt())> {
 | 
				
			||||||
 | 
					 public:
 | 
				
			||||||
 | 
					  static void Print(decltype(Nullopt()), ::std::ostream* os) {
 | 
				
			||||||
 | 
					    *os << "(nullopt)";
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif  // GTEST_INTERNAL_HAS_OPTIONAL
 | 
					#endif  // GTEST_INTERNAL_HAS_OPTIONAL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if GTEST_INTERNAL_HAS_VARIANT
 | 
					#if GTEST_INTERNAL_HAS_VARIANT
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2325,6 +2325,7 @@ namespace testing {
 | 
				
			|||||||
namespace internal {
 | 
					namespace internal {
 | 
				
			||||||
template <typename T>
 | 
					template <typename T>
 | 
				
			||||||
using Optional = ::absl::optional<T>;
 | 
					using Optional = ::absl::optional<T>;
 | 
				
			||||||
 | 
					inline ::absl::nullopt_t Nullopt() { return ::absl::nullopt; }
 | 
				
			||||||
}  // namespace internal
 | 
					}  // namespace internal
 | 
				
			||||||
}  // namespace testing
 | 
					}  // namespace testing
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
@@ -2338,6 +2339,7 @@ namespace testing {
 | 
				
			|||||||
namespace internal {
 | 
					namespace internal {
 | 
				
			||||||
template <typename T>
 | 
					template <typename T>
 | 
				
			||||||
using Optional = ::std::optional<T>;
 | 
					using Optional = ::std::optional<T>;
 | 
				
			||||||
 | 
					inline ::std::nullopt_t Nullopt() { return ::std::nullopt; }
 | 
				
			||||||
}  // namespace internal
 | 
					}  // namespace internal
 | 
				
			||||||
}  // namespace testing
 | 
					}  // namespace testing
 | 
				
			||||||
// The case where absl is configured NOT to alias std::optional is not
 | 
					// The case where absl is configured NOT to alias std::optional is not
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1873,6 +1873,7 @@ TEST_F(PrintAnyTest, NonEmpty) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#if GTEST_INTERNAL_HAS_OPTIONAL
 | 
					#if GTEST_INTERNAL_HAS_OPTIONAL
 | 
				
			||||||
TEST(PrintOptionalTest, Basic) {
 | 
					TEST(PrintOptionalTest, Basic) {
 | 
				
			||||||
 | 
					  EXPECT_EQ("(nullopt)", PrintToString(internal::Nullopt()));
 | 
				
			||||||
  internal::Optional<int> value;
 | 
					  internal::Optional<int> value;
 | 
				
			||||||
  EXPECT_EQ("(nullopt)", PrintToString(value));
 | 
					  EXPECT_EQ("(nullopt)", PrintToString(value));
 | 
				
			||||||
  value = {7};
 | 
					  value = {7};
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user