Googletest export
Add printer for std::type_info. PiperOrigin-RevId: 408375407
This commit is contained in:
		@@ -591,6 +591,12 @@ inline void PrintTo(internal::StringView sp, ::std::ostream* os) {
 | 
			
		||||
 | 
			
		||||
inline void PrintTo(std::nullptr_t, ::std::ostream* os) { *os << "(nullptr)"; }
 | 
			
		||||
 | 
			
		||||
#if GTEST_HAS_RTTI
 | 
			
		||||
inline void PrintTo(const std::type_info& info, std::ostream* os) {
 | 
			
		||||
  *os << internal::GetTypeName(info);
 | 
			
		||||
}
 | 
			
		||||
#endif  // GTEST_HAS_RTTI
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
void PrintTo(std::reference_wrapper<T> ref, ::std::ostream* os) {
 | 
			
		||||
  UniversalPrinter<T&>::Print(ref.get(), os);
 | 
			
		||||
 
 | 
			
		||||
@@ -473,6 +473,16 @@ TEST(PrintBuiltInTypeTest, FloatingPoints) {
 | 
			
		||||
  EXPECT_EQ("-2.5", Print(-2.5));  // double
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if GTEST_HAS_RTTI
 | 
			
		||||
TEST(PrintBuiltInTypeTest, TypeInfo) {
 | 
			
		||||
  struct MyStruct {};
 | 
			
		||||
  auto res = Print(typeid(MyStruct{}));
 | 
			
		||||
  // We can't guarantee that we can demangle the name, but either name should
 | 
			
		||||
  // contain the substring "MyStruct".
 | 
			
		||||
  EXPECT_NE(res.find("MyStruct"), res.npos) << res;
 | 
			
		||||
}
 | 
			
		||||
#endif  // GTEST_HAS_RTTI
 | 
			
		||||
 | 
			
		||||
// Since ::std::stringstream::operator<<(const void *) formats the pointer
 | 
			
		||||
// output differently with different compilers, we have to create the expected
 | 
			
		||||
// output first and use it as our expectation.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user