tesseract v5.3.3.20231005
gtest_unittest.cc File Reference
#include "gtest/gtest.h"
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <cstdint>
#include <map>
#include <ostream>
#include <string>
#include <type_traits>
#include <unordered_set>
#include <vector>
#include "gtest/gtest-spi.h"
#include "src/gtest-internal-inl.h"

Go to the source code of this file.

Classes

class  testing::internal::TestEventListenersAccessor
 
class  testing::internal::UnitTestRecordPropertyTestHelper
 
class  TestingVector
 
struct  ConvertibleToAssertionResult
 
class  Base
 
class  namespace1::MyTypeInNameSpace1
 
class  namespace2::MyTypeInNameSpace2
 
class  testing::TestInfoTest
 
class  testing::CodeLocationForTESTF
 
class  testing::CodeLocationForTESTP
 
class  testing::CodeLocationForTYPEDTEST< T >
 
class  testing::CodeLocationForTYPEDTESTP< T >
 
class  testing::SetUpTestCaseTest
 
class  testing::SetUpTestSuiteTest
 
struct  testing::Flags
 
class  testing::ParseFlagsTest
 
class  testing::CurrentTestInfoTest
 
class  my_namespace::testing::Test
 
class  my_namespace::testing::Message
 
class  my_namespace::testing::AssertionResult
 
class  ProtectedFixtureMethodsTest
 
class  StaticAssertTypeEqTestHelper< T >
 
class  TestListener
 
class  SequenceTestingListener
 
class  ConversionHelperBase
 
class  ConversionHelperDerived
 
struct  HasDebugStringMethods
 
struct  InheritsDebugStringMethods
 
struct  WrongTypeDebugStringMethod
 
struct  NotConstDebugStringMethod
 
struct  MissingDebugStringMethod
 
class  NonContainer
 
struct  ConstOnlyContainerWithPointerIterator
 
struct  ConstOnlyContainerWithClassIterator
 
struct  ConstOnlyContainerWithClassIterator::const_iterator
 
struct  AHashTable
 
struct  NotReallyAHashTable
 
struct  ConstructionCounting
 
class  DynamicUnitTestFixture
 
class  DynamicTest< Pass >
 

Namespaces

namespace  testing
 
namespace  testing::internal
 
namespace  namespace1
 
namespace  namespace2
 
namespace  my_namespace
 
namespace  my_namespace::testing
 

Macros

#define GTEST_USE_UNPROTECTED_COMMA_   global_var++, global_var++
 
#define VERIFY_CODE_LOCATION
 
#define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help)
 
#define GTEST_FLAT_TUPLE_INT8   int, int, int, int, int, int, int, int,
 
#define GTEST_FLAT_TUPLE_INT16   GTEST_FLAT_TUPLE_INT8 GTEST_FLAT_TUPLE_INT8
 
#define GTEST_FLAT_TUPLE_INT32   GTEST_FLAT_TUPLE_INT16 GTEST_FLAT_TUPLE_INT16
 
#define GTEST_FLAT_TUPLE_INT64   GTEST_FLAT_TUPLE_INT32 GTEST_FLAT_TUPLE_INT32
 
#define GTEST_FLAT_TUPLE_INT128   GTEST_FLAT_TUPLE_INT64 GTEST_FLAT_TUPLE_INT64
 
#define GTEST_FLAT_TUPLE_INT256   GTEST_FLAT_TUPLE_INT128 GTEST_FLAT_TUPLE_INT128
 

Typedefs

typedef int IntAlias
 

Functions

 TEST (CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded)
 
::std::ostream & operator<< (::std::ostream &os, const TestingVector &vector)
 
 testing::TEST (SuccessfulAssertionTest, SUCCEED)
 
 testing::TEST (SuccessfulAssertionTest, EXPECT)
 
 testing::TEST (SuccessfulAssertionTest, EXPECT_STR)
 
 testing::TEST (SuccessfulAssertionTest, ASSERT)
 
 testing::TEST (SuccessfulAssertionTest, ASSERT_STR)
 
 TEST (AssertionResultTest, CopyConstructorWorksWhenNotOptimied)
 
 TEST (AssertionResultTest, ConstructionWorks)
 
 TEST (AssertionResultTest, NegationWorks)
 
 TEST (AssertionResultTest, StreamingWorks)
 
 TEST (AssertionResultTest, CanStreamOstreamManipulators)
 
 TEST (AssertionResultTest, ConstructibleFromContextuallyConvertibleToBool)
 
 TEST (AssertionResultTest, ConstructibleFromImplicitlyConvertible)
 
std::ostream & operator<< (std::ostream &os, const Base &val)
 
std::ostream & operator<< (std::ostream &os, const Base *pointer)
 
 TEST (MessageTest, CanStreamUserTypeInGlobalNameSpace)
 
 TEST (MessageTest, CanStreamUserTypeInUnnamedNameSpace)
 
std::ostream & namespace1::operator<< (std::ostream &os, const MyTypeInNameSpace1 &val)
 
std::ostream & namespace1::operator<< (std::ostream &os, const MyTypeInNameSpace1 *pointer)
 
 TEST (MessageTest, CanStreamUserTypeInUserNameSpace)
 
std::ostream & operator<< (std::ostream &os, const namespace2::MyTypeInNameSpace2 &val)
 
std::ostream & operator<< (std::ostream &os, const namespace2::MyTypeInNameSpace2 *pointer)
 
 TEST (MessageTest, CanStreamUserTypeInUserNameSpaceWithStreamOperatorInGlobal)
 
 TEST (MessageTest, NullPointers)
 
 TEST (MessageTest, WideStrings)
 
 testing::TEST_F (TestInfoTest, Names)
 
 testing::TEST_F (TestInfoTest, result)
 
 testing::TEST (CodeLocationForTEST, Verify)
 
 testing::TEST_F (CodeLocationForTESTF, Verify)
 
 testing::TEST_P (CodeLocationForTESTP, Verify)
 
 testing::INSTANTIATE_TEST_SUITE_P (, CodeLocationForTESTP, Values(0))
 
 testing::TYPED_TEST_SUITE (CodeLocationForTYPEDTEST, int)
 
 testing::TYPED_TEST (CodeLocationForTYPEDTEST, Verify)
 
 testing::TYPED_TEST_SUITE_P (CodeLocationForTYPEDTESTP)
 
 testing::TYPED_TEST_P (CodeLocationForTYPEDTESTP, Verify)
 
 testing::REGISTER_TYPED_TEST_SUITE_P (CodeLocationForTYPEDTESTP, Verify)
 
 testing::INSTANTIATE_TYPED_TEST_SUITE_P (My, CodeLocationForTYPEDTESTP, int)
 
 testing::TEST_F (SetUpTestCaseTest, Test1)
 
 testing::TEST_F (SetUpTestCaseTest, Test2)
 
 testing::TEST_F (SetUpTestSuiteTest, TestSetupTestSuite1)
 
 testing::TEST_F (SetUpTestSuiteTest, TestSetupTestSuite2)
 
 testing::TEST_F (ParseFlagsTest, Empty)
 
 testing::TEST_F (ParseFlagsTest, NoFlag)
 
 testing::TEST_F (ParseFlagsTest, FailFast)
 
 testing::TEST_F (ParseFlagsTest, FilterBad)
 
 testing::TEST_F (ParseFlagsTest, FilterEmpty)
 
 testing::TEST_F (ParseFlagsTest, FilterNonEmpty)
 
 testing::TEST_F (ParseFlagsTest, BreakOnFailureWithoutValue)
 
 testing::TEST_F (ParseFlagsTest, BreakOnFailureFalse_0)
 
 testing::TEST_F (ParseFlagsTest, BreakOnFailureFalse_f)
 
 testing::TEST_F (ParseFlagsTest, BreakOnFailureFalse_F)
 
 testing::TEST_F (ParseFlagsTest, BreakOnFailureTrue)
 
 testing::TEST_F (ParseFlagsTest, CatchExceptions)
 
 testing::TEST_F (ParseFlagsTest, DeathTestUseFork)
 
 testing::TEST_F (ParseFlagsTest, DuplicatedFlags)
 
 testing::TEST_F (ParseFlagsTest, UnrecognizedFlag)
 
 testing::TEST_F (ParseFlagsTest, ListTestsFlag)
 
 testing::TEST_F (ParseFlagsTest, ListTestsTrue)
 
 testing::TEST_F (ParseFlagsTest, ListTestsFalse)
 
 testing::TEST_F (ParseFlagsTest, ListTestsFalse_f)
 
 testing::TEST_F (ParseFlagsTest, ListTestsFalse_F)
 
 testing::TEST_F (ParseFlagsTest, OutputEmpty)
 
 testing::TEST_F (ParseFlagsTest, OutputXml)
 
 testing::TEST_F (ParseFlagsTest, OutputXmlFile)
 
 testing::TEST_F (ParseFlagsTest, OutputXmlDirectory)
 
 testing::TEST_F (ParseFlagsTest, BriefFlag)
 
 testing::TEST_F (ParseFlagsTest, BriefFlagTrue)
 
 testing::TEST_F (ParseFlagsTest, BriefFlagFalse)
 
 testing::TEST_F (ParseFlagsTest, PrintTimeFlag)
 
 testing::TEST_F (ParseFlagsTest, PrintTimeTrue)
 
 testing::TEST_F (ParseFlagsTest, PrintTimeFalse)
 
 testing::TEST_F (ParseFlagsTest, PrintTimeFalse_f)
 
 testing::TEST_F (ParseFlagsTest, PrintTimeFalse_F)
 
 testing::TEST_F (ParseFlagsTest, RandomSeed)
 
 testing::TEST_F (ParseFlagsTest, Repeat)
 
 testing::TEST_F (ParseFlagsTest, AlsoRunDisabledTestsFlag)
 
 testing::TEST_F (ParseFlagsTest, AlsoRunDisabledTestsTrue)
 
 testing::TEST_F (ParseFlagsTest, AlsoRunDisabledTestsFalse)
 
 testing::TEST_F (ParseFlagsTest, ShuffleWithoutValue)
 
 testing::TEST_F (ParseFlagsTest, ShuffleFalse_0)
 
 testing::TEST_F (ParseFlagsTest, ShuffleTrue)
 
 testing::TEST_F (ParseFlagsTest, StackTraceDepth)
 
 testing::TEST_F (ParseFlagsTest, StreamResultTo)
 
 testing::TEST_F (ParseFlagsTest, ThrowOnFailureWithoutValue)
 
 testing::TEST_F (ParseFlagsTest, ThrowOnFailureFalse_0)
 
 testing::TEST_F (ParseFlagsTest, ThrowOnFailureTrue)
 
 testing::TEST_F (CurrentTestInfoTest, WorksForFirstTestInATestSuite)
 
 testing::TEST_F (CurrentTestInfoTest, WorksForSecondTestInATestSuite)
 
 my_namespace::testing::TEST (NestedTestingNamespaceTest, Success)
 
 my_namespace::testing::TEST (NestedTestingNamespaceTest, Failure)
 
 TEST (StreamingAssertionsTest, Unconditional)
 
 TEST (StreamingAssertionsTest, Truth)
 
 TEST (StreamingAssertionsTest, Truth2)
 
 TEST (StreamingAssertionsTest, IntegerEquals)
 
 TEST (StreamingAssertionsTest, IntegerLessThan)
 
 TEST (StreamingAssertionsTest, StringsEqual)
 
 TEST (StreamingAssertionsTest, StringsNotEqual)
 
 TEST (StreamingAssertionsTest, StringsEqualIgnoringCase)
 
 TEST (StreamingAssertionsTest, StringNotEqualIgnoringCase)
 
 TEST (StreamingAssertionsTest, FloatingPointEquals)
 
 TEST (ColoredOutputTest, UsesColorsWhenGTestColorFlagIsYes)
 
 TEST (ColoredOutputTest, UsesColorsWhenGTestColorFlagIsAliasOfYes)
 
 TEST (ColoredOutputTest, UsesNoColorWhenGTestColorFlagIsNo)
 
 TEST (ColoredOutputTest, UsesNoColorWhenGTestColorFlagIsInvalid)
 
 TEST (ColoredOutputTest, UsesColorsWhenStdoutIsTty)
 
 TEST (ColoredOutputTest, UsesColorsWhenTermSupportsColors)
 
 TEST (StaticAssertTypeEqTest, WorksInClass)
 
 TEST (StaticAssertTypeEqTest, CompilesForEqualTypes)
 
 TEST (HasNonfatalFailureTest, ReturnsFalseWhenThereIsNoFailure)
 
 TEST (HasNonfatalFailureTest, ReturnsFalseWhenThereIsOnlyFatalFailure)
 
 TEST (HasNonfatalFailureTest, ReturnsTrueWhenThereIsNonfatalFailure)
 
 TEST (HasNonfatalFailureTest, ReturnsTrueWhenThereAreFatalAndNonfatalFailures)
 
 TEST (HasNonfatalFailureTest, WorksOutsideOfTestBody)
 
 TEST (HasNonfatalFailureTest, WorksOutsideOfTestBody2)
 
 TEST (HasFailureTest, ReturnsFalseWhenThereIsNoFailure)
 
 TEST (HasFailureTest, ReturnsTrueWhenThereIsFatalFailure)
 
 TEST (HasFailureTest, ReturnsTrueWhenThereIsNonfatalFailure)
 
 TEST (HasFailureTest, ReturnsTrueWhenThereAreFatalAndNonfatalFailures)
 
 TEST (HasFailureTest, WorksOutsideOfTestBody)
 
 TEST (HasFailureTest, WorksOutsideOfTestBody2)
 
 TEST (TestEventListenersTest, ConstructionWorks)
 
 TEST (TestEventListenersTest, DestructionWorks)
 
 TEST (TestEventListenersTest, Append)
 
 TEST (EventListenerTest, AppendKeepsOrder)
 
 TEST (TestEventListenersTest, Release)
 
 TEST (EventListenerTest, SuppressEventForwarding)
 
 TEST (EventListenerDeathTest, EventsNotForwardedInDeathTestSubprecesses)
 
 TEST (EventListenerTest, default_result_printer)
 
 TEST (EventListenerTest, RemovingDefaultResultPrinterWorks)
 
 TEST (EventListenerTest, default_xml_generator)
 
 TEST (EventListenerTest, RemovingDefaultXmlGeneratorWorks)
 
 GTEST_TEST (AlternativeNameTest, Works)
 
 TEST (HasDebugStringAndShortDebugStringTest, ValueIsCompileTimeConstant)
 
 TEST (HasDebugStringAndShortDebugStringTest, ValueIsTrueWhenTypeHasDebugStringAndShortDebugString)
 
 TEST (HasDebugStringAndShortDebugStringTest, ValueIsFalseWhenTypeIsNotAProtocolMessage)
 
template<typename T1 , typename T2 >
void TestGTestRemoveReferenceAndConst ()
 
 TEST (RemoveReferenceToConstTest, Works)
 
template<typename T1 , typename T2 >
void TestGTestReferenceToConst ()
 
 TEST (GTestReferenceToConstTest, Works)
 
 TEST (IsContainerTestTest, WorksForNonContainer)
 
 TEST (IsContainerTestTest, WorksForContainer)
 
 TEST (IsContainerTestTest, ConstOnlyContainer)
 
 TEST (IsHashTable, Basic)
 
 TEST (ArrayEqTest, WorksForDegeneratedArrays)
 
 TEST (ArrayEqTest, WorksForOneDimensionalArrays)
 
 TEST (ArrayEqTest, WorksForTwoDimensionalArrays)
 
 TEST (ArrayAwareFindTest, WorksForOneDimensionalArray)
 
 TEST (ArrayAwareFindTest, WorksForTwoDimensionalArray)
 
 TEST (CopyArrayTest, WorksForDegeneratedArrays)
 
 TEST (CopyArrayTest, WorksForOneDimensionalArrays)
 
 TEST (CopyArrayTest, WorksForTwoDimensionalArrays)
 
 TEST (NativeArrayTest, ConstructorFromArrayWorks)
 
 TEST (NativeArrayTest, CreatesAndDeletesCopyOfArrayWhenAskedTo)
 
 TEST (NativeArrayTest, TypeMembersAreCorrect)
 
 TEST (NativeArrayTest, MethodsWork)
 
 TEST (NativeArrayTest, WorksForTwoDimensionalArray)
 
 TEST (IndexSequence, MakeIndexSequence)
 
 TEST (ElemFromList, Basic)
 
 TEST (FlatTuple, Basic)
 
 TEST (FlatTuple, Apply)
 
 TEST (FlatTuple, ConstructorCalls)
 
 TEST (FlatTuple, ManyTypes)
 
 TEST (SkipPrefixTest, SkipsWhenPrefixMatches)
 
 TEST (SkipPrefixTest, DoesNotSkipWhenPrefixDoesNotMatch)
 
 TEST (AdHocTestResultTest, AdHocTestResultForUnitTestDoesNotShowFailure)
 
 TEST (RegisterTest, WasRegistered)
 

Variables

auto * dynamic_test
 

Macro Definition Documentation

◆ GTEST_FLAT_TUPLE_INT128

#define GTEST_FLAT_TUPLE_INT128   GTEST_FLAT_TUPLE_INT64 GTEST_FLAT_TUPLE_INT64

◆ GTEST_FLAT_TUPLE_INT16

#define GTEST_FLAT_TUPLE_INT16   GTEST_FLAT_TUPLE_INT8 GTEST_FLAT_TUPLE_INT8

◆ GTEST_FLAT_TUPLE_INT256

#define GTEST_FLAT_TUPLE_INT256   GTEST_FLAT_TUPLE_INT128 GTEST_FLAT_TUPLE_INT128

◆ GTEST_FLAT_TUPLE_INT32

#define GTEST_FLAT_TUPLE_INT32   GTEST_FLAT_TUPLE_INT16 GTEST_FLAT_TUPLE_INT16

◆ GTEST_FLAT_TUPLE_INT64

#define GTEST_FLAT_TUPLE_INT64   GTEST_FLAT_TUPLE_INT32 GTEST_FLAT_TUPLE_INT32

◆ GTEST_FLAT_TUPLE_INT8

#define GTEST_FLAT_TUPLE_INT8   int, int, int, int, int, int, int, int,

◆ GTEST_TEST_PARSING_FLAGS_

#define GTEST_TEST_PARSING_FLAGS_ (   argv1,
  argv2,
  expected,
  should_print_help 
)
Value:
TestParsingFlags(sizeof(argv1)/sizeof(*argv1) - 1, argv1, \
sizeof(argv2)/sizeof(*argv2) - 1, argv2, \
expected, should_print_help)

Definition at line 5842 of file gtest_unittest.cc.

◆ GTEST_USE_UNPROTECTED_COMMA_

#define GTEST_USE_UNPROTECTED_COMMA_   global_var++, global_var++

Definition at line 1305 of file gtest_unittest.cc.

◆ VERIFY_CODE_LOCATION

#define VERIFY_CODE_LOCATION
Value:
const int expected_line = __LINE__ - 1; \
const TestInfo* const test_info = GetUnitTestImpl()->current_test_info(); \
ASSERT_TRUE(test_info); \
EXPECT_STREQ(__FILE__, test_info->file()); \
EXPECT_EQ(expected_line, test_info->line())

Definition at line 5387 of file gtest_unittest.cc.

Typedef Documentation

◆ IntAlias

typedef int IntAlias

Definition at line 6750 of file gtest_unittest.cc.

Function Documentation

◆ GTEST_TEST()

GTEST_TEST ( AlternativeNameTest  ,
Works   
)

Definition at line 7162 of file gtest_unittest.cc.

7162 { // GTEST_TEST is the same as TEST.
7163 GTEST_SUCCEED() << "OK"; // GTEST_SUCCEED is the same as SUCCEED.
7164
7165 // GTEST_FAIL is the same as FAIL.
7166 EXPECT_FATAL_FAILURE(GTEST_FAIL() << "An expected failure",
7167 "An expected failure");
7168
7169 // GTEST_ASSERT_XY is the same as ASSERT_XY.
7170
7171 GTEST_ASSERT_EQ(0, 0);
7172 EXPECT_FATAL_FAILURE(GTEST_ASSERT_EQ(0, 1) << "An expected failure",
7173 "An expected failure");
7174 EXPECT_FATAL_FAILURE(GTEST_ASSERT_EQ(1, 0) << "An expected failure",
7175 "An expected failure");
7176
7177 GTEST_ASSERT_NE(0, 1);
7178 GTEST_ASSERT_NE(1, 0);
7179 EXPECT_FATAL_FAILURE(GTEST_ASSERT_NE(0, 0) << "An expected failure",
7180 "An expected failure");
7181
7182 GTEST_ASSERT_LE(0, 0);
7183 GTEST_ASSERT_LE(0, 1);
7184 EXPECT_FATAL_FAILURE(GTEST_ASSERT_LE(1, 0) << "An expected failure",
7185 "An expected failure");
7186
7187 GTEST_ASSERT_LT(0, 1);
7188 EXPECT_FATAL_FAILURE(GTEST_ASSERT_LT(0, 0) << "An expected failure",
7189 "An expected failure");
7190 EXPECT_FATAL_FAILURE(GTEST_ASSERT_LT(1, 0) << "An expected failure",
7191 "An expected failure");
7192
7193 GTEST_ASSERT_GE(0, 0);
7194 GTEST_ASSERT_GE(1, 0);
7195 EXPECT_FATAL_FAILURE(GTEST_ASSERT_GE(0, 1) << "An expected failure",
7196 "An expected failure");
7197
7198 GTEST_ASSERT_GT(1, 0);
7199 EXPECT_FATAL_FAILURE(GTEST_ASSERT_GT(0, 1) << "An expected failure",
7200 "An expected failure");
7201 EXPECT_FATAL_FAILURE(GTEST_ASSERT_GT(1, 1) << "An expected failure",
7202 "An expected failure");
7203}
#define GTEST_ASSERT_GT(val1, val2)
Definition: gtest.h:2066
#define GTEST_SUCCEED()
Definition: gtest.h:1932
#define GTEST_ASSERT_GE(val1, val2)
Definition: gtest.h:2064
#define GTEST_ASSERT_LT(val1, val2)
Definition: gtest.h:2062
#define GTEST_FAIL()
Definition: gtest.h:1918
#define GTEST_ASSERT_NE(val1, val2)
Definition: gtest.h:2058
#define GTEST_ASSERT_EQ(val1, val2)
Definition: gtest.h:2056
#define GTEST_ASSERT_LE(val1, val2)
Definition: gtest.h:2060
#define EXPECT_FATAL_FAILURE(statement, substr)

◆ operator<<() [1/5]

::std::ostream & operator<< ( ::std::ostream &  os,
const TestingVector vector 
)

Definition at line 297 of file gtest_unittest.cc.

300 {
301 os << "{ ";
302 for (size_t i = 0; i < vector.size(); i++) {
303 os << vector[i] << " ";
304 }
305 os << "}";
306 return os;
307}

◆ operator<<() [2/5]

std::ostream & operator<< ( std::ostream &  os,
const Base val 
)

Definition at line 5212 of file gtest_unittest.cc.

5213 {
5214 return os << val.x();
5215}

◆ operator<<() [3/5]

std::ostream & operator<< ( std::ostream &  os,
const Base pointer 
)

Definition at line 5216 of file gtest_unittest.cc.

5217 {
5218 return os << "(" << pointer->x() << ")";
5219}

◆ operator<<() [4/5]

std::ostream & operator<< ( std::ostream &  os,
const namespace2::MyTypeInNameSpace2 val 
)

Definition at line 5287 of file gtest_unittest.cc.

5288 {
5289 return os << val.x();
5290}

◆ operator<<() [5/5]

std::ostream & operator<< ( std::ostream &  os,
const namespace2::MyTypeInNameSpace2 pointer 
)

Definition at line 5291 of file gtest_unittest.cc.

5292 {
5293 return os << "(" << pointer->x() << ")";
5294}

◆ TEST() [1/87]

TEST ( AdHocTestResultTest  ,
AdHocTestResultForUnitTestDoesNotShowFailure   
)

Definition at line 7753 of file gtest_unittest.cc.

7753 {
7754 const testing::TestResult& test_result =
7756 EXPECT_FALSE(test_result.Failed());
7757}
#define EXPECT_FALSE(condition)
Definition: gtest.h:1986
bool Failed() const
Definition: gtest.cc:2375
static UnitTest * GetInstance()
Definition: gtest.cc:5123
const TestResult & ad_hoc_test_result() const
Definition: gtest.cc:5242

◆ TEST() [2/87]

TEST ( ArrayAwareFindTest  ,
WorksForOneDimensionalArray   
)

Definition at line 7397 of file gtest_unittest.cc.

7397 {
7398 const char a[] = "hello";
7399 EXPECT_EQ(a + 4, ArrayAwareFind(a, a + 5, 'o'));
7400 EXPECT_EQ(a + 5, ArrayAwareFind(a, a + 5, 'x'));
7401}
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:2043
Iter ArrayAwareFind(Iter begin, Iter end, const Element &elem)

◆ TEST() [3/87]

TEST ( ArrayAwareFindTest  ,
WorksForTwoDimensionalArray   
)

Definition at line 7403 of file gtest_unittest.cc.

7403 {
7404 int a[][2] = { { 0, 1 }, { 2, 3 }, { 4, 5 } };
7405 const int b[2] = { 2, 3 };
7406 EXPECT_EQ(a + 1, ArrayAwareFind(a, a + 3, b));
7407
7408 const int c[2] = { 6, 7 };
7409 EXPECT_EQ(a + 3, ArrayAwareFind(a, a + 3, c));
7410}

◆ TEST() [4/87]

TEST ( ArrayEqTest  ,
WorksForDegeneratedArrays   
)

Definition at line 7366 of file gtest_unittest.cc.

7366 {
7367 EXPECT_TRUE(ArrayEq(5, 5L));
7368 EXPECT_FALSE(ArrayEq('a', 0));
7369}
#define EXPECT_TRUE(condition)
Definition: gtest.h:1982
bool ArrayEq(const T *lhs, size_t size, const U *rhs)

◆ TEST() [5/87]

TEST ( ArrayEqTest  ,
WorksForOneDimensionalArrays   
)

Definition at line 7371 of file gtest_unittest.cc.

7371 {
7372 // Note that a and b are distinct but compatible types.
7373 const int a[] = { 0, 1 };
7374 long b[] = { 0, 1 };
7375 EXPECT_TRUE(ArrayEq(a, b));
7376 EXPECT_TRUE(ArrayEq(a, 2, b));
7377
7378 b[0] = 2;
7379 EXPECT_FALSE(ArrayEq(a, b));
7380 EXPECT_FALSE(ArrayEq(a, 1, b));
7381}

◆ TEST() [6/87]

TEST ( ArrayEqTest  ,
WorksForTwoDimensionalArrays   
)

Definition at line 7383 of file gtest_unittest.cc.

7383 {
7384 const char a[][3] = { "hi", "lo" };
7385 const char b[][3] = { "hi", "lo" };
7386 const char c[][3] = { "hi", "li" };
7387
7388 EXPECT_TRUE(ArrayEq(a, b));
7389 EXPECT_TRUE(ArrayEq(a, 2, b));
7390
7391 EXPECT_FALSE(ArrayEq(a, c));
7392 EXPECT_FALSE(ArrayEq(a, 2, c));
7393}

◆ TEST() [7/87]

TEST ( AssertionResultTest  ,
CanStreamOstreamManipulators   
)

Definition at line 5175 of file gtest_unittest.cc.

5175 {
5176 AssertionResult r = AssertionSuccess();
5177 r << "Data" << std::endl << std::flush << std::ends << "Will be visible";
5178 EXPECT_STREQ("Data\n\\0Will be visible", r.message());
5179}
#define EXPECT_STREQ(s1, s2)
Definition: gtest.h:2112
AssertionResult AssertionSuccess()
Definition: gtest.cc:1209

◆ TEST() [8/87]

TEST ( AssertionResultTest  ,
ConstructibleFromContextuallyConvertibleToBool   
)

Definition at line 5183 of file gtest_unittest.cc.

5183 {
5184 struct ExplicitlyConvertibleToBool {
5185 explicit operator bool() const { return value; }
5186 bool value;
5187 };
5188 ExplicitlyConvertibleToBool v1 = {false};
5189 ExplicitlyConvertibleToBool v2 = {true};
5190 EXPECT_FALSE(v1);
5191 EXPECT_TRUE(v2);
5192}
int value

◆ TEST() [9/87]

TEST ( AssertionResultTest  ,
ConstructibleFromImplicitlyConvertible   
)

Definition at line 5198 of file gtest_unittest.cc.

◆ TEST() [10/87]

TEST ( AssertionResultTest  ,
ConstructionWorks   
)

Definition at line 5136 of file gtest_unittest.cc.

5136 {
5137 AssertionResult r1 = AssertionSuccess();
5138 EXPECT_TRUE(r1);
5139 EXPECT_STREQ("", r1.message());
5140
5141 AssertionResult r2 = AssertionSuccess() << "abc";
5142 EXPECT_TRUE(r2);
5143 EXPECT_STREQ("abc", r2.message());
5144
5145 AssertionResult r3 = AssertionFailure();
5146 EXPECT_FALSE(r3);
5147 EXPECT_STREQ("", r3.message());
5148
5149 AssertionResult r4 = AssertionFailure() << "def";
5150 EXPECT_FALSE(r4);
5151 EXPECT_STREQ("def", r4.message());
5152
5153 AssertionResult r5 = AssertionFailure(Message() << "ghi");
5154 EXPECT_FALSE(r5);
5155 EXPECT_STREQ("ghi", r5.message());
5156}
AssertionResult AssertionFailure()
Definition: gtest.cc:1214

◆ TEST() [11/87]

TEST ( AssertionResultTest  ,
CopyConstructorWorksWhenNotOptimied   
)

Definition at line 5120 of file gtest_unittest.cc.

5120 {
5121 // Checks that the copy constructor doesn't try to dereference NULL pointers
5122 // in the source object.
5123 AssertionResult r1 = AssertionSuccess();
5124 AssertionResult r2 = r1;
5125 // The following line is added to prevent the compiler from optimizing
5126 // away the constructor call.
5127 r1 << "abc";
5128
5129 AssertionResult r3 = r1;
5130 EXPECT_EQ(static_cast<bool>(r3), static_cast<bool>(r1));
5131 EXPECT_STREQ("abc", r1.message());
5132}

◆ TEST() [12/87]

TEST ( AssertionResultTest  ,
NegationWorks   
)

Definition at line 5159 of file gtest_unittest.cc.

5159 {
5160 AssertionResult r1 = AssertionSuccess() << "abc";
5161 EXPECT_FALSE(!r1);
5162 EXPECT_STREQ("abc", (!r1).message());
5163
5164 AssertionResult r2 = AssertionFailure() << "def";
5165 EXPECT_TRUE(!r2);
5166 EXPECT_STREQ("def", (!r2).message());
5167}

◆ TEST() [13/87]

TEST ( AssertionResultTest  ,
StreamingWorks   
)

Definition at line 5169 of file gtest_unittest.cc.

5169 {
5170 AssertionResult r = AssertionSuccess();
5171 r << "abc" << 'd' << 0 << true;
5172 EXPECT_STREQ("abcd0true", r.message());
5173}

◆ TEST() [14/87]

TEST ( ColoredOutputTest  ,
UsesColorsWhenGTestColorFlagIsAliasOfYes   
)

Definition at line 6619 of file gtest_unittest.cc.

6619 {
6620 SetEnv("TERM", "dumb"); // TERM doesn't support colors.
6621
6622 GTEST_FLAG(color) = "True";
6623 EXPECT_TRUE(ShouldUseColor(false)); // Stdout is not a TTY.
6624
6625 GTEST_FLAG(color) = "t";
6626 EXPECT_TRUE(ShouldUseColor(false)); // Stdout is not a TTY.
6627
6628 GTEST_FLAG(color) = "1";
6629 EXPECT_TRUE(ShouldUseColor(false)); // Stdout is not a TTY.
6630}
#define GTEST_FLAG(name)
Definition: gtest-port.h:2205
bool ShouldUseColor(bool stdout_is_tty)
Definition: gtest.cc:3234

◆ TEST() [15/87]

TEST ( ColoredOutputTest  ,
UsesColorsWhenGTestColorFlagIsYes   
)

Definition at line 6607 of file gtest_unittest.cc.

6607 {
6608 GTEST_FLAG(color) = "yes";
6609
6610 SetEnv("TERM", "xterm"); // TERM supports colors.
6611 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6612 EXPECT_TRUE(ShouldUseColor(false)); // Stdout is not a TTY.
6613
6614 SetEnv("TERM", "dumb"); // TERM doesn't support colors.
6615 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6616 EXPECT_TRUE(ShouldUseColor(false)); // Stdout is not a TTY.
6617}

◆ TEST() [16/87]

TEST ( ColoredOutputTest  ,
UsesColorsWhenStdoutIsTty   
)

Definition at line 6657 of file gtest_unittest.cc.

6657 {
6658 GTEST_FLAG(color) = "auto";
6659
6660 SetEnv("TERM", "xterm"); // TERM supports colors.
6661 EXPECT_FALSE(ShouldUseColor(false)); // Stdout is not a TTY.
6662 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6663}

◆ TEST() [17/87]

TEST ( ColoredOutputTest  ,
UsesColorsWhenTermSupportsColors   
)

Definition at line 6665 of file gtest_unittest.cc.

6665 {
6666 GTEST_FLAG(color) = "auto";
6667
6668#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
6669 // On Windows, we ignore the TERM variable as it's usually not set.
6670
6671 SetEnv("TERM", "dumb");
6672 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6673
6674 SetEnv("TERM", "");
6675 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6676
6677 SetEnv("TERM", "xterm");
6678 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6679#else
6680 // On non-Windows platforms, we rely on TERM to determine if the
6681 // terminal supports colors.
6682
6683 SetEnv("TERM", "dumb"); // TERM doesn't support colors.
6684 EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
6685
6686 SetEnv("TERM", "emacs"); // TERM doesn't support colors.
6687 EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
6688
6689 SetEnv("TERM", "vt100"); // TERM doesn't support colors.
6690 EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
6691
6692 SetEnv("TERM", "xterm-mono"); // TERM doesn't support colors.
6693 EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
6694
6695 SetEnv("TERM", "xterm"); // TERM supports colors.
6696 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6697
6698 SetEnv("TERM", "xterm-color"); // TERM supports colors.
6699 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6700
6701 SetEnv("TERM", "xterm-256color"); // TERM supports colors.
6702 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6703
6704 SetEnv("TERM", "screen"); // TERM supports colors.
6705 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6706
6707 SetEnv("TERM", "screen-256color"); // TERM supports colors.
6708 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6709
6710 SetEnv("TERM", "tmux"); // TERM supports colors.
6711 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6712
6713 SetEnv("TERM", "tmux-256color"); // TERM supports colors.
6714 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6715
6716 SetEnv("TERM", "rxvt-unicode"); // TERM supports colors.
6717 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6718
6719 SetEnv("TERM", "rxvt-unicode-256color"); // TERM supports colors.
6720 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6721
6722 SetEnv("TERM", "linux"); // TERM supports colors.
6723 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6724
6725 SetEnv("TERM", "cygwin"); // TERM supports colors.
6726 EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
6727#endif // GTEST_OS_WINDOWS
6728}

◆ TEST() [18/87]

TEST ( ColoredOutputTest  ,
UsesNoColorWhenGTestColorFlagIsInvalid   
)

Definition at line 6644 of file gtest_unittest.cc.

6644 {
6645 SetEnv("TERM", "xterm"); // TERM supports colors.
6646
6647 GTEST_FLAG(color) = "F";
6648 EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
6649
6650 GTEST_FLAG(color) = "0";
6651 EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
6652
6653 GTEST_FLAG(color) = "unknown";
6654 EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
6655}

◆ TEST() [19/87]

TEST ( ColoredOutputTest  ,
UsesNoColorWhenGTestColorFlagIsNo   
)

Definition at line 6632 of file gtest_unittest.cc.

6632 {
6633 GTEST_FLAG(color) = "no";
6634
6635 SetEnv("TERM", "xterm"); // TERM supports colors.
6636 EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
6637 EXPECT_FALSE(ShouldUseColor(false)); // Stdout is not a TTY.
6638
6639 SetEnv("TERM", "dumb"); // TERM doesn't support colors.
6640 EXPECT_FALSE(ShouldUseColor(true)); // Stdout is a TTY.
6641 EXPECT_FALSE(ShouldUseColor(false)); // Stdout is not a TTY.
6642}

◆ TEST() [20/87]

TEST ( CommandLineFlagsTest  ,
CanBeAccessedInCodeOnceGTestHIsIncluded   
)

Definition at line 39 of file gtest_unittest.cc.

39 {
40 bool dummy = testing::GTEST_FLAG(also_run_disabled_tests) ||
41 testing::GTEST_FLAG(break_on_failure) ||
42 testing::GTEST_FLAG(catch_exceptions) ||
43 testing::GTEST_FLAG(color) != "unknown" ||
44 testing::GTEST_FLAG(fail_fast) ||
45 testing::GTEST_FLAG(filter) != "unknown" ||
46 testing::GTEST_FLAG(list_tests) ||
47 testing::GTEST_FLAG(output) != "unknown" ||
48 testing::GTEST_FLAG(brief) || testing::GTEST_FLAG(print_time) ||
49 testing::GTEST_FLAG(random_seed) ||
50 testing::GTEST_FLAG(repeat) > 0 ||
51 testing::GTEST_FLAG(show_internal_stack_frames) ||
52 testing::GTEST_FLAG(shuffle) ||
53 testing::GTEST_FLAG(stack_trace_depth) > 0 ||
54 testing::GTEST_FLAG(stream_result_to) != "unknown" ||
55 testing::GTEST_FLAG(throw_on_failure);
56 EXPECT_TRUE(dummy || !dummy); // Suppresses warning that dummy is unused.
57}

◆ TEST() [21/87]

TEST ( CopyArrayTest  ,
WorksForDegeneratedArrays   
)

Definition at line 7414 of file gtest_unittest.cc.

7414 {
7415 int n = 0;
7416 CopyArray('a', &n);
7417 EXPECT_EQ('a', n);
7418}
void CopyArray(const T *from, size_t size, U *to)

◆ TEST() [22/87]

TEST ( CopyArrayTest  ,
WorksForOneDimensionalArrays   
)

Definition at line 7420 of file gtest_unittest.cc.

7420 {
7421 const char a[3] = "hi";
7422 int b[3];
7423#ifndef __BORLANDC__ // C++Builder cannot compile some array size deductions.
7424 CopyArray(a, &b);
7425 EXPECT_TRUE(ArrayEq(a, b));
7426#endif
7427
7428 int c[3];
7429 CopyArray(a, 3, c);
7430 EXPECT_TRUE(ArrayEq(a, c));
7431}

◆ TEST() [23/87]

TEST ( CopyArrayTest  ,
WorksForTwoDimensionalArrays   
)

Definition at line 7433 of file gtest_unittest.cc.

7433 {
7434 const int a[2][3] = { { 0, 1, 2 }, { 3, 4, 5 } };
7435 int b[2][3];
7436#ifndef __BORLANDC__ // C++Builder cannot compile some array size deductions.
7437 CopyArray(a, &b);
7438 EXPECT_TRUE(ArrayEq(a, b));
7439#endif
7440
7441 int c[2][3];
7442 CopyArray(a, 2, c);
7443 EXPECT_TRUE(ArrayEq(a, c));
7444}

◆ TEST() [24/87]

TEST ( ElemFromList  ,
Basic   
)

Definition at line 7528 of file gtest_unittest.cc.

7528 {
7533 (std::is_same<double, ElemFromList<1, int, double, char>::type>::value));
7536 EXPECT_TRUE((
7537 std::is_same<char, ElemFromList<7, int, int, int, int, int, int, int,
7538 char, int, int, int, int>::type>::value));
7539}
type
Definition: upload.py:458

◆ TEST() [25/87]

TEST ( EventListenerDeathTest  ,
EventsNotForwardedInDeathTestSubprecesses   
)

Definition at line 7032 of file gtest_unittest.cc.

7032 {
7034 GTEST_CHECK_(TestEventListenersAccessor::EventForwardingEnabled(
7035 *GetUnitTestImpl()->listeners())) << "expected failure";},
7036 "expected failure");
7037}
#define GTEST_CHECK_(condition)
Definition: gtest-port.h:1008
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex)

◆ TEST() [26/87]

TEST ( EventListenerTest  ,
AppendKeepsOrder   
)

Definition at line 6954 of file gtest_unittest.cc.

6954 {
6955 std::vector<std::string> vec;
6956 TestEventListeners listeners;
6957 listeners.Append(new SequenceTestingListener(&vec, "1st"));
6958 listeners.Append(new SequenceTestingListener(&vec, "2nd"));
6959 listeners.Append(new SequenceTestingListener(&vec, "3rd"));
6960
6961 TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(
6962 *UnitTest::GetInstance());
6963 ASSERT_EQ(3U, vec.size());
6964 EXPECT_STREQ("1st.OnTestProgramStart", vec[0].c_str());
6965 EXPECT_STREQ("2nd.OnTestProgramStart", vec[1].c_str());
6966 EXPECT_STREQ("3rd.OnTestProgramStart", vec[2].c_str());
6967
6968 vec.clear();
6969 TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramEnd(
6970 *UnitTest::GetInstance());
6971 ASSERT_EQ(3U, vec.size());
6972 EXPECT_STREQ("3rd.OnTestProgramEnd", vec[0].c_str());
6973 EXPECT_STREQ("2nd.OnTestProgramEnd", vec[1].c_str());
6974 EXPECT_STREQ("1st.OnTestProgramEnd", vec[2].c_str());
6975
6976 vec.clear();
6977 TestEventListenersAccessor::GetRepeater(&listeners)->OnTestIterationStart(
6978 *UnitTest::GetInstance(), 0);
6979 ASSERT_EQ(3U, vec.size());
6980 EXPECT_STREQ("1st.OnTestIterationStart", vec[0].c_str());
6981 EXPECT_STREQ("2nd.OnTestIterationStart", vec[1].c_str());
6982 EXPECT_STREQ("3rd.OnTestIterationStart", vec[2].c_str());
6983
6984 vec.clear();
6985 TestEventListenersAccessor::GetRepeater(&listeners)->OnTestIterationEnd(
6986 *UnitTest::GetInstance(), 0);
6987 ASSERT_EQ(3U, vec.size());
6988 EXPECT_STREQ("3rd.OnTestIterationEnd", vec[0].c_str());
6989 EXPECT_STREQ("2nd.OnTestIterationEnd", vec[1].c_str());
6990 EXPECT_STREQ("1st.OnTestIterationEnd", vec[2].c_str());
6991}
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:2073
void Append(TestEventListener *listener)
Definition: gtest.cc:5055

◆ TEST() [27/87]

TEST ( EventListenerTest  ,
default_result_printer   
)

Definition at line 7042 of file gtest_unittest.cc.

7042 {
7043 int on_start_counter = 0;
7044 bool is_destroyed = false;
7045 TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);
7046
7047 TestEventListeners listeners;
7048 TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, listener);
7049
7050 EXPECT_EQ(listener, listeners.default_result_printer());
7051
7052 TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(
7053 *UnitTest::GetInstance());
7054
7055 EXPECT_EQ(1, on_start_counter);
7056
7057 // Replacing default_result_printer with something else should remove it
7058 // from the list and destroy it.
7059 TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, nullptr);
7060
7061 EXPECT_TRUE(listeners.default_result_printer() == nullptr);
7062 EXPECT_TRUE(is_destroyed);
7063
7064 // After broadcasting an event the counter is still the same, indicating
7065 // the listener is not in the list anymore.
7066 TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(
7067 *UnitTest::GetInstance());
7068 EXPECT_EQ(1, on_start_counter);
7069}
TestEventListener * default_result_printer() const
Definition: gtest.h:1207

◆ TEST() [28/87]

TEST ( EventListenerTest  ,
default_xml_generator   
)

Definition at line 7101 of file gtest_unittest.cc.

7101 {
7102 int on_start_counter = 0;
7103 bool is_destroyed = false;
7104 TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);
7105
7106 TestEventListeners listeners;
7107 TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, listener);
7108
7109 EXPECT_EQ(listener, listeners.default_xml_generator());
7110
7111 TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(
7112 *UnitTest::GetInstance());
7113
7114 EXPECT_EQ(1, on_start_counter);
7115
7116 // Replacing default_xml_generator with something else should remove it
7117 // from the list and destroy it.
7118 TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, nullptr);
7119
7120 EXPECT_TRUE(listeners.default_xml_generator() == nullptr);
7121 EXPECT_TRUE(is_destroyed);
7122
7123 // After broadcasting an event the counter is still the same, indicating
7124 // the listener is not in the list anymore.
7125 TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(
7126 *UnitTest::GetInstance());
7127 EXPECT_EQ(1, on_start_counter);
7128}
TestEventListener * default_xml_generator() const
Definition: gtest.h:1218

◆ TEST() [29/87]

TEST ( EventListenerTest  ,
RemovingDefaultResultPrinterWorks   
)

Definition at line 7073 of file gtest_unittest.cc.

7073 {
7074 int on_start_counter = 0;
7075 bool is_destroyed = false;
7076 // Although Append passes the ownership of this object to the list,
7077 // the following calls release it, and we need to delete it before the
7078 // test ends.
7079 TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);
7080 {
7081 TestEventListeners listeners;
7082 TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, listener);
7083
7084 EXPECT_EQ(listener, listeners.Release(listener));
7085 EXPECT_TRUE(listeners.default_result_printer() == nullptr);
7086 EXPECT_FALSE(is_destroyed);
7087
7088 // Broadcasting events now should not affect default_result_printer.
7089 TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(
7090 *UnitTest::GetInstance());
7091 EXPECT_EQ(0, on_start_counter);
7092 }
7093 // Destroying the list should not affect the listener now, too.
7094 EXPECT_FALSE(is_destroyed);
7095 delete listener;
7096}
TestEventListener * Release(TestEventListener *listener)
Definition: gtest.cc:5062

◆ TEST() [30/87]

TEST ( EventListenerTest  ,
RemovingDefaultXmlGeneratorWorks   
)

Definition at line 7132 of file gtest_unittest.cc.

7132 {
7133 int on_start_counter = 0;
7134 bool is_destroyed = false;
7135 // Although Append passes the ownership of this object to the list,
7136 // the following calls release it, and we need to delete it before the
7137 // test ends.
7138 TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);
7139 {
7140 TestEventListeners listeners;
7141 TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, listener);
7142
7143 EXPECT_EQ(listener, listeners.Release(listener));
7144 EXPECT_TRUE(listeners.default_xml_generator() == nullptr);
7145 EXPECT_FALSE(is_destroyed);
7146
7147 // Broadcasting events now should not affect default_xml_generator.
7148 TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(
7149 *UnitTest::GetInstance());
7150 EXPECT_EQ(0, on_start_counter);
7151 }
7152 // Destroying the list should not affect the listener now, too.
7153 EXPECT_FALSE(is_destroyed);
7154 delete listener;
7155}

◆ TEST() [31/87]

TEST ( EventListenerTest  ,
SuppressEventForwarding   
)

Definition at line 7016 of file gtest_unittest.cc.

7016 {
7017 int on_start_counter = 0;
7018 TestListener* listener = new TestListener(&on_start_counter, nullptr);
7019
7020 TestEventListeners listeners;
7021 listeners.Append(listener);
7022 ASSERT_TRUE(TestEventListenersAccessor::EventForwardingEnabled(listeners));
7023 TestEventListenersAccessor::SuppressEventForwarding(&listeners);
7024 ASSERT_FALSE(TestEventListenersAccessor::EventForwardingEnabled(listeners));
7025 TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(
7026 *UnitTest::GetInstance());
7027 EXPECT_EQ(0, on_start_counter);
7028}
#define ASSERT_FALSE(condition)
Definition: gtest.h:1994
#define ASSERT_TRUE(condition)
Definition: gtest.h:1990

◆ TEST() [32/87]

TEST ( FlatTuple  ,
Apply   
)

Definition at line 7566 of file gtest_unittest.cc.

7566 {
7568
7569 FlatTuple<int, std::string> tuple{testing::internal::FlatTupleConstructTag{},
7570 5, "Hello"};
7571
7572 // Lambda.
7573 EXPECT_TRUE(tuple.Apply([](int i, const std::string& s) -> bool {
7574 return i == static_cast<int>(s.size());
7575 }));
7576
7577 // Function.
7578 EXPECT_EQ(tuple.Apply(AddIntToString), "Hello5");
7579
7580 // Mutating operations.
7581 tuple.Apply([](int& i, std::string& s) {
7582 ++i;
7583 s += s;
7584 });
7585 EXPECT_EQ(tuple.Get<0>(), 6);
7586 EXPECT_EQ(tuple.Get<1>(), "HelloHello");
7587}

◆ TEST() [33/87]

TEST ( FlatTuple  ,
Basic   
)

Definition at line 7542 of file gtest_unittest.cc.

7542 {
7544
7545 FlatTuple<int, double, const char*> tuple = {};
7546 EXPECT_EQ(0, tuple.Get<0>());
7547 EXPECT_EQ(0.0, tuple.Get<1>());
7548 EXPECT_EQ(nullptr, tuple.Get<2>());
7549
7550 tuple = FlatTuple<int, double, const char*>(
7552 EXPECT_EQ(7, tuple.Get<0>());
7553 EXPECT_EQ(3.2, tuple.Get<1>());
7554 EXPECT_EQ(std::string("Foo"), tuple.Get<2>());
7555
7556 tuple.Get<1>() = 5.1;
7557 EXPECT_EQ(5.1, tuple.Get<1>());
7558}

◆ TEST() [34/87]

TEST ( FlatTuple  ,
ConstructorCalls   
)

Definition at line 7627 of file gtest_unittest.cc.

7627 {
7629
7630 // Default construction.
7632 { FlatTuple<ConstructionCounting> tuple; }
7639
7640 // Copy construction.
7642 {
7644 FlatTuple<ConstructionCounting> tuple{
7646 }
7653
7654 // Move construction.
7656 {
7657 FlatTuple<ConstructionCounting> tuple{
7659 }
7666
7667 // Copy assignment.
7668 // TODO(ofats): it should be testing assignment operator of FlatTuple, not its
7669 // elements
7671 {
7672 FlatTuple<ConstructionCounting> tuple;
7674 tuple.Get<0>() = elem;
7675 }
7682
7683 // Move assignment.
7684 // TODO(ofats): it should be testing assignment operator of FlatTuple, not its
7685 // elements
7687 {
7688 FlatTuple<ConstructionCounting> tuple;
7689 tuple.Get<0>() = ConstructionCounting{};
7690 }
7697
7699}
static int copy_assignment_calls
static int move_assignment_calls

◆ TEST() [35/87]

TEST ( FlatTuple  ,
ManyTypes   
)

Definition at line 7701 of file gtest_unittest.cc.

7701 {
7703
7704 // Instantiate FlatTuple with 257 ints.
7705 // Tests show that we can do it with thousands of elements, but very long
7706 // compile times makes it unusuitable for this test.
7707#define GTEST_FLAT_TUPLE_INT8 int, int, int, int, int, int, int, int,
7708#define GTEST_FLAT_TUPLE_INT16 GTEST_FLAT_TUPLE_INT8 GTEST_FLAT_TUPLE_INT8
7709#define GTEST_FLAT_TUPLE_INT32 GTEST_FLAT_TUPLE_INT16 GTEST_FLAT_TUPLE_INT16
7710#define GTEST_FLAT_TUPLE_INT64 GTEST_FLAT_TUPLE_INT32 GTEST_FLAT_TUPLE_INT32
7711#define GTEST_FLAT_TUPLE_INT128 GTEST_FLAT_TUPLE_INT64 GTEST_FLAT_TUPLE_INT64
7712#define GTEST_FLAT_TUPLE_INT256 GTEST_FLAT_TUPLE_INT128 GTEST_FLAT_TUPLE_INT128
7713
7714 // Let's make sure that we can have a very long list of types without blowing
7715 // up the template instantiation depth.
7716 FlatTuple<GTEST_FLAT_TUPLE_INT256 int> tuple;
7717
7718 tuple.Get<0>() = 7;
7719 tuple.Get<99>() = 17;
7720 tuple.Get<256>() = 1000;
7721 EXPECT_EQ(7, tuple.Get<0>());
7722 EXPECT_EQ(17, tuple.Get<99>());
7723 EXPECT_EQ(1000, tuple.Get<256>());
7724}

◆ TEST() [36/87]

TEST ( GTestReferenceToConstTest  ,
Works   
)

Definition at line 7302 of file gtest_unittest.cc.

7302 {
7303 TestGTestReferenceToConst<const char&, char>();
7304 TestGTestReferenceToConst<const int&, const int>();
7305 TestGTestReferenceToConst<const double&, double>();
7306 TestGTestReferenceToConst<const std::string&, const std::string&>();
7307}

◆ TEST() [37/87]

◆ TEST() [38/87]

TEST ( HasDebugStringAndShortDebugStringTest  ,
ValueIsFalseWhenTypeIsNotAProtocolMessage   
)

◆ TEST() [39/87]

TEST ( HasDebugStringAndShortDebugStringTest  ,
ValueIsTrueWhenTypeHasDebugStringAndShortDebugString   
)

◆ TEST() [40/87]

TEST ( HasFailureTest  ,
ReturnsFalseWhenThereIsNoFailure   
)

Definition at line 6801 of file gtest_unittest.cc.

6801 {
6802 EXPECT_FALSE(HasFailure());
6803}

◆ TEST() [41/87]

TEST ( HasFailureTest  ,
ReturnsTrueWhenThereAreFatalAndNonfatalFailures   
)

Definition at line 6819 of file gtest_unittest.cc.

6819 {
6820 FailFatally();
6821 ADD_FAILURE();
6822 const bool has_failure = HasFailure();
6823 ClearCurrentTestPartResults();
6824 EXPECT_TRUE(has_failure);
6825}
#define ADD_FAILURE()
Definition: gtest.h:1909

◆ TEST() [42/87]

TEST ( HasFailureTest  ,
ReturnsTrueWhenThereIsFatalFailure   
)

Definition at line 6805 of file gtest_unittest.cc.

6805 {
6806 FailFatally();
6807 const bool has_failure = HasFailure();
6808 ClearCurrentTestPartResults();
6809 EXPECT_TRUE(has_failure);
6810}

◆ TEST() [43/87]

TEST ( HasFailureTest  ,
ReturnsTrueWhenThereIsNonfatalFailure   
)

Definition at line 6812 of file gtest_unittest.cc.

6812 {
6813 ADD_FAILURE();
6814 const bool has_failure = HasFailure();
6815 ClearCurrentTestPartResults();
6816 EXPECT_TRUE(has_failure);
6817}

◆ TEST() [44/87]

TEST ( HasFailureTest  ,
WorksOutsideOfTestBody   
)

Definition at line 6830 of file gtest_unittest.cc.

6830 {
6831 EXPECT_FALSE(HasFailureHelper());
6832}

◆ TEST() [45/87]

TEST ( HasFailureTest  ,
WorksOutsideOfTestBody2   
)

Definition at line 6834 of file gtest_unittest.cc.

6834 {
6835 ADD_FAILURE();
6836 const bool has_failure = HasFailureHelper();
6837 ClearCurrentTestPartResults();
6838 EXPECT_TRUE(has_failure);
6839}

◆ TEST() [46/87]

TEST ( HasNonfatalFailureTest  ,
ReturnsFalseWhenThereIsNoFailure   
)

Definition at line 6757 of file gtest_unittest.cc.

6757 {
6758 EXPECT_FALSE(HasNonfatalFailure());
6759}

◆ TEST() [47/87]

TEST ( HasNonfatalFailureTest  ,
ReturnsFalseWhenThereIsOnlyFatalFailure   
)

Definition at line 6763 of file gtest_unittest.cc.

6763 {
6764 FailFatally();
6765 const bool has_nonfatal_failure = HasNonfatalFailure();
6766 ClearCurrentTestPartResults();
6767 EXPECT_FALSE(has_nonfatal_failure);
6768}

◆ TEST() [48/87]

TEST ( HasNonfatalFailureTest  ,
ReturnsTrueWhenThereAreFatalAndNonfatalFailures   
)

Definition at line 6777 of file gtest_unittest.cc.

6777 {
6778 FailFatally();
6779 ADD_FAILURE();
6780 const bool has_nonfatal_failure = HasNonfatalFailure();
6781 ClearCurrentTestPartResults();
6782 EXPECT_TRUE(has_nonfatal_failure);
6783}

◆ TEST() [49/87]

TEST ( HasNonfatalFailureTest  ,
ReturnsTrueWhenThereIsNonfatalFailure   
)

Definition at line 6770 of file gtest_unittest.cc.

6770 {
6771 ADD_FAILURE();
6772 const bool has_nonfatal_failure = HasNonfatalFailure();
6773 ClearCurrentTestPartResults();
6774 EXPECT_TRUE(has_nonfatal_failure);
6775}

◆ TEST() [50/87]

TEST ( HasNonfatalFailureTest  ,
WorksOutsideOfTestBody   
)

Definition at line 6790 of file gtest_unittest.cc.

6790 {
6791 EXPECT_FALSE(HasNonfatalFailureHelper());
6792}

◆ TEST() [51/87]

TEST ( HasNonfatalFailureTest  ,
WorksOutsideOfTestBody2   
)

Definition at line 6794 of file gtest_unittest.cc.

6794 {
6795 ADD_FAILURE();
6796 const bool has_nonfatal_failure = HasNonfatalFailureHelper();
6797 ClearCurrentTestPartResults();
6798 EXPECT_TRUE(has_nonfatal_failure);
6799}

◆ TEST() [52/87]

TEST ( IndexSequence  ,
MakeIndexSequence   
)

Definition at line 7512 of file gtest_unittest.cc.

7512 {
7518 (std::is_same<IndexSequence<0>, MakeIndexSequence<1>::type>::value));
7520 (std::is_same<IndexSequence<0, 1>, MakeIndexSequence<2>::type>::value));
7521 EXPECT_TRUE((
7522 std::is_same<IndexSequence<0, 1, 2>, MakeIndexSequence<3>::type>::value));
7524 (std::is_base_of<IndexSequence<0, 1, 2>, MakeIndexSequence<3>>::value));
7525}
typename MakeIndexSequenceImpl< N >::type MakeIndexSequence

◆ TEST() [53/87]

TEST ( IsContainerTestTest  ,
ConstOnlyContainer   
)

Definition at line 7342 of file gtest_unittest.cc.

7342 {
7343 EXPECT_EQ(sizeof(IsContainer),
7344 sizeof(IsContainerTest<ConstOnlyContainerWithPointerIterator>(0)));
7345 EXPECT_EQ(sizeof(IsContainer),
7346 sizeof(IsContainerTest<ConstOnlyContainerWithClassIterator>(0)));
7347}

◆ TEST() [54/87]

TEST ( IsContainerTestTest  ,
WorksForContainer   
)

Definition at line 7320 of file gtest_unittest.cc.

7320 {
7321 EXPECT_EQ(sizeof(IsContainer),
7322 sizeof(IsContainerTest<std::vector<bool> >(0)));
7323 EXPECT_EQ(sizeof(IsContainer),
7324 sizeof(IsContainerTest<std::map<int, double> >(0)));
7325}
IsContainer IsContainerTest(int)

◆ TEST() [55/87]

TEST ( IsContainerTestTest  ,
WorksForNonContainer   
)

Definition at line 7314 of file gtest_unittest.cc.

7314 {
7315 EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<int>(0)));
7316 EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<char[5]>(0)));
7317 EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<NonContainer>(0)));
7318}

◆ TEST() [56/87]

◆ TEST() [57/87]

TEST ( MessageTest  ,
CanStreamUserTypeInGlobalNameSpace   
)

Definition at line 5221 of file gtest_unittest.cc.

5221 {
5222 Message msg;
5223 Base a(1);
5224
5225 msg << a << &a; // Uses ::operator<<.
5226 EXPECT_STREQ("1(1)", msg.GetString().c_str());
5227}
std::string GetString() const
Definition: gtest.cc:1182

◆ TEST() [58/87]

TEST ( MessageTest  ,
CanStreamUserTypeInUnnamedNameSpace   
)

Definition at line 5246 of file gtest_unittest.cc.

5246 {
5247 Message msg;
5248 MyTypeInUnnamedNameSpace a(1);
5249
5250 msg << a << &a; // Uses <unnamed_namespace>::operator<<.
5251 EXPECT_STREQ("1(1)", msg.GetString().c_str());
5252}

◆ TEST() [59/87]

TEST ( MessageTest  ,
CanStreamUserTypeInUserNameSpace   
)

Definition at line 5271 of file gtest_unittest.cc.

5271 {
5272 Message msg;
5274
5275 msg << a << &a; // Uses namespace1::operator<<.
5276 EXPECT_STREQ("1(1)", msg.GetString().c_str());
5277}

◆ TEST() [60/87]

TEST ( MessageTest  ,
CanStreamUserTypeInUserNameSpaceWithStreamOperatorInGlobal   
)

Definition at line 5296 of file gtest_unittest.cc.

5296 {
5297 Message msg;
5299
5300 msg << a << &a; // Uses ::operator<<.
5301 EXPECT_STREQ("1(1)", msg.GetString().c_str());
5302}

◆ TEST() [61/87]

TEST ( MessageTest  ,
NullPointers   
)

Definition at line 5305 of file gtest_unittest.cc.

5305 {
5306 Message msg;
5307 char* const p1 = nullptr;
5308 unsigned char* const p2 = nullptr;
5309 int* p3 = nullptr;
5310 double* p4 = nullptr;
5311 bool* p5 = nullptr;
5312 Message* p6 = nullptr;
5313
5314 msg << p1 << p2 << p3 << p4 << p5 << p6;
5315 ASSERT_STREQ("(null)(null)(null)(null)(null)(null)",
5316 msg.GetString().c_str());
5317}
#define ASSERT_STREQ(s1, s2)
Definition: gtest.h:2121

◆ TEST() [62/87]

TEST ( MessageTest  ,
WideStrings   
)

Definition at line 5320 of file gtest_unittest.cc.

5320 {
5321 // Streams a NULL of type const wchar_t*.
5322 const wchar_t* const_wstr = nullptr;
5323 EXPECT_STREQ("(null)",
5324 (Message() << const_wstr).GetString().c_str());
5325
5326 // Streams a NULL of type wchar_t*.
5327 wchar_t* wstr = nullptr;
5328 EXPECT_STREQ("(null)",
5329 (Message() << wstr).GetString().c_str());
5330
5331 // Streams a non-NULL of type const wchar_t*.
5332 const_wstr = L"abc\x8119";
5333 EXPECT_STREQ("abc\xe8\x84\x99",
5334 (Message() << const_wstr).GetString().c_str());
5335
5336 // Streams a non-NULL of type wchar_t*.
5337 wstr = const_cast<wchar_t*>(const_wstr);
5338 EXPECT_STREQ("abc\xe8\x84\x99",
5339 (Message() << wstr).GetString().c_str());
5340}

◆ TEST() [63/87]

TEST ( NativeArrayTest  ,
ConstructorFromArrayWorks   
)

Definition at line 7448 of file gtest_unittest.cc.

7448 {
7449 const int a[3] = { 0, 1, 2 };
7451 EXPECT_EQ(3U, na.size());
7452 EXPECT_EQ(a, na.begin());
7453}

◆ TEST() [64/87]

TEST ( NativeArrayTest  ,
CreatesAndDeletesCopyOfArrayWhenAskedTo   
)

Definition at line 7455 of file gtest_unittest.cc.

7455 {
7456 typedef int Array[2];
7457 Array* a = new Array[1];
7458 (*a)[0] = 0;
7459 (*a)[1] = 1;
7461 EXPECT_NE(*a, na.begin());
7462 delete[] a;
7463 EXPECT_EQ(0, na.begin()[0]);
7464 EXPECT_EQ(1, na.begin()[1]);
7465
7466 // We rely on the heap checker to verify that na deletes the copy of
7467 // array.
7468}
#define EXPECT_NE(val1, val2)
Definition: gtest.h:2045

◆ TEST() [65/87]

TEST ( NativeArrayTest  ,
MethodsWork   
)

Definition at line 7478 of file gtest_unittest.cc.

7478 {
7479 const int a[3] = { 0, 1, 2 };
7481 ASSERT_EQ(3U, na.size());
7482 EXPECT_EQ(3, na.end() - na.begin());
7483
7485 EXPECT_EQ(0, *it);
7486 ++it;
7487 EXPECT_EQ(1, *it);
7488 it++;
7489 EXPECT_EQ(2, *it);
7490 ++it;
7491 EXPECT_EQ(na.end(), it);
7492
7493 EXPECT_TRUE(na == na);
7494
7496 EXPECT_TRUE(na == na2);
7497
7498 const int b1[3] = { 0, 1, 1 };
7499 const int b2[4] = { 0, 1, 2, 3 };
7502}
const_iterator begin() const

◆ TEST() [66/87]

TEST ( NativeArrayTest  ,
TypeMembersAreCorrect   
)

Definition at line 7470 of file gtest_unittest.cc.

7470 {
7471 StaticAssertTypeEq<char, NativeArray<char>::value_type>();
7472 StaticAssertTypeEq<int[2], NativeArray<int[2]>::value_type>();
7473
7474 StaticAssertTypeEq<const char*, NativeArray<char>::const_iterator>();
7476}
constexpr bool StaticAssertTypeEq() noexcept
Definition: gtest.h:2316

◆ TEST() [67/87]

TEST ( NativeArrayTest  ,
WorksForTwoDimensionalArray   
)

Definition at line 7504 of file gtest_unittest.cc.

7504 {
7505 const char a[2][3] = { "hi", "lo" };
7507 ASSERT_EQ(2U, na.size());
7508 EXPECT_EQ(a, na.begin());
7509}

◆ TEST() [68/87]

TEST ( RegisterTest  ,
WasRegistered   
)

Definition at line 7769 of file gtest_unittest.cc.

7769 {
7770 auto* unittest = testing::UnitTest::GetInstance();
7771 for (int i = 0; i < unittest->total_test_suite_count(); ++i) {
7772 auto* tests = unittest->GetTestSuite(i);
7773 if (tests->name() != std::string("DynamicUnitTestFixture")) continue;
7774 for (int j = 0; j < tests->total_test_count(); ++j) {
7775 if (tests->GetTestInfo(j)->name() != std::string("DynamicTest")) continue;
7776 // Found it.
7777 EXPECT_STREQ(tests->GetTestInfo(j)->value_param(), "VALUE");
7778 EXPECT_STREQ(tests->GetTestInfo(j)->type_param(), "TYPE");
7779 return;
7780 }
7781 }
7782
7783 FAIL() << "Didn't find the test!";
7784}
#define FAIL()
Definition: gtest.h:1928

◆ TEST() [69/87]

TEST ( RemoveReferenceToConstTest  ,
Works   
)

Definition at line 7286 of file gtest_unittest.cc.

7286 {
7287 TestGTestRemoveReferenceAndConst<int, int>();
7288 TestGTestRemoveReferenceAndConst<double, double&>();
7289 TestGTestRemoveReferenceAndConst<char, const char>();
7290 TestGTestRemoveReferenceAndConst<char, const char&>();
7291 TestGTestRemoveReferenceAndConst<const char*, const char*>();
7292}

◆ TEST() [70/87]

TEST ( SkipPrefixTest  ,
DoesNotSkipWhenPrefixDoesNotMatch   
)

Definition at line 7740 of file gtest_unittest.cc.

7740 {
7741 const char* const str = "world";
7742
7743 const char* p = str;
7744 EXPECT_FALSE(SkipPrefix("W", &p));
7745 EXPECT_EQ(str, p);
7746
7747 p = str;
7748 EXPECT_FALSE(SkipPrefix("world!", &p));
7749 EXPECT_EQ(str, p);
7750}
const char * p
GTEST_API_ bool SkipPrefix(const char *prefix, const char **pstr)
Definition: gtest.cc:6253

◆ TEST() [71/87]

TEST ( SkipPrefixTest  ,
SkipsWhenPrefixMatches   
)

Definition at line 7728 of file gtest_unittest.cc.

7728 {
7729 const char* const str = "hello";
7730
7731 const char* p = str;
7732 EXPECT_TRUE(SkipPrefix("", &p));
7733 EXPECT_EQ(str, p);
7734
7735 p = str;
7736 EXPECT_TRUE(SkipPrefix("hell", &p));
7737 EXPECT_EQ(str + 4, p);
7738}

◆ TEST() [72/87]

TEST ( StaticAssertTypeEqTest  ,
CompilesForEqualTypes   
)

Definition at line 6752 of file gtest_unittest.cc.

6752 {
6753 StaticAssertTypeEq<int, IntAlias>();
6754 StaticAssertTypeEq<int*, IntAlias*>();
6755}

◆ TEST() [73/87]

TEST ( StaticAssertTypeEqTest  ,
WorksInClass   
)

◆ TEST() [74/87]

TEST ( StreamingAssertionsTest  ,
FloatingPointEquals   
)

Definition at line 6565 of file gtest_unittest.cc.

6565 {
6566 EXPECT_FLOAT_EQ(1.0, 1.0) << "unexpected failure";
6567 ASSERT_FLOAT_EQ(1.0, 1.0) << "unexpected failure";
6568 EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(0.0, 1.0) << "expected failure",
6569 "expected failure");
6570 EXPECT_FATAL_FAILURE(ASSERT_FLOAT_EQ(0.0, 1.0) << "expected failure",
6571 "expected failure");
6572}
#define ASSERT_FLOAT_EQ(val1, val2)
Definition: gtest.h:2152
#define EXPECT_FLOAT_EQ(val1, val2)
Definition: gtest.h:2144
#define EXPECT_NONFATAL_FAILURE(statement, substr)

◆ TEST() [75/87]

TEST ( StreamingAssertionsTest  ,
IntegerEquals   
)

Definition at line 6511 of file gtest_unittest.cc.

6511 {
6512 EXPECT_EQ(1, 1) << "unexpected failure";
6513 ASSERT_EQ(1, 1) << "unexpected failure";
6514 EXPECT_NONFATAL_FAILURE(EXPECT_EQ(1, 2) << "expected failure",
6515 "expected failure");
6516 EXPECT_FATAL_FAILURE(ASSERT_EQ(1, 2) << "expected failure",
6517 "expected failure");
6518}

◆ TEST() [76/87]

TEST ( StreamingAssertionsTest  ,
IntegerLessThan   
)

Definition at line 6520 of file gtest_unittest.cc.

6520 {
6521 EXPECT_LT(1, 2) << "unexpected failure";
6522 ASSERT_LT(1, 2) << "unexpected failure";
6523 EXPECT_NONFATAL_FAILURE(EXPECT_LT(2, 1) << "expected failure",
6524 "expected failure");
6525 EXPECT_FATAL_FAILURE(ASSERT_LT(2, 1) << "expected failure",
6526 "expected failure");
6527}
#define EXPECT_LT(val1, val2)
Definition: gtest.h:2049
#define ASSERT_LT(val1, val2)
Definition: gtest.h:2085

◆ TEST() [77/87]

TEST ( StreamingAssertionsTest  ,
StringNotEqualIgnoringCase   
)

Definition at line 6556 of file gtest_unittest.cc.

6556 {
6557 EXPECT_STRCASENE("foo", "bar") << "unexpected failure";
6558 ASSERT_STRCASENE("foo", "bar") << "unexpected failure";
6559 EXPECT_NONFATAL_FAILURE(EXPECT_STRCASENE("foo", "FOO") << "expected failure",
6560 "expected failure");
6561 EXPECT_FATAL_FAILURE(ASSERT_STRCASENE("bar", "BAR") << "expected failure",
6562 "expected failure");
6563}
#define EXPECT_STRCASENE(s1, s2)
Definition: gtest.h:2118
#define ASSERT_STRCASENE(s1, s2)
Definition: gtest.h:2127

◆ TEST() [78/87]

TEST ( StreamingAssertionsTest  ,
StringsEqual   
)

Definition at line 6529 of file gtest_unittest.cc.

6529 {
6530 EXPECT_STREQ("foo", "foo") << "unexpected failure";
6531 ASSERT_STREQ("foo", "foo") << "unexpected failure";
6532 EXPECT_NONFATAL_FAILURE(EXPECT_STREQ("foo", "bar") << "expected failure",
6533 "expected failure");
6534 EXPECT_FATAL_FAILURE(ASSERT_STREQ("foo", "bar") << "expected failure",
6535 "expected failure");
6536}

◆ TEST() [79/87]

TEST ( StreamingAssertionsTest  ,
StringsEqualIgnoringCase   
)

Definition at line 6547 of file gtest_unittest.cc.

6547 {
6548 EXPECT_STRCASEEQ("foo", "FOO") << "unexpected failure";
6549 ASSERT_STRCASEEQ("foo", "FOO") << "unexpected failure";
6550 EXPECT_NONFATAL_FAILURE(EXPECT_STRCASEEQ("foo", "bar") << "expected failure",
6551 "expected failure");
6552 EXPECT_FATAL_FAILURE(ASSERT_STRCASEEQ("foo", "bar") << "expected failure",
6553 "expected failure");
6554}
#define ASSERT_STRCASEEQ(s1, s2)
Definition: gtest.h:2125
#define EXPECT_STRCASEEQ(s1, s2)
Definition: gtest.h:2116

◆ TEST() [80/87]

TEST ( StreamingAssertionsTest  ,
StringsNotEqual   
)

Definition at line 6538 of file gtest_unittest.cc.

6538 {
6539 EXPECT_STRNE("foo", "bar") << "unexpected failure";
6540 ASSERT_STRNE("foo", "bar") << "unexpected failure";
6541 EXPECT_NONFATAL_FAILURE(EXPECT_STRNE("foo", "foo") << "expected failure",
6542 "expected failure");
6543 EXPECT_FATAL_FAILURE(ASSERT_STRNE("foo", "foo") << "expected failure",
6544 "expected failure");
6545}
#define ASSERT_STRNE(s1, s2)
Definition: gtest.h:2123
#define EXPECT_STRNE(s1, s2)
Definition: gtest.h:2114

◆ TEST() [81/87]

TEST ( StreamingAssertionsTest  ,
Truth   
)

Definition at line 6488 of file gtest_unittest.cc.

6488 {
6489 EXPECT_TRUE(true) << "unexpected failure";
6490 ASSERT_TRUE(true) << "unexpected failure";
6491 EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(false) << "expected failure",
6492 "expected failure");
6493 EXPECT_FATAL_FAILURE(ASSERT_TRUE(false) << "expected failure",
6494 "expected failure");
6495}

◆ TEST() [82/87]

TEST ( StreamingAssertionsTest  ,
Truth2   
)

Definition at line 6497 of file gtest_unittest.cc.

6497 {
6498 EXPECT_FALSE(false) << "unexpected failure";
6499 ASSERT_FALSE(false) << "unexpected failure";
6500 EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(true) << "expected failure",
6501 "expected failure");
6502 EXPECT_FATAL_FAILURE(ASSERT_FALSE(true) << "expected failure",
6503 "expected failure");
6504}

◆ TEST() [83/87]

TEST ( StreamingAssertionsTest  ,
Unconditional   
)

Definition at line 6475 of file gtest_unittest.cc.

6475 {
6476 SUCCEED() << "expected success";
6477 EXPECT_NONFATAL_FAILURE(ADD_FAILURE() << "expected failure",
6478 "expected failure");
6479 EXPECT_FATAL_FAILURE(FAIL() << "expected failure",
6480 "expected failure");
6481}
#define SUCCEED()
Definition: gtest.h:1937

◆ TEST() [84/87]

TEST ( TestEventListenersTest  ,
Append   
)

Definition at line 6900 of file gtest_unittest.cc.

6900 {
6901 int on_start_counter = 0;
6902 bool is_destroyed = false;
6903 TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);
6904 {
6905 TestEventListeners listeners;
6906 listeners.Append(listener);
6907 TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(
6908 *UnitTest::GetInstance());
6909 EXPECT_EQ(1, on_start_counter);
6910 }
6911 EXPECT_TRUE(is_destroyed);
6912}

◆ TEST() [85/87]

TEST ( TestEventListenersTest  ,
ConstructionWorks   
)

Definition at line 6864 of file gtest_unittest.cc.

6864 {
6865 TestEventListeners listeners;
6866
6867 EXPECT_TRUE(TestEventListenersAccessor::GetRepeater(&listeners) != nullptr);
6868 EXPECT_TRUE(listeners.default_result_printer() == nullptr);
6869 EXPECT_TRUE(listeners.default_xml_generator() == nullptr);
6870}

◆ TEST() [86/87]

TEST ( TestEventListenersTest  ,
DestructionWorks   
)

Definition at line 6874 of file gtest_unittest.cc.

6874 {
6875 bool default_result_printer_is_destroyed = false;
6876 bool default_xml_printer_is_destroyed = false;
6877 bool extra_listener_is_destroyed = false;
6878 TestListener* default_result_printer =
6879 new TestListener(nullptr, &default_result_printer_is_destroyed);
6880 TestListener* default_xml_printer =
6881 new TestListener(nullptr, &default_xml_printer_is_destroyed);
6882 TestListener* extra_listener =
6883 new TestListener(nullptr, &extra_listener_is_destroyed);
6884
6885 {
6886 TestEventListeners listeners;
6887 TestEventListenersAccessor::SetDefaultResultPrinter(&listeners,
6888 default_result_printer);
6889 TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners,
6890 default_xml_printer);
6891 listeners.Append(extra_listener);
6892 }
6893 EXPECT_TRUE(default_result_printer_is_destroyed);
6894 EXPECT_TRUE(default_xml_printer_is_destroyed);
6895 EXPECT_TRUE(extra_listener_is_destroyed);
6896}

◆ TEST() [87/87]

TEST ( TestEventListenersTest  ,
Release   
)

Definition at line 6995 of file gtest_unittest.cc.

6995 {
6996 int on_start_counter = 0;
6997 bool is_destroyed = false;
6998 // Although Append passes the ownership of this object to the list,
6999 // the following calls release it, and we need to delete it before the
7000 // test ends.
7001 TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);
7002 {
7003 TestEventListeners listeners;
7004 listeners.Append(listener);
7005 EXPECT_EQ(listener, listeners.Release(listener));
7006 TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(
7007 *UnitTest::GetInstance());
7008 EXPECT_TRUE(listeners.Release(listener) == nullptr);
7009 }
7010 EXPECT_EQ(0, on_start_counter);
7011 EXPECT_FALSE(is_destroyed);
7012 delete listener;
7013}

◆ TestGTestReferenceToConst()

template<typename T1 , typename T2 >
void TestGTestReferenceToConst ( )

Definition at line 7297 of file gtest_unittest.cc.

7297 {
7298 static_assert(std::is_same<T1, GTEST_REFERENCE_TO_CONST_(T2)>::value,
7299 "GTEST_REFERENCE_TO_CONST_ failed.");
7300}
@ T1
Definition: rune.c:27
@ T2
Definition: rune.c:29
#define GTEST_REFERENCE_TO_CONST_(T)
Definition: gtest-port.h:1043

◆ TestGTestRemoveReferenceAndConst()

template<typename T1 , typename T2 >
void TestGTestRemoveReferenceAndConst ( )

Definition at line 7281 of file gtest_unittest.cc.

7281 {
7282 static_assert(std::is_same<T1, GTEST_REMOVE_REFERENCE_AND_CONST_(T2)>::value,
7283 "GTEST_REMOVE_REFERENCE_AND_CONST_ failed.");
7284}
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T)

Variable Documentation

◆ dynamic_test

auto* dynamic_test
Initial value:
"DynamicUnitTestFixture", "DynamicTest", "TYPE", "VALUE", __FILE__,
__LINE__, []() -> DynamicUnitTestFixture* { return new DynamicTest; })
TestInfo * RegisterTest(const char *test_suite_name, const char *test_name, const char *type_param, const char *value_param, const char *file, int line, Factory factory)
Definition: gtest.h:2455

Definition at line 7765 of file gtest_unittest.cc.