Commit 4327d95b authored by Jerry Turcios's avatar Jerry Turcios
Browse files

Merge branch 'master' of https://github.com/google/googletest

parents 7caf5ffd 40f82ce5
...@@ -48,7 +48,7 @@ static const char* SkipSpaces(const char* str) { ...@@ -48,7 +48,7 @@ static const char* SkipSpaces(const char* str) {
static std::vector<std::string> SplitIntoTestNames(const char* src) { static std::vector<std::string> SplitIntoTestNames(const char* src) {
std::vector<std::string> name_vec; std::vector<std::string> name_vec;
src = SkipSpaces(src); src = SkipSpaces(src);
for (; src != NULL; src = SkipComma(src)) { for (; src != nullptr; src = SkipComma(src)) {
name_vec.push_back(StripTrailingSpaces(GetPrefixUntilComma(src))); name_vec.push_back(StripTrailingSpaces(GetPrefixUntilComma(src)));
} }
return name_vec; return name_vec;
......
This diff is collapsed.
...@@ -277,7 +277,7 @@ TEST(CxxExceptionTest, ThrowsNonStdCxxException) { ...@@ -277,7 +277,7 @@ TEST(CxxExceptionTest, ThrowsNonStdCxxException) {
// ones. // ones.
void TerminateHandler() { void TerminateHandler() {
fprintf(stderr, "%s\n", "Unhandled C++ exception terminating the program."); fprintf(stderr, "%s\n", "Unhandled C++ exception terminating the program.");
fflush(NULL); fflush(nullptr);
exit(3); exit(3);
} }
......
...@@ -370,13 +370,13 @@ void SetSigprofActionAndTimer() { ...@@ -370,13 +370,13 @@ void SetSigprofActionAndTimer() {
timer.it_interval.tv_sec = 0; timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = 1; timer.it_interval.tv_usec = 1;
timer.it_value = timer.it_interval; 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; struct sigaction signal_action;
memset(&signal_action, 0, sizeof(signal_action)); memset(&signal_action, 0, sizeof(signal_action));
sigemptyset(&signal_action.sa_mask); sigemptyset(&signal_action.sa_mask);
signal_action.sa_sigaction = SigprofAction; signal_action.sa_sigaction = SigprofAction;
signal_action.sa_flags = SA_RESTART | SA_SIGINFO; 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. // Disables ITIMER_PROF timer and ignores SIGPROF signal.
...@@ -385,7 +385,7 @@ void DisableSigprofActionAndTimer(struct sigaction* old_signal_action) { ...@@ -385,7 +385,7 @@ void DisableSigprofActionAndTimer(struct sigaction* old_signal_action) {
timer.it_interval.tv_sec = 0; timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = 0; timer.it_interval.tv_usec = 0;
timer.it_value = timer.it_interval; 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; struct sigaction signal_action;
memset(&signal_action, 0, sizeof(signal_action)); memset(&signal_action, 0, sizeof(signal_action));
sigemptyset(&signal_action.sa_mask); sigemptyset(&signal_action.sa_mask);
...@@ -466,7 +466,7 @@ TEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) { ...@@ -466,7 +466,7 @@ TEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) {
if (!testing::GTEST_FLAG(death_test_use_fork)) { if (!testing::GTEST_FLAG(death_test_use_fork)) {
testing::GTEST_FLAG(death_test_style) = "threadsafe"; testing::GTEST_FLAG(death_test_style) = "threadsafe";
pthread_flag = false; pthread_flag = false;
ASSERT_EQ(0, pthread_atfork(&SetPthreadFlag, NULL, NULL)); ASSERT_EQ(0, pthread_atfork(&SetPthreadFlag, nullptr, nullptr));
ASSERT_DEATH(_exit(1), ""); ASSERT_DEATH(_exit(1), "");
ASSERT_FALSE(pthread_flag); ASSERT_FALSE(pthread_flag);
} }
...@@ -1001,7 +1001,7 @@ bool MockDeathTestFactory::Create(const char* /*statement*/, ...@@ -1001,7 +1001,7 @@ bool MockDeathTestFactory::Create(const char* /*statement*/,
if (create_) { if (create_) {
*test = new MockDeathTest(this, role_, status_, passed_); *test = new MockDeathTest(this, role_, status_, passed_);
} else { } else {
*test = NULL; *test = nullptr;
} }
return true; return true;
} }
...@@ -1021,9 +1021,9 @@ class MacroLogicDeathTest : public testing::Test { ...@@ -1021,9 +1021,9 @@ class MacroLogicDeathTest : public testing::Test {
static void TearDownTestCase() { static void TearDownTestCase() {
delete replacer_; delete replacer_;
replacer_ = NULL; replacer_ = nullptr;
delete factory_; delete factory_;
factory_ = NULL; factory_ = nullptr;
} }
// Runs a death test that breaks the rules by returning. Such a death // Runs a death test that breaks the rules by returning. Such a death
...@@ -1037,10 +1037,9 @@ class MacroLogicDeathTest : public testing::Test { ...@@ -1037,10 +1037,9 @@ class MacroLogicDeathTest : public testing::Test {
} }
}; };
testing::internal::ReplaceDeathTestFactory* MacroLogicDeathTest::replacer_ testing::internal::ReplaceDeathTestFactory* MacroLogicDeathTest::replacer_ =
= NULL; nullptr;
MockDeathTestFactory* MacroLogicDeathTest::factory_ = NULL; MockDeathTestFactory* MacroLogicDeathTest::factory_ = nullptr;
// Test that nothing happens when the factory doesn't return a DeathTest: // Test that nothing happens when the factory doesn't return a DeathTest:
TEST_F(MacroLogicDeathTest, NothingHappens) { TEST_F(MacroLogicDeathTest, NothingHappens) {
......
...@@ -38,7 +38,7 @@ using testing::Message; ...@@ -38,7 +38,7 @@ using testing::Message;
using testing::internal::linked_ptr; using testing::internal::linked_ptr;
int num; int num;
Message* history = NULL; Message* history = nullptr;
// Class which tracks allocation/deallocation // Class which tracks allocation/deallocation
class A { class A {
...@@ -67,7 +67,7 @@ class LinkedPtrTest : public testing::Test { ...@@ -67,7 +67,7 @@ class LinkedPtrTest : public testing::Test {
virtual ~LinkedPtrTest() { virtual ~LinkedPtrTest() {
delete history; delete history;
history = NULL; history = nullptr;
} }
}; };
...@@ -77,18 +77,18 @@ TEST_F(LinkedPtrTest, GeneralTest) { ...@@ -77,18 +77,18 @@ TEST_F(LinkedPtrTest, GeneralTest) {
// Use explicit function call notation here to suppress self-assign warning. // Use explicit function call notation here to suppress self-assign warning.
a0.operator=(a0); a0.operator=(a0);
a1 = a2; a1 = a2;
ASSERT_EQ(a0.get(), static_cast<A*>(NULL)); ASSERT_EQ(a0.get(), static_cast<A*>(nullptr));
ASSERT_EQ(a1.get(), static_cast<A*>(NULL)); ASSERT_EQ(a1.get(), static_cast<A*>(nullptr));
ASSERT_EQ(a2.get(), static_cast<A*>(NULL)); ASSERT_EQ(a2.get(), static_cast<A*>(nullptr));
ASSERT_TRUE(a0 == NULL); ASSERT_TRUE(a0 == nullptr);
ASSERT_TRUE(a1 == NULL); ASSERT_TRUE(a1 == nullptr);
ASSERT_TRUE(a2 == NULL); ASSERT_TRUE(a2 == nullptr);
{ {
linked_ptr<A> a3(new A); linked_ptr<A> a3(new A);
a0 = a3; a0 = a3;
ASSERT_TRUE(a0 == a3); ASSERT_TRUE(a0 == a3);
ASSERT_TRUE(a0 != NULL); ASSERT_TRUE(a0 != nullptr);
ASSERT_TRUE(a0.get() == a3); ASSERT_TRUE(a0.get() == a3);
ASSERT_TRUE(a0 == a3.get()); ASSERT_TRUE(a0 == a3.get());
linked_ptr<A> a4(a0); linked_ptr<A> a4(a0);
...@@ -101,7 +101,7 @@ TEST_F(LinkedPtrTest, GeneralTest) { ...@@ -101,7 +101,7 @@ TEST_F(LinkedPtrTest, GeneralTest) {
linked_ptr<A> a6(b0); linked_ptr<A> a6(b0);
ASSERT_TRUE(b0 == a6); ASSERT_TRUE(b0 == a6);
ASSERT_TRUE(a6 == b0); ASSERT_TRUE(a6 == b0);
ASSERT_TRUE(b0 != NULL); ASSERT_TRUE(b0 != nullptr);
a5 = b0; a5 = b0;
a5 = b0; a5 = b0;
a3->Use(); a3->Use();
......
...@@ -47,7 +47,7 @@ using ::testing::TestPartResult; ...@@ -47,7 +47,7 @@ using ::testing::TestPartResult;
using ::testing::UnitTest; using ::testing::UnitTest;
// Used by tests to register their events. // Used by tests to register their events.
std::vector<std::string>* g_events = NULL; std::vector<std::string>* g_events = nullptr;
namespace testing { namespace testing {
namespace internal { namespace internal {
......
...@@ -85,7 +85,7 @@ TEST(MessageTest, StreamsPointer) { ...@@ -85,7 +85,7 @@ TEST(MessageTest, StreamsPointer) {
// Tests streaming a NULL non-char pointer. // Tests streaming a NULL non-char pointer.
TEST(MessageTest, StreamsNullPointer) { TEST(MessageTest, StreamsNullPointer) {
int* p = NULL; int* p = nullptr;
EXPECT_EQ("(null)", (Message() << p).GetString()); EXPECT_EQ("(null)", (Message() << p).GetString());
} }
...@@ -96,7 +96,7 @@ TEST(MessageTest, StreamsCString) { ...@@ -96,7 +96,7 @@ TEST(MessageTest, StreamsCString) {
// Tests streaming a NULL C string. // Tests streaming a NULL C string.
TEST(MessageTest, StreamsNullCString) { TEST(MessageTest, StreamsNullCString) {
char* p = NULL; char* p = nullptr;
EXPECT_EQ("(null)", (Message() << p).GetString()); EXPECT_EQ("(null)", (Message() << p).GetString());
} }
......
...@@ -174,7 +174,7 @@ TEST(SCOPED_TRACETest, AcceptedValues) { ...@@ -174,7 +174,7 @@ TEST(SCOPED_TRACETest, AcceptedValues) {
SCOPED_TRACE("literal string"); SCOPED_TRACE("literal string");
SCOPED_TRACE(std::string("std::string")); SCOPED_TRACE(std::string("std::string"));
SCOPED_TRACE(1337); // streamable type SCOPED_TRACE(1337); // streamable type
const char* null_value = NULL; const char* null_value = nullptr;
SCOPED_TRACE(null_value); SCOPED_TRACE(null_value);
ADD_FAILURE() << "Just checking that all these values work fine."; ADD_FAILURE() << "Just checking that all these values work fine.";
...@@ -306,9 +306,8 @@ TEST(SCOPED_TRACETest, WorksConcurrently) { ...@@ -306,9 +306,8 @@ TEST(SCOPED_TRACETest, WorksConcurrently) {
printf("(expecting 6 failures)\n"); printf("(expecting 6 failures)\n");
CheckPoints check_points; CheckPoints check_points;
ThreadWithParam<CheckPoints*> thread(&ThreadWithScopedTrace, ThreadWithParam<CheckPoints*> thread(&ThreadWithScopedTrace, &check_points,
&check_points, nullptr);
NULL);
check_points.n1.WaitForNotification(); check_points.n1.WaitForNotification();
{ {
...@@ -511,7 +510,7 @@ class DeathTestAndMultiThreadsTest : public testing::Test { ...@@ -511,7 +510,7 @@ class DeathTestAndMultiThreadsTest : public testing::Test {
// Starts a thread and waits for it to begin. // Starts a thread and waits for it to begin.
virtual void SetUp() { virtual void SetUp() {
thread_.reset(new ThreadWithParam<SpawnThreadNotifications*>( thread_.reset(new ThreadWithParam<SpawnThreadNotifications*>(
&ThreadRoutine, &notifications_, NULL)); &ThreadRoutine, &notifications_, nullptr));
notifications_.spawn_thread_started.WaitForNotification(); notifications_.spawn_thread_started.WaitForNotification();
} }
// Tells the thread to finish, and reaps it. // Tells the thread to finish, and reaps it.
...@@ -966,7 +965,7 @@ TEST_F(ExpectFailureTest, ExpectNonFatalFailure) { ...@@ -966,7 +965,7 @@ TEST_F(ExpectFailureTest, ExpectNonFatalFailure) {
class ExpectFailureWithThreadsTest : public ExpectFailureTest { class ExpectFailureWithThreadsTest : public ExpectFailureTest {
protected: protected:
static void AddFailureInOtherThread(FailureMode failure) { static void AddFailureInOtherThread(FailureMode failure) {
ThreadWithParam<FailureMode> thread(&AddFailure, failure, NULL); ThreadWithParam<FailureMode> thread(&AddFailure, failure, nullptr);
thread.Join(); thread.Join();
} }
}; };
......
...@@ -262,9 +262,9 @@ TEST(FormatFileLocationTest, FormatsFileLocation) { ...@@ -262,9 +262,9 @@ TEST(FormatFileLocationTest, FormatsFileLocation) {
} }
TEST(FormatFileLocationTest, FormatsUnknownFile) { TEST(FormatFileLocationTest, FormatsUnknownFile) {
EXPECT_PRED_FORMAT2( EXPECT_PRED_FORMAT2(IsSubstring, "unknown file",
IsSubstring, "unknown file", FormatFileLocation(NULL, 42)); FormatFileLocation(nullptr, 42));
EXPECT_PRED_FORMAT2(IsSubstring, "42", FormatFileLocation(NULL, 42)); EXPECT_PRED_FORMAT2(IsSubstring, "42", FormatFileLocation(nullptr, 42));
} }
TEST(FormatFileLocationTest, FormatsUknownLine) { TEST(FormatFileLocationTest, FormatsUknownLine) {
...@@ -272,7 +272,7 @@ TEST(FormatFileLocationTest, FormatsUknownLine) { ...@@ -272,7 +272,7 @@ TEST(FormatFileLocationTest, FormatsUknownLine) {
} }
TEST(FormatFileLocationTest, FormatsUknownFileAndLine) { TEST(FormatFileLocationTest, FormatsUknownFileAndLine) {
EXPECT_EQ("unknown file:", FormatFileLocation(NULL, -1)); EXPECT_EQ("unknown file:", FormatFileLocation(nullptr, -1));
} }
// Verifies behavior of FormatCompilerIndependentFileLocation. // Verifies behavior of FormatCompilerIndependentFileLocation.
...@@ -282,7 +282,7 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsFileLocation) { ...@@ -282,7 +282,7 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsFileLocation) {
TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFile) { TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFile) {
EXPECT_EQ("unknown file:42", EXPECT_EQ("unknown file:42",
FormatCompilerIndependentFileLocation(NULL, 42)); FormatCompilerIndependentFileLocation(nullptr, 42));
} }
TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownLine) { TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownLine) {
...@@ -290,7 +290,7 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownLine) { ...@@ -290,7 +290,7 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownLine) {
} }
TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFileAndLine) { 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 #if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX || GTEST_OS_FUCHSIA
...@@ -298,7 +298,7 @@ void* ThreadFunc(void* data) { ...@@ -298,7 +298,7 @@ void* ThreadFunc(void* data) {
internal::Mutex* mutex = static_cast<internal::Mutex*>(data); internal::Mutex* mutex = static_cast<internal::Mutex*>(data);
mutex->Lock(); mutex->Lock();
mutex->Unlock(); mutex->Unlock();
return NULL; return nullptr;
} }
TEST(GetThreadCountTest, ReturnsCorrectValue) { TEST(GetThreadCountTest, ReturnsCorrectValue) {
...@@ -965,7 +965,7 @@ TEST(ThreadLocalTest, DefaultConstructorInitializesToDefaultValues) { ...@@ -965,7 +965,7 @@ TEST(ThreadLocalTest, DefaultConstructorInitializesToDefaultValues) {
EXPECT_EQ(0, t1.get()); EXPECT_EQ(0, t1.get());
ThreadLocal<void*> t2; ThreadLocal<void*> t2;
EXPECT_TRUE(t2.get() == NULL); EXPECT_TRUE(t2.get() == nullptr);
} }
TEST(ThreadLocalTest, SingleParamConstructorInitializesToParam) { TEST(ThreadLocalTest, SingleParamConstructorInitializesToParam) {
...@@ -1015,7 +1015,7 @@ void AddTwo(int* param) { *param += 2; } ...@@ -1015,7 +1015,7 @@ void AddTwo(int* param) { *param += 2; }
TEST(ThreadWithParamTest, ConstructorExecutesThreadFunc) { TEST(ThreadWithParamTest, ConstructorExecutesThreadFunc) {
int i = 40; int i = 40;
ThreadWithParam<int*> thread(&AddTwo, &i, NULL); ThreadWithParam<int*> thread(&AddTwo, &i, nullptr);
thread.Join(); thread.Join();
EXPECT_EQ(42, i); EXPECT_EQ(42, i);
} }
...@@ -1055,7 +1055,7 @@ class AtomicCounterWithMutex { ...@@ -1055,7 +1055,7 @@ class AtomicCounterWithMutex {
// functionality as we are testing them here. // functionality as we are testing them here.
pthread_mutex_t memory_barrier_mutex; pthread_mutex_t memory_barrier_mutex;
GTEST_CHECK_POSIX_SUCCESS_( 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)); GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&memory_barrier_mutex));
SleepMilliseconds(random_.Generate(30)); SleepMilliseconds(random_.Generate(30));
...@@ -1118,7 +1118,7 @@ TEST(MutexTest, OnlyOneThreadCanLockAtATime) { ...@@ -1118,7 +1118,7 @@ TEST(MutexTest, OnlyOneThreadCanLockAtATime) {
template <typename T> template <typename T>
void RunFromThread(void (func)(T), T param) { void RunFromThread(void (func)(T), T param) {
ThreadWithParam<T> thread(func, param, NULL); ThreadWithParam<T> thread(func, param, nullptr);
thread.Join(); thread.Join();
} }
...@@ -1250,8 +1250,8 @@ TEST(ThreadLocalTest, DestroysManagedObjectAtThreadExit) { ...@@ -1250,8 +1250,8 @@ TEST(ThreadLocalTest, DestroysManagedObjectAtThreadExit) {
ASSERT_EQ(0U, DestructorCall::List().size()); ASSERT_EQ(0U, DestructorCall::List().size());
// This creates another DestructorTracker object in the new thread. // This creates another DestructorTracker object in the new thread.
ThreadWithParam<ThreadParam> thread( ThreadWithParam<ThreadParam> thread(&CallThreadLocalGet,
&CallThreadLocalGet, &thread_local_tracker, NULL); &thread_local_tracker, nullptr);
thread.Join(); thread.Join();
// The thread has exited, and we should have a DestroyedTracker // The thread has exited, and we should have a DestroyedTracker
......
...@@ -405,7 +405,7 @@ TEST(PrintCStringTest, NonConst) { ...@@ -405,7 +405,7 @@ TEST(PrintCStringTest, NonConst) {
// NULL C string. // NULL C string.
TEST(PrintCStringTest, Null) { TEST(PrintCStringTest, Null) {
const char* p = NULL; const char* p = nullptr;
EXPECT_EQ("NULL", Print(p)); EXPECT_EQ("NULL", Print(p));
} }
...@@ -440,7 +440,7 @@ TEST(PrintWideCStringTest, NonConst) { ...@@ -440,7 +440,7 @@ TEST(PrintWideCStringTest, NonConst) {
// NULL wide C string. // NULL wide C string.
TEST(PrintWideCStringTest, Null) { TEST(PrintWideCStringTest, Null) {
const wchar_t* p = NULL; const wchar_t* p = nullptr;
EXPECT_EQ("NULL", Print(p)); EXPECT_EQ("NULL", Print(p));
} }
...@@ -460,7 +460,7 @@ TEST(PrintWideCStringTest, EscapesProperly) { ...@@ -460,7 +460,7 @@ TEST(PrintWideCStringTest, EscapesProperly) {
TEST(PrintCharPointerTest, SignedChar) { TEST(PrintCharPointerTest, SignedChar) {
signed char* p = reinterpret_cast<signed char*>(0x1234); signed char* p = reinterpret_cast<signed char*>(0x1234);
EXPECT_EQ(PrintPointer(p), Print(p)); EXPECT_EQ(PrintPointer(p), Print(p));
p = NULL; p = nullptr;
EXPECT_EQ("NULL", Print(p)); EXPECT_EQ("NULL", Print(p));
} }
...@@ -468,7 +468,7 @@ TEST(PrintCharPointerTest, SignedChar) { ...@@ -468,7 +468,7 @@ TEST(PrintCharPointerTest, SignedChar) {
TEST(PrintCharPointerTest, ConstSignedChar) { TEST(PrintCharPointerTest, ConstSignedChar) {
signed char* p = reinterpret_cast<signed char*>(0x1234); signed char* p = reinterpret_cast<signed char*>(0x1234);
EXPECT_EQ(PrintPointer(p), Print(p)); EXPECT_EQ(PrintPointer(p), Print(p));
p = NULL; p = nullptr;
EXPECT_EQ("NULL", Print(p)); EXPECT_EQ("NULL", Print(p));
} }
...@@ -476,7 +476,7 @@ TEST(PrintCharPointerTest, ConstSignedChar) { ...@@ -476,7 +476,7 @@ TEST(PrintCharPointerTest, ConstSignedChar) {
TEST(PrintCharPointerTest, UnsignedChar) { TEST(PrintCharPointerTest, UnsignedChar) {
unsigned char* p = reinterpret_cast<unsigned char*>(0x1234); unsigned char* p = reinterpret_cast<unsigned char*>(0x1234);
EXPECT_EQ(PrintPointer(p), Print(p)); EXPECT_EQ(PrintPointer(p), Print(p));
p = NULL; p = nullptr;
EXPECT_EQ("NULL", Print(p)); EXPECT_EQ("NULL", Print(p));
} }
...@@ -484,7 +484,7 @@ TEST(PrintCharPointerTest, UnsignedChar) { ...@@ -484,7 +484,7 @@ TEST(PrintCharPointerTest, UnsignedChar) {
TEST(PrintCharPointerTest, ConstUnsignedChar) { TEST(PrintCharPointerTest, ConstUnsignedChar) {
const unsigned char* p = reinterpret_cast<const unsigned char*>(0x1234); const unsigned char* p = reinterpret_cast<const unsigned char*>(0x1234);
EXPECT_EQ(PrintPointer(p), Print(p)); EXPECT_EQ(PrintPointer(p), Print(p));
p = NULL; p = nullptr;
EXPECT_EQ("NULL", Print(p)); EXPECT_EQ("NULL", Print(p));
} }
...@@ -494,7 +494,7 @@ TEST(PrintCharPointerTest, ConstUnsignedChar) { ...@@ -494,7 +494,7 @@ TEST(PrintCharPointerTest, ConstUnsignedChar) {
TEST(PrintPointerToBuiltInTypeTest, Bool) { TEST(PrintPointerToBuiltInTypeTest, Bool) {
bool* p = reinterpret_cast<bool*>(0xABCD); bool* p = reinterpret_cast<bool*>(0xABCD);
EXPECT_EQ(PrintPointer(p), Print(p)); EXPECT_EQ(PrintPointer(p), Print(p));
p = NULL; p = nullptr;
EXPECT_EQ("NULL", Print(p)); EXPECT_EQ("NULL", Print(p));
} }
...@@ -502,7 +502,7 @@ TEST(PrintPointerToBuiltInTypeTest, Bool) { ...@@ -502,7 +502,7 @@ TEST(PrintPointerToBuiltInTypeTest, Bool) {
TEST(PrintPointerToBuiltInTypeTest, Void) { TEST(PrintPointerToBuiltInTypeTest, Void) {
void* p = reinterpret_cast<void*>(0xABCD); void* p = reinterpret_cast<void*>(0xABCD);
EXPECT_EQ(PrintPointer(p), Print(p)); EXPECT_EQ(PrintPointer(p), Print(p));
p = NULL; p = nullptr;
EXPECT_EQ("NULL", Print(p)); EXPECT_EQ("NULL", Print(p));
} }
...@@ -510,7 +510,7 @@ TEST(PrintPointerToBuiltInTypeTest, Void) { ...@@ -510,7 +510,7 @@ TEST(PrintPointerToBuiltInTypeTest, Void) {
TEST(PrintPointerToBuiltInTypeTest, ConstVoid) { TEST(PrintPointerToBuiltInTypeTest, ConstVoid) {
const void* p = reinterpret_cast<const void*>(0xABCD); const void* p = reinterpret_cast<const void*>(0xABCD);
EXPECT_EQ(PrintPointer(p), Print(p)); EXPECT_EQ(PrintPointer(p), Print(p));
p = NULL; p = nullptr;
EXPECT_EQ("NULL", Print(p)); EXPECT_EQ("NULL", Print(p));
} }
...@@ -518,7 +518,7 @@ TEST(PrintPointerToBuiltInTypeTest, ConstVoid) { ...@@ -518,7 +518,7 @@ TEST(PrintPointerToBuiltInTypeTest, ConstVoid) {
TEST(PrintPointerToPointerTest, IntPointerPointer) { TEST(PrintPointerToPointerTest, IntPointerPointer) {
int** p = reinterpret_cast<int**>(0xABCD); int** p = reinterpret_cast<int**>(0xABCD);
EXPECT_EQ(PrintPointer(p), Print(p)); EXPECT_EQ(PrintPointer(p), Print(p));
p = NULL; p = nullptr;
EXPECT_EQ("NULL", Print(p)); EXPECT_EQ("NULL", Print(p));
} }
...@@ -1398,7 +1398,7 @@ TEST(FormatForComparisonFailureMessageTest, WorksForWCharPointerVsStdWString) { ...@@ -1398,7 +1398,7 @@ TEST(FormatForComparisonFailureMessageTest, WorksForWCharPointerVsStdWString) {
// char array vs pointer // char array vs pointer
TEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsPointer) { TEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsPointer) {
char str[] = "hi \"world\""; char str[] = "hi \"world\"";
char* p = NULL; char* p = nullptr;
EXPECT_EQ(PrintPointer(str), EXPECT_EQ(PrintPointer(str),
FormatForComparisonFailureMessage(str, p).c_str()); FormatForComparisonFailureMessage(str, p).c_str());
} }
...@@ -1413,7 +1413,7 @@ TEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsCharArray) { ...@@ -1413,7 +1413,7 @@ TEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsCharArray) {
// wchar_t array vs pointer // wchar_t array vs pointer
TEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsPointer) { TEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsPointer) {
wchar_t str[] = L"hi \"world\""; wchar_t str[] = L"hi \"world\"";
wchar_t* p = NULL; wchar_t* p = nullptr;
EXPECT_EQ(PrintPointer(str), EXPECT_EQ(PrintPointer(str),
FormatForComparisonFailureMessage(str, p).c_str()); FormatForComparisonFailureMessage(str, p).c_str());
} }
...@@ -1614,7 +1614,7 @@ TEST(UniversalTersePrintTest, WorksForCString) { ...@@ -1614,7 +1614,7 @@ TEST(UniversalTersePrintTest, WorksForCString) {
UniversalTersePrint(s2, &ss2); UniversalTersePrint(s2, &ss2);
EXPECT_EQ("\"abc\"", ss2.str()); EXPECT_EQ("\"abc\"", ss2.str());
const char* s3 = NULL; const char* s3 = nullptr;
::std::stringstream ss3; ::std::stringstream ss3;
UniversalTersePrint(s3, &ss3); UniversalTersePrint(s3, &ss3);
EXPECT_EQ("NULL", ss3.str()); EXPECT_EQ("NULL", ss3.str());
...@@ -1644,7 +1644,7 @@ TEST(UniversalPrintTest, WorksForCString) { ...@@ -1644,7 +1644,7 @@ TEST(UniversalPrintTest, WorksForCString) {
UniversalPrint(s2, &ss2); UniversalPrint(s2, &ss2);
EXPECT_EQ(PrintPointer(s2) + " pointing to \"abc\"", std::string(ss2.str())); EXPECT_EQ(PrintPointer(s2) + " pointing to \"abc\"", std::string(ss2.str()));
const char* s3 = NULL; const char* s3 = nullptr;
::std::stringstream ss3; ::std::stringstream ss3;
UniversalPrint(s3, &ss3); UniversalPrint(s3, &ss3);
EXPECT_EQ("NULL", ss3.str()); EXPECT_EQ("NULL", ss3.str());
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
// ones. // ones.
void TerminateHandler() { void TerminateHandler() {
fprintf(stderr, "%s\n", "Unhandled C++ exception terminating the program."); fprintf(stderr, "%s\n", "Unhandled C++ exception terminating the program.");
fflush(NULL); fflush(nullptr);
exit(1); exit(1);
} }
......
...@@ -158,7 +158,7 @@ TEST(TupleConstructorTest, DefaultConstructorDefaultInitializesEachField) { ...@@ -158,7 +158,7 @@ TEST(TupleConstructorTest, DefaultConstructorDefaultInitializesEachField) {
b3 = a3; b3 = a3;
EXPECT_EQ(0.0, get<0>(b3)); EXPECT_EQ(0.0, get<0>(b3));
EXPECT_EQ('\0', get<1>(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; tuple<int, int, int, int, int, int, int, int, int, int> a10, b10;
b10 = a10; b10 = a10;
......
...@@ -55,7 +55,7 @@ class CommonTest : public Test { ...@@ -55,7 +55,7 @@ class CommonTest : public Test {
static void TearDownTestCase() { static void TearDownTestCase() {
delete shared_; delete shared_;
shared_ = NULL; shared_ = nullptr;
} }
// This 'protected:' is optional. There's no harm in making all // This 'protected:' is optional. There's no harm in making all
...@@ -85,7 +85,7 @@ class CommonTest : public Test { ...@@ -85,7 +85,7 @@ class CommonTest : public Test {
}; };
template <typename T> template <typename T>
T* CommonTest<T>::shared_ = NULL; T* CommonTest<T>::shared_ = nullptr;
// This #ifdef block tests typed tests. // This #ifdef block tests typed tests.
#if GTEST_HAS_TYPED_TEST #if GTEST_HAS_TYPED_TEST
...@@ -121,7 +121,7 @@ TYPED_TEST(CommonTest, ValuesAreCorrect) { ...@@ -121,7 +121,7 @@ TYPED_TEST(CommonTest, ValuesAreCorrect) {
TYPED_TEST(CommonTest, ValuesAreStillCorrect) { TYPED_TEST(CommonTest, ValuesAreStillCorrect) {
// Static members of the fixture class template can also be visited // Static members of the fixture class template can also be visited
// via 'this'. // via 'this'.
ASSERT_TRUE(this->shared_ != NULL); ASSERT_TRUE(this->shared_ != nullptr);
EXPECT_EQ(5, *this->shared_); EXPECT_EQ(5, *this->shared_);
// TypeParam can be used to refer to the type parameter. // TypeParam can be used to refer to the type parameter.
...@@ -292,7 +292,7 @@ TYPED_TEST_P(DerivedTest, ValuesAreCorrect) { ...@@ -292,7 +292,7 @@ TYPED_TEST_P(DerivedTest, ValuesAreCorrect) {
TYPED_TEST_P(DerivedTest, ValuesAreStillCorrect) { TYPED_TEST_P(DerivedTest, ValuesAreStillCorrect) {
// Static members of the fixture class template can also be visited // Static members of the fixture class template can also be visited
// via 'this'. // via 'this'.
ASSERT_TRUE(this->shared_ != NULL); ASSERT_TRUE(this->shared_ != nullptr);
EXPECT_EQ(5, *this->shared_); EXPECT_EQ(5, *this->shared_);
EXPECT_EQ(2, this->value_); EXPECT_EQ(2, this->value_);
} }
......
...@@ -76,7 +76,7 @@ class UnitTestHelper { ...@@ -76,7 +76,7 @@ class UnitTestHelper {
if (0 == strcmp(test_case->name(), name)) if (0 == strcmp(test_case->name(), name))
return test_case; return test_case;
} }
return NULL; return nullptr;
} }
// Returns the array of pointers to all tests in a particular test case // Returns the array of pointers to all tests in a particular test case
...@@ -137,7 +137,7 @@ TEST(ApiTest, UnitTestImmutableAccessorsWork) { ...@@ -137,7 +137,7 @@ TEST(ApiTest, UnitTestImmutableAccessorsWork) {
} }
AssertionResult IsNull(const char* str) { AssertionResult IsNull(const char* str) {
if (str != NULL) { if (str != nullptr) {
return testing::AssertionFailure() << "argument is " << str; return testing::AssertionFailure() << "argument is " << str;
} }
return AssertionSuccess(); return AssertionSuccess();
...@@ -145,7 +145,7 @@ AssertionResult IsNull(const char* str) { ...@@ -145,7 +145,7 @@ AssertionResult IsNull(const char* str) {
TEST(ApiTest, TestCaseImmutableAccessorsWork) { TEST(ApiTest, TestCaseImmutableAccessorsWork) {
const TestCase* test_case = UnitTestHelper::FindTestCase("ApiTest"); const TestCase* test_case = UnitTestHelper::FindTestCase("ApiTest");
ASSERT_TRUE(test_case != NULL); ASSERT_TRUE(test_case != nullptr);
EXPECT_STREQ("ApiTest", test_case->name()); EXPECT_STREQ("ApiTest", test_case->name());
EXPECT_TRUE(IsNull(test_case->type_param())); EXPECT_TRUE(IsNull(test_case->type_param()));
...@@ -181,11 +181,11 @@ TEST(ApiTest, TestCaseImmutableAccessorsWork) { ...@@ -181,11 +181,11 @@ TEST(ApiTest, TestCaseImmutableAccessorsWork) {
EXPECT_TRUE(tests[3]->should_run()); EXPECT_TRUE(tests[3]->should_run());
delete[] tests; delete[] tests;
tests = NULL; tests = nullptr;
#if GTEST_HAS_TYPED_TEST #if GTEST_HAS_TYPED_TEST
test_case = UnitTestHelper::FindTestCase("TestCaseWithCommentTest/0"); 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("TestCaseWithCommentTest/0", test_case->name());
EXPECT_STREQ(GetTypeName<int>().c_str(), test_case->type_param()); EXPECT_STREQ(GetTypeName<int>().c_str(), test_case->type_param());
...@@ -208,7 +208,7 @@ TEST(ApiTest, TestCaseImmutableAccessorsWork) { ...@@ -208,7 +208,7 @@ TEST(ApiTest, TestCaseImmutableAccessorsWork) {
TEST(ApiTest, TestCaseDisabledAccessorsWork) { TEST(ApiTest, TestCaseDisabledAccessorsWork) {
const TestCase* test_case = UnitTestHelper::FindTestCase("DISABLED_Test"); 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_STREQ("DISABLED_Test", test_case->name());
EXPECT_TRUE(IsNull(test_case->type_param())); EXPECT_TRUE(IsNull(test_case->type_param()));
......
...@@ -80,8 +80,7 @@ TEST(Test, Test) { ...@@ -80,8 +80,7 @@ TEST(Test, Test) {
try { try {
AssertFalse(); AssertFalse();
} catch(const testing::AssertionException& e) { } catch(const testing::AssertionException& e) {
if (strstr(e.what(), "Expected failure") != NULL) if (strstr(e.what(), "Expected failure") != nullptr) throw;
throw;
printf("%s", printf("%s",
"A failed assertion did throw an exception of the right type, " "A failed assertion did throw an exception of the right type, "
......
...@@ -56,7 +56,7 @@ class PrematureExitTest : public Test { ...@@ -56,7 +56,7 @@ class PrematureExitTest : public Test {
premature_exit_file_path_ = GetEnv("TEST_PREMATURE_EXIT_FILE"); premature_exit_file_path_ = GetEnv("TEST_PREMATURE_EXIT_FILE");
// Normalize NULL to "" for ease of handling. // Normalize NULL to "" for ease of handling.
if (premature_exit_file_path_ == NULL) { if (premature_exit_file_path_ == nullptr) {
premature_exit_file_path_ = ""; premature_exit_file_path_ = "";
} }
} }
...@@ -113,7 +113,7 @@ int main(int argc, char **argv) { ...@@ -113,7 +113,7 @@ int main(int argc, char **argv) {
// Test that the premature-exit file is deleted upon return from // Test that the premature-exit file is deleted upon return from
// RUN_ALL_TESTS(). // RUN_ALL_TESTS().
const char* const filepath = GetEnv("TEST_PREMATURE_EXIT_FILE"); const char* const filepath = GetEnv("TEST_PREMATURE_EXIT_FILE");
if (filepath != NULL && *filepath != '\0') { if (filepath != nullptr && *filepath != '\0') {
if (PrematureExitTest::FileExists(filepath)) { if (PrematureExitTest::FileExists(filepath)) {
printf( printf(
"File %s shouldn't exist after the test program finishes, but does.", "File %s shouldn't exist after the test program finishes, but does.",
......
...@@ -163,7 +163,7 @@ void FailingThread(bool is_fatal) { ...@@ -163,7 +163,7 @@ void FailingThread(bool is_fatal) {
} }
void GenerateFatalFailureInAnotherThread(bool is_fatal) { void GenerateFatalFailureInAnotherThread(bool is_fatal) {
ThreadWithParam<bool> thread(&FailingThread, is_fatal, NULL); ThreadWithParam<bool> thread(&FailingThread, is_fatal, nullptr);
thread.Join(); thread.Join();
} }
......
...@@ -63,8 +63,7 @@ void TestFailureThrowsRuntimeError() { ...@@ -63,8 +63,7 @@ void TestFailureThrowsRuntimeError() {
try { try {
EXPECT_EQ(2, 3) << "Expected failure"; EXPECT_EQ(2, 3) << "Expected failure";
} catch(const std::runtime_error& e) { } catch(const std::runtime_error& e) {
if (strstr(e.what(), "Expected failure") != NULL) if (strstr(e.what(), "Expected failure") != nullptr) return;
return;
printf("%s", printf("%s",
"A failed assertion did throw an exception of the right type, " "A failed assertion did throw an exception of the right type, "
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment