tesseract v5.3.3.20231005
testing::gtest_printers_test Namespace Reference

Classes

class  AllowsGenericStreaming
 
class  AllowsGenericStreamingAndImplicitConversionTemplate
 
class  AllowsGenericStreamingTemplate
 
struct  Big
 
struct  const_iterator
 
struct  Foo
 
struct  iterator
 

Functions

template<typename T >
std::string Print (const T &value)
 
template<typename T >
std::string PrintByRef (const T &value)
 
 TEST (PrintEnumTest, AnonymousEnum)
 
 TEST (PrintEnumTest, EnumWithoutPrinter)
 
 TEST (PrintEnumTest, EnumWithStreaming)
 
 TEST (PrintEnumTest, EnumWithPrintTo)
 
 TEST (PrintClassTest, BiggestIntConvertible)
 
 TEST (PrintCharTest, PlainChar)
 
 TEST (PrintCharTest, SignedChar)
 
 TEST (PrintCharTest, UnsignedChar)
 
 TEST (PrintCharTest, Char16)
 
 TEST (PrintCharTest, Char32)
 
 TEST (PrintBuiltInTypeTest, Bool)
 
 TEST (PrintBuiltInTypeTest, Wchar_t)
 
 TEST (PrintTypeSizeTest, Wchar_t)
 
 TEST (PrintBuiltInTypeTest, Integer)
 
 TEST (PrintBuiltInTypeTest, Size_t)
 
 TEST (PrintBuiltInTypeTest, FloatingPoints)
 
 TEST (PrintCStringTest, Const)
 
 TEST (PrintCStringTest, NonConst)
 
 TEST (PrintCStringTest, Null)
 
 TEST (PrintCStringTest, EscapesProperly)
 
 TEST (PrintU16StringTest, Const)
 
 TEST (PrintU16StringTest, NonConst)
 
 TEST (PrintU16StringTest, Null)
 
 TEST (PrintU16StringTest, EscapesProperly)
 
 TEST (PrintU32StringTest, Const)
 
 TEST (PrintU32StringTest, NonConst)
 
 TEST (PrintU32StringTest, Null)
 
 TEST (PrintU32StringTest, EscapesProperly)
 
 TEST (PrintWideCStringTest, Const)
 
 TEST (PrintWideCStringTest, NonConst)
 
 TEST (PrintWideCStringTest, Null)
 
 TEST (PrintWideCStringTest, EscapesProperly)
 
 TEST (PrintCharPointerTest, SignedChar)
 
 TEST (PrintCharPointerTest, ConstSignedChar)
 
 TEST (PrintCharPointerTest, UnsignedChar)
 
 TEST (PrintCharPointerTest, ConstUnsignedChar)
 
 TEST (PrintPointerToBuiltInTypeTest, Bool)
 
 TEST (PrintPointerToBuiltInTypeTest, Void)
 
 TEST (PrintPointerToBuiltInTypeTest, ConstVoid)
 
 TEST (PrintPointerToPointerTest, IntPointerPointer)
 
void MyFunction (int)
 
 TEST (PrintPointerTest, NonMemberFunctionPointer)
 
template<typename StringType >
AssertionResult HasPrefix (const StringType &str, const StringType &prefix)
 
 TEST (PrintPointerTest, MemberVariablePointer)
 
 TEST (PrintPointerTest, MemberFunctionPointer)
 
template<typename T , size_t N>
std::string PrintArrayHelper (T(&a)[N])
 
 TEST (PrintArrayTest, OneDimensionalArray)
 
 TEST (PrintArrayTest, TwoDimensionalArray)
 
 TEST (PrintArrayTest, ConstArray)
 
 TEST (PrintArrayTest, CharArrayWithNoTerminatingNul)
 
 TEST (PrintArrayTest, CharArrayWithTerminatingNul)
 
 TEST (PrintArrayTest, Char16ArrayWithNoTerminatingNul)
 
 TEST (PrintArrayTest, Char16ArrayWithTerminatingNul)
 
 TEST (PrintArrayTest, Char32ArrayWithNoTerminatingNul)
 
 TEST (PrintArrayTest, Char32ArrayWithTerminatingNul)
 
 TEST (PrintArrayTest, WCharArrayWithNoTerminatingNul)
 
 TEST (PrintArrayTest, WCharArrayWithTerminatingNul)
 
 TEST (PrintArrayTest, ObjectArray)
 
 TEST (PrintArrayTest, BigArray)
 
 TEST (PrintStringTest, StringInStdNamespace)
 
 TEST (PrintStringTest, StringAmbiguousHex)
 
 TEST (PrintStringTest, U16String)
 
 TEST (PrintStringTest, U32String)
 
template<typename Char , typename CharTraits >
std::basic_ostream< Char, CharTraits > & operator<< (std::basic_ostream< Char, CharTraits > &os, const AllowsGenericStreaming &)
 
 TEST (PrintTypeWithGenericStreamingTest, NonTemplateType)
 
template<typename Char , typename CharTraits , typename T >
std::basic_ostream< Char, CharTraits > & operator<< (std::basic_ostream< Char, CharTraits > &os, const AllowsGenericStreamingTemplate< T > &)
 
 TEST (PrintTypeWithGenericStreamingTest, TemplateType)
 
template<typename Char , typename CharTraits , typename T >
std::basic_ostream< Char, CharTraits > & operator<< (std::basic_ostream< Char, CharTraits > &os, const AllowsGenericStreamingAndImplicitConversionTemplate< T > &)
 
 TEST (PrintTypeWithGenericStreamingTest, TypeImplicitlyConvertible)
 
 TEST (PrintStlContainerTest, EmptyDeque)
 
 TEST (PrintStlContainerTest, NonEmptyDeque)
 
 TEST (PrintStlContainerTest, OneElementHashMap)
 
 TEST (PrintStlContainerTest, HashMultiMap)
 
 TEST (PrintStlContainerTest, HashSet)
 
 TEST (PrintStlContainerTest, HashMultiSet)
 
 TEST (PrintStlContainerTest, List)
 
 TEST (PrintStlContainerTest, Map)
 
 TEST (PrintStlContainerTest, MultiMap)
 
 TEST (PrintStlContainerTest, Set)
 
 TEST (PrintStlContainerTest, MultiSet)
 
 TEST (PrintStlContainerTest, SinglyLinkedList)
 
 TEST (PrintStlContainerTest, Pair)
 
 TEST (PrintStlContainerTest, Vector)
 
 TEST (PrintStlContainerTest, LongSequence)
 
 TEST (PrintStlContainerTest, NestedContainer)
 
 TEST (PrintStlContainerTest, OneDimensionalNativeArray)
 
 TEST (PrintStlContainerTest, TwoDimensionalNativeArray)
 
 TEST (PrintStlContainerTest, Iterator)
 
 TEST (PrintStlContainerTest, ConstIterator)
 
 TEST (PrintStdTupleTest, VariousSizes)
 
 TEST (PrintStdTupleTest, NestedTuple)
 
 TEST (PrintNullptrT, Basic)
 
 TEST (PrintReferenceWrapper, Printable)
 
 TEST (PrintReferenceWrapper, Unprintable)
 
 TEST (PrintUnprintableTypeTest, InGlobalNamespace)
 
 TEST (PrintUnprintableTypeTest, InUserNamespace)
 
 TEST (PrintUnpritableTypeTest, BigObject)
 
 TEST (PrintStreamableTypeTest, InGlobalNamespace)
 
 TEST (PrintStreamableTypeTest, TemplateTypeInUserNamespace)
 
 TEST (PrintStreamableTypeTest, TypeInUserNamespaceWithTemplatedStreamOperator)
 
 TEST (PrintStreamableTypeTest, SubclassUsesSuperclassStreamOperator)
 
 TEST (PrintStreamableTypeTest, PathLikeInUserNamespace)
 
 TEST (PrintPrintableTypeTest, InUserNamespace)
 
 TEST (PrintPrintableTypeTest, PointerInUserNamespace)
 
 TEST (PrintPrintableTypeTest, TemplateInUserNamespace)
 
 TEST (PrintReferenceTest, PrintsAddressAndValue)
 
 TEST (PrintReferenceTest, HandlesFunctionPointer)
 
 TEST (PrintReferenceTest, HandlesMemberFunctionPointer)
 
 TEST (PrintReferenceTest, HandlesMemberVariablePointer)
 
 TEST (FormatForComparisonFailureMessageTest, WorksForScalar)
 
 TEST (FormatForComparisonFailureMessageTest, WorksForNonCharPointer)
 
 TEST (FormatForComparisonFailureMessageTest, FormatsNonCharArrayAsPointer)
 
 TEST (FormatForComparisonFailureMessageTest, WorksForCharPointerVsPointer)
 
 TEST (FormatForComparisonFailureMessageTest, WorksForWCharPointerVsPointer)
 
 TEST (FormatForComparisonFailureMessageTest, WorksForCharPointerVsStdString)
 
 TEST (FormatForComparisonFailureMessageTest, WorksForCharArrayVsPointer)
 
 TEST (FormatForComparisonFailureMessageTest, WorksForCharArrayVsCharArray)
 
 TEST (FormatForComparisonFailureMessageTest, WorksForWCharArrayVsPointer)
 
 TEST (FormatForComparisonFailureMessageTest, WorksForWCharArrayVsWCharArray)
 
 TEST (FormatForComparisonFailureMessageTest, WorksForCharArrayVsStdString)
 
 TEST (PrintToStringTest, WorksForScalar)
 
 TEST (PrintToStringTest, WorksForPointerToConstChar)
 
 TEST (PrintToStringTest, WorksForPointerToNonConstChar)
 
 TEST (PrintToStringTest, EscapesForPointerToConstChar)
 
 TEST (PrintToStringTest, EscapesForPointerToNonConstChar)
 
 TEST (PrintToStringTest, WorksForArray)
 
 TEST (PrintToStringTest, WorksForCharArray)
 
 TEST (PrintToStringTest, WorksForCharArrayWithEmbeddedNul)
 
 TEST (PrintToStringTest, ContainsNonLatin)
 
 TEST (IsValidUTF8Test, IllFormedUTF8)
 
 TEST (UniversalTersePrintTest, WorksForNonReference)
 
 TEST (UniversalTersePrintTest, WorksForReference)
 
 TEST (UniversalTersePrintTest, WorksForCString)
 
 TEST (UniversalPrintTest, WorksForNonReference)
 
 TEST (UniversalPrintTest, WorksForReference)
 
 TEST (UniversalPrintTest, WorksForPairWithConst)
 
 TEST (UniversalPrintTest, WorksForCString)
 
 TEST (UniversalPrintTest, WorksForCharArray)
 
 TEST (UniversalPrintTest, IncompleteType)
 
 TEST (UniversalPrintTest, SmartPointers)
 
 TEST (UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsEmptyTuple)
 
 TEST (UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsOneTuple)
 
 TEST (UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsTwoTuple)
 
 TEST (UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsTersely)
 

Function Documentation

◆ HasPrefix()

template<typename StringType >
AssertionResult testing::gtest_printers_test::HasPrefix ( const StringType &  str,
const StringType &  prefix 
)

Definition at line 707 of file googletest-printers-test.cc.

707 {
708 if (str.find(prefix, 0) == 0)
709 return AssertionSuccess();
710
711 const bool is_wide_string = sizeof(prefix[0]) > 1;
712 const char* const begin_string_quote = is_wide_string ? "L\"" : "\"";
713 return AssertionFailure()
714 << begin_string_quote << prefix << "\" is not a prefix of "
715 << begin_string_quote << str << "\"\n";
716}
AssertionResult AssertionFailure()
Definition: gtest.cc:1214
AssertionResult AssertionSuccess()
Definition: gtest.cc:1209

◆ MyFunction()

void testing::gtest_printers_test::MyFunction ( int  )

Definition at line 689 of file googletest-printers-test.cc.

689{}

◆ operator<<() [1/3]

template<typename Char , typename CharTraits >
std::basic_ostream< Char, CharTraits > & testing::gtest_printers_test::operator<< ( std::basic_ostream< Char, CharTraits > &  os,
const AllowsGenericStreaming  
)

Definition at line 929 of file googletest-printers-test.cc.

946 {
947 return os << "AllowsGenericStreaming";
948}

◆ operator<<() [2/3]

template<typename Char , typename CharTraits , typename T >
std::basic_ostream< Char, CharTraits > & testing::gtest_printers_test::operator<< ( std::basic_ostream< Char, CharTraits > &  os,
const AllowsGenericStreamingAndImplicitConversionTemplate< T > &   
)

Definition at line 967 of file googletest-printers-test.cc.

984 {
985 return os << "AllowsGenericStreamingAndImplicitConversionTemplate";
986}

◆ operator<<() [3/3]

template<typename Char , typename CharTraits , typename T >
std::basic_ostream< Char, CharTraits > & testing::gtest_printers_test::operator<< ( std::basic_ostream< Char, CharTraits > &  os,
const AllowsGenericStreamingTemplate< T > &   
)

Definition at line 950 of file googletest-printers-test.cc.

963 {
964 return os << "AllowsGenericStreamingTemplate";
965}

◆ Print()

template<typename T >
std::string testing::gtest_printers_test::Print ( const T &  value)

Definition at line 284 of file googletest-printers-test.cc.

284 {
285 ::std::stringstream ss;
287 return ss.str();
288}
int value
std::string Print(const T &value)

◆ PrintArrayHelper()

template<typename T , size_t N>
std::string testing::gtest_printers_test::PrintArrayHelper ( T(&)  a[N])

Definition at line 760 of file googletest-printers-test.cc.

760 {
761 return Print(a);
762}

◆ PrintByRef()

template<typename T >
std::string testing::gtest_printers_test::PrintByRef ( const T &  value)

Definition at line 294 of file googletest-printers-test.cc.

294 {
295 ::std::stringstream ss;
297 return ss.str();
298}

◆ TEST() [1/138]

testing::gtest_printers_test::TEST ( FormatForComparisonFailureMessageTest  ,
FormatsNonCharArrayAsPointer   
)

Definition at line 1418 of file googletest-printers-test.cc.

1418 {
1419 // In expression 'array == x', 'array' is compared by pointer.
1420 // Therefore we want to print an array operand as a pointer.
1421 int n[] = { 1, 2, 3 };
1422 EXPECT_EQ(PrintPointer(n),
1423 FormatForComparisonFailureMessage(n, n).c_str());
1424}
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:2043
std::string FormatForComparisonFailureMessage(const T1 &value, const T2 &)

◆ TEST() [2/138]

testing::gtest_printers_test::TEST ( FormatForComparisonFailureMessageTest  ,
WorksForCharArrayVsCharArray   
)

Definition at line 1510 of file googletest-printers-test.cc.

1510 {
1511 const char str[] = "hi \"world\"";
1512 EXPECT_EQ(PrintPointer(str),
1513 FormatForComparisonFailureMessage(str, str).c_str());
1514}

◆ TEST() [3/138]

testing::gtest_printers_test::TEST ( FormatForComparisonFailureMessageTest  ,
WorksForCharArrayVsPointer   
)

Definition at line 1502 of file googletest-printers-test.cc.

1502 {
1503 char str[] = "hi \"world\"";
1504 char* p = nullptr;
1505 EXPECT_EQ(PrintPointer(str),
1506 FormatForComparisonFailureMessage(str, p).c_str());
1507}
const char * p

◆ TEST() [4/138]

testing::gtest_printers_test::TEST ( FormatForComparisonFailureMessageTest  ,
WorksForCharArrayVsStdString   
)

Definition at line 1535 of file googletest-printers-test.cc.

1535 {
1536 const char str[] = "hi \"world\"";
1537 EXPECT_STREQ("\"hi \\\"world\\\"\"", // The content should be escaped.
1538 FormatForComparisonFailureMessage(str, ::std::string()).c_str());
1539}
#define EXPECT_STREQ(s1, s2)
Definition: gtest.h:2112

◆ TEST() [5/138]

testing::gtest_printers_test::TEST ( FormatForComparisonFailureMessageTest  ,
WorksForCharPointerVsPointer   
)

Definition at line 1431 of file googletest-printers-test.cc.

1431 {
1432 // In expression 'p == x', where 'p' and 'x' are (const or not) char
1433 // pointers, the operands are compared by pointer. Therefore we
1434 // want to print 'p' as a pointer instead of a C string (we don't
1435 // even know if it's supposed to point to a valid C string).
1436
1437 // const char*
1438 const char* s = "hello";
1439 EXPECT_EQ(PrintPointer(s),
1440 FormatForComparisonFailureMessage(s, s).c_str());
1441
1442 // char*
1443 char ch = 'a';
1444 EXPECT_EQ(PrintPointer(&ch),
1446}

◆ TEST() [6/138]

testing::gtest_printers_test::TEST ( FormatForComparisonFailureMessageTest  ,
WorksForCharPointerVsStdString   
)

Definition at line 1470 of file googletest-printers-test.cc.

1470 {
1471 const char* s = "hello \"world";
1472 EXPECT_STREQ("\"hello \\\"world\"", // The string content should be escaped.
1473 FormatForComparisonFailureMessage(s, ::std::string()).c_str());
1474
1475 // char*
1476 char str[] = "hi\1";
1477 char* p = str;
1478 EXPECT_STREQ("\"hi\\x1\"", // The string content should be escaped.
1479 FormatForComparisonFailureMessage(p, ::std::string()).c_str());
1480}

◆ TEST() [7/138]

testing::gtest_printers_test::TEST ( FormatForComparisonFailureMessageTest  ,
WorksForNonCharPointer   
)

Definition at line 1411 of file googletest-printers-test.cc.

1411 {
1412 int n = 0;
1413 EXPECT_EQ(PrintPointer(&n),
1414 FormatForComparisonFailureMessage(&n, &n).c_str());
1415}

◆ TEST() [8/138]

testing::gtest_printers_test::TEST ( FormatForComparisonFailureMessageTest  ,
WorksForScalar   
)

Definition at line 1405 of file googletest-printers-test.cc.

1405 {
1406 EXPECT_STREQ("123",
1407 FormatForComparisonFailureMessage(123, 124).c_str());
1408}

◆ TEST() [9/138]

testing::gtest_printers_test::TEST ( FormatForComparisonFailureMessageTest  ,
WorksForWCharArrayVsPointer   
)

Definition at line 1517 of file googletest-printers-test.cc.

1517 {
1518 wchar_t str[] = L"hi \"world\"";
1519 wchar_t* p = nullptr;
1520 EXPECT_EQ(PrintPointer(str),
1521 FormatForComparisonFailureMessage(str, p).c_str());
1522}

◆ TEST() [10/138]

testing::gtest_printers_test::TEST ( FormatForComparisonFailureMessageTest  ,
WorksForWCharArrayVsWCharArray   
)

Definition at line 1525 of file googletest-printers-test.cc.

1525 {
1526 const wchar_t str[] = L"hi \"world\"";
1527 EXPECT_EQ(PrintPointer(str),
1528 FormatForComparisonFailureMessage(str, str).c_str());
1529}

◆ TEST() [11/138]

testing::gtest_printers_test::TEST ( FormatForComparisonFailureMessageTest  ,
WorksForWCharPointerVsPointer   
)

Definition at line 1449 of file googletest-printers-test.cc.

1449 {
1450 // In expression 'p == x', where 'p' and 'x' are (const or not) char
1451 // pointers, the operands are compared by pointer. Therefore we
1452 // want to print 'p' as a pointer instead of a wide C string (we don't
1453 // even know if it's supposed to point to a valid wide C string).
1454
1455 // const wchar_t*
1456 const wchar_t* s = L"hello";
1457 EXPECT_EQ(PrintPointer(s),
1458 FormatForComparisonFailureMessage(s, s).c_str());
1459
1460 // wchar_t*
1461 wchar_t ch = L'a';
1462 EXPECT_EQ(PrintPointer(&ch),
1464}

◆ TEST() [12/138]

testing::gtest_printers_test::TEST ( IsValidUTF8Test  ,
IllFormedUTF8   
)

Definition at line 1615 of file googletest-printers-test.cc.

1615 {
1616 // The following test strings are ill-formed UTF-8 and are printed
1617 // as hex only (or ASCII, in case of ASCII bytes) because IsValidUTF8() is
1618 // expected to fail, thus output does not contain "As Text:".
1619
1620 static const char *const kTestdata[][2] = {
1621 // 2-byte lead byte followed by a single-byte character.
1622 {"\xC3\x74", "\"\\xC3t\""},
1623 // Valid 2-byte character followed by an orphan trail byte.
1624 {"\xC3\x84\xA4", "\"\\xC3\\x84\\xA4\""},
1625 // Lead byte without trail byte.
1626 {"abc\xC3", "\"abc\\xC3\""},
1627 // 3-byte lead byte, single-byte character, orphan trail byte.
1628 {"x\xE2\x70\x94", "\"x\\xE2p\\x94\""},
1629 // Truncated 3-byte character.
1630 {"\xE2\x80", "\"\\xE2\\x80\""},
1631 // Truncated 3-byte character followed by valid 2-byte char.
1632 {"\xE2\x80\xC3\x84", "\"\\xE2\\x80\\xC3\\x84\""},
1633 // Truncated 3-byte character followed by a single-byte character.
1634 {"\xE2\x80\x7A", "\"\\xE2\\x80z\""},
1635 // 3-byte lead byte followed by valid 3-byte character.
1636 {"\xE2\xE2\x80\x94", "\"\\xE2\\xE2\\x80\\x94\""},
1637 // 4-byte lead byte followed by valid 3-byte character.
1638 {"\xF0\xE2\x80\x94", "\"\\xF0\\xE2\\x80\\x94\""},
1639 // Truncated 4-byte character.
1640 {"\xF0\xE2\x80", "\"\\xF0\\xE2\\x80\""},
1641 // Invalid UTF-8 byte sequences embedded in other chars.
1642 {"abc\xE2\x80\x94\xC3\x74xyc", "\"abc\\xE2\\x80\\x94\\xC3txyc\""},
1643 {"abc\xC3\x84\xE2\x80\xC3\x84xyz",
1644 "\"abc\\xC3\\x84\\xE2\\x80\\xC3\\x84xyz\""},
1645 // Non-shortest UTF-8 byte sequences are also ill-formed.
1646 // The classics: xC0, xC1 lead byte.
1647 {"\xC0\x80", "\"\\xC0\\x80\""},
1648 {"\xC1\x81", "\"\\xC1\\x81\""},
1649 // Non-shortest sequences.
1650 {"\xE0\x80\x80", "\"\\xE0\\x80\\x80\""},
1651 {"\xf0\x80\x80\x80", "\"\\xF0\\x80\\x80\\x80\""},
1652 // Last valid code point before surrogate range, should be printed as text,
1653 // too.
1654 {"\xED\x9F\xBF", "\"\\xED\\x9F\\xBF\"\n As Text: \"퟿\""},
1655 // Start of surrogate lead. Surrogates are not printed as text.
1656 {"\xED\xA0\x80", "\"\\xED\\xA0\\x80\""},
1657 // Last non-private surrogate lead.
1658 {"\xED\xAD\xBF", "\"\\xED\\xAD\\xBF\""},
1659 // First private-use surrogate lead.
1660 {"\xED\xAE\x80", "\"\\xED\\xAE\\x80\""},
1661 // Last private-use surrogate lead.
1662 {"\xED\xAF\xBF", "\"\\xED\\xAF\\xBF\""},
1663 // Mid-point of surrogate trail.
1664 {"\xED\xB3\xBF", "\"\\xED\\xB3\\xBF\""},
1665 // First valid code point after surrogate range, should be printed as text,
1666 // too.
1667 {"\xEE\x80\x80", "\"\\xEE\\x80\\x80\"\n As Text: \"\""}
1668 };
1669
1670 for (int i = 0; i < int(sizeof(kTestdata)/sizeof(kTestdata[0])); ++i) {
1671 EXPECT_PRINT_TO_STRING_(kTestdata[i][0], kTestdata[i][1]);
1672 }
1673}
#define EXPECT_PRINT_TO_STRING_(value, expected_string)

◆ TEST() [13/138]

testing::gtest_printers_test::TEST ( PrintArrayTest  ,
BigArray   
)

Definition at line 863 of file googletest-printers-test.cc.

863 {
864 int a[100] = { 1, 2, 3 };
865 EXPECT_EQ("{ 1, 2, 3, 0, 0, 0, 0, 0, ..., 0, 0, 0, 0, 0, 0, 0, 0 }",
867}

◆ TEST() [14/138]

testing::gtest_printers_test::TEST ( PrintArrayTest  ,
Char16ArrayWithNoTerminatingNul   
)

Definition at line 816 of file googletest-printers-test.cc.

816 {
817 // Array a contains '\0' in the middle and doesn't end with '\0'.
818 const char16_t a[] = {u'こ', u'\0', u'ん', u'に', u'ち', u'は'};
819 EXPECT_EQ("u\"\\x3053\\0\\x3093\\x306B\\x3061\\x306F\" (no terminating NUL)",
821}

◆ TEST() [15/138]

testing::gtest_printers_test::TEST ( PrintArrayTest  ,
Char16ArrayWithTerminatingNul   
)

Definition at line 824 of file googletest-printers-test.cc.

824 {
825 const char16_t a[] = u"\0こんにちは";
826 EXPECT_EQ("u\"\\0\\x3053\\x3093\\x306B\\x3061\\x306F\"", PrintArrayHelper(a));
827}

◆ TEST() [16/138]

testing::gtest_printers_test::TEST ( PrintArrayTest  ,
Char32ArrayWithNoTerminatingNul   
)

Definition at line 830 of file googletest-printers-test.cc.

830 {
831 // Array a contains '\0' in the middle and doesn't end with '\0'.
832 const char32_t a[] = {U'👋', U'\0', U'🌌'};
833 EXPECT_EQ("U\"\\x1F44B\\0\\x1F30C\" (no terminating NUL)",
835}

◆ TEST() [17/138]

testing::gtest_printers_test::TEST ( PrintArrayTest  ,
Char32ArrayWithTerminatingNul   
)

Definition at line 838 of file googletest-printers-test.cc.

838 {
839 const char32_t a[] = U"\0👋🌌";
840 EXPECT_EQ("U\"\\0\\x1F44B\\x1F30C\"", PrintArrayHelper(a));
841}

◆ TEST() [18/138]

testing::gtest_printers_test::TEST ( PrintArrayTest  ,
CharArrayWithNoTerminatingNul   
)

Definition at line 786 of file googletest-printers-test.cc.

786 {
787 // Array a contains '\0' in the middle and doesn't end with '\0'.
788 char a[] = { 'H', '\0', 'i' };
789 EXPECT_EQ("\"H\\0i\" (no terminating NUL)", PrintArrayHelper(a));
790}

◆ TEST() [19/138]

testing::gtest_printers_test::TEST ( PrintArrayTest  ,
CharArrayWithTerminatingNul   
)

Definition at line 793 of file googletest-printers-test.cc.

793 {
794 const char a[] = "\0Hi";
795 EXPECT_EQ("\"\\0Hi\"", PrintArrayHelper(a));
796}

◆ TEST() [20/138]

testing::gtest_printers_test::TEST ( PrintArrayTest  ,
ConstArray   
)

Definition at line 780 of file googletest-printers-test.cc.

780 {
781 const bool a[1] = { false };
782 EXPECT_EQ("{ false }", PrintArrayHelper(a));
783}

◆ TEST() [21/138]

testing::gtest_printers_test::TEST ( PrintArrayTest  ,
ObjectArray   
)

Definition at line 857 of file googletest-printers-test.cc.

857 {
858 std::string a[3] = {"Hi", "Hello", "Ni hao"};
859 EXPECT_EQ("{ \"Hi\", \"Hello\", \"Ni hao\" }", PrintArrayHelper(a));
860}

◆ TEST() [22/138]

testing::gtest_printers_test::TEST ( PrintArrayTest  ,
OneDimensionalArray   
)

Definition at line 765 of file googletest-printers-test.cc.

765 {
766 int a[5] = { 1, 2, 3, 4, 5 };
767 EXPECT_EQ("{ 1, 2, 3, 4, 5 }", PrintArrayHelper(a));
768}

◆ TEST() [23/138]

testing::gtest_printers_test::TEST ( PrintArrayTest  ,
TwoDimensionalArray   
)

Definition at line 771 of file googletest-printers-test.cc.

771 {
772 int a[2][5] = {
773 { 1, 2, 3, 4, 5 },
774 { 6, 7, 8, 9, 0 }
775 };
776 EXPECT_EQ("{ { 1, 2, 3, 4, 5 }, { 6, 7, 8, 9, 0 } }", PrintArrayHelper(a));
777}

◆ TEST() [24/138]

testing::gtest_printers_test::TEST ( PrintArrayTest  ,
WCharArrayWithNoTerminatingNul   
)

Definition at line 844 of file googletest-printers-test.cc.

844 {
845 // Array a contains '\0' in the middle and doesn't end with '\0'.
846 const wchar_t a[] = {L'H', L'\0', L'i'};
847 EXPECT_EQ("L\"H\\0i\" (no terminating NUL)", PrintArrayHelper(a));
848}

◆ TEST() [25/138]

testing::gtest_printers_test::TEST ( PrintArrayTest  ,
WCharArrayWithTerminatingNul   
)

Definition at line 851 of file googletest-printers-test.cc.

851 {
852 const wchar_t a[] = L"\0Hi";
853 EXPECT_EQ("L\"\\0Hi\"", PrintArrayHelper(a));
854}

◆ TEST() [26/138]

testing::gtest_printers_test::TEST ( PrintBuiltInTypeTest  ,
Bool   
)

Definition at line 381 of file googletest-printers-test.cc.

381 {
382 EXPECT_EQ("false", Print(false));
383 EXPECT_EQ("true", Print(true));
384}

◆ TEST() [27/138]

testing::gtest_printers_test::TEST ( PrintBuiltInTypeTest  ,
FloatingPoints   
)

Definition at line 453 of file googletest-printers-test.cc.

453 {
454 EXPECT_EQ("1.5", Print(1.5f)); // float
455 EXPECT_EQ("-2.5", Print(-2.5)); // double
456}

◆ TEST() [28/138]

testing::gtest_printers_test::TEST ( PrintBuiltInTypeTest  ,
Integer   
)

Definition at line 414 of file googletest-printers-test.cc.

414 {
415 EXPECT_EQ("'\\xFF' (255)", Print(static_cast<unsigned char>(255))); // uint8
416 EXPECT_EQ("'\\x80' (-128)", Print(static_cast<signed char>(-128))); // int8
417 EXPECT_EQ("65535", Print(std::numeric_limits<uint16_t>::max())); // uint16
418 EXPECT_EQ("-32768", Print(std::numeric_limits<int16_t>::min())); // int16
419 EXPECT_EQ("4294967295",
420 Print(std::numeric_limits<uint32_t>::max())); // uint32
421 EXPECT_EQ("-2147483648",
422 Print(std::numeric_limits<int32_t>::min())); // int32
423 EXPECT_EQ("18446744073709551615",
424 Print(std::numeric_limits<uint64_t>::max())); // uint64
425 EXPECT_EQ("-9223372036854775808",
426 Print(std::numeric_limits<int64_t>::min())); // int64
427#ifdef __cpp_char8_t
428 EXPECT_EQ("U+0000",
429 Print(std::numeric_limits<char8_t>::min())); // char8_t
430 EXPECT_EQ("U+00FF",
431 Print(std::numeric_limits<char8_t>::max())); // char8_t
432#endif
433 EXPECT_EQ("U+0000",
434 Print(std::numeric_limits<char16_t>::min())); // char16_t
435 EXPECT_EQ("U+FFFF",
436 Print(std::numeric_limits<char16_t>::max())); // char16_t
437 EXPECT_EQ("U+0000",
438 Print(std::numeric_limits<char32_t>::min())); // char32_t
439 EXPECT_EQ("U+FFFFFFFF",
440 Print(std::numeric_limits<char32_t>::max())); // char32_t
441}

◆ TEST() [29/138]

testing::gtest_printers_test::TEST ( PrintBuiltInTypeTest  ,
Size_t   
)

Definition at line 444 of file googletest-printers-test.cc.

444 {
445 EXPECT_EQ("1", Print(sizeof('a'))); // size_t.
446#if !GTEST_OS_WINDOWS
447 // Windows has no ssize_t type.
448 EXPECT_EQ("-2", Print(static_cast<ssize_t>(-2))); // ssize_t.
449#endif // !GTEST_OS_WINDOWS
450}

◆ TEST() [30/138]

testing::gtest_printers_test::TEST ( PrintBuiltInTypeTest  ,
Wchar_t   
)

Definition at line 387 of file googletest-printers-test.cc.

387 {
388 EXPECT_EQ("L'\\0'", Print(L'\0'));
389 EXPECT_EQ("L'\\'' (39, 0x27)", Print(L'\''));
390 EXPECT_EQ("L'\"' (34, 0x22)", Print(L'"'));
391 EXPECT_EQ("L'?' (63, 0x3F)", Print(L'?'));
392 EXPECT_EQ("L'\\\\' (92, 0x5C)", Print(L'\\'));
393 EXPECT_EQ("L'\\a' (7)", Print(L'\a'));
394 EXPECT_EQ("L'\\b' (8)", Print(L'\b'));
395 EXPECT_EQ("L'\\f' (12, 0xC)", Print(L'\f'));
396 EXPECT_EQ("L'\\n' (10, 0xA)", Print(L'\n'));
397 EXPECT_EQ("L'\\r' (13, 0xD)", Print(L'\r'));
398 EXPECT_EQ("L'\\t' (9)", Print(L'\t'));
399 EXPECT_EQ("L'\\v' (11, 0xB)", Print(L'\v'));
400 EXPECT_EQ("L'\\x7F' (127)", Print(L'\x7F'));
401 EXPECT_EQ("L'\\xFF' (255)", Print(L'\xFF'));
402 EXPECT_EQ("L' ' (32, 0x20)", Print(L' '));
403 EXPECT_EQ("L'a' (97, 0x61)", Print(L'a'));
404 EXPECT_EQ("L'\\x576' (1398)", Print(static_cast<wchar_t>(0x576)));
405 EXPECT_EQ("L'\\xC74D' (51021)", Print(static_cast<wchar_t>(0xC74D)));
406}

◆ TEST() [31/138]

testing::gtest_printers_test::TEST ( PrintCharPointerTest  ,
ConstSignedChar   
)

Definition at line 630 of file googletest-printers-test.cc.

630 {
631 signed char* p = reinterpret_cast<signed char*>(0x1234);
632 EXPECT_EQ(PrintPointer(p), Print(p));
633 p = nullptr;
634 EXPECT_EQ("NULL", Print(p));
635}

◆ TEST() [32/138]

testing::gtest_printers_test::TEST ( PrintCharPointerTest  ,
ConstUnsignedChar   
)

Definition at line 646 of file googletest-printers-test.cc.

646 {
647 const unsigned char* p = reinterpret_cast<const unsigned char*>(0x1234);
648 EXPECT_EQ(PrintPointer(p), Print(p));
649 p = nullptr;
650 EXPECT_EQ("NULL", Print(p));
651}

◆ TEST() [33/138]

testing::gtest_printers_test::TEST ( PrintCharPointerTest  ,
SignedChar   
)

Definition at line 622 of file googletest-printers-test.cc.

622 {
623 signed char* p = reinterpret_cast<signed char*>(0x1234);
624 EXPECT_EQ(PrintPointer(p), Print(p));
625 p = nullptr;
626 EXPECT_EQ("NULL", Print(p));
627}

◆ TEST() [34/138]

testing::gtest_printers_test::TEST ( PrintCharPointerTest  ,
UnsignedChar   
)

Definition at line 638 of file googletest-printers-test.cc.

638 {
639 unsigned char* p = reinterpret_cast<unsigned char*>(0x1234);
640 EXPECT_EQ(PrintPointer(p), Print(p));
641 p = nullptr;
642 EXPECT_EQ("NULL", Print(p));
643}

◆ TEST() [35/138]

testing::gtest_printers_test::TEST ( PrintCharTest  ,
Char16   
)

Definition at line 364 of file googletest-printers-test.cc.

364 {
365 EXPECT_EQ("U+0041", Print(u'A'));
366}

◆ TEST() [36/138]

testing::gtest_printers_test::TEST ( PrintCharTest  ,
Char32   
)

Definition at line 368 of file googletest-printers-test.cc.

368 {
369 EXPECT_EQ("U+0041", Print(U'A'));
370}

◆ TEST() [37/138]

testing::gtest_printers_test::TEST ( PrintCharTest  ,
PlainChar   
)

Definition at line 331 of file googletest-printers-test.cc.

331 {
332 EXPECT_EQ("'\\0'", Print('\0'));
333 EXPECT_EQ("'\\'' (39, 0x27)", Print('\''));
334 EXPECT_EQ("'\"' (34, 0x22)", Print('"'));
335 EXPECT_EQ("'?' (63, 0x3F)", Print('?'));
336 EXPECT_EQ("'\\\\' (92, 0x5C)", Print('\\'));
337 EXPECT_EQ("'\\a' (7)", Print('\a'));
338 EXPECT_EQ("'\\b' (8)", Print('\b'));
339 EXPECT_EQ("'\\f' (12, 0xC)", Print('\f'));
340 EXPECT_EQ("'\\n' (10, 0xA)", Print('\n'));
341 EXPECT_EQ("'\\r' (13, 0xD)", Print('\r'));
342 EXPECT_EQ("'\\t' (9)", Print('\t'));
343 EXPECT_EQ("'\\v' (11, 0xB)", Print('\v'));
344 EXPECT_EQ("'\\x7F' (127)", Print('\x7F'));
345 EXPECT_EQ("'\\xFF' (255)", Print('\xFF'));
346 EXPECT_EQ("' ' (32, 0x20)", Print(' '));
347 EXPECT_EQ("'a' (97, 0x61)", Print('a'));
348}

◆ TEST() [38/138]

testing::gtest_printers_test::TEST ( PrintCharTest  ,
SignedChar   
)

Definition at line 351 of file googletest-printers-test.cc.

351 {
352 EXPECT_EQ("'\\0'", Print(static_cast<signed char>('\0')));
353 EXPECT_EQ("'\\xCE' (-50)",
354 Print(static_cast<signed char>(-50)));
355}

◆ TEST() [39/138]

testing::gtest_printers_test::TEST ( PrintCharTest  ,
UnsignedChar   
)

Definition at line 358 of file googletest-printers-test.cc.

358 {
359 EXPECT_EQ("'\\0'", Print(static_cast<unsigned char>('\0')));
360 EXPECT_EQ("'b' (98, 0x62)",
361 Print(static_cast<unsigned char>('b')));
362}

◆ TEST() [40/138]

testing::gtest_printers_test::TEST ( PrintClassTest  ,
BiggestIntConvertible   
)

◆ TEST() [41/138]

testing::gtest_printers_test::TEST ( PrintCStringTest  ,
Const   
)

Definition at line 470 of file googletest-printers-test.cc.

470 {
471 const char* p = "World";
472 EXPECT_EQ(PrintPointer(p) + " pointing to \"World\"", Print(p));
473}

◆ TEST() [42/138]

testing::gtest_printers_test::TEST ( PrintCStringTest  ,
EscapesProperly   
)

Definition at line 489 of file googletest-printers-test.cc.

489 {
490 const char* p = "'\"?\\\a\b\f\n\r\t\v\x7F\xFF a";
491 EXPECT_EQ(PrintPointer(p) + " pointing to \"'\\\"?\\\\\\a\\b\\f"
492 "\\n\\r\\t\\v\\x7F\\xFF a\"",
493 Print(p));
494}

◆ TEST() [43/138]

testing::gtest_printers_test::TEST ( PrintCStringTest  ,
NonConst   
)

Definition at line 476 of file googletest-printers-test.cc.

476 {
477 char p[] = "Hi";
478 EXPECT_EQ(PrintPointer(p) + " pointing to \"Hi\"",
479 Print(static_cast<char*>(p)));
480}

◆ TEST() [44/138]

testing::gtest_printers_test::TEST ( PrintCStringTest  ,
Null   
)

Definition at line 483 of file googletest-printers-test.cc.

483 {
484 const char* p = nullptr;
485 EXPECT_EQ("NULL", Print(p));
486}

◆ TEST() [45/138]

testing::gtest_printers_test::TEST ( PrintEnumTest  ,
AnonymousEnum   
)

Definition at line 302 of file googletest-printers-test.cc.

302 {
303 EXPECT_EQ("-1", Print(kAE1));
304 EXPECT_EQ("1", Print(kAE2));
305}

◆ TEST() [46/138]

testing::gtest_printers_test::TEST ( PrintEnumTest  ,
EnumWithoutPrinter   
)

Definition at line 307 of file googletest-printers-test.cc.

307 {
308 EXPECT_EQ("-2", Print(kEWP1));
309 EXPECT_EQ("42", Print(kEWP2));
310}

◆ TEST() [47/138]

testing::gtest_printers_test::TEST ( PrintEnumTest  ,
EnumWithPrintTo   
)

Definition at line 317 of file googletest-printers-test.cc.

317 {
318 EXPECT_EQ("kEWPT1", Print(kEWPT1));
319 EXPECT_EQ("invalid", Print(static_cast<EnumWithPrintTo>(0)));
320}

◆ TEST() [48/138]

testing::gtest_printers_test::TEST ( PrintEnumTest  ,
EnumWithStreaming   
)

Definition at line 312 of file googletest-printers-test.cc.

312 {
313 EXPECT_EQ("kEWS1", Print(kEWS1));
314 EXPECT_EQ("invalid", Print(static_cast<EnumWithStreaming>(0)));
315}

◆ TEST() [49/138]

testing::gtest_printers_test::TEST ( PrintNullptrT  ,
Basic   
)

Definition at line 1229 of file googletest-printers-test.cc.

1229 {
1230 EXPECT_EQ("(nullptr)", Print(nullptr));
1231}

◆ TEST() [50/138]

testing::gtest_printers_test::TEST ( PrintPointerTest  ,
MemberFunctionPointer   
)

Definition at line 744 of file googletest-printers-test.cc.

744 {
745 EXPECT_TRUE(HasPrefix(Print(&Foo::MyMethod),
746 Print(sizeof(&Foo::MyMethod)) + "-byte object "));
748 HasPrefix(Print(&Foo::MyVirtualMethod),
749 Print(sizeof((&Foo::MyVirtualMethod))) + "-byte object "));
750 int (Foo::*p)(char) = NULL; // NOLINT
752 Print(sizeof(p)) + "-byte object "));
753}
#define EXPECT_TRUE(condition)
Definition: gtest.h:1982
AssertionResult HasPrefix(const StringType &str, const StringType &prefix)

◆ TEST() [51/138]

testing::gtest_printers_test::TEST ( PrintPointerTest  ,
MemberVariablePointer   
)

Definition at line 732 of file googletest-printers-test.cc.

732 {
734 Print(sizeof(&Foo::value)) + "-byte object "));
735 int Foo::*p = NULL; // NOLINT
737 Print(sizeof(p)) + "-byte object "));
738}

◆ TEST() [52/138]

testing::gtest_printers_test::TEST ( PrintPointerTest  ,
NonMemberFunctionPointer   
)

Definition at line 691 of file googletest-printers-test.cc.

691 {
692 // We cannot directly cast &MyFunction to const void* because the
693 // standard disallows casting between pointers to functions and
694 // pointers to objects, and some compilers (e.g. GCC 3.4) enforce
695 // this limitation.
696 EXPECT_EQ(
697 PrintPointer(reinterpret_cast<const void*>(
698 reinterpret_cast<internal::BiggestInt>(&MyFunction))),
699 Print(&MyFunction));
700 int (*p)(bool) = NULL; // NOLINT
701 EXPECT_EQ("NULL", Print(p));
702}
long long BiggestInt
Definition: gtest-port.h:2151

◆ TEST() [53/138]

testing::gtest_printers_test::TEST ( PrintPointerToBuiltInTypeTest  ,
Bool   
)

Definition at line 656 of file googletest-printers-test.cc.

656 {
657 bool* p = reinterpret_cast<bool*>(0xABCD);
658 EXPECT_EQ(PrintPointer(p), Print(p));
659 p = nullptr;
660 EXPECT_EQ("NULL", Print(p));
661}

◆ TEST() [54/138]

testing::gtest_printers_test::TEST ( PrintPointerToBuiltInTypeTest  ,
ConstVoid   
)

Definition at line 672 of file googletest-printers-test.cc.

672 {
673 const void* p = reinterpret_cast<const void*>(0xABCD);
674 EXPECT_EQ(PrintPointer(p), Print(p));
675 p = nullptr;
676 EXPECT_EQ("NULL", Print(p));
677}

◆ TEST() [55/138]

testing::gtest_printers_test::TEST ( PrintPointerToBuiltInTypeTest  ,
Void   
)

Definition at line 664 of file googletest-printers-test.cc.

664 {
665 void* p = reinterpret_cast<void*>(0xABCD);
666 EXPECT_EQ(PrintPointer(p), Print(p));
667 p = nullptr;
668 EXPECT_EQ("NULL", Print(p));
669}

◆ TEST() [56/138]

testing::gtest_printers_test::TEST ( PrintPointerToPointerTest  ,
IntPointerPointer   
)

Definition at line 680 of file googletest-printers-test.cc.

680 {
681 int** p = reinterpret_cast<int**>(0xABCD);
682 EXPECT_EQ(PrintPointer(p), Print(p));
683 p = nullptr;
684 EXPECT_EQ("NULL", Print(p));
685}

◆ TEST() [57/138]

testing::gtest_printers_test::TEST ( PrintPrintableTypeTest  ,
InUserNamespace   
)

Definition at line 1322 of file googletest-printers-test.cc.

1322 {
1323 EXPECT_EQ("PrintableViaPrintTo: 0",
1325}

◆ TEST() [58/138]

testing::gtest_printers_test::TEST ( PrintPrintableTypeTest  ,
PointerInUserNamespace   
)

Definition at line 1329 of file googletest-printers-test.cc.

1329 {
1331 EXPECT_EQ("PointerPrintable*", Print(&x));
1332}

◆ TEST() [59/138]

testing::gtest_printers_test::TEST ( PrintPrintableTypeTest  ,
TemplateInUserNamespace   
)

Definition at line 1335 of file googletest-printers-test.cc.

1335 {
1336 EXPECT_EQ("PrintableViaPrintToTemplate: 5",
1338}

◆ TEST() [60/138]

testing::gtest_printers_test::TEST ( PrintReferenceTest  ,
HandlesFunctionPointer   
)

Definition at line 1361 of file googletest-printers-test.cc.

1361 {
1362 void (*fp)(int n) = &MyFunction;
1363 const std::string fp_pointer_string =
1364 PrintPointer(reinterpret_cast<const void*>(&fp));
1365 // We cannot directly cast &MyFunction to const void* because the
1366 // standard disallows casting between pointers to functions and
1367 // pointers to objects, and some compilers (e.g. GCC 3.4) enforce
1368 // this limitation.
1369 const std::string fp_string = PrintPointer(reinterpret_cast<const void*>(
1370 reinterpret_cast<internal::BiggestInt>(fp)));
1371 EXPECT_EQ("@" + fp_pointer_string + " " + fp_string,
1372 PrintByRef(fp));
1373}
std::string PrintByRef(const T &value)

◆ TEST() [61/138]

testing::gtest_printers_test::TEST ( PrintReferenceTest  ,
HandlesMemberFunctionPointer   
)

Definition at line 1377 of file googletest-printers-test.cc.

1377 {
1378 int (Foo::*p)(char ch) = &Foo::MyMethod;
1380 PrintByRef(p),
1381 "@" + PrintPointer(reinterpret_cast<const void*>(&p)) + " " +
1382 Print(sizeof(p)) + "-byte object "));
1383
1384 char (Foo::*p2)(int n) = &Foo::MyVirtualMethod;
1386 PrintByRef(p2),
1387 "@" + PrintPointer(reinterpret_cast<const void*>(&p2)) + " " +
1388 Print(sizeof(p2)) + "-byte object "));
1389}

◆ TEST() [62/138]

testing::gtest_printers_test::TEST ( PrintReferenceTest  ,
HandlesMemberVariablePointer   
)

Definition at line 1393 of file googletest-printers-test.cc.

1393 {
1394 int Foo::*p = &Foo::value; // NOLINT
1396 PrintByRef(p),
1397 "@" + PrintPointer(&p) + " " + Print(sizeof(p)) + "-byte object "));
1398}

◆ TEST() [63/138]

testing::gtest_printers_test::TEST ( PrintReferenceTest  ,
PrintsAddressAndValue   
)

Definition at line 1342 of file googletest-printers-test.cc.

1342 {
1343 int n = 5;
1344 EXPECT_EQ("@" + PrintPointer(&n) + " 5", PrintByRef(n));
1345
1346 int a[2][3] = {
1347 { 0, 1, 2 },
1348 { 3, 4, 5 }
1349 };
1350 EXPECT_EQ("@" + PrintPointer(a) + " { { 0, 1, 2 }, { 3, 4, 5 } }",
1351 PrintByRef(a));
1352
1353 const ::foo::UnprintableInFoo x;
1354 EXPECT_EQ("@" + PrintPointer(&x) + " 16-byte object "
1355 "<EF-12 00-00 34-AB 00-00 00-00 00-00 00-00 00-00>",
1356 PrintByRef(x));
1357}

◆ TEST() [64/138]

testing::gtest_printers_test::TEST ( PrintReferenceWrapper  ,
Printable   
)

Definition at line 1233 of file googletest-printers-test.cc.

1233 {
1234 int x = 5;
1235 EXPECT_EQ("@" + PrintPointer(&x) + " 5", Print(std::ref(x)));
1236 EXPECT_EQ("@" + PrintPointer(&x) + " 5", Print(std::cref(x)));
1237}

◆ TEST() [65/138]

testing::gtest_printers_test::TEST ( PrintReferenceWrapper  ,
Unprintable   
)

Definition at line 1239 of file googletest-printers-test.cc.

1239 {
1241 EXPECT_EQ(
1242 "@" + PrintPointer(&up) +
1243 " 16-byte object <EF-12 00-00 34-AB 00-00 00-00 00-00 00-00 00-00>",
1244 Print(std::ref(up)));
1245 EXPECT_EQ(
1246 "@" + PrintPointer(&up) +
1247 " 16-byte object <EF-12 00-00 34-AB 00-00 00-00 00-00 00-00 00-00>",
1248 Print(std::cref(up)));
1249}

◆ TEST() [66/138]

testing::gtest_printers_test::TEST ( PrintStdTupleTest  ,
NestedTuple   
)

Definition at line 1223 of file googletest-printers-test.cc.

1223 {
1224 ::std::tuple< ::std::tuple<int, bool>, char> nested(
1225 ::std::make_tuple(5, true), 'a');
1226 EXPECT_EQ("((5, true), 'a' (97, 0x61))", Print(nested));
1227}

◆ TEST() [67/138]

testing::gtest_printers_test::TEST ( PrintStdTupleTest  ,
VariousSizes   
)

Definition at line 1196 of file googletest-printers-test.cc.

1196 {
1197 ::std::tuple<> t0;
1198 EXPECT_EQ("()", Print(t0));
1199
1200 ::std::tuple<int> t1(5);
1201 EXPECT_EQ("(5)", Print(t1));
1202
1203 ::std::tuple<char, bool> t2('a', true);
1204 EXPECT_EQ("('a' (97, 0x61), true)", Print(t2));
1205
1206 ::std::tuple<bool, int, int> t3(false, 2, 3);
1207 EXPECT_EQ("(false, 2, 3)", Print(t3));
1208
1209 ::std::tuple<bool, int, int, int> t4(false, 2, 3, 4);
1210 EXPECT_EQ("(false, 2, 3, 4)", Print(t4));
1211
1212 const char* const str = "8";
1213 ::std::tuple<bool, char, short, int32_t, int64_t, float, double, // NOLINT
1214 const char*, void*, std::string>
1215 t10(false, 'a', static_cast<short>(3), 4, 5, 1.5F, -2.5, str, // NOLINT
1216 nullptr, "10");
1217 EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) +
1218 " pointing to \"8\", NULL, \"10\")",
1219 Print(t10));
1220}

◆ TEST() [68/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
ConstIterator   
)

Definition at line 1188 of file googletest-printers-test.cc.

1188 {
1189 const_iterator it = {};
1190 EXPECT_EQ("1-byte object <00>", Print(it));
1191}

◆ TEST() [69/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
EmptyDeque   
)

Definition at line 1012 of file googletest-printers-test.cc.

1012 {
1013 deque<char> empty;
1014 EXPECT_EQ("{}", Print(empty));
1015}

◆ TEST() [70/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
HashMultiMap   
)

Definition at line 1031 of file googletest-printers-test.cc.

1031 {
1032 ::std::unordered_multimap<int, bool> map1;
1033 map1.insert(make_pair(5, true));
1034 map1.insert(make_pair(5, false));
1035
1036 // Elements of hash_multimap can be printed in any order.
1037 const std::string result = Print(map1);
1038 EXPECT_TRUE(result == "{ (5, true), (5, false) }" ||
1039 result == "{ (5, false), (5, true) }")
1040 << " where Print(map1) returns \"" << result << "\".";
1041}

◆ TEST() [71/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
HashMultiSet   
)

Definition at line 1051 of file googletest-printers-test.cc.

1051 {
1052 const int kSize = 5;
1053 int a[kSize] = { 1, 1, 2, 5, 1 };
1054 ::std::unordered_multiset<int> set1(a, a + kSize);
1055
1056 // Elements of hash_multiset can be printed in any order.
1057 const std::string result = Print(set1);
1058 const std::string expected_pattern = "{ d, d, d, d, d }"; // d means a digit.
1059
1060 // Verifies the result matches the expected pattern; also extracts
1061 // the numbers in the result.
1062 ASSERT_EQ(expected_pattern.length(), result.length());
1063 std::vector<int> numbers;
1064 for (size_t i = 0; i != result.length(); i++) {
1065 if (expected_pattern[i] == 'd') {
1066 ASSERT_NE(isdigit(static_cast<unsigned char>(result[i])), 0);
1067 numbers.push_back(result[i] - '0');
1068 } else {
1069 EXPECT_EQ(expected_pattern[i], result[i]) << " where result is "
1070 << result;
1071 }
1072 }
1073
1074 // Makes sure the result contains the right numbers.
1075 std::sort(numbers.begin(), numbers.end());
1076 std::sort(a, a + kSize);
1077 EXPECT_TRUE(std::equal(a, a + kSize, numbers.begin()));
1078}
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:2073
#define ASSERT_NE(val1, val2)
Definition: gtest.h:2077

◆ TEST() [72/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
HashSet   
)

Definition at line 1045 of file googletest-printers-test.cc.

1045 {
1046 ::std::unordered_set<int> set1;
1047 set1.insert(1);
1048 EXPECT_EQ("{ 1 }", Print(set1));
1049}

◆ TEST() [73/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
Iterator   
)

Definition at line 1177 of file googletest-printers-test.cc.

1177 {
1178 iterator it = {};
1179 EXPECT_EQ("1-byte object <00>", Print(it));
1180}

◆ TEST() [74/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
List   
)

Definition at line 1081 of file googletest-printers-test.cc.

1081 {
1082 const std::string a[] = {"hello", "world"};
1083 const list<std::string> strings(a, a + 2);
1084 EXPECT_EQ("{ \"hello\", \"world\" }", Print(strings));
1085}

◆ TEST() [75/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
LongSequence   
)

Definition at line 1140 of file googletest-printers-test.cc.

1140 {
1141 const int a[100] = { 1, 2, 3 };
1142 const vector<int> v(a, a + 100);
1143 EXPECT_EQ("{ 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "
1144 "0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... }", Print(v));
1145}

◆ TEST() [76/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
Map   
)

Definition at line 1087 of file googletest-printers-test.cc.

1087 {
1088 map<int, bool> map1;
1089 map1[1] = true;
1090 map1[5] = false;
1091 map1[3] = true;
1092 EXPECT_EQ("{ (1, true), (3, true), (5, false) }", Print(map1));
1093}

◆ TEST() [77/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
MultiMap   
)

Definition at line 1095 of file googletest-printers-test.cc.

1095 {
1096 multimap<bool, int> map1;
1097 // The make_pair template function would deduce the type as
1098 // pair<bool, int> here, and since the key part in a multimap has to
1099 // be constant, without a templated ctor in the pair class (as in
1100 // libCstd on Solaris), make_pair call would fail to compile as no
1101 // implicit conversion is found. Thus explicit typename is used
1102 // here instead.
1103 map1.insert(pair<const bool, int>(true, 0));
1104 map1.insert(pair<const bool, int>(true, 1));
1105 map1.insert(pair<const bool, int>(false, 2));
1106 EXPECT_EQ("{ (false, 2), (true, 0), (true, 1) }", Print(map1));
1107}

◆ TEST() [78/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
MultiSet   
)

Definition at line 1115 of file googletest-printers-test.cc.

1115 {
1116 const int a[] = { 1, 1, 2, 5, 1 };
1117 multiset<int> set1(a, a + 5);
1118 EXPECT_EQ("{ 1, 1, 1, 2, 5 }", Print(set1));
1119}

◆ TEST() [79/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
NestedContainer   
)

Definition at line 1147 of file googletest-printers-test.cc.

1147 {
1148 const int a1[] = { 1, 2 };
1149 const int a2[] = { 3, 4, 5 };
1150 const list<int> l1(a1, a1 + 2);
1151 const list<int> l2(a2, a2 + 3);
1152
1153 vector<list<int> > v;
1154 v.push_back(l1);
1155 v.push_back(l2);
1156 EXPECT_EQ("{ { 1, 2 }, { 3, 4, 5 } }", Print(v));
1157}

◆ TEST() [80/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
NonEmptyDeque   
)

Definition at line 1017 of file googletest-printers-test.cc.

1017 {
1018 deque<int> non_empty;
1019 non_empty.push_back(1);
1020 non_empty.push_back(3);
1021 EXPECT_EQ("{ 1, 3 }", Print(non_empty));
1022}

◆ TEST() [81/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
OneDimensionalNativeArray   
)

Definition at line 1159 of file googletest-printers-test.cc.

1159 {
1160 const int a[3] = { 1, 2, 3 };
1161 NativeArray<int> b(a, 3, RelationToSourceReference());
1162 EXPECT_EQ("{ 1, 2, 3 }", Print(b));
1163}

◆ TEST() [82/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
OneElementHashMap   
)

Definition at line 1025 of file googletest-printers-test.cc.

1025 {
1026 ::std::unordered_map<int, char> map1;
1027 map1[1] = 'a';
1028 EXPECT_EQ("{ (1, 'a' (97, 0x61)) }", Print(map1));
1029}

◆ TEST() [83/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
Pair   
)

Definition at line 1128 of file googletest-printers-test.cc.

1128 {
1129 pair<const bool, int> p(true, 5);
1130 EXPECT_EQ("(true, 5)", Print(p));
1131}

◆ TEST() [84/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
Set   
)

Definition at line 1109 of file googletest-printers-test.cc.

1109 {
1110 const unsigned int a[] = { 3, 0, 5 };
1111 set<unsigned int> set1(a, a + 3);
1112 EXPECT_EQ("{ 0, 3, 5 }", Print(set1));
1113}

◆ TEST() [85/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
SinglyLinkedList   
)

Definition at line 1122 of file googletest-printers-test.cc.

1122 {
1123 int a[] = { 9, 2, 8 };
1124 const std::forward_list<int> ints(a, a + 3);
1125 EXPECT_EQ("{ 9, 2, 8 }", Print(ints));
1126}

◆ TEST() [86/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
TwoDimensionalNativeArray   
)

Definition at line 1165 of file googletest-printers-test.cc.

1165 {
1166 const int a[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } };
1167 NativeArray<int[3]> b(a, 2, RelationToSourceReference());
1168 EXPECT_EQ("{ { 1, 2, 3 }, { 4, 5, 6 } }", Print(b));
1169}

◆ TEST() [87/138]

testing::gtest_printers_test::TEST ( PrintStlContainerTest  ,
Vector   
)

Definition at line 1133 of file googletest-printers-test.cc.

1133 {
1134 vector<int> v;
1135 v.push_back(1);
1136 v.push_back(2);
1137 EXPECT_EQ("{ 1, 2 }", Print(v));
1138}

◆ TEST() [88/138]

testing::gtest_printers_test::TEST ( PrintStreamableTypeTest  ,
InGlobalNamespace   
)

Definition at line 1286 of file googletest-printers-test.cc.

1286 {
1288 EXPECT_EQ("StreamableInGlobal", Print(x));
1289 EXPECT_EQ("StreamableInGlobal*", Print(&x));
1290}

◆ TEST() [89/138]

testing::gtest_printers_test::TEST ( PrintStreamableTypeTest  ,
PathLikeInUserNamespace   
)

Definition at line 1314 of file googletest-printers-test.cc.

1314 {
1316 EXPECT_EQ("Streamable-PathLike", Print(x));
1317 const ::foo::PathLike cx;
1318 EXPECT_EQ("Streamable-PathLike", Print(cx));
1319}

◆ TEST() [90/138]

testing::gtest_printers_test::TEST ( PrintStreamableTypeTest  ,
SubclassUsesSuperclassStreamOperator   
)

Definition at line 1303 of file googletest-printers-test.cc.

1303 {
1304 ParentClass parent;
1305 ChildClassWithStreamOperator child_stream;
1306 ChildClassWithoutStreamOperator child_no_stream;
1307 EXPECT_EQ("ParentClass", Print(parent));
1308 EXPECT_EQ("ChildClassWithStreamOperator", Print(child_stream));
1309 EXPECT_EQ("ParentClass", Print(child_no_stream));
1310}

◆ TEST() [91/138]

testing::gtest_printers_test::TEST ( PrintStreamableTypeTest  ,
TemplateTypeInUserNamespace   
)

Definition at line 1293 of file googletest-printers-test.cc.

1293 {
1294 EXPECT_EQ("StreamableTemplateInFoo: 0",
1296}

◆ TEST() [92/138]

testing::gtest_printers_test::TEST ( PrintStreamableTypeTest  ,
TypeInUserNamespaceWithTemplatedStreamOperator   
)

Definition at line 1298 of file googletest-printers-test.cc.

1298 {
1299 EXPECT_EQ("TemplatedStreamableInFoo",
1301}

◆ TEST() [93/138]

testing::gtest_printers_test::TEST ( PrintStringTest  ,
StringAmbiguousHex   
)

Definition at line 879 of file googletest-printers-test.cc.

879 {
880 // "\x6BANANA" is ambiguous, it can be interpreted as starting with either of:
881 // '\x6', '\x6B', or '\x6BA'.
882
883 // a hex escaping sequence following by a decimal digit
884 EXPECT_EQ("\"0\\x12\" \"3\"", Print(::std::string("0\x12" "3")));
885 // a hex escaping sequence following by a hex digit (lower-case)
886 EXPECT_EQ("\"mm\\x6\" \"bananas\"", Print(::std::string("mm\x6" "bananas")));
887 // a hex escaping sequence following by a hex digit (upper-case)
888 EXPECT_EQ("\"NOM\\x6\" \"BANANA\"", Print(::std::string("NOM\x6" "BANANA")));
889 // a hex escaping sequence following by a non-xdigit
890 EXPECT_EQ("\"!\\x5-!\"", Print(::std::string("!\x5-!")));
891}

◆ TEST() [94/138]

testing::gtest_printers_test::TEST ( PrintStringTest  ,
StringInStdNamespace   
)

Definition at line 872 of file googletest-printers-test.cc.

872 {
873 const char s[] = "'\"?\\\a\b\f\n\0\r\t\v\x7F\xFF a";
874 const ::std::string str(s, sizeof(s));
875 EXPECT_EQ("\"'\\\"?\\\\\\a\\b\\f\\n\\0\\r\\t\\v\\x7F\\xFF a\\0\"",
876 Print(str));
877}

◆ TEST() [95/138]

testing::gtest_printers_test::TEST ( PrintStringTest  ,
U16String   
)

Definition at line 923 of file googletest-printers-test.cc.

923 {
924 std::u16string str = u"Hello, 世界";
925 EXPECT_EQ(str, str); // Verify EXPECT_EQ compiles with this type.
926 EXPECT_EQ("u\"Hello, \\x4E16\\x754C\"", Print(str));
927}

◆ TEST() [96/138]

testing::gtest_printers_test::TEST ( PrintStringTest  ,
U32String   
)

Definition at line 929 of file googletest-printers-test.cc.

929 {
930 std::u32string str = U"Hello, 🗺️";
931 EXPECT_EQ(str, str); // Verify EXPECT_EQ compiles with this type
932 EXPECT_EQ("U\"Hello, \\x1F5FA\\xFE0F\"", Print(str));
933}

◆ TEST() [97/138]

testing::gtest_printers_test::TEST ( PrintToStringTest  ,
ContainsNonLatin   
)

Definition at line 1603 of file googletest-printers-test.cc.

1603 {
1604 // Sanity test with valid UTF-8. Prints both in hex and as text.
1605 std::string non_ascii_str = ::std::string("오전 4:30");
1606 EXPECT_PRINT_TO_STRING_(non_ascii_str,
1607 "\"\\xEC\\x98\\xA4\\xEC\\xA0\\x84 4:30\"\n"
1608 " As Text: \"오전 4:30\"");
1609 non_ascii_str = ::std::string("From ä — ẑ");
1610 EXPECT_PRINT_TO_STRING_(non_ascii_str,
1611 "\"From \\xC3\\xA4 \\xE2\\x80\\x94 \\xE1\\xBA\\x91\""
1612 "\n As Text: \"From ä — ẑ\"");
1613}

◆ TEST() [98/138]

testing::gtest_printers_test::TEST ( PrintToStringTest  ,
EscapesForPointerToConstChar   
)

Definition at line 1574 of file googletest-printers-test.cc.

1574 {
1575 const char* p = "hello\n";
1576 EXPECT_PRINT_TO_STRING_(p, "\"hello\\n\"");
1577}

◆ TEST() [99/138]

testing::gtest_printers_test::TEST ( PrintToStringTest  ,
EscapesForPointerToNonConstChar   
)

Definition at line 1579 of file googletest-printers-test.cc.

1579 {
1580 char s[] = "hello\1";
1581 char* p = s;
1582 EXPECT_PRINT_TO_STRING_(p, "\"hello\\x1\"");
1583}

◆ TEST() [100/138]

testing::gtest_printers_test::TEST ( PrintToStringTest  ,
WorksForArray   
)

Definition at line 1585 of file googletest-printers-test.cc.

1585 {
1586 int n[3] = { 1, 2, 3 };
1587 EXPECT_PRINT_TO_STRING_(n, "{ 1, 2, 3 }");
1588}

◆ TEST() [101/138]

testing::gtest_printers_test::TEST ( PrintToStringTest  ,
WorksForCharArray   
)

Definition at line 1590 of file googletest-printers-test.cc.

1590 {
1591 char s[] = "hello";
1592 EXPECT_PRINT_TO_STRING_(s, "\"hello\"");
1593}

◆ TEST() [102/138]

testing::gtest_printers_test::TEST ( PrintToStringTest  ,
WorksForCharArrayWithEmbeddedNul   
)

Definition at line 1595 of file googletest-printers-test.cc.

1595 {
1596 const char str_with_nul[] = "hello\0 world";
1597 EXPECT_PRINT_TO_STRING_(str_with_nul, "\"hello\\0 world\"");
1598
1599 char mutable_str_with_nul[] = "hello\0 world";
1600 EXPECT_PRINT_TO_STRING_(mutable_str_with_nul, "\"hello\\0 world\"");
1601}

◆ TEST() [103/138]

testing::gtest_printers_test::TEST ( PrintToStringTest  ,
WorksForPointerToConstChar   
)

Definition at line 1563 of file googletest-printers-test.cc.

1563 {
1564 const char* p = "hello";
1565 EXPECT_PRINT_TO_STRING_(p, "\"hello\"");
1566}

◆ TEST() [104/138]

testing::gtest_printers_test::TEST ( PrintToStringTest  ,
WorksForPointerToNonConstChar   
)

Definition at line 1568 of file googletest-printers-test.cc.

1568 {
1569 char s[] = "hello";
1570 char* p = s;
1571 EXPECT_PRINT_TO_STRING_(p, "\"hello\"");
1572}

◆ TEST() [105/138]

testing::gtest_printers_test::TEST ( PrintToStringTest  ,
WorksForScalar   
)

Definition at line 1559 of file googletest-printers-test.cc.

1559 {
1560 EXPECT_PRINT_TO_STRING_(123, "123");
1561}

◆ TEST() [106/138]

testing::gtest_printers_test::TEST ( PrintTypeSizeTest  ,
Wchar_t   
)

Definition at line 409 of file googletest-printers-test.cc.

409 {
410 EXPECT_LT(sizeof(wchar_t), sizeof(int64_t));
411}
#define EXPECT_LT(val1, val2)
Definition: gtest.h:2049

◆ TEST() [107/138]

testing::gtest_printers_test::TEST ( PrintTypeWithGenericStreamingTest  ,
NonTemplateType   
)

Definition at line 950 of file googletest-printers-test.cc.

◆ TEST() [108/138]

testing::gtest_printers_test::TEST ( PrintTypeWithGenericStreamingTest  ,
TemplateType   
)

◆ TEST() [109/138]

testing::gtest_printers_test::TEST ( PrintTypeWithGenericStreamingTest  ,
TypeImplicitlyConvertible   
)

◆ TEST() [110/138]

testing::gtest_printers_test::TEST ( PrintU16StringTest  ,
Const   
)

Definition at line 527 of file googletest-printers-test.cc.

527 {
528 const char16_t* p = u"界";
529 EXPECT_EQ(PrintPointer(p) + " pointing to u\"\\x754C\"", Print(p));
530}

◆ TEST() [111/138]

testing::gtest_printers_test::TEST ( PrintU16StringTest  ,
EscapesProperly   
)

Definition at line 546 of file googletest-printers-test.cc.

546 {
547 const char16_t* p = u"'\"?\\\a\b\f\n\r\t\v\x7F\xFF hello 世界";
548 EXPECT_EQ(PrintPointer(p) +
549 " pointing to u\"'\\\"?\\\\\\a\\b\\f\\n\\r\\t\\v\\x7F\\xFF "
550 "hello \\x4E16\\x754C\"",
551 Print(p));
552}

◆ TEST() [112/138]

testing::gtest_printers_test::TEST ( PrintU16StringTest  ,
NonConst   
)

Definition at line 533 of file googletest-printers-test.cc.

533 {
534 char16_t p[] = u"世";
535 EXPECT_EQ(PrintPointer(p) + " pointing to u\"\\x4E16\"",
536 Print(static_cast<char16_t*>(p)));
537}

◆ TEST() [113/138]

testing::gtest_printers_test::TEST ( PrintU16StringTest  ,
Null   
)

Definition at line 540 of file googletest-printers-test.cc.

540 {
541 const char16_t* p = nullptr;
542 EXPECT_EQ("NULL", Print(p));
543}

◆ TEST() [114/138]

testing::gtest_printers_test::TEST ( PrintU32StringTest  ,
Const   
)

Definition at line 555 of file googletest-printers-test.cc.

555 {
556 const char32_t* p = U"🗺️";
557 EXPECT_EQ(PrintPointer(p) + " pointing to U\"\\x1F5FA\\xFE0F\"", Print(p));
558}

◆ TEST() [115/138]

testing::gtest_printers_test::TEST ( PrintU32StringTest  ,
EscapesProperly   
)

Definition at line 574 of file googletest-printers-test.cc.

574 {
575 const char32_t* p = U"'\"?\\\a\b\f\n\r\t\v\x7F\xFF hello 🗺️";
576 EXPECT_EQ(PrintPointer(p) +
577 " pointing to U\"'\\\"?\\\\\\a\\b\\f\\n\\r\\t\\v\\x7F\\xFF "
578 "hello \\x1F5FA\\xFE0F\"",
579 Print(p));
580}

◆ TEST() [116/138]

testing::gtest_printers_test::TEST ( PrintU32StringTest  ,
NonConst   
)

Definition at line 561 of file googletest-printers-test.cc.

561 {
562 char32_t p[] = U"🌌";
563 EXPECT_EQ(PrintPointer(p) + " pointing to U\"\\x1F30C\"",
564 Print(static_cast<char32_t*>(p)));
565}

◆ TEST() [117/138]

testing::gtest_printers_test::TEST ( PrintU32StringTest  ,
Null   
)

Definition at line 568 of file googletest-printers-test.cc.

568 {
569 const char32_t* p = nullptr;
570 EXPECT_EQ("NULL", Print(p));
571}

◆ TEST() [118/138]

testing::gtest_printers_test::TEST ( PrintUnprintableTypeTest  ,
InGlobalNamespace   
)

Definition at line 1254 of file googletest-printers-test.cc.

◆ TEST() [119/138]

testing::gtest_printers_test::TEST ( PrintUnprintableTypeTest  ,
InUserNamespace   
)

Definition at line 1260 of file googletest-printers-test.cc.

1260 {
1261 EXPECT_EQ("16-byte object <EF-12 00-00 34-AB 00-00 00-00 00-00 00-00 00-00>",
1263}

◆ TEST() [120/138]

testing::gtest_printers_test::TEST ( PrintUnpritableTypeTest  ,
BigObject   
)

Definition at line 1272 of file googletest-printers-test.cc.

1272 {
1273 EXPECT_EQ("257-byte object <00-00 00-00 00-00 00-00 00-00 00-00 "
1274 "00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 "
1275 "00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 "
1276 "00-00 00-00 00-00 00-00 00-00 00-00 ... 00-00 00-00 00-00 "
1277 "00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 "
1278 "00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 "
1279 "00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00>",
1280 Print(Big()));
1281}

◆ TEST() [121/138]

testing::gtest_printers_test::TEST ( PrintWideCStringTest  ,
Const   
)

Definition at line 591 of file googletest-printers-test.cc.

591 {
592 const wchar_t* p = L"World";
593 EXPECT_EQ(PrintPointer(p) + " pointing to L\"World\"", Print(p));
594}

◆ TEST() [122/138]

testing::gtest_printers_test::TEST ( PrintWideCStringTest  ,
EscapesProperly   
)

Definition at line 610 of file googletest-printers-test.cc.

610 {
611 const wchar_t s[] = {'\'', '"', '?', '\\', '\a', '\b', '\f', '\n', '\r',
612 '\t', '\v', 0xD3, 0x576, 0x8D3, 0xC74D, ' ', 'a', '\0'};
613 EXPECT_EQ(PrintPointer(s) + " pointing to L\"'\\\"?\\\\\\a\\b\\f"
614 "\\n\\r\\t\\v\\xD3\\x576\\x8D3\\xC74D a\"",
615 Print(static_cast<const wchar_t*>(s)));
616}

◆ TEST() [123/138]

testing::gtest_printers_test::TEST ( PrintWideCStringTest  ,
NonConst   
)

Definition at line 597 of file googletest-printers-test.cc.

597 {
598 wchar_t p[] = L"Hi";
599 EXPECT_EQ(PrintPointer(p) + " pointing to L\"Hi\"",
600 Print(static_cast<wchar_t*>(p)));
601}

◆ TEST() [124/138]

testing::gtest_printers_test::TEST ( PrintWideCStringTest  ,
Null   
)

Definition at line 604 of file googletest-printers-test.cc.

604 {
605 const wchar_t* p = nullptr;
606 EXPECT_EQ("NULL", Print(p));
607}

◆ TEST() [125/138]

testing::gtest_printers_test::TEST ( UniversalPrintTest  ,
IncompleteType   
)

Definition at line 1756 of file googletest-printers-test.cc.

1756 {
1757 struct Incomplete;
1758 char some_object = 0;
1759 EXPECT_EQ("(incomplete type)",
1760 PrintToString(reinterpret_cast<Incomplete&>(some_object)));
1761}
::std::string PrintToString(const T &value)

◆ TEST() [126/138]

testing::gtest_printers_test::TEST ( UniversalPrintTest  ,
SmartPointers   
)

Definition at line 1763 of file googletest-printers-test.cc.

1763 {
1764 EXPECT_EQ("(nullptr)", PrintToString(std::unique_ptr<int>()));
1765 std::unique_ptr<int> p(new int(17));
1766 EXPECT_EQ("(ptr = " + PrintPointer(p.get()) + ", value = 17)",
1767 PrintToString(p));
1768 std::unique_ptr<int[]> p2(new int[2]);
1769 EXPECT_EQ("(" + PrintPointer(p2.get()) + ")", PrintToString(p2));
1770
1771 EXPECT_EQ("(nullptr)", PrintToString(std::shared_ptr<int>()));
1772 std::shared_ptr<int> p3(new int(1979));
1773 EXPECT_EQ("(ptr = " + PrintPointer(p3.get()) + ", value = 1979)",
1774 PrintToString(p3));
1775#if __cpp_lib_shared_ptr_arrays >= 201611L
1776 std::shared_ptr<int[]> p4(new int[2]);
1777 EXPECT_EQ("(" + PrintPointer(p4.get()) + ")", PrintToString(p4));
1778#endif
1779
1780 // modifiers
1781 EXPECT_EQ("(nullptr)", PrintToString(std::unique_ptr<int>()));
1782 EXPECT_EQ("(nullptr)", PrintToString(std::unique_ptr<const int>()));
1783 EXPECT_EQ("(nullptr)", PrintToString(std::unique_ptr<volatile int>()));
1784 EXPECT_EQ("(nullptr)", PrintToString(std::unique_ptr<volatile const int>()));
1785 EXPECT_EQ("(nullptr)", PrintToString(std::unique_ptr<int[]>()));
1786 EXPECT_EQ("(nullptr)", PrintToString(std::unique_ptr<const int[]>()));
1787 EXPECT_EQ("(nullptr)", PrintToString(std::unique_ptr<volatile int[]>()));
1788 EXPECT_EQ("(nullptr)",
1789 PrintToString(std::unique_ptr<volatile const int[]>()));
1790 EXPECT_EQ("(nullptr)", PrintToString(std::shared_ptr<int>()));
1791 EXPECT_EQ("(nullptr)", PrintToString(std::shared_ptr<const int>()));
1792 EXPECT_EQ("(nullptr)", PrintToString(std::shared_ptr<volatile int>()));
1793 EXPECT_EQ("(nullptr)", PrintToString(std::shared_ptr<volatile const int>()));
1794#if __cpp_lib_shared_ptr_arrays >= 201611L
1795 EXPECT_EQ("(nullptr)", PrintToString(std::shared_ptr<int[]>()));
1796 EXPECT_EQ("(nullptr)", PrintToString(std::shared_ptr<const int[]>()));
1797 EXPECT_EQ("(nullptr)", PrintToString(std::shared_ptr<volatile int[]>()));
1798 EXPECT_EQ("(nullptr)",
1799 PrintToString(std::shared_ptr<volatile const int[]>()));
1800#endif
1801
1802 // void
1803 EXPECT_EQ("(nullptr)", PrintToString(std::unique_ptr<void, void (*)(void*)>(
1804 nullptr, nullptr)));
1805 EXPECT_EQ("(" + PrintPointer(p.get()) + ")",
1807 std::unique_ptr<void, void (*)(void*)>(p.get(), [](void*) {})));
1808 EXPECT_EQ("(nullptr)", PrintToString(std::shared_ptr<void>()));
1809 EXPECT_EQ("(" + PrintPointer(p.get()) + ")",
1810 PrintToString(std::shared_ptr<void>(p.get(), [](void*) {})));
1811}

◆ TEST() [127/138]

testing::gtest_printers_test::TEST ( UniversalPrintTest  ,
WorksForCharArray   
)

Definition at line 1744 of file googletest-printers-test.cc.

1744 {
1745 const char str[] = "\"Line\0 1\"\nLine 2";
1746 ::std::stringstream ss1;
1747 UniversalPrint(str, &ss1);
1748 EXPECT_EQ("\"\\\"Line\\0 1\\\"\\nLine 2\"", ss1.str());
1749
1750 const char mutable_str[] = "\"Line\0 1\"\nLine 2";
1751 ::std::stringstream ss2;
1752 UniversalPrint(mutable_str, &ss2);
1753 EXPECT_EQ("\"\\\"Line\\0 1\\\"\\nLine 2\"", ss2.str());
1754}
void UniversalPrint(const T &value, ::std::ostream *os)

◆ TEST() [128/138]

testing::gtest_printers_test::TEST ( UniversalPrintTest  ,
WorksForCString   
)

Definition at line 1727 of file googletest-printers-test.cc.

1727 {
1728 const char* s1 = "abc";
1729 ::std::stringstream ss1;
1730 UniversalPrint(s1, &ss1);
1731 EXPECT_EQ(PrintPointer(s1) + " pointing to \"abc\"", std::string(ss1.str()));
1732
1733 char* s2 = const_cast<char*>(s1);
1734 ::std::stringstream ss2;
1735 UniversalPrint(s2, &ss2);
1736 EXPECT_EQ(PrintPointer(s2) + " pointing to \"abc\"", std::string(ss2.str()));
1737
1738 const char* s3 = nullptr;
1739 ::std::stringstream ss3;
1740 UniversalPrint(s3, &ss3);
1741 EXPECT_EQ("NULL", ss3.str());
1742}

◆ TEST() [129/138]

testing::gtest_printers_test::TEST ( UniversalPrintTest  ,
WorksForNonReference   
)

Definition at line 1707 of file googletest-printers-test.cc.

1707 {
1708 ::std::stringstream ss;
1709 UniversalPrint(123, &ss);
1710 EXPECT_EQ("123", ss.str());
1711}

◆ TEST() [130/138]

testing::gtest_printers_test::TEST ( UniversalPrintTest  ,
WorksForPairWithConst   
)

Definition at line 1720 of file googletest-printers-test.cc.

1720 {
1721 std::pair<const Wrapper<std::string>, int> p(Wrapper<std::string>("abc"), 1);
1722 ::std::stringstream ss;
1723 UniversalPrint(p, &ss);
1724 EXPECT_EQ("(Wrapper(\"abc\"), 1)", ss.str());
1725}

◆ TEST() [131/138]

testing::gtest_printers_test::TEST ( UniversalPrintTest  ,
WorksForReference   
)

Definition at line 1713 of file googletest-printers-test.cc.

1713 {
1714 const int& n = 123;
1715 ::std::stringstream ss;
1716 UniversalPrint(n, &ss);
1717 EXPECT_EQ("123", ss.str());
1718}

◆ TEST() [132/138]

testing::gtest_printers_test::TEST ( UniversalTersePrintTest  ,
WorksForCString   
)

Definition at line 1690 of file googletest-printers-test.cc.

1690 {
1691 const char* s1 = "abc";
1692 ::std::stringstream ss1;
1693 UniversalTersePrint(s1, &ss1);
1694 EXPECT_EQ("\"abc\"", ss1.str());
1695
1696 char* s2 = const_cast<char*>(s1);
1697 ::std::stringstream ss2;
1698 UniversalTersePrint(s2, &ss2);
1699 EXPECT_EQ("\"abc\"", ss2.str());
1700
1701 const char* s3 = nullptr;
1702 ::std::stringstream ss3;
1703 UniversalTersePrint(s3, &ss3);
1704 EXPECT_EQ("NULL", ss3.str());
1705}
void UniversalTersePrint(const T &value, ::std::ostream *os)

◆ TEST() [133/138]

testing::gtest_printers_test::TEST ( UniversalTersePrintTest  ,
WorksForNonReference   
)

Definition at line 1677 of file googletest-printers-test.cc.

1677 {
1678 ::std::stringstream ss;
1679 UniversalTersePrint(123, &ss);
1680 EXPECT_EQ("123", ss.str());
1681}

◆ TEST() [134/138]

testing::gtest_printers_test::TEST ( UniversalTersePrintTest  ,
WorksForReference   
)

Definition at line 1683 of file googletest-printers-test.cc.

1683 {
1684 const int& n = 123;
1685 ::std::stringstream ss;
1686 UniversalTersePrint(n, &ss);
1687 EXPECT_EQ("123", ss.str());
1688}

◆ TEST() [135/138]

testing::gtest_printers_test::TEST ( UniversalTersePrintTupleFieldsToStringsTestWithStd  ,
PrintsEmptyTuple   
)

Definition at line 1813 of file googletest-printers-test.cc.

1813 {
1814 Strings result = UniversalTersePrintTupleFieldsToStrings(::std::make_tuple());
1815 EXPECT_EQ(0u, result.size());
1816}
::std::vector< ::std::string > Strings
Strings UniversalTersePrintTupleFieldsToStrings(const Tuple &value)

◆ TEST() [136/138]

testing::gtest_printers_test::TEST ( UniversalTersePrintTupleFieldsToStringsTestWithStd  ,
PrintsOneTuple   
)

Definition at line 1818 of file googletest-printers-test.cc.

1818 {
1820 ::std::make_tuple(1));
1821 ASSERT_EQ(1u, result.size());
1822 EXPECT_EQ("1", result[0]);
1823}

◆ TEST() [137/138]

testing::gtest_printers_test::TEST ( UniversalTersePrintTupleFieldsToStringsTestWithStd  ,
PrintsTersely   
)

Definition at line 1833 of file googletest-printers-test.cc.

1833 {
1834 const int n = 1;
1836 ::std::tuple<const int&, const char*>(n, "a"));
1837 ASSERT_EQ(2u, result.size());
1838 EXPECT_EQ("1", result[0]);
1839 EXPECT_EQ("\"a\"", result[1]);
1840}

◆ TEST() [138/138]

testing::gtest_printers_test::TEST ( UniversalTersePrintTupleFieldsToStringsTestWithStd  ,
PrintsTwoTuple   
)

Definition at line 1825 of file googletest-printers-test.cc.

1825 {
1827 ::std::make_tuple(1, 'a'));
1828 ASSERT_EQ(2u, result.size());
1829 EXPECT_EQ("1", result[0]);
1830 EXPECT_EQ("'a' (97, 0x61)", result[1]);
1831}