diff options
author | Abseil Team <absl-team@google.com> | 2018-10-04 22:28:05 (GMT) |
---|---|---|
committer | Gennadiy Civil <misterg@google.com> | 2018-10-05 16:54:14 (GMT) |
commit | 4bb49ed640e34e23187ad7ea689693ef9927033f (patch) | |
tree | 31bfca77d3e46134fddebe28118bcba3af711e45 /googletest/test | |
parent | f13bbe2992d188e834339abe6f715b2b2f840a77 (diff) | |
download | googletest-4bb49ed640e34e23187ad7ea689693ef9927033f.zip googletest-4bb49ed640e34e23187ad7ea689693ef9927033f.tar.gz googletest-4bb49ed640e34e23187ad7ea689693ef9927033f.tar.bz2 |
Apply clang-tidy modernize-use-nullptr to googletest.
Now that googletest has moved to C++11, it should no longer
use NULL or 0 for the null pointer. This patch converts all
such usages to nullptr using clang-tidy.
This prevents LLVM from issuing -Wzero-as-null-pointer-constant
warnings.
PiperOrigin-RevId: 215814400
Diffstat (limited to 'googletest/test')
-rw-r--r-- | googletest/test/googletest-catch-exceptions-test_.cc | 2 | ||||
-rw-r--r-- | googletest/test/googletest-death-test-test.cc | 21 | ||||
-rw-r--r-- | googletest/test/googletest-linked-ptr-test.cc | 20 | ||||
-rw-r--r-- | googletest/test/googletest-listener-test.cc | 2 | ||||
-rw-r--r-- | googletest/test/googletest-message-test.cc | 4 | ||||
-rw-r--r-- | googletest/test/googletest-output-test_.cc | 11 | ||||
-rw-r--r-- | googletest/test/googletest-port-test.cc | 26 | ||||
-rw-r--r-- | googletest/test/googletest-printers-test.cc | 28 | ||||
-rw-r--r-- | googletest/test/googletest-throw-on-failure-test_.cc | 2 | ||||
-rw-r--r-- | googletest/test/googletest-tuple-test.cc | 2 | ||||
-rw-r--r-- | googletest/test/gtest-typed-test_test.cc | 8 | ||||
-rw-r--r-- | googletest/test/gtest-unittest-api_test.cc | 12 | ||||
-rw-r--r-- | googletest/test/gtest_assert_by_exception_test.cc | 3 | ||||
-rw-r--r-- | googletest/test/gtest_premature_exit_test.cc | 4 | ||||
-rw-r--r-- | googletest/test/gtest_stress_test.cc | 2 | ||||
-rw-r--r-- | googletest/test/gtest_throw_on_failure_ex_test.cc | 3 | ||||
-rw-r--r-- | googletest/test/gtest_unittest.cc | 693 |
17 files changed, 276 insertions, 567 deletions
diff --git a/googletest/test/googletest-catch-exceptions-test_.cc b/googletest/test/googletest-catch-exceptions-test_.cc index f1708a9..75d1d2d 100644 --- a/googletest/test/googletest-catch-exceptions-test_.cc +++ b/googletest/test/googletest-catch-exceptions-test_.cc @@ -277,7 +277,7 @@ TEST(CxxExceptionTest, ThrowsNonStdCxxException) { // ones. void TerminateHandler() { fprintf(stderr, "%s\n", "Unhandled C++ exception terminating the program."); - fflush(NULL); + fflush(nullptr); exit(3); } diff --git a/googletest/test/googletest-death-test-test.cc b/googletest/test/googletest-death-test-test.cc index c0c3026..a81702c 100644 --- a/googletest/test/googletest-death-test-test.cc +++ b/googletest/test/googletest-death-test-test.cc @@ -370,13 +370,13 @@ void SetSigprofActionAndTimer() { timer.it_interval.tv_sec = 0; timer.it_interval.tv_usec = 1; timer.it_value = timer.it_interval; - ASSERT_EQ(0, setitimer(ITIMER_PROF, &timer, NULL)); + ASSERT_EQ(0, setitimer(ITIMER_PROF, &timer, nullptr)); struct sigaction signal_action; memset(&signal_action, 0, sizeof(signal_action)); sigemptyset(&signal_action.sa_mask); signal_action.sa_sigaction = SigprofAction; signal_action.sa_flags = SA_RESTART | SA_SIGINFO; - ASSERT_EQ(0, sigaction(SIGPROF, &signal_action, NULL)); + ASSERT_EQ(0, sigaction(SIGPROF, &signal_action, nullptr)); } // Disables ITIMER_PROF timer and ignores SIGPROF signal. @@ -385,7 +385,7 @@ void DisableSigprofActionAndTimer(struct sigaction* old_signal_action) { timer.it_interval.tv_sec = 0; timer.it_interval.tv_usec = 0; timer.it_value = timer.it_interval; - ASSERT_EQ(0, setitimer(ITIMER_PROF, &timer, NULL)); + ASSERT_EQ(0, setitimer(ITIMER_PROF, &timer, nullptr)); struct sigaction signal_action; memset(&signal_action, 0, sizeof(signal_action)); sigemptyset(&signal_action.sa_mask); @@ -466,7 +466,7 @@ TEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) { if (!testing::GTEST_FLAG(death_test_use_fork)) { testing::GTEST_FLAG(death_test_style) = "threadsafe"; pthread_flag = false; - ASSERT_EQ(0, pthread_atfork(&SetPthreadFlag, NULL, NULL)); + ASSERT_EQ(0, pthread_atfork(&SetPthreadFlag, nullptr, nullptr)); ASSERT_DEATH(_exit(1), ""); ASSERT_FALSE(pthread_flag); } @@ -1001,7 +1001,7 @@ bool MockDeathTestFactory::Create(const char* /*statement*/, if (create_) { *test = new MockDeathTest(this, role_, status_, passed_); } else { - *test = NULL; + *test = nullptr; } return true; } @@ -1021,9 +1021,9 @@ class MacroLogicDeathTest : public testing::Test { static void TearDownTestCase() { delete replacer_; - replacer_ = NULL; + replacer_ = nullptr; delete factory_; - factory_ = NULL; + factory_ = nullptr; } // Runs a death test that breaks the rules by returning. Such a death @@ -1037,10 +1037,9 @@ class MacroLogicDeathTest : public testing::Test { } }; -testing::internal::ReplaceDeathTestFactory* MacroLogicDeathTest::replacer_ - = NULL; -MockDeathTestFactory* MacroLogicDeathTest::factory_ = NULL; - +testing::internal::ReplaceDeathTestFactory* MacroLogicDeathTest::replacer_ = + nullptr; +MockDeathTestFactory* MacroLogicDeathTest::factory_ = nullptr; // Test that nothing happens when the factory doesn't return a DeathTest: TEST_F(MacroLogicDeathTest, NothingHappens) { diff --git a/googletest/test/googletest-linked-ptr-test.cc b/googletest/test/googletest-linked-ptr-test.cc index fa00f34..f680253 100644 --- a/googletest/test/googletest-linked-ptr-test.cc +++ b/googletest/test/googletest-linked-ptr-test.cc @@ -38,7 +38,7 @@ using testing::Message; using testing::internal::linked_ptr; int num; -Message* history = NULL; +Message* history = nullptr; // Class which tracks allocation/deallocation class A { @@ -67,7 +67,7 @@ class LinkedPtrTest : public testing::Test { virtual ~LinkedPtrTest() { delete history; - history = NULL; + history = nullptr; } }; @@ -77,18 +77,18 @@ TEST_F(LinkedPtrTest, GeneralTest) { // Use explicit function call notation here to suppress self-assign warning. a0.operator=(a0); a1 = a2; - ASSERT_EQ(a0.get(), static_cast<A*>(NULL)); - ASSERT_EQ(a1.get(), static_cast<A*>(NULL)); - ASSERT_EQ(a2.get(), static_cast<A*>(NULL)); - ASSERT_TRUE(a0 == NULL); - ASSERT_TRUE(a1 == NULL); - ASSERT_TRUE(a2 == NULL); + ASSERT_EQ(a0.get(), static_cast<A*>(nullptr)); + ASSERT_EQ(a1.get(), static_cast<A*>(nullptr)); + ASSERT_EQ(a2.get(), static_cast<A*>(nullptr)); + ASSERT_TRUE(a0 == nullptr); + ASSERT_TRUE(a1 == nullptr); + ASSERT_TRUE(a2 == nullptr); { linked_ptr<A> a3(new A); a0 = a3; ASSERT_TRUE(a0 == a3); - ASSERT_TRUE(a0 != NULL); + ASSERT_TRUE(a0 != nullptr); ASSERT_TRUE(a0.get() == a3); ASSERT_TRUE(a0 == a3.get()); linked_ptr<A> a4(a0); @@ -101,7 +101,7 @@ TEST_F(LinkedPtrTest, GeneralTest) { linked_ptr<A> a6(b0); ASSERT_TRUE(b0 == a6); ASSERT_TRUE(a6 == b0); - ASSERT_TRUE(b0 != NULL); + ASSERT_TRUE(b0 != nullptr); a5 = b0; a5 = b0; a3->Use(); diff --git a/googletest/test/googletest-listener-test.cc b/googletest/test/googletest-listener-test.cc index 8355597..a4f42eb 100644 --- a/googletest/test/googletest-listener-test.cc +++ b/googletest/test/googletest-listener-test.cc @@ -47,7 +47,7 @@ using ::testing::TestPartResult; using ::testing::UnitTest; // Used by tests to register their events. -std::vector<std::string>* g_events = NULL; +std::vector<std::string>* g_events = nullptr; namespace testing { namespace internal { diff --git a/googletest/test/googletest-message-test.cc b/googletest/test/googletest-message-test.cc index c644585..962d519 100644 --- a/googletest/test/googletest-message-test.cc +++ b/googletest/test/googletest-message-test.cc @@ -85,7 +85,7 @@ TEST(MessageTest, StreamsPointer) { // Tests streaming a NULL non-char pointer. TEST(MessageTest, StreamsNullPointer) { - int* p = NULL; + int* p = nullptr; EXPECT_EQ("(null)", (Message() << p).GetString()); } @@ -96,7 +96,7 @@ TEST(MessageTest, StreamsCString) { // Tests streaming a NULL C string. TEST(MessageTest, StreamsNullCString) { - char* p = NULL; + char* p = nullptr; EXPECT_EQ("(null)", (Message() << p).GetString()); } diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc index f6525ec..a24dfce 100644 --- a/googletest/test/googletest-output-test_.cc +++ b/googletest/test/googletest-output-test_.cc @@ -174,7 +174,7 @@ TEST(SCOPED_TRACETest, AcceptedValues) { SCOPED_TRACE("literal string"); SCOPED_TRACE(std::string("std::string")); SCOPED_TRACE(1337); // streamable type - const char* null_value = NULL; + const char* null_value = nullptr; SCOPED_TRACE(null_value); ADD_FAILURE() << "Just checking that all these values work fine."; @@ -306,9 +306,8 @@ TEST(SCOPED_TRACETest, WorksConcurrently) { printf("(expecting 6 failures)\n"); CheckPoints check_points; - ThreadWithParam<CheckPoints*> thread(&ThreadWithScopedTrace, - &check_points, - NULL); + ThreadWithParam<CheckPoints*> thread(&ThreadWithScopedTrace, &check_points, + nullptr); check_points.n1.WaitForNotification(); { @@ -511,7 +510,7 @@ class DeathTestAndMultiThreadsTest : public testing::Test { // Starts a thread and waits for it to begin. virtual void SetUp() { thread_.reset(new ThreadWithParam<SpawnThreadNotifications*>( - &ThreadRoutine, ¬ifications_, NULL)); + &ThreadRoutine, ¬ifications_, nullptr)); notifications_.spawn_thread_started.WaitForNotification(); } // Tells the thread to finish, and reaps it. @@ -966,7 +965,7 @@ TEST_F(ExpectFailureTest, ExpectNonFatalFailure) { class ExpectFailureWithThreadsTest : public ExpectFailureTest { protected: static void AddFailureInOtherThread(FailureMode failure) { - ThreadWithParam<FailureMode> thread(&AddFailure, failure, NULL); + ThreadWithParam<FailureMode> thread(&AddFailure, failure, nullptr); thread.Join(); } }; diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc index 399316f..2de35e0 100644 --- a/googletest/test/googletest-port-test.cc +++ b/googletest/test/googletest-port-test.cc @@ -262,9 +262,9 @@ TEST(FormatFileLocationTest, FormatsFileLocation) { } TEST(FormatFileLocationTest, FormatsUnknownFile) { - EXPECT_PRED_FORMAT2( - IsSubstring, "unknown file", FormatFileLocation(NULL, 42)); - EXPECT_PRED_FORMAT2(IsSubstring, "42", FormatFileLocation(NULL, 42)); + EXPECT_PRED_FORMAT2(IsSubstring, "unknown file", + FormatFileLocation(nullptr, 42)); + EXPECT_PRED_FORMAT2(IsSubstring, "42", FormatFileLocation(nullptr, 42)); } TEST(FormatFileLocationTest, FormatsUknownLine) { @@ -272,7 +272,7 @@ TEST(FormatFileLocationTest, FormatsUknownLine) { } TEST(FormatFileLocationTest, FormatsUknownFileAndLine) { - EXPECT_EQ("unknown file:", FormatFileLocation(NULL, -1)); + EXPECT_EQ("unknown file:", FormatFileLocation(nullptr, -1)); } // Verifies behavior of FormatCompilerIndependentFileLocation. @@ -282,7 +282,7 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsFileLocation) { TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFile) { EXPECT_EQ("unknown file:42", - FormatCompilerIndependentFileLocation(NULL, 42)); + FormatCompilerIndependentFileLocation(nullptr, 42)); } TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownLine) { @@ -290,7 +290,7 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownLine) { } TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFileAndLine) { - EXPECT_EQ("unknown file", FormatCompilerIndependentFileLocation(NULL, -1)); + EXPECT_EQ("unknown file", FormatCompilerIndependentFileLocation(nullptr, -1)); } #if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX || GTEST_OS_FUCHSIA @@ -298,7 +298,7 @@ void* ThreadFunc(void* data) { internal::Mutex* mutex = static_cast<internal::Mutex*>(data); mutex->Lock(); mutex->Unlock(); - return NULL; + return nullptr; } TEST(GetThreadCountTest, ReturnsCorrectValue) { @@ -965,7 +965,7 @@ TEST(ThreadLocalTest, DefaultConstructorInitializesToDefaultValues) { EXPECT_EQ(0, t1.get()); ThreadLocal<void*> t2; - EXPECT_TRUE(t2.get() == NULL); + EXPECT_TRUE(t2.get() == nullptr); } TEST(ThreadLocalTest, SingleParamConstructorInitializesToParam) { @@ -1015,7 +1015,7 @@ void AddTwo(int* param) { *param += 2; } TEST(ThreadWithParamTest, ConstructorExecutesThreadFunc) { int i = 40; - ThreadWithParam<int*> thread(&AddTwo, &i, NULL); + ThreadWithParam<int*> thread(&AddTwo, &i, nullptr); thread.Join(); EXPECT_EQ(42, i); } @@ -1055,7 +1055,7 @@ class AtomicCounterWithMutex { // functionality as we are testing them here. pthread_mutex_t memory_barrier_mutex; GTEST_CHECK_POSIX_SUCCESS_( - pthread_mutex_init(&memory_barrier_mutex, NULL)); + pthread_mutex_init(&memory_barrier_mutex, nullptr)); GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&memory_barrier_mutex)); SleepMilliseconds(random_.Generate(30)); @@ -1118,7 +1118,7 @@ TEST(MutexTest, OnlyOneThreadCanLockAtATime) { template <typename T> void RunFromThread(void (func)(T), T param) { - ThreadWithParam<T> thread(func, param, NULL); + ThreadWithParam<T> thread(func, param, nullptr); thread.Join(); } @@ -1250,8 +1250,8 @@ TEST(ThreadLocalTest, DestroysManagedObjectAtThreadExit) { ASSERT_EQ(0U, DestructorCall::List().size()); // This creates another DestructorTracker object in the new thread. - ThreadWithParam<ThreadParam> thread( - &CallThreadLocalGet, &thread_local_tracker, NULL); + ThreadWithParam<ThreadParam> thread(&CallThreadLocalGet, + &thread_local_tracker, nullptr); thread.Join(); // The thread has exited, and we should have a DestroyedTracker diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc index 87fdd28..ce7806c 100644 --- a/googletest/test/googletest-printers-test.cc +++ b/googletest/test/googletest-printers-test.cc @@ -405,7 +405,7 @@ TEST(PrintCStringTest, NonConst) { // NULL C string. TEST(PrintCStringTest, Null) { - const char* p = NULL; + const char* p = nullptr; EXPECT_EQ("NULL", Print(p)); } @@ -440,7 +440,7 @@ TEST(PrintWideCStringTest, NonConst) { // NULL wide C string. TEST(PrintWideCStringTest, Null) { - const wchar_t* p = NULL; + const wchar_t* p = nullptr; EXPECT_EQ("NULL", Print(p)); } @@ -460,7 +460,7 @@ TEST(PrintWideCStringTest, EscapesProperly) { TEST(PrintCharPointerTest, SignedChar) { signed char* p = reinterpret_cast<signed char*>(0x1234); EXPECT_EQ(PrintPointer(p), Print(p)); - p = NULL; + p = nullptr; EXPECT_EQ("NULL", Print(p)); } @@ -468,7 +468,7 @@ TEST(PrintCharPointerTest, SignedChar) { TEST(PrintCharPointerTest, ConstSignedChar) { signed char* p = reinterpret_cast<signed char*>(0x1234); EXPECT_EQ(PrintPointer(p), Print(p)); - p = NULL; + p = nullptr; EXPECT_EQ("NULL", Print(p)); } @@ -476,7 +476,7 @@ TEST(PrintCharPointerTest, ConstSignedChar) { TEST(PrintCharPointerTest, UnsignedChar) { unsigned char* p = reinterpret_cast<unsigned char*>(0x1234); EXPECT_EQ(PrintPointer(p), Print(p)); - p = NULL; + p = nullptr; EXPECT_EQ("NULL", Print(p)); } @@ -484,7 +484,7 @@ TEST(PrintCharPointerTest, UnsignedChar) { TEST(PrintCharPointerTest, ConstUnsignedChar) { const unsigned char* p = reinterpret_cast<const unsigned char*>(0x1234); EXPECT_EQ(PrintPointer(p), Print(p)); - p = NULL; + p = nullptr; EXPECT_EQ("NULL", Print(p)); } @@ -494,7 +494,7 @@ TEST(PrintCharPointerTest, ConstUnsignedChar) { TEST(PrintPointerToBuiltInTypeTest, Bool) { bool* p = reinterpret_cast<bool*>(0xABCD); EXPECT_EQ(PrintPointer(p), Print(p)); - p = NULL; + p = nullptr; EXPECT_EQ("NULL", Print(p)); } @@ -502,7 +502,7 @@ TEST(PrintPointerToBuiltInTypeTest, Bool) { TEST(PrintPointerToBuiltInTypeTest, Void) { void* p = reinterpret_cast<void*>(0xABCD); EXPECT_EQ(PrintPointer(p), Print(p)); - p = NULL; + p = nullptr; EXPECT_EQ("NULL", Print(p)); } @@ -510,7 +510,7 @@ TEST(PrintPointerToBuiltInTypeTest, Void) { TEST(PrintPointerToBuiltInTypeTest, ConstVoid) { const void* p = reinterpret_cast<const void*>(0xABCD); EXPECT_EQ(PrintPointer(p), Print(p)); - p = NULL; + p = nullptr; EXPECT_EQ("NULL", Print(p)); } @@ -518,7 +518,7 @@ TEST(PrintPointerToBuiltInTypeTest, ConstVoid) { TEST(PrintPointerToPointerTest, IntPointerPointer) { int** p = reinterpret_cast<int**>(0xABCD); EXPECT_EQ(PrintPointer(p), Print(p)); - p = NULL; + p = nullptr; EXPECT_EQ("NULL", Print(p)); } @@ -1398,7 +1398,7 @@ TEST(FormatForComparisonFailureMessageTest, WorksForWCharPointerVsStdWString) { // char array vs pointer TEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsPointer) { char str[] = "hi \"world\""; - char* p = NULL; + char* p = nullptr; EXPECT_EQ(PrintPointer(str), FormatForComparisonFailureMessage(str, p).c_str()); } @@ -1413,7 +1413,7 @@ TEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsCharArray) { // wchar_t array vs pointer TEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsPointer) { wchar_t str[] = L"hi \"world\""; - wchar_t* p = NULL; + wchar_t* p = nullptr; EXPECT_EQ(PrintPointer(str), FormatForComparisonFailureMessage(str, p).c_str()); } @@ -1614,7 +1614,7 @@ TEST(UniversalTersePrintTest, WorksForCString) { UniversalTersePrint(s2, &ss2); EXPECT_EQ("\"abc\"", ss2.str()); - const char* s3 = NULL; + const char* s3 = nullptr; ::std::stringstream ss3; UniversalTersePrint(s3, &ss3); EXPECT_EQ("NULL", ss3.str()); @@ -1644,7 +1644,7 @@ TEST(UniversalPrintTest, WorksForCString) { UniversalPrint(s2, &ss2); EXPECT_EQ(PrintPointer(s2) + " pointing to \"abc\"", std::string(ss2.str())); - const char* s3 = NULL; + const char* s3 = nullptr; ::std::stringstream ss3; UniversalPrint(s3, &ss3); EXPECT_EQ("NULL", ss3.str()); diff --git a/googletest/test/googletest-throw-on-failure-test_.cc b/googletest/test/googletest-throw-on-failure-test_.cc index f9a2c64..83bb914 100644 --- a/googletest/test/googletest-throw-on-failure-test_.cc +++ b/googletest/test/googletest-throw-on-failure-test_.cc @@ -45,7 +45,7 @@ // ones. void TerminateHandler() { fprintf(stderr, "%s\n", "Unhandled C++ exception terminating the program."); - fflush(NULL); + fflush(nullptr); exit(1); } diff --git a/googletest/test/googletest-tuple-test.cc b/googletest/test/googletest-tuple-test.cc index dd82c16..7a5bf42 100644 --- a/googletest/test/googletest-tuple-test.cc +++ b/googletest/test/googletest-tuple-test.cc @@ -158,7 +158,7 @@ TEST(TupleConstructorTest, DefaultConstructorDefaultInitializesEachField) { b3 = a3; EXPECT_EQ(0.0, get<0>(b3)); EXPECT_EQ('\0', get<1>(b3)); - EXPECT_TRUE(get<2>(b3) == NULL); + EXPECT_TRUE(get<2>(b3) == nullptr); tuple<int, int, int, int, int, int, int, int, int, int> a10, b10; b10 = a10; diff --git a/googletest/test/gtest-typed-test_test.cc b/googletest/test/gtest-typed-test_test.cc index 4e39869..95e9e0e 100644 --- a/googletest/test/gtest-typed-test_test.cc +++ b/googletest/test/gtest-typed-test_test.cc @@ -55,7 +55,7 @@ class CommonTest : public Test { static void TearDownTestCase() { delete shared_; - shared_ = NULL; + shared_ = nullptr; } // This 'protected:' is optional. There's no harm in making all @@ -85,7 +85,7 @@ class CommonTest : public Test { }; template <typename T> -T* CommonTest<T>::shared_ = NULL; +T* CommonTest<T>::shared_ = nullptr; // This #ifdef block tests typed tests. #if GTEST_HAS_TYPED_TEST @@ -121,7 +121,7 @@ TYPED_TEST(CommonTest, ValuesAreCorrect) { TYPED_TEST(CommonTest, ValuesAreStillCorrect) { // Static members of the fixture class template can also be visited // via 'this'. - ASSERT_TRUE(this->shared_ != NULL); + ASSERT_TRUE(this->shared_ != nullptr); EXPECT_EQ(5, *this->shared_); // TypeParam can be used to refer to the type parameter. @@ -292,7 +292,7 @@ TYPED_TEST_P(DerivedTest, ValuesAreCorrect) { TYPED_TEST_P(DerivedTest, ValuesAreStillCorrect) { // Static members of the fixture class template can also be visited // via 'this'. - ASSERT_TRUE(this->shared_ != NULL); + ASSERT_TRUE(this->shared_ != nullptr); EXPECT_EQ(5, *this->shared_); EXPECT_EQ(2, this->value_); } diff --git a/googletest/test/gtest-unittest-api_test.cc b/googletest/test/gtest-unittest-api_test.cc index f3ea03a..7898286 100644 --- a/googletest/test/gtest-unittest-api_test.cc +++ b/googletest/test/gtest-unittest-api_test.cc @@ -76,7 +76,7 @@ class UnitTestHelper { if (0 == strcmp(test_case->name(), name)) return test_case; } - return NULL; + return nullptr; } // Returns the array of pointers to all tests in a particular test case @@ -137,7 +137,7 @@ TEST(ApiTest, UnitTestImmutableAccessorsWork) { } AssertionResult IsNull(const char* str) { - if (str != NULL) { + if (str != nullptr) { return testing::AssertionFailure() << "argument is " << str; } return AssertionSuccess(); @@ -145,7 +145,7 @@ AssertionResult IsNull(const char* str) { TEST(ApiTest, TestCaseImmutableAccessorsWork) { const TestCase* test_case = UnitTestHelper::FindTestCase("ApiTest"); - ASSERT_TRUE(test_case != NULL); + ASSERT_TRUE(test_case != nullptr); EXPECT_STREQ("ApiTest", test_case->name()); EXPECT_TRUE(IsNull(test_case->type_param())); @@ -181,11 +181,11 @@ TEST(ApiTest, TestCaseImmutableAccessorsWork) { EXPECT_TRUE(tests[3]->should_run()); delete[] tests; - tests = NULL; + tests = nullptr; #if GTEST_HAS_TYPED_TEST test_case = UnitTestHelper::FindTestCase("TestCaseWithCommentTest/0"); - ASSERT_TRUE(test_case != NULL); + ASSERT_TRUE(test_case != nullptr); EXPECT_STREQ("TestCaseWithCommentTest/0", test_case->name()); EXPECT_STREQ(GetTypeName<int>().c_str(), test_case->type_param()); @@ -208,7 +208,7 @@ TEST(ApiTest, TestCaseImmutableAccessorsWork) { TEST(ApiTest, TestCaseDisabledAccessorsWork) { const TestCase* test_case = UnitTestHelper::FindTestCase("DISABLED_Test"); - ASSERT_TRUE(test_case != NULL); + ASSERT_TRUE(test_case != nullptr); EXPECT_STREQ("DISABLED_Test", test_case->name()); EXPECT_TRUE(IsNull(test_case->type_param())); diff --git a/googletest/test/gtest_assert_by_exception_test.cc b/googletest/test/gtest_assert_by_exception_test.cc index 0eae857..7dfd48c 100644 --- a/googletest/test/gtest_assert_by_exception_test.cc +++ b/googletest/test/gtest_assert_by_exception_test.cc @@ -80,8 +80,7 @@ TEST(Test, Test) { try { AssertFalse(); } catch(const testing::AssertionException& e) { - if (strstr(e.what(), "Expected failure") != NULL) - throw; + if (strstr(e.what(), "Expected failure") != nullptr) throw; printf("%s", "A failed assertion did throw an exception of the right type, " diff --git a/googletest/test/gtest_premature_exit_test.cc b/googletest/test/gtest_premature_exit_test.cc index c1e9305..0920a97 100644 --- a/googletest/test/gtest_premature_exit_test.cc +++ b/googletest/test/gtest_premature_exit_test.cc @@ -56,7 +56,7 @@ class PrematureExitTest : public Test { premature_exit_file_path_ = GetEnv("TEST_PREMATURE_EXIT_FILE"); // Normalize NULL to "" for ease of handling. - if (premature_exit_file_path_ == NULL) { + if (premature_exit_file_path_ == nullptr) { premature_exit_file_path_ = ""; } } @@ -113,7 +113,7 @@ int main(int argc, char **argv) { // Test that the premature-exit file is deleted upon return from // RUN_ALL_TESTS(). const char* const filepath = GetEnv("TEST_PREMATURE_EXIT_FILE"); - if (filepath != NULL && *filepath != '\0') { + if (filepath != nullptr && *filepath != '\0') { if (PrematureExitTest::FileExists(filepath)) { printf( "File %s shouldn't exist after the test program finishes, but does.", diff --git a/googletest/test/gtest_stress_test.cc b/googletest/test/gtest_stress_test.cc index 95ada39..3af1403 100644 --- a/googletest/test/gtest_stress_test.cc +++ b/googletest/test/gtest_stress_test.cc @@ -163,7 +163,7 @@ void FailingThread(bool is_fatal) { } void GenerateFatalFailureInAnotherThread(bool is_fatal) { - ThreadWithParam<bool> thread(&FailingThread, is_fatal, NULL); + ThreadWithParam<bool> thread(&FailingThread, is_fatal, nullptr); thread.Join(); } diff --git a/googletest/test/gtest_throw_on_failure_ex_test.cc b/googletest/test/gtest_throw_on_failure_ex_test.cc index 93f59d4..1d95adb 100644 --- a/googletest/test/gtest_throw_on_failure_ex_test.cc +++ b/googletest/test/gtest_throw_on_failure_ex_test.cc @@ -63,8 +63,7 @@ void TestFailureThrowsRuntimeError() { try { EXPECT_EQ(2, 3) << "Expected failure"; } catch(const std::runtime_error& e) { - if (strstr(e.what(), "Expected failure") != NULL) - return; + if (strstr(e.what(), "Expected failure") != nullptr) return; printf("%s", "A failed assertion did throw an exception of the right type, " diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index c03b367..c6280ca 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -86,8 +86,8 @@ class StreamingListenerTest : public Test { StreamingListenerTest() : fake_sock_writer_(new FakeSocketWriter), streamer_(fake_sock_writer_), - test_info_obj_("FooTest", "Bar", NULL, NULL, - CodeLocation(__FILE__, __LINE__), 0, NULL) {} + test_info_obj_("FooTest", "Bar", nullptr, nullptr, + CodeLocation(__FILE__, __LINE__), nullptr, nullptr) {} protected: std::string* output() { return &(fake_sock_writer_->output_); } @@ -112,13 +112,13 @@ TEST_F(StreamingListenerTest, OnTestIterationEnd) { TEST_F(StreamingListenerTest, OnTestCaseStart) { *output() = ""; - streamer_.OnTestCaseStart(TestCase("FooTest", "Bar", NULL, NULL)); + streamer_.OnTestCaseStart(TestCase("FooTest", "Bar", nullptr, nullptr)); EXPECT_EQ("event=TestCaseStart&name=FooTest\n", *output()); } TEST_F(StreamingListenerTest, OnTestCaseEnd) { *output() = ""; - streamer_.OnTestCaseEnd(TestCase("FooTest", "Bar", NULL, NULL)); + streamer_.OnTestCaseEnd(TestCase("FooTest", "Bar", nullptr, nullptr)); EXPECT_EQ("event=TestCaseEnd&passed=1&elapsed_time=0ms\n", *output()); } @@ -439,7 +439,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { private: virtual void SetUp() { - saved_tz_ = NULL; + saved_tz_ = nullptr; GTEST_DISABLE_MSC_DEPRECATED_PUSH_(/* getenv, strdup: deprecated */) if (getenv("TZ")) @@ -455,7 +455,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { virtual void TearDown() { SetTimeZone(saved_tz_); free(const_cast<char*>(saved_tz_)); - saved_tz_ = NULL; + saved_tz_ = nullptr; } static void SetTimeZone(const char* time_zone) { @@ -521,10 +521,10 @@ TEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsEpochStart) { // Tests that GTEST_IS_NULL_LITERAL_(x) is true when x is a null // pointer literal. TEST(NullLiteralTest, IsTrueForNullLiterals) { - EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(NULL)); - EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0)); - EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0U)); - EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0L)); + EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(nullptr)); + EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(nullptr)); + EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(nullptr)); + EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(nullptr)); } // Tests that GTEST_IS_NULL_LITERAL_(x) is false when x is not a null @@ -533,7 +533,7 @@ TEST(NullLiteralTest, IsFalseForNonNullLiterals) { EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(1)); EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(0.0)); EXPECT_FALSE(GTEST_IS_NULL_LITERAL_('a')); - EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(static_cast<void*>(NULL))); + EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(static_cast<void*>(nullptr))); } # ifdef __BORLANDC__ @@ -1032,11 +1032,11 @@ TEST(StringTest, EndsWithCaseInsensitive) { // C++Builder's preprocessor is buggy; it fails to expand macros that // appear in macro parameters after wide char literals. Provide an alias // for NULL as a workaround. -static const wchar_t* const kNull = NULL; +static const wchar_t* const kNull = nullptr; // Tests String::CaseInsensitiveWideCStringEquals TEST(StringTest, CaseInsensitiveWideCStringEquals) { - EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(NULL, NULL)); + EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(nullptr, nullptr)); EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(kNull, L"")); EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(L"", kNull)); EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(kNull, L"foobar")); @@ -1157,7 +1157,7 @@ class ScopedFakeTestPartResultReporterWithThreadsTest : public ScopedFakeTestPartResultReporterTest { protected: static void AddFailureInOtherThread(FailureMode failure) { - ThreadWithParam<FailureMode> thread(&AddFailure, failure, NULL); + ThreadWithParam<FailureMode> thread(&AddFailure, failure, nullptr); thread.Join(); } }; @@ -1578,7 +1578,7 @@ class GTestFlagSaverTest : public Test { // be called after the last test in this test case is run. static void TearDownTestCase() { delete saver_; - saver_ = NULL; + saver_ = nullptr; } // Verifies that the Google Test flags have their default values, and then @@ -1622,7 +1622,7 @@ class GTestFlagSaverTest : public Test { static GTestFlagSaver* saver_; }; -GTestFlagSaver* GTestFlagSaverTest::saver_ = NULL; +GTestFlagSaver* GTestFlagSaverTest::saver_ = nullptr; // Google Test doesn't guarantee the order of tests. The following two // tests are designed to work regardless of their order. @@ -1947,7 +1947,7 @@ TEST(ShouldRunTestOnShardTest, IsPartitionWhenThereAreFiveShards) { // TEST, TEST_F, RUN_ALL_TESTS TEST(UnitTestTest, CanGetOriginalWorkingDir) { - ASSERT_TRUE(UnitTest::GetInstance()->original_working_dir() != NULL); + ASSERT_TRUE(UnitTest::GetInstance()->original_working_dir() != nullptr); EXPECT_STRNE(UnitTest::GetInstance()->original_working_dir(), ""); } @@ -1969,7 +1969,7 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKey( void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest( const char* key) { const TestInfo* test_info = UnitTest::GetInstance()->current_test_info(); - ASSERT_TRUE(test_info != NULL); + ASSERT_TRUE(test_info != nullptr); ExpectNonFatalFailureRecordingPropertyWithReservedKey(*test_info->result(), key); } @@ -1977,7 +1977,7 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest( void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( const char* key) { const TestCase* test_case = UnitTest::GetInstance()->current_test_case(); - ASSERT_TRUE(test_case != NULL); + ASSERT_TRUE(test_case != nullptr); ExpectNonFatalFailureRecordingPropertyWithReservedKey( test_case->ad_hoc_test_result(), key); } @@ -2010,7 +2010,7 @@ class UnitTestRecordPropertyTest : Test::RecordProperty("test_case_key_1", "1"); const TestCase* test_case = UnitTest::GetInstance()->current_test_case(); - ASSERT_TRUE(test_case != NULL); + ASSERT_TRUE(test_case != nullptr); ASSERT_EQ(1, test_case->ad_hoc_test_result().test_property_count()); EXPECT_STREQ("test_case_key_1", @@ -2454,24 +2454,22 @@ TEST(StringAssertionTest, ASSERT_STREQ) { // Tests ASSERT_STREQ with NULL arguments. TEST(StringAssertionTest, ASSERT_STREQ_Null) { - ASSERT_STREQ(static_cast<const char *>(NULL), NULL); - EXPECT_FATAL_FAILURE(ASSERT_STREQ(NULL, "non-null"), - "non-null"); + ASSERT_STREQ(static_cast<const char*>(nullptr), nullptr); + EXPECT_FATAL_FAILURE(ASSERT_STREQ(nullptr, "non-null"), "non-null"); } // Tests ASSERT_STREQ with NULL arguments. TEST(StringAssertionTest, ASSERT_STREQ_Null2) { - EXPECT_FATAL_FAILURE(ASSERT_STREQ("non-null", NULL), - "non-null"); + EXPECT_FATAL_FAILURE(ASSERT_STREQ("non-null", nullptr), "non-null"); } // Tests ASSERT_STRNE. TEST(StringAssertionTest, ASSERT_STRNE) { ASSERT_STRNE("hi", "Hi"); - ASSERT_STRNE("Hi", NULL); - ASSERT_STRNE(NULL, "Hi"); - ASSERT_STRNE("", NULL); - ASSERT_STRNE(NULL, ""); + ASSERT_STRNE("Hi", nullptr); + ASSERT_STRNE(nullptr, "Hi"); + ASSERT_STRNE("", nullptr); + ASSERT_STRNE(nullptr, ""); ASSERT_STRNE("", "Hi"); ASSERT_STRNE("Hi", ""); EXPECT_FATAL_FAILURE(ASSERT_STRNE("Hi", "Hi"), @@ -2481,7 +2479,7 @@ TEST(StringAssertionTest, ASSERT_STRNE) { // Tests ASSERT_STRCASEEQ. TEST(StringAssertionTest, ASSERT_STRCASEEQ) { ASSERT_STRCASEEQ("hi", "Hi"); - ASSERT_STRCASEEQ(static_cast<const char *>(NULL), NULL); + ASSERT_STRCASEEQ(static_cast<const char*>(nullptr), nullptr); ASSERT_STRCASEEQ("", ""); EXPECT_FATAL_FAILURE(ASSERT_STRCASEEQ("Hi", "hi2"), @@ -2491,10 +2489,10 @@ TEST(StringAssertionTest, ASSERT_STRCASEEQ) { // Tests ASSERT_STRCASENE. TEST(StringAssertionTest, ASSERT_STRCASENE) { ASSERT_STRCASENE("hi1", "Hi2"); - ASSERT_STRCASENE("Hi", NULL); - ASSERT_STRCASENE(NULL, "Hi"); - ASSERT_STRCASENE("", NULL); - ASSERT_STRCASENE(NULL, ""); + ASSERT_STRCASENE("Hi", nullptr); + ASSERT_STRCASENE(nullptr, "Hi"); + ASSERT_STRCASENE("", nullptr); + ASSERT_STRCASENE(nullptr, ""); ASSERT_STRCASENE("", "Hi"); ASSERT_STRCASENE("Hi", ""); EXPECT_FATAL_FAILURE(ASSERT_STRCASENE("Hi", "hi"), @@ -2504,14 +2502,13 @@ TEST(StringAssertionTest, ASSERT_STRCASENE) { // Tests *_STREQ on wide strings. TEST(StringAssertionTest, STREQ_Wide) { // NULL strings. - ASSERT_STREQ(static_cast<const wchar_t *>(NULL), NULL); + ASSERT_STREQ(static_cast<const wchar_t*>(nullptr), nullptr); // Empty strings. ASSERT_STREQ(L"", L""); // Non-null vs NULL. - EXPECT_NONFATAL_FAILURE(EXPECT_STREQ(L"non-null", NULL), - "non-null"); + EXPECT_NONFATAL_FAILURE(EXPECT_STREQ(L"non-null", nullptr), "non-null"); // Equal strings. EXPECT_STREQ(L"Hi", L"Hi"); @@ -2533,16 +2530,18 @@ TEST(StringAssertionTest, STREQ_Wide) { // Tests *_STRNE on wide strings. TEST(StringAssertionTest, STRNE_Wide) { // NULL strings. - EXPECT_NONFATAL_FAILURE({ // NOLINT - EXPECT_STRNE(static_cast<const wchar_t *>(NULL), NULL); - }, ""); + EXPECT_NONFATAL_FAILURE( + { // NOLINT + EXPECT_STRNE(static_cast<const wchar_t*>(nullptr), nullptr); + }, + ""); // Empty strings. EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(L"", L""), "L\"\""); // Non-null vs NULL. - ASSERT_STRNE(L"non-null", NULL); + ASSERT_STRNE(L"non-null", nullptr); // Equal strings. EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(L"Hi", L"Hi"), @@ -2564,11 +2563,11 @@ TEST(StringAssertionTest, STRNE_Wide) { // Tests that IsSubstring() returns the correct result when the input // argument type is const char*. TEST(IsSubstringTest, ReturnsCorrectResultForCString) { - EXPECT_FALSE(IsSubstring("", "", NULL, "a")); - EXPECT_FALSE(IsSubstring("", "", "b", NULL)); + EXPECT_FALSE(IsSubstring("", "", nullptr, "a")); + EXPECT_FALSE(IsSubstring("", "", "b", nullptr)); EXPECT_FALSE(IsSubstring("", "", "needle", "haystack")); - EXPECT_TRUE(IsSubstring("", "", static_cast<const char*>(NULL), NULL)); + EXPECT_TRUE(IsSubstring("", "", static_cast<const char*>(nullptr), nullptr)); EXPECT_TRUE(IsSubstring("", "", "needle", "two needles")); } @@ -2579,7 +2578,8 @@ TEST(IsSubstringTest, ReturnsCorrectResultForWideCString) { EXPECT_FALSE(IsSubstring("", "", L"b", kNull)); EXPECT_FALSE(IsSubstring("", "", L"needle", L"haystack")); - EXPECT_TRUE(IsSubstring("", "", static_cast<const wchar_t*>(NULL), NULL)); + EXPECT_TRUE( + IsSubstring("", "", static_cast<const wchar_t*>(nullptr), nullptr)); EXPECT_TRUE(IsSubstring("", "", L"needle", L"two needles")); } @@ -3714,17 +3714,16 @@ TEST(AssertionTest, ASSERT_EQ) { #if GTEST_CAN_COMPARE_NULL TEST(AssertionTest, ASSERT_EQ_NULL) { // A success. - const char* p = NULL; + const char* p = nullptr; // Some older GCC versions may issue a spurious warning in this or the next // assertion statement. This warning should not be suppressed with // static_cast since the test verifies the ability to use bare NULL as the // expected parameter to the macro. - ASSERT_EQ(NULL, p); + ASSERT_EQ(nullptr, p); // A failure. static int n = 0; - EXPECT_FATAL_FAILURE(ASSERT_EQ(NULL, &n), - " &n\n Which is:"); + EXPECT_FATAL_FAILURE(ASSERT_EQ(nullptr, &n), " &n\n Which is:"); } #endif // GTEST_CAN_COMPARE_NULL @@ -4330,10 +4329,12 @@ TEST(AssertionWithMessageTest, SUCCEED) { TEST(AssertionWithMessageTest, ASSERT_TRUE) { ASSERT_TRUE(true) << "This should succeed."; ASSERT_TRUE(true) << true; - EXPECT_FATAL_FAILURE({ // NOLINT - ASSERT_TRUE(false) << static_cast<const char *>(NULL) - << static_cast<char *>(NULL); - }, "(null)(null)"); + EXPECT_FATAL_FAILURE( + { // NOLINT + ASSERT_TRUE(false) << static_cast<const char*>(nullptr) + << static_cast<char*>(nullptr); + }, + "(null)(null)"); } #if GTEST_OS_WINDOWS @@ -4442,17 +4443,16 @@ TEST(ExpectTest, EXPECT_EQ_Double) { // Tests EXPECT_EQ(NULL, pointer). TEST(ExpectTest, EXPECT_EQ_NULL) { // A success. - const char* p = NULL; + const char* p = nullptr; // Some older GCC versions may issue a spurious warning in this or the next // assertion statement. This warning should not be suppressed with // static_cast since the test verifies the ability to use bare NULL as the // expected parameter to the macro. - EXPECT_EQ(NULL, p); + EXPECT_EQ(nullptr, p); // A failure. int n = 0; - EXPECT_NONFATAL_FAILURE(EXPECT_EQ(NULL, &n), - " &n\n Which is:"); + EXPECT_NONFATAL_FAILURE(EXPECT_EQ(nullptr, &n), " &n\n Which is:"); } #endif // GTEST_CAN_COMPARE_NULL @@ -4480,7 +4480,7 @@ TEST(ExpectTest, EXPECT_NE) { "actual: 'a' (97, 0x61) vs 'a' (97, 0x61)"); EXPECT_NONFATAL_FAILURE(EXPECT_NE(2, 2), "2"); - char* const p0 = NULL; + char* const p0 = nullptr; EXPECT_NONFATAL_FAILURE(EXPECT_NE(p0, p0), "p0"); // Only way to get the Nokia compiler to compile the cast @@ -4588,7 +4588,7 @@ TEST(StreamableToStringTest, Pointer) { // Tests using StreamableToString() on a NULL non-char pointer. TEST(StreamableToStringTest, NullPointer) { - int* p = NULL; + int* p = nullptr; EXPECT_STREQ("(null)", StreamableToString(p).c_str()); } @@ -4599,7 +4599,7 @@ TEST(StreamableToStringTest, CString) { // Tests using StreamableToString() on a NULL C string. TEST(StreamableToStringTest, NullCString) { - char* p = NULL; + char* p = nullptr; EXPECT_STREQ("(null)", StreamableToString(p).c_str()); } @@ -4644,8 +4644,7 @@ TEST(StreamableTest, int) { // implemented a workaround (substituting "(null)" for NULL). This // tests whether the workaround works. TEST(StreamableTest, NullCharPtr) { - EXPECT_FATAL_FAILURE(FAIL() << static_cast<const char*>(NULL), - "(null)"); + EXPECT_FATAL_FAILURE(FAIL() << static_cast<const char*>(nullptr), "(null)"); } // Tests that basic IO manipulators (endl, ends, and flush) can be @@ -4898,7 +4897,7 @@ TEST(EqAssertionTest, GlobalWideString) { // Tests using char pointers in {EXPECT|ASSERT}_EQ. TEST(EqAssertionTest, CharPointer) { - char* const p0 = NULL; + char* const p0 = nullptr; // Only way to get the Nokia compiler to compile the cast // is to have a separate void* variable first. Putting // the two casts on the same line doesn't work, neither does @@ -4920,7 +4919,7 @@ TEST(EqAssertionTest, CharPointer) { // Tests using wchar_t pointers in {EXPECT|ASSERT}_EQ. TEST(EqAssertionTest, WideCharPointer) { - wchar_t* const p0 = NULL; + wchar_t* const p0 = nullptr; // Only way to get the Nokia compiler to compile the cast // is to have a separate void* variable first. Putting // the two casts on the same line doesn't work, neither does @@ -4945,9 +4944,8 @@ TEST(EqAssertionTest, WideCharPointer) { // Tests using other types of pointers in {EXPECT|ASSERT}_EQ. TEST(EqAssertionTest, OtherPointer) { - ASSERT_EQ(static_cast<const int*>(NULL), - static_cast<const int*>(NULL)); - EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<const int*>(NULL), + ASSERT_EQ(static_cast<const int*>(nullptr), static_cast<const int*>(nullptr)); + EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<const int*>(nullptr), reinterpret_cast<const int*>(0x1234)), "0x1234"); } @@ -5280,12 +5278,12 @@ TEST(MessageTest, CanStreamUserTypeInUserNameSpaceWithStreamOperatorInGlobal) { // Tests streaming NULL pointers to testing::Message. TEST(MessageTest, NullPointers) { Message msg; - char* const p1 = NULL; - unsigned char* const p2 = NULL; - int* p3 = NULL; - double* p4 = NULL; - bool* p5 = NULL; - Message* p6 = NULL; + char* const p1 = nullptr; + unsigned char* const p2 = nullptr; + int* p3 = nullptr; + double* p4 = nullptr; + bool* p5 = nullptr; + Message* p6 = nullptr; msg << p1 << p2 << p3 << p4 << p5 << p6; ASSERT_STREQ("(null)(null)(null)(null)(null)(null)", @@ -5295,12 +5293,12 @@ TEST(MessageTest, NullPointers) { // Tests streaming wide strings to testing::Message. TEST(MessageTest, WideStrings) { // Streams a NULL of type const wchar_t*. - const wchar_t* const_wstr = NULL; + const wchar_t* const_wstr = nullptr; EXPECT_STREQ("(null)", (Message() << const_wstr).GetString().c_str()); // Streams a NULL of type wchar_t*. - wchar_t* wstr = NULL; + wchar_t* wstr = nullptr; EXPECT_STREQ("(null)", (Message() << wstr).GetString().c_str()); @@ -5324,15 +5322,15 @@ namespace testing { class TestInfoTest : public Test { protected: static const TestInfo* GetTestInfo(const char* test_name) { - const TestCase* const test_case = GetUnitTestImpl()-> - GetTestCase("TestInfoTest", "", NULL, NULL); + const TestCase* const test_case = + GetUnitTestImpl()->GetTestCase("TestInfoTest", "", nullptr, nullptr); for (int i = 0; i < test_case->total_test_count(); ++i) { const TestInfo* const test_info = test_case->GetTestInfo(i); if (strcmp(test_name, test_info->name()) == 0) return test_info; } - return NULL; + return nullptr; } static const TestResult* GetTestResult( @@ -5446,7 +5444,7 @@ class SetUpTestCaseTest : public Test { EXPECT_EQ(0, counter_); // Cleans up the shared resource. - shared_resource_ = NULL; + shared_resource_ = nullptr; } // This will be called before each test in this test case. @@ -5464,12 +5462,10 @@ class SetUpTestCaseTest : public Test { }; int SetUpTestCaseTest::counter_ = 0; -const char* SetUpTestCaseTest::shared_resource_ = NULL; +const char* SetUpTestCaseTest::shared_resource_ = nullptr; // A test that uses the shared resource. -TEST_F(SetUpTestCaseTest, Test1) { - EXPECT_STRNE(NULL, shared_resource_); -} +TEST_F(SetUpTestCaseTest, Test1) { EXPECT_STRNE(nullptr, shared_resource_); } // Another test that uses the shared resource. TEST_F(SetUpTestCaseTest, Test2) { @@ -5737,141 +5733,81 @@ class ParseFlagsTest : public Test { // Tests parsing an empty command line. TEST_F(ParseFlagsTest, Empty) { - const char* argv[] = { - NULL - }; + const char* argv[] = {nullptr}; - const char* argv2[] = { - NULL - }; + const char* argv2[] = {nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), false); } // Tests parsing a command line that has no flag. TEST_F(ParseFlagsTest, NoFlag) { - const char* argv[] = { - "foo.exe", - NULL - }; + const char* argv[] = {"foo.exe", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), false); } // Tests parsing a bad --gtest_filter flag. TEST_F(ParseFlagsTest, FilterBad) { - const char* argv[] = { - "foo.exe", - "--gtest_filter", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_filter", nullptr}; - const char* argv2[] = { - "foo.exe", - "--gtest_filter", - NULL - }; + const char* argv2[] = {"foo.exe", "--gtest_filter", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), true); } // Tests parsing an empty --gtest_filter flag. TEST_F(ParseFlagsTest, FilterEmpty) { - const char* argv[] = { - "foo.exe", - "--gtest_filter=", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_filter=", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), false); } // Tests parsing a non-empty --gtest_filter flag. TEST_F(ParseFlagsTest, FilterNonEmpty) { - const char* argv[] = { - "foo.exe", - "--gtest_filter=abc", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_filter=abc", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter("abc"), false); } // Tests parsing --gtest_break_on_failure. TEST_F(ParseFlagsTest, BreakOnFailureWithoutValue) { - const char* argv[] = { - "foo.exe", - "--gtest_break_on_failure", - NULL -}; + const char* argv[] = {"foo.exe", "--gtest_break_on_failure", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(true), false); } // Tests parsing --gtest_break_on_failure=0. TEST_F(ParseFlagsTest, BreakOnFailureFalse_0) { - const char* argv[] = { - "foo.exe", - "--gtest_break_on_failure=0", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_break_on_failure=0", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false); } // Tests parsing --gtest_break_on_failure=f. TEST_F(ParseFlagsTest, BreakOnFailureFalse_f) { - const char* argv[] = { - "foo.exe", - "--gtest_break_on_failure=f", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_break_on_failure=f", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false); } // Tests parsing --gtest_break_on_failure=F. TEST_F(ParseFlagsTest, BreakOnFailureFalse_F) { - const char* argv[] = { - "foo.exe", - "--gtest_break_on_failure=F", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_break_on_failure=F", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false); } @@ -5879,48 +5815,27 @@ TEST_F(ParseFlagsTest, BreakOnFailureFalse_F) { // Tests parsing a --gtest_break_on_failure flag that has a "true" // definition. TEST_F(ParseFlagsTest, BreakOnFailureTrue) { - const char* argv[] = { - "foo.exe", - "--gtest_break_on_failure=1", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_break_on_failure=1", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(true), false); } // Tests parsing --gtest_catch_exceptions. TEST_F(ParseFlagsTest, CatchExceptions) { - const char* argv[] = { - "foo.exe", - "--gtest_catch_exceptions", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_catch_exceptions", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::CatchExceptions(true), false); } // Tests parsing --gtest_death_test_use_fork. TEST_F(ParseFlagsTest, DeathTestUseFork) { - const char* argv[] = { - "foo.exe", - "--gtest_death_test_use_fork", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_death_test_use_fork", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::DeathTestUseFork(true), false); } @@ -5928,36 +5843,21 @@ TEST_F(ParseFlagsTest, DeathTestUseFork) { // Tests having the same flag twice with different values. The // expected behavior is that the one coming last takes precedence. TEST_F(ParseFlagsTest, DuplicatedFlags) { - const char* argv[] = { - "foo.exe", - "--gtest_filter=a", - "--gtest_filter=b", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_filter=a", "--gtest_filter=b", + nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter("b"), false); } // Tests having an unrecognized flag on the command line. TEST_F(ParseFlagsTest, UnrecognizedFlag) { - const char* argv[] = { - "foo.exe", - "--gtest_break_on_failure", - "bar", // Unrecognized by Google Test. - "--gtest_filter=b", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_break_on_failure", + "bar", // Unrecognized by Google Test. + "--gtest_filter=b", nullptr}; - const char* argv2[] = { - "foo.exe", - "bar", - NULL - }; + const char* argv2[] = {"foo.exe", "bar", nullptr}; Flags flags; flags.break_on_failure = true; @@ -5967,145 +5867,82 @@ TEST_F(ParseFlagsTest, UnrecognizedFlag) { // Tests having a --gtest_list_tests flag TEST_F(ParseFlagsTest, ListTestsFlag) { - const char* argv[] = { - "foo.exe", - "--gtest_list_tests", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_list_tests", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; - GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(true), false); + GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(true), false); } // Tests having a --gtest_list_tests flag with a "true" value TEST_F(ParseFlagsTest, ListTestsTrue) { - const char* argv[] = { - "foo.exe", - "--gtest_list_tests=1", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_list_tests=1", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; - GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(true), false); + GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(true), false); } // Tests having a --gtest_list_tests flag with a "false" value TEST_F(ParseFlagsTest, ListTestsFalse) { - const char* argv[] = { - "foo.exe", - "--gtest_list_tests=0", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_list_tests=0", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; - GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(false), false); + GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(false), false); } // Tests parsing --gtest_list_tests=f. TEST_F(ParseFlagsTest, ListTestsFalse_f) { - const char* argv[] = { - "foo.exe", - "--gtest_list_tests=f", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_list_tests=f", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(false), false); } // Tests parsing --gtest_list_tests=F. TEST_F(ParseFlagsTest, ListTestsFalse_F) { - const char* argv[] = { - "foo.exe", - "--gtest_list_tests=F", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_list_tests=F", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(false), false); } // Tests parsing --gtest_output (invalid). TEST_F(ParseFlagsTest, OutputEmpty) { - const char* argv[] = { - "foo.exe", - "--gtest_output", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_output", nullptr}; - const char* argv2[] = { - "foo.exe", - "--gtest_output", - NULL - }; + const char* argv2[] = {"foo.exe", "--gtest_output", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true); } // Tests parsing --gtest_output=xml TEST_F(ParseFlagsTest, OutputXml) { - const char* argv[] = { - "foo.exe", - "--gtest_output=xml", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_output=xml", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Output("xml"), false); } // Tests parsing --gtest_output=xml:file TEST_F(ParseFlagsTest, OutputXmlFile) { - const char* argv[] = { - "foo.exe", - "--gtest_output=xml:file", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_output=xml:file", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Output("xml:file"), false); } // Tests parsing --gtest_output=xml:directory/path/ TEST_F(ParseFlagsTest, OutputXmlDirectory) { - const char* argv[] = { - "foo.exe", - "--gtest_output=xml:directory/path/", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_output=xml:directory/path/", + nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Output("xml:directory/path/"), false); @@ -6113,242 +5950,140 @@ TEST_F(ParseFlagsTest, OutputXmlDirectory) { // Tests having a --gtest_print_time flag TEST_F(ParseFlagsTest, PrintTimeFlag) { - const char* argv[] = { - "foo.exe", - "--gtest_print_time", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_print_time", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; - GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(true), false); + GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(true), false); } // Tests having a --gtest_print_time flag with a "true" value TEST_F(ParseFlagsTest, PrintTimeTrue) { - const char* argv[] = { - "foo.exe", - "--gtest_print_time=1", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_print_time=1", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; - GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(true), false); + GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(true), false); } // Tests having a --gtest_print_time flag with a "false" value TEST_F(ParseFlagsTest, PrintTimeFalse) { - const char* argv[] = { - "foo.exe", - "--gtest_print_time=0", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_print_time=0", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; - GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(false), false); + GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(false), false); } // Tests parsing --gtest_print_time=f. TEST_F(ParseFlagsTest, PrintTimeFalse_f) { - const char* argv[] = { - "foo.exe", - "--gtest_print_time=f", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_print_time=f", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(false), false); } // Tests parsing --gtest_print_time=F. TEST_F(ParseFlagsTest, PrintTimeFalse_F) { - const char* argv[] = { - "foo.exe", - "--gtest_print_time=F", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_print_time=F", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(false), false); } // Tests parsing --gtest_random_seed=number TEST_F(ParseFlagsTest, RandomSeed) { - const char* argv[] = { - "foo.exe", - "--gtest_random_seed=1000", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_random_seed=1000", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::RandomSeed(1000), false); } // Tests parsing --gtest_repeat=number TEST_F(ParseFlagsTest, Repeat) { - const char* argv[] = { - "foo.exe", - "--gtest_repeat=1000", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_repeat=1000", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Repeat(1000), false); } // Tests having a --gtest_also_run_disabled_tests flag TEST_F(ParseFlagsTest, AlsoRunDisabledTestsFlag) { - const char* argv[] = { - "foo.exe", - "--gtest_also_run_disabled_tests", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_also_run_disabled_tests", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; - GTEST_TEST_PARSING_FLAGS_(argv, argv2, - Flags::AlsoRunDisabledTests(true), false); + GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::AlsoRunDisabledTests(true), + false); } // Tests having a --gtest_also_run_disabled_tests flag with a "true" value TEST_F(ParseFlagsTest, AlsoRunDisabledTestsTrue) { - const char* argv[] = { - "foo.exe", - "--gtest_also_run_disabled_tests=1", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_also_run_disabled_tests=1", + nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; - GTEST_TEST_PARSING_FLAGS_(argv, argv2, - Flags::AlsoRunDisabledTests(true), false); + GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::AlsoRunDisabledTests(true), + false); } // Tests having a --gtest_also_run_disabled_tests flag with a "false" value TEST_F(ParseFlagsTest, AlsoRunDisabledTestsFalse) { - const char* argv[] = { - "foo.exe", - "--gtest_also_run_disabled_tests=0", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_also_run_disabled_tests=0", + nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; - GTEST_TEST_PARSING_FLAGS_(argv, argv2, - Flags::AlsoRunDisabledTests(false), false); + GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::AlsoRunDisabledTests(false), + false); } // Tests parsing --gtest_shuffle. TEST_F(ParseFlagsTest, ShuffleWithoutValue) { - const char* argv[] = { - "foo.exe", - "--gtest_shuffle", - NULL -}; + const char* argv[] = {"foo.exe", "--gtest_shuffle", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(true), false); } // Tests parsing --gtest_shuffle=0. TEST_F(ParseFlagsTest, ShuffleFalse_0) { - const char* argv[] = { - "foo.exe", - "--gtest_shuffle=0", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_shuffle=0", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(false), false); } // Tests parsing a --gtest_shuffle flag that has a "true" definition. TEST_F(ParseFlagsTest, ShuffleTrue) { - const char* argv[] = { - "foo.exe", - "--gtest_shuffle=1", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_shuffle=1", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(true), false); } // Tests parsing --gtest_stack_trace_depth=number. TEST_F(ParseFlagsTest, StackTraceDepth) { - const char* argv[] = { - "foo.exe", - "--gtest_stack_trace_depth=5", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_stack_trace_depth=5", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::StackTraceDepth(5), false); } TEST_F(ParseFlagsTest, StreamResultTo) { - const char* argv[] = { - "foo.exe", - "--gtest_stream_result_to=localhost:1234", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_stream_result_to=localhost:1234", + nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_( argv, argv2, Flags::StreamResultTo("localhost:1234"), false); @@ -6356,32 +6091,18 @@ TEST_F(ParseFlagsTest, StreamResultTo) { // Tests parsing --gtest_throw_on_failure. TEST_F(ParseFlagsTest, ThrowOnFailureWithoutValue) { - const char* argv[] = { - "foo.exe", - "--gtest_throw_on_failure", - NULL -}; + const char* argv[] = {"foo.exe", "--gtest_throw_on_failure", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(true), false); } // Tests parsing --gtest_throw_on_failure=0. TEST_F(ParseFlagsTest, ThrowOnFailureFalse_0) { - const char* argv[] = { - "foo.exe", - "--gtest_throw_on_failure=0", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_throw_on_failure=0", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(false), false); } @@ -6389,16 +6110,9 @@ TEST_F(ParseFlagsTest, ThrowOnFailureFalse_0) { // Tests parsing a --gtest_throw_on_failure flag that has a "true" // definition. TEST_F(ParseFlagsTest, ThrowOnFailureTrue) { - const char* argv[] = { - "foo.exe", - "--gtest_throw_on_failure=1", - NULL - }; + const char* argv[] = {"foo.exe", "--gtest_throw_on_failure=1", nullptr}; - const char* argv2[] = { - "foo.exe", - NULL - }; + const char* argv2[] = {"foo.exe", nullptr}; GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(true), false); } @@ -6540,7 +6254,7 @@ class CurrentTestInfoTest : public Test { // There should be no tests running at this point. const TestInfo* test_info = UnitTest::GetInstance()->current_test_info(); - EXPECT_TRUE(test_info == NULL) + EXPECT_TRUE(test_info == nullptr) << "There should be no tests running at this point."; } @@ -6549,7 +6263,7 @@ class CurrentTestInfoTest : public Test { static void TearDownTestCase() { const TestInfo* test_info = UnitTest::GetInstance()->current_test_info(); - EXPECT_TRUE(test_info == NULL) + EXPECT_TRUE(test_info == nullptr) << "There should be no tests running at this point."; } }; @@ -6559,7 +6273,7 @@ class CurrentTestInfoTest : public Test { TEST_F(CurrentTestInfoTest, WorksForFirstTestInATestCase) { const TestInfo* test_info = UnitTest::GetInstance()->current_test_info(); - ASSERT_TRUE(NULL != test_info) + ASSERT_TRUE(nullptr != test_info) << "There is a test running so we should have a valid TestInfo."; EXPECT_STREQ("CurrentTestInfoTest", test_info->test_case_name()) << "Expected the name of the currently running test case."; @@ -6574,7 +6288,7 @@ TEST_F(CurrentTestInfoTest, WorksForFirstTestInATestCase) { TEST_F(CurrentTestInfoTest, WorksForSecondTestInATestCase) { const TestInfo* test_info = UnitTest::GetInstance()->current_test_info(); - ASSERT_TRUE(NULL != test_info) + ASSERT_TRUE(nullptr != test_info) << "There is a test running so we should have a valid TestInfo."; EXPECT_STREQ("CurrentTestInfoTest", test_info->test_case_name()) << "Expected the name of the currently running test case."; @@ -7001,7 +6715,7 @@ TEST(HasFailureTest, WorksOutsideOfTestBody2) { class TestListener : public EmptyTestEventListener { public: - TestListener() : on_start_counter_(NULL), is_destroyed_(NULL) {} + TestListener() : on_start_counter_(nullptr), is_destroyed_(nullptr) {} TestListener(int* on_start_counter, bool* is_destroyed) : on_start_counter_(on_start_counter), is_destroyed_(is_destroyed) {} @@ -7013,8 +6727,7 @@ class TestListener : public EmptyTestEventListener { protected: virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) { - if (on_start_counter_ != NULL) - (*on_start_counter_)++; + if (on_start_counter_ != nullptr) (*on_start_counter_)++; } private: @@ -7026,9 +6739,9 @@ class TestListener : public EmptyTestEventListener { TEST(TestEventListenersTest, ConstructionWorks) { TestEventListeners listeners; - EXPECT_TRUE(TestEventListenersAccessor::GetRepeater(&listeners) != NULL); - EXPECT_TRUE(listeners.default_result_printer() == NULL); - EXPECT_TRUE(listeners.default_xml_generator() == NULL); + EXPECT_TRUE(TestEventListenersAccessor::GetRepeater(&listeners) != nullptr); + EXPECT_TRUE(listeners.default_result_printer() == nullptr); + EXPECT_TRUE(listeners.default_xml_generator() == nullptr); } // Tests that the TestEventListeners destructor deletes all the listeners it @@ -7037,12 +6750,12 @@ TEST(TestEventListenersTest, DestructionWorks) { bool default_result_printer_is_destroyed = false; bool default_xml_printer_is_destroyed = false; bool extra_listener_is_destroyed = false; - TestListener* default_result_printer = new TestListener( - NULL, &default_result_printer_is_destroyed); - TestListener* default_xml_printer = new TestListener( - NULL, &default_xml_printer_is_destroyed); - TestListener* extra_listener = new TestListener( - NULL, &extra_listener_is_destroyed); + TestListener* default_result_printer = + new TestListener(nullptr, &default_result_printer_is_destroyed); + TestListener* default_xml_printer = + new TestListener(nullptr, &default_xml_printer_is_destroyed); + TestListener* extra_listener = + new TestListener(nullptr, &extra_listener_is_destroyed); { TestEventListeners listeners; @@ -7167,7 +6880,7 @@ TEST(TestEventListenersTest, Release) { EXPECT_EQ(listener, listeners.Release(listener)); TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart( *UnitTest::GetInstance()); - EXPECT_TRUE(listeners.Release(listener) == NULL); + EXPECT_TRUE(listeners.Release(listener) == nullptr); } EXPECT_EQ(0, on_start_counter); EXPECT_FALSE(is_destroyed); @@ -7177,7 +6890,7 @@ TEST(TestEventListenersTest, Release) { // Tests that no events are forwarded when event forwarding is disabled. TEST(EventListenerTest, SuppressEventForwarding) { int on_start_counter = 0; - TestListener* listener = new TestListener(&on_start_counter, NULL); + TestListener* listener = new TestListener(&on_start_counter, nullptr); TestEventListeners listeners; listeners.Append(listener); @@ -7218,9 +6931,9 @@ TEST(EventListenerTest, default_result_printer) { // Replacing default_result_printer with something else should remove it // from the list and destroy it. - TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, NULL); + TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, nullptr); - EXPECT_TRUE(listeners.default_result_printer() == NULL); + EXPECT_TRUE(listeners.default_result_printer() == nullptr); EXPECT_TRUE(is_destroyed); // After broadcasting an event the counter is still the same, indicating @@ -7244,7 +6957,7 @@ TEST(EventListenerTest, RemovingDefaultResultPrinterWorks) { TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, listener); EXPECT_EQ(listener, listeners.Release(listener)); - EXPECT_TRUE(listeners.default_result_printer() == NULL); + EXPECT_TRUE(listeners.default_result_printer() == nullptr); EXPECT_FALSE(is_destroyed); // Broadcasting events now should not affect default_result_printer. @@ -7277,9 +6990,9 @@ TEST(EventListenerTest, default_xml_generator) { // Replacing default_xml_generator with something else should remove it // from the list and destroy it. - TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, NULL); + TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, nullptr); - EXPECT_TRUE(listeners.default_xml_generator() == NULL); + EXPECT_TRUE(listeners.default_xml_generator() == nullptr); EXPECT_TRUE(is_destroyed); // After broadcasting an event the counter is still the same, indicating @@ -7303,7 +7016,7 @@ TEST(EventListenerTest, RemovingDefaultXmlGeneratorWorks) { TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, listener); EXPECT_EQ(listener, listeners.Release(listener)); - EXPECT_TRUE(listeners.default_xml_generator() == NULL); + EXPECT_TRUE(listeners.default_xml_generator() == nullptr); EXPECT_FALSE(is_destroyed); // Broadcasting events now should not affect default_xml_generator. |