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;
......
...@@ -196,14 +196,14 @@ bool g_help_flag = false; ...@@ -196,14 +196,14 @@ bool g_help_flag = false;
// Utilty function to Open File for Writing // Utilty function to Open File for Writing
static FILE* OpenFileForWriting(const std::string& output_file) { static FILE* OpenFileForWriting(const std::string& output_file) {
FILE* fileout = NULL; FILE* fileout = nullptr;
FilePath output_file_path(output_file); FilePath output_file_path(output_file);
FilePath output_dir(output_file_path.RemoveFileName()); FilePath output_dir(output_file_path.RemoveFileName());
if (output_dir.CreateDirectoriesRecursively()) { if (output_dir.CreateDirectoriesRecursively()) {
fileout = posix::FOpen(output_file.c_str(), "w"); fileout = posix::FOpen(output_file.c_str(), "w");
} }
if (fileout == NULL) { if (fileout == nullptr) {
GTEST_LOG_(FATAL) << "Unable to open file \"" << output_file << "\""; GTEST_LOG_(FATAL) << "Unable to open file \"" << output_file << "\"";
} }
return fileout; return fileout;
...@@ -216,7 +216,7 @@ static FILE* OpenFileForWriting(const std::string& output_file) { ...@@ -216,7 +216,7 @@ static FILE* OpenFileForWriting(const std::string& output_file) {
static const char* GetDefaultFilter() { static const char* GetDefaultFilter() {
const char* const testbridge_test_only = const char* const testbridge_test_only =
internal::posix::GetEnv("TESTBRIDGE_TEST_ONLY"); internal::posix::GetEnv("TESTBRIDGE_TEST_ONLY");
if (testbridge_test_only != NULL) { if (testbridge_test_only != nullptr) {
return testbridge_test_only; return testbridge_test_only;
} }
return kUniversalFilter; return kUniversalFilter;
...@@ -460,9 +460,9 @@ FilePath GetCurrentExecutableName() { ...@@ -460,9 +460,9 @@ FilePath GetCurrentExecutableName() {
std::string UnitTestOptions::GetOutputFormat() { std::string UnitTestOptions::GetOutputFormat() {
const char* const gtest_output_flag = GTEST_FLAG(output).c_str(); const char* const gtest_output_flag = GTEST_FLAG(output).c_str();
const char* const colon = strchr(gtest_output_flag, ':'); const char* const colon = strchr(gtest_output_flag, ':');
return (colon == NULL) ? return (colon == nullptr)
std::string(gtest_output_flag) : ? std::string(gtest_output_flag)
std::string(gtest_output_flag, colon - gtest_output_flag); : std::string(gtest_output_flag, colon - gtest_output_flag);
} }
// Returns the name of the requested output file, or the default if none // Returns the name of the requested output file, or the default if none
...@@ -475,7 +475,7 @@ std::string UnitTestOptions::GetAbsolutePathToOutputFile() { ...@@ -475,7 +475,7 @@ std::string UnitTestOptions::GetAbsolutePathToOutputFile() {
format = std::string(kDefaultOutputFormat); format = std::string(kDefaultOutputFormat);
const char* const colon = strchr(gtest_output_flag, ':'); const char* const colon = strchr(gtest_output_flag, ':');
if (colon == NULL) if (colon == nullptr)
return internal::FilePath::MakeFileName( return internal::FilePath::MakeFileName(
internal::FilePath( internal::FilePath(
UnitTest::GetInstance()->original_working_dir()), UnitTest::GetInstance()->original_working_dir()),
...@@ -535,7 +535,7 @@ bool UnitTestOptions::MatchesFilter( ...@@ -535,7 +535,7 @@ bool UnitTestOptions::MatchesFilter(
cur_pattern = strchr(cur_pattern, ':'); cur_pattern = strchr(cur_pattern, ':');
// Returns if no more pattern can be found. // Returns if no more pattern can be found.
if (cur_pattern == NULL) { if (cur_pattern == nullptr) {
return false; return false;
} }
...@@ -556,7 +556,7 @@ bool UnitTestOptions::FilterMatchesTest(const std::string &test_case_name, ...@@ -556,7 +556,7 @@ bool UnitTestOptions::FilterMatchesTest(const std::string &test_case_name,
const char* const dash = strchr(p, '-'); const char* const dash = strchr(p, '-');
std::string positive; std::string positive;
std::string negative; std::string negative;
if (dash == NULL) { if (dash == nullptr) {
positive = GTEST_FLAG(filter).c_str(); // Whole string is a positive filter positive = GTEST_FLAG(filter).c_str(); // Whole string is a positive filter
negative = ""; negative = "";
} else { } else {
...@@ -701,7 +701,7 @@ static AssertionResult HasOneFailure(const char* /* results_expr */, ...@@ -701,7 +701,7 @@ static AssertionResult HasOneFailure(const char* /* results_expr */,
<< r; << r;
} }
if (strstr(r.message(), substr.c_str()) == NULL) { if (strstr(r.message(), substr.c_str()) == nullptr) {
return AssertionFailure() << "Expected: " << expected << " containing \"" return AssertionFailure() << "Expected: " << expected << " containing \""
<< substr << "\"\n" << substr << "\"\n"
<< " Actual:\n" << " Actual:\n"
...@@ -888,7 +888,7 @@ TimeInMillis GetTimeInMillis() { ...@@ -888,7 +888,7 @@ TimeInMillis GetTimeInMillis() {
return static_cast<TimeInMillis>(now.time) * 1000 + now.millitm; return static_cast<TimeInMillis>(now.time) * 1000 + now.millitm;
#elif GTEST_HAS_GETTIMEOFDAY_ #elif GTEST_HAS_GETTIMEOFDAY_
struct timeval now; struct timeval now;
gettimeofday(&now, NULL); gettimeofday(&now, nullptr);
return static_cast<TimeInMillis>(now.tv_sec) * 1000 + now.tv_usec / 1000; return static_cast<TimeInMillis>(now.tv_sec) * 1000 + now.tv_usec / 1000;
#else #else
# error "Don't know how to get the current time on your system." # error "Don't know how to get the current time on your system."
...@@ -941,9 +941,9 @@ const char* String::Utf16ToAnsi(LPCWSTR utf16_str) { ...@@ -941,9 +941,9 @@ const char* String::Utf16ToAnsi(LPCWSTR utf16_str) {
// C string is considered different to any non-NULL C string, // C string is considered different to any non-NULL C string,
// including the empty string. // including the empty string.
bool String::CStringEquals(const char * lhs, const char * rhs) { bool String::CStringEquals(const char * lhs, const char * rhs) {
if ( lhs == NULL ) return rhs == NULL; if (lhs == nullptr) return rhs == nullptr;
if ( rhs == NULL ) return false; if (rhs == nullptr) return false;
return strcmp(lhs, rhs) == 0; return strcmp(lhs, rhs) == 0;
} }
...@@ -1035,10 +1035,9 @@ std::string Message::GetString() const { ...@@ -1035,10 +1035,9 @@ std::string Message::GetString() const {
// Used in EXPECT_TRUE/FALSE(assertion_result). // Used in EXPECT_TRUE/FALSE(assertion_result).
AssertionResult::AssertionResult(const AssertionResult& other) AssertionResult::AssertionResult(const AssertionResult& other)
: success_(other.success_), : success_(other.success_),
message_(other.message_.get() != NULL ? message_(other.message_.get() != nullptr
new ::std::string(*other.message_) : ? new ::std::string(*other.message_)
static_cast< ::std::string*>(NULL)) { : static_cast< ::std::string*>(nullptr)) {}
}
// Swaps two AssertionResults. // Swaps two AssertionResults.
void AssertionResult::swap(AssertionResult& other) { void AssertionResult::swap(AssertionResult& other) {
...@@ -1050,8 +1049,7 @@ void AssertionResult::swap(AssertionResult& other) { ...@@ -1050,8 +1049,7 @@ void AssertionResult::swap(AssertionResult& other) {
// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE. // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
AssertionResult AssertionResult::operator!() const { AssertionResult AssertionResult::operator!() const {
AssertionResult negation(!success_); AssertionResult negation(!success_);
if (message_.get() != NULL) if (message_.get() != nullptr) negation << *message_;
negation << *message_;
return negation; return negation;
} }
...@@ -1605,17 +1603,15 @@ namespace { ...@@ -1605,17 +1603,15 @@ namespace {
// only. // only.
bool IsSubstringPred(const char* needle, const char* haystack) { bool IsSubstringPred(const char* needle, const char* haystack) {
if (needle == NULL || haystack == NULL) if (needle == nullptr || haystack == nullptr) return needle == haystack;
return needle == haystack;
return strstr(haystack, needle) != NULL; return strstr(haystack, needle) != nullptr;
} }
bool IsSubstringPred(const wchar_t* needle, const wchar_t* haystack) { bool IsSubstringPred(const wchar_t* needle, const wchar_t* haystack) {
if (needle == NULL || haystack == NULL) if (needle == nullptr || haystack == nullptr) return needle == haystack;
return needle == haystack;
return wcsstr(haystack, needle) != NULL; return wcsstr(haystack, needle) != nullptr;
} }
// StringType here can be either ::std::string or ::std::wstring. // StringType here can be either ::std::string or ::std::wstring.
...@@ -1896,7 +1892,7 @@ std::string WideStringToUtf8(const wchar_t* str, int num_chars) { ...@@ -1896,7 +1892,7 @@ std::string WideStringToUtf8(const wchar_t* str, int num_chars) {
// Converts a wide C string to an std::string using the UTF-8 encoding. // Converts a wide C string to an std::string using the UTF-8 encoding.
// NULL will be converted to "(null)". // NULL will be converted to "(null)".
std::string String::ShowWideCString(const wchar_t * wide_c_str) { std::string String::ShowWideCString(const wchar_t * wide_c_str) {
if (wide_c_str == NULL) return "(null)"; if (wide_c_str == nullptr) return "(null)";
return internal::WideStringToUtf8(wide_c_str, -1); return internal::WideStringToUtf8(wide_c_str, -1);
} }
...@@ -1908,9 +1904,9 @@ std::string String::ShowWideCString(const wchar_t * wide_c_str) { ...@@ -1908,9 +1904,9 @@ std::string String::ShowWideCString(const wchar_t * wide_c_str) {
// C string is considered different to any non-NULL C string, // C string is considered different to any non-NULL C string,
// including the empty string. // including the empty string.
bool String::WideCStringEquals(const wchar_t * lhs, const wchar_t * rhs) { bool String::WideCStringEquals(const wchar_t * lhs, const wchar_t * rhs) {
if (lhs == NULL) return rhs == NULL; if (lhs == nullptr) return rhs == nullptr;
if (rhs == NULL) return false; if (rhs == nullptr) return false;
return wcscmp(lhs, rhs) == 0; return wcscmp(lhs, rhs) == 0;
} }
...@@ -1953,10 +1949,8 @@ AssertionResult CmpHelperSTRNE(const char* s1_expression, ...@@ -1953,10 +1949,8 @@ AssertionResult CmpHelperSTRNE(const char* s1_expression,
// NULL C string is considered different to any non-NULL C string, // NULL C string is considered different to any non-NULL C string,
// including the empty string. // including the empty string.
bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) { bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) {
if (lhs == NULL) if (lhs == nullptr) return rhs == nullptr;
return rhs == NULL; if (rhs == nullptr) return false;
if (rhs == NULL)
return false;
return posix::StrCaseCmp(lhs, rhs) == 0; return posix::StrCaseCmp(lhs, rhs) == 0;
} }
...@@ -1974,9 +1968,9 @@ bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) { ...@@ -1974,9 +1968,9 @@ bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) {
// current locale. // current locale.
bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs, bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
const wchar_t* rhs) { const wchar_t* rhs) {
if (lhs == NULL) return rhs == NULL; if (lhs == nullptr) return rhs == nullptr;
if (rhs == NULL) return false; if (rhs == nullptr) return false;
#if GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
return _wcsicmp(lhs, rhs) == 0; return _wcsicmp(lhs, rhs) == 0;
...@@ -2309,10 +2303,10 @@ void ReportFailureInUnknownLocation(TestPartResult::Type result_type, ...@@ -2309,10 +2303,10 @@ void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
// AddTestPartResult. // AddTestPartResult.
UnitTest::GetInstance()->AddTestPartResult( UnitTest::GetInstance()->AddTestPartResult(
result_type, result_type,
NULL, // No info about the source file where the exception occurred. nullptr, // No info about the source file where the exception occurred.
-1, // We have no info on which line caused the exception. -1, // We have no info on which line caused the exception.
message, message,
""); // No stack trace, either. ""); // No stack trace, either.
} }
} // namespace internal } // namespace internal
...@@ -2562,16 +2556,15 @@ bool Test::IsSkipped() { ...@@ -2562,16 +2556,15 @@ bool Test::IsSkipped() {
// Constructs a TestInfo object. It assumes ownership of the test factory // Constructs a TestInfo object. It assumes ownership of the test factory
// object. // object.
TestInfo::TestInfo(const std::string& a_test_case_name, TestInfo::TestInfo(const std::string& a_test_case_name,
const std::string& a_name, const std::string& a_name, const char* a_type_param,
const char* a_type_param,
const char* a_value_param, const char* a_value_param,
internal::CodeLocation a_code_location, internal::CodeLocation a_code_location,
internal::TypeId fixture_class_id, internal::TypeId fixture_class_id,
internal::TestFactoryBase* factory) internal::TestFactoryBase* factory)
: test_case_name_(a_test_case_name), : test_case_name_(a_test_case_name),
name_(a_name), name_(a_name),
type_param_(a_type_param ? new std::string(a_type_param) : NULL), type_param_(a_type_param ? new std::string(a_type_param) : nullptr),
value_param_(a_value_param ? new std::string(a_value_param) : NULL), value_param_(a_value_param ? new std::string(a_value_param) : nullptr),
location_(a_code_location), location_(a_code_location),
fixture_class_id_(fixture_class_id), fixture_class_id_(fixture_class_id),
should_run_(false), should_run_(false),
...@@ -2725,7 +2718,7 @@ void TestInfo::Run() { ...@@ -2725,7 +2718,7 @@ void TestInfo::Run() {
// Tells UnitTest to stop associating assertion results to this // Tells UnitTest to stop associating assertion results to this
// test. // test.
impl->set_current_test_info(NULL); impl->set_current_test_info(nullptr);
} }
// class TestCase // class TestCase
...@@ -2783,12 +2776,11 @@ TestCase::TestCase(const char* a_name, const char* a_type_param, ...@@ -2783,12 +2776,11 @@ TestCase::TestCase(const char* a_name, const char* a_type_param,
Test::SetUpTestCaseFunc set_up_tc, Test::SetUpTestCaseFunc set_up_tc,
Test::TearDownTestCaseFunc tear_down_tc) Test::TearDownTestCaseFunc tear_down_tc)
: name_(a_name), : name_(a_name),
type_param_(a_type_param ? new std::string(a_type_param) : NULL), type_param_(a_type_param ? new std::string(a_type_param) : nullptr),
set_up_tc_(set_up_tc), set_up_tc_(set_up_tc),
tear_down_tc_(tear_down_tc), tear_down_tc_(tear_down_tc),
should_run_(false), should_run_(false),
elapsed_time_(0) { elapsed_time_(0) {}
}
// Destructor of TestCase. // Destructor of TestCase.
TestCase::~TestCase() { TestCase::~TestCase() {
...@@ -2800,14 +2792,14 @@ TestCase::~TestCase() { ...@@ -2800,14 +2792,14 @@ TestCase::~TestCase() {
// total_test_count() - 1. If i is not in that range, returns NULL. // total_test_count() - 1. If i is not in that range, returns NULL.
const TestInfo* TestCase::GetTestInfo(int i) const { const TestInfo* TestCase::GetTestInfo(int i) const {
const int index = GetElementOr(test_indices_, i, -1); const int index = GetElementOr(test_indices_, i, -1);
return index < 0 ? NULL : test_info_list_[index]; return index < 0 ? nullptr : test_info_list_[index];
} }
// Returns the i-th test among all the tests. i can range from 0 to // Returns the i-th test among all the tests. i can range from 0 to
// total_test_count() - 1. If i is not in that range, returns NULL. // total_test_count() - 1. If i is not in that range, returns NULL.
TestInfo* TestCase::GetMutableTestInfo(int i) { TestInfo* TestCase::GetMutableTestInfo(int i) {
const int index = GetElementOr(test_indices_, i, -1); const int index = GetElementOr(test_indices_, i, -1);
return index < 0 ? NULL : test_info_list_[index]; return index < 0 ? nullptr : test_info_list_[index];
} }
// Adds a test to this test case. Will delete the test upon // Adds a test to this test case. Will delete the test upon
...@@ -2842,7 +2834,7 @@ void TestCase::Run() { ...@@ -2842,7 +2834,7 @@ void TestCase::Run() {
this, &TestCase::RunTearDownTestCase, "TearDownTestCase()"); this, &TestCase::RunTearDownTestCase, "TearDownTestCase()");
repeater->OnTestCaseEnd(*this); repeater->OnTestCaseEnd(*this);
impl->set_current_test_case(NULL); impl->set_current_test_case(nullptr);
} }
// Clears the results of all tests in this test case. // Clears the results of all tests in this test case.
...@@ -2940,14 +2932,6 @@ static void PrintTestPartResult(const TestPartResult& test_part_result) { ...@@ -2940,14 +2932,6 @@ static void PrintTestPartResult(const TestPartResult& test_part_result) {
} }
// class PrettyUnitTestResultPrinter // class PrettyUnitTestResultPrinter
enum GTestColor {
COLOR_DEFAULT,
COLOR_RED,
COLOR_GREEN,
COLOR_YELLOW
};
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \ #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \
!GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW
...@@ -3001,7 +2985,8 @@ static const char* GetAnsiColorCode(GTestColor color) { ...@@ -3001,7 +2985,8 @@ static const char* GetAnsiColorCode(GTestColor color) {
case COLOR_RED: return "1"; case COLOR_RED: return "1";
case COLOR_GREEN: return "2"; case COLOR_GREEN: return "2";
case COLOR_YELLOW: return "3"; case COLOR_YELLOW: return "3";
default: return NULL; default:
return nullptr;
}; };
} }
...@@ -3048,7 +3033,7 @@ bool ShouldUseColor(bool stdout_is_tty) { ...@@ -3048,7 +3033,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
// cannot simply emit special characters and have the terminal change colors. // cannot simply emit special characters and have the terminal change colors.
// This routine must actually emit the characters rather than return a string // This routine must actually emit the characters rather than return a string
// that would be colored when printed, as can be done on Linux. // that would be colored when printed, as can be done on Linux.
static void ColoredPrintf(GTestColor color, const char* fmt, ...) { void ColoredPrintf(GTestColor color, const char* fmt, ...) {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
...@@ -3106,14 +3091,13 @@ static void PrintFullTestCommentIfPresent(const TestInfo& test_info) { ...@@ -3106,14 +3091,13 @@ static void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
const char* const type_param = test_info.type_param(); const char* const type_param = test_info.type_param();
const char* const value_param = test_info.value_param(); const char* const value_param = test_info.value_param();
if (type_param != NULL || value_param != NULL) { if (type_param != nullptr || value_param != nullptr) {
printf(", where "); printf(", where ");
if (type_param != NULL) { if (type_param != nullptr) {
printf("%s = %s", kTypeParamLabel, type_param); printf("%s = %s", kTypeParamLabel, type_param);
if (value_param != NULL) if (value_param != nullptr) printf(" and ");
printf(" and ");
} }
if (value_param != NULL) { if (value_param != nullptr) {
printf("%s = %s", kValueParamLabel, value_param); printf("%s = %s", kValueParamLabel, value_param);
} }
} }
...@@ -3197,7 +3181,7 @@ void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) { ...@@ -3197,7 +3181,7 @@ void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) {
FormatCountableNoun(test_case.test_to_run_count(), "test", "tests"); FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
ColoredPrintf(COLOR_GREEN, "[----------] "); ColoredPrintf(COLOR_GREEN, "[----------] ");
printf("%s from %s", counts.c_str(), test_case.name()); printf("%s from %s", counts.c_str(), test_case.name());
if (test_case.type_param() == NULL) { if (test_case.type_param() == nullptr) {
printf("\n"); printf("\n");
} else { } else {
printf(", where %s = %s\n", kTypeParamLabel, test_case.type_param()); printf(", where %s = %s\n", kTypeParamLabel, test_case.type_param());
...@@ -3421,7 +3405,7 @@ TestEventListener* TestEventRepeater::Release(TestEventListener *listener) { ...@@ -3421,7 +3405,7 @@ TestEventListener* TestEventRepeater::Release(TestEventListener *listener) {
} }
} }
return NULL; return nullptr;
} }
// Since most methods are very similar, use macros to reduce boilerplate. // Since most methods are very similar, use macros to reduce boilerplate.
...@@ -3695,7 +3679,7 @@ static bool PortableLocaltime(time_t seconds, struct tm* out) { ...@@ -3695,7 +3679,7 @@ static bool PortableLocaltime(time_t seconds, struct tm* out) {
*out = *tm_ptr; *out = *tm_ptr;
return true; return true;
#else #else
return localtime_r(&seconds, out) != NULL; return localtime_r(&seconds, out) != nullptr;
#endif #endif
} }
...@@ -3721,7 +3705,7 @@ void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream, ...@@ -3721,7 +3705,7 @@ void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,
*stream << "<![CDATA["; *stream << "<![CDATA[";
for (;;) { for (;;) {
const char* const next_segment = strstr(segment, "]]>"); const char* const next_segment = strstr(segment, "]]>");
if (next_segment != NULL) { if (next_segment != nullptr) {
stream->write( stream->write(
segment, static_cast<std::streamsize>(next_segment - segment)); segment, static_cast<std::streamsize>(next_segment - segment));
*stream << "]]>]]&gt;<![CDATA["; *stream << "]]>]]&gt;<![CDATA[";
...@@ -3765,11 +3749,11 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream, ...@@ -3765,11 +3749,11 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
*stream << " <testcase"; *stream << " <testcase";
OutputXmlAttribute(stream, kTestcase, "name", test_info.name()); OutputXmlAttribute(stream, kTestcase, "name", test_info.name());
if (test_info.value_param() != NULL) { if (test_info.value_param() != nullptr) {
OutputXmlAttribute(stream, kTestcase, "value_param", OutputXmlAttribute(stream, kTestcase, "value_param",
test_info.value_param()); test_info.value_param());
} }
if (test_info.type_param() != NULL) { if (test_info.type_param() != nullptr) {
OutputXmlAttribute(stream, kTestcase, "type_param", test_info.type_param()); OutputXmlAttribute(stream, kTestcase, "type_param", test_info.type_param());
} }
if (GTEST_FLAG(list_tests)) { if (GTEST_FLAG(list_tests)) {
...@@ -4130,11 +4114,11 @@ void JsonUnitTestResultPrinter::OutputJsonTestInfo(::std::ostream* stream, ...@@ -4130,11 +4114,11 @@ void JsonUnitTestResultPrinter::OutputJsonTestInfo(::std::ostream* stream,
*stream << Indent(8) << "{\n"; *stream << Indent(8) << "{\n";
OutputJsonKey(stream, kTestcase, "name", test_info.name(), kIndent); OutputJsonKey(stream, kTestcase, "name", test_info.name(), kIndent);
if (test_info.value_param() != NULL) { if (test_info.value_param() != nullptr) {
OutputJsonKey(stream, kTestcase, "value_param", OutputJsonKey(stream, kTestcase, "value_param",
test_info.value_param(), kIndent); test_info.value_param(), kIndent);
} }
if (test_info.type_param() != NULL) { if (test_info.type_param() != nullptr) {
OutputJsonKey(stream, kTestcase, "type_param", test_info.type_param(), OutputJsonKey(stream, kTestcase, "type_param", test_info.type_param(),
kIndent); kIndent);
} }
...@@ -4335,7 +4319,7 @@ void StreamingListener::SocketWriter::MakeConnection() { ...@@ -4335,7 +4319,7 @@ void StreamingListener::SocketWriter::MakeConnection() {
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC; // To allow both IPv4 and IPv6 addresses. hints.ai_family = AF_UNSPEC; // To allow both IPv4 and IPv6 addresses.
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
addrinfo* servinfo = NULL; addrinfo* servinfo = nullptr;
// Use the getaddrinfo() to get a linked list of IP addresses for // Use the getaddrinfo() to get a linked list of IP addresses for
// the given host name. // the given host name.
...@@ -4347,7 +4331,7 @@ void StreamingListener::SocketWriter::MakeConnection() { ...@@ -4347,7 +4331,7 @@ void StreamingListener::SocketWriter::MakeConnection() {
} }
// Loop through all the results and connect to the first we can. // Loop through all the results and connect to the first we can.
for (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != NULL; for (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != nullptr;
cur_addr = cur_addr->ai_next) { cur_addr = cur_addr->ai_next) {
sockfd_ = socket( sockfd_ = socket(
cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol); cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol);
...@@ -4479,9 +4463,8 @@ class ScopedPrematureExitFile { ...@@ -4479,9 +4463,8 @@ class ScopedPrematureExitFile {
TestEventListeners::TestEventListeners() TestEventListeners::TestEventListeners()
: repeater_(new internal::TestEventRepeater()), : repeater_(new internal::TestEventRepeater()),
default_result_printer_(NULL), default_result_printer_(nullptr),
default_xml_generator_(NULL) { default_xml_generator_(nullptr) {}
}
TestEventListeners::~TestEventListeners() { delete repeater_; } TestEventListeners::~TestEventListeners() { delete repeater_; }
...@@ -4498,9 +4481,9 @@ void TestEventListeners::Append(TestEventListener* listener) { ...@@ -4498,9 +4481,9 @@ void TestEventListeners::Append(TestEventListener* listener) {
// NULL if the listener is not found in the list. // NULL if the listener is not found in the list.
TestEventListener* TestEventListeners::Release(TestEventListener* listener) { TestEventListener* TestEventListeners::Release(TestEventListener* listener) {
if (listener == default_result_printer_) if (listener == default_result_printer_)
default_result_printer_ = NULL; default_result_printer_ = nullptr;
else if (listener == default_xml_generator_) else if (listener == default_xml_generator_)
default_xml_generator_ = NULL; default_xml_generator_ = nullptr;
return repeater_->Release(listener); return repeater_->Release(listener);
} }
...@@ -4519,8 +4502,7 @@ void TestEventListeners::SetDefaultResultPrinter(TestEventListener* listener) { ...@@ -4519,8 +4502,7 @@ void TestEventListeners::SetDefaultResultPrinter(TestEventListener* listener) {
// list. // list.
delete Release(default_result_printer_); delete Release(default_result_printer_);
default_result_printer_ = listener; default_result_printer_ = listener;
if (listener != NULL) if (listener != nullptr) Append(listener);
Append(listener);
} }
} }
...@@ -4535,8 +4517,7 @@ void TestEventListeners::SetDefaultXmlGenerator(TestEventListener* listener) { ...@@ -4535,8 +4517,7 @@ void TestEventListeners::SetDefaultXmlGenerator(TestEventListener* listener) {
// list. // list.
delete Release(default_xml_generator_); delete Release(default_xml_generator_);
default_xml_generator_ = listener; default_xml_generator_ = listener;
if (listener != NULL) if (listener != nullptr) Append(listener);
Append(listener);
} }
} }
...@@ -4688,8 +4669,8 @@ TestEventListeners& UnitTest::listeners() { ...@@ -4688,8 +4669,8 @@ TestEventListeners& UnitTest::listeners() {
// We don't protect this under mutex_, as we only support calling it // We don't protect this under mutex_, as we only support calling it
// from the main thread. // from the main thread.
Environment* UnitTest::AddEnvironment(Environment* env) { Environment* UnitTest::AddEnvironment(Environment* env) {
if (env == NULL) { if (env == nullptr) {
return NULL; return nullptr;
} }
impl_->environments().push_back(env); impl_->environments().push_back(env);
...@@ -4721,13 +4702,12 @@ void UnitTest::AddTestPartResult( ...@@ -4721,13 +4702,12 @@ void UnitTest::AddTestPartResult(
} }
} }
if (os_stack_trace.c_str() != NULL && !os_stack_trace.empty()) { if (os_stack_trace.c_str() != nullptr && !os_stack_trace.empty()) {
msg << internal::kStackTraceMarker << os_stack_trace; msg << internal::kStackTraceMarker << os_stack_trace;
} }
const TestPartResult result = const TestPartResult result = TestPartResult(
TestPartResult(result_type, file_name, line_number, result_type, file_name, line_number, msg.GetString().c_str());
msg.GetString().c_str());
impl_->GetTestPartResultReporterForCurrentThread()-> impl_->GetTestPartResultReporterForCurrentThread()->
ReportTestPartResult(result); ReportTestPartResult(result);
...@@ -4809,8 +4789,9 @@ int UnitTest::Run() { ...@@ -4809,8 +4789,9 @@ int UnitTest::Run() {
// that understands the premature-exit-file protocol to report the // that understands the premature-exit-file protocol to report the
// test as having failed. // test as having failed.
const internal::ScopedPrematureExitFile premature_exit_file( const internal::ScopedPrematureExitFile premature_exit_file(
in_death_test_child_process ? in_death_test_child_process
NULL : internal::posix::GetEnv("TEST_PREMATURE_EXIT_FILE")); ? nullptr
: internal::posix::GetEnv("TEST_PREMATURE_EXIT_FILE"));
// Captures the value of GTEST_FLAG(catch_exceptions). This value will be // Captures the value of GTEST_FLAG(catch_exceptions). This value will be
// used for the duration of the program. // used for the duration of the program.
...@@ -4924,23 +4905,22 @@ namespace internal { ...@@ -4924,23 +4905,22 @@ namespace internal {
UnitTestImpl::UnitTestImpl(UnitTest* parent) UnitTestImpl::UnitTestImpl(UnitTest* parent)
: parent_(parent), : parent_(parent),
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4355 /* using this in initializer */) GTEST_DISABLE_MSC_WARNINGS_PUSH_(4355 /* using this in initializer */)
default_global_test_part_result_reporter_(this), default_global_test_part_result_reporter_(this),
default_per_thread_test_part_result_reporter_(this), default_per_thread_test_part_result_reporter_(this),
GTEST_DISABLE_MSC_WARNINGS_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_() global_test_part_result_repoter_(
global_test_part_result_repoter_(
&default_global_test_part_result_reporter_), &default_global_test_part_result_reporter_),
per_thread_test_part_result_reporter_( per_thread_test_part_result_reporter_(
&default_per_thread_test_part_result_reporter_), &default_per_thread_test_part_result_reporter_),
parameterized_test_registry_(), parameterized_test_registry_(),
parameterized_tests_registered_(false), parameterized_tests_registered_(false),
last_death_test_case_(-1), last_death_test_case_(-1),
current_test_case_(NULL), current_test_case_(nullptr),
current_test_info_(NULL), current_test_info_(nullptr),
ad_hoc_test_result_(), ad_hoc_test_result_(),
os_stack_trace_getter_(NULL), os_stack_trace_getter_(nullptr),
post_flag_parse_init_performed_(false), post_flag_parse_init_performed_(false),
random_seed_(0), // Will be overridden by the flag before first use. random_seed_(0), // Will be overridden by the flag before first use.
random_(0), // Will be reseeded before first use. random_(0), // Will be reseeded before first use.
start_timestamp_(0), start_timestamp_(0),
elapsed_time_(0), elapsed_time_(0),
#if GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
...@@ -4970,10 +4950,10 @@ void UnitTestImpl::RecordProperty(const TestProperty& test_property) { ...@@ -4970,10 +4950,10 @@ void UnitTestImpl::RecordProperty(const TestProperty& test_property) {
std::string xml_element; std::string xml_element;
TestResult* test_result; // TestResult appropriate for property recording. TestResult* test_result; // TestResult appropriate for property recording.
if (current_test_info_ != NULL) { if (current_test_info_ != nullptr) {
xml_element = "testcase"; xml_element = "testcase";
test_result = &(current_test_info_->result_); test_result = &(current_test_info_->result_);
} else if (current_test_case_ != NULL) { } else if (current_test_case_ != nullptr) {
xml_element = "testsuite"; xml_element = "testsuite";
test_result = &(current_test_case_->ad_hoc_test_result_); test_result = &(current_test_case_->ad_hoc_test_result_);
} else { } else {
...@@ -4987,7 +4967,7 @@ void UnitTestImpl::RecordProperty(const TestProperty& test_property) { ...@@ -4987,7 +4967,7 @@ void UnitTestImpl::RecordProperty(const TestProperty& test_property) {
// Disables event forwarding if the control is currently in a death test // Disables event forwarding if the control is currently in a death test
// subprocess. Must not be called before InitGoogleTest. // subprocess. Must not be called before InitGoogleTest.
void UnitTestImpl::SuppressTestEventsIfInSubprocess() { void UnitTestImpl::SuppressTestEventsIfInSubprocess() {
if (internal_run_death_test_flag_.get() != NULL) if (internal_run_death_test_flag_.get() != nullptr)
listeners()->SuppressEventForwarding(); listeners()->SuppressEventForwarding();
} }
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
...@@ -5085,7 +5065,8 @@ class TestCaseNameIs { ...@@ -5085,7 +5065,8 @@ class TestCaseNameIs {
// Returns true iff the name of test_case matches name_. // Returns true iff the name of test_case matches name_.
bool operator()(const TestCase* test_case) const { bool operator()(const TestCase* test_case) const {
return test_case != NULL && strcmp(test_case->name(), name_.c_str()) == 0; return test_case != nullptr &&
strcmp(test_case->name(), name_.c_str()) == 0;
} }
private: private:
...@@ -5175,7 +5156,8 @@ bool UnitTestImpl::RunAllTests() { ...@@ -5175,7 +5156,8 @@ bool UnitTestImpl::RunAllTests() {
bool in_subprocess_for_death_test = false; bool in_subprocess_for_death_test = false;
#if GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL); in_subprocess_for_death_test =
(internal_run_death_test_flag_.get() != nullptr);
# if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_) # if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
if (in_subprocess_for_death_test) { if (in_subprocess_for_death_test) {
GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_(); GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_();
...@@ -5306,9 +5288,9 @@ bool UnitTestImpl::RunAllTests() { ...@@ -5306,9 +5288,9 @@ bool UnitTestImpl::RunAllTests() {
// be created, prints an error and exits. // be created, prints an error and exits.
void WriteToShardStatusFileIfNeeded() { void WriteToShardStatusFileIfNeeded() {
const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile); const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile);
if (test_shard_file != NULL) { if (test_shard_file != nullptr) {
FILE* const file = posix::FOpen(test_shard_file, "w"); FILE* const file = posix::FOpen(test_shard_file, "w");
if (file == NULL) { if (file == nullptr) {
ColoredPrintf(COLOR_RED, ColoredPrintf(COLOR_RED,
"Could not write to the test shard status file \"%s\" " "Could not write to the test shard status file \"%s\" "
"specified by the %s environment variable.\n", "specified by the %s environment variable.\n",
...@@ -5343,7 +5325,7 @@ bool ShouldShard(const char* total_shards_env, ...@@ -5343,7 +5325,7 @@ bool ShouldShard(const char* total_shards_env,
<< "Invalid environment variables: you have " << "Invalid environment variables: you have "
<< kTestShardIndex << " = " << shard_index << kTestShardIndex << " = " << shard_index
<< ", but have left " << kTestTotalShards << " unset.\n"; << ", but have left " << kTestTotalShards << " unset.\n";
ColoredPrintf(COLOR_RED, msg.GetString().c_str()); ColoredPrintf(COLOR_RED, "%s", msg.GetString().c_str());
fflush(stdout); fflush(stdout);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} else if (total_shards != -1 && shard_index == -1) { } else if (total_shards != -1 && shard_index == -1) {
...@@ -5351,7 +5333,7 @@ bool ShouldShard(const char* total_shards_env, ...@@ -5351,7 +5333,7 @@ bool ShouldShard(const char* total_shards_env,
<< "Invalid environment variables: you have " << "Invalid environment variables: you have "
<< kTestTotalShards << " = " << total_shards << kTestTotalShards << " = " << total_shards
<< ", but have left " << kTestShardIndex << " unset.\n"; << ", but have left " << kTestShardIndex << " unset.\n";
ColoredPrintf(COLOR_RED, msg.GetString().c_str()); ColoredPrintf(COLOR_RED, "%s", msg.GetString().c_str());
fflush(stdout); fflush(stdout);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} else if (shard_index < 0 || shard_index >= total_shards) { } else if (shard_index < 0 || shard_index >= total_shards) {
...@@ -5360,7 +5342,7 @@ bool ShouldShard(const char* total_shards_env, ...@@ -5360,7 +5342,7 @@ bool ShouldShard(const char* total_shards_env,
<< kTestShardIndex << " < " << kTestTotalShards << kTestShardIndex << " < " << kTestTotalShards
<< ", but you have " << kTestShardIndex << "=" << shard_index << ", but you have " << kTestShardIndex << "=" << shard_index
<< ", " << kTestTotalShards << "=" << total_shards << ".\n"; << ", " << kTestTotalShards << "=" << total_shards << ".\n";
ColoredPrintf(COLOR_RED, msg.GetString().c_str()); ColoredPrintf(COLOR_RED, "%s", msg.GetString().c_str());
fflush(stdout); fflush(stdout);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -5373,7 +5355,7 @@ bool ShouldShard(const char* total_shards_env, ...@@ -5373,7 +5355,7 @@ bool ShouldShard(const char* total_shards_env,
// and aborts. // and aborts.
Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) { Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) {
const char* str_val = posix::GetEnv(var); const char* str_val = posix::GetEnv(var);
if (str_val == NULL) { if (str_val == nullptr) {
return default_val; return default_val;
} }
...@@ -5459,7 +5441,7 @@ int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) { ...@@ -5459,7 +5441,7 @@ int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
// max_length characters, only prints the first max_length characters // max_length characters, only prints the first max_length characters
// and "...". // and "...".
static void PrintOnOneLine(const char* str, int max_length) { static void PrintOnOneLine(const char* str, int max_length) {
if (str != NULL) { if (str != nullptr) {
for (int i = 0; *str != '\0'; ++str) { for (int i = 0; *str != '\0'; ++str) {
if (i >= max_length) { if (i >= max_length) {
printf("..."); printf("...");
...@@ -5492,7 +5474,7 @@ void UnitTestImpl::ListTestsMatchingFilter() { ...@@ -5492,7 +5474,7 @@ void UnitTestImpl::ListTestsMatchingFilter() {
if (!printed_test_case_name) { if (!printed_test_case_name) {
printed_test_case_name = true; printed_test_case_name = true;
printf("%s.", test_case->name()); printf("%s.", test_case->name());
if (test_case->type_param() != NULL) { if (test_case->type_param() != nullptr) {
printf(" # %s = ", kTypeParamLabel); printf(" # %s = ", kTypeParamLabel);
// We print the type parameter on a single line to make // We print the type parameter on a single line to make
// the output easy to parse by a program. // the output easy to parse by a program.
...@@ -5501,7 +5483,7 @@ void UnitTestImpl::ListTestsMatchingFilter() { ...@@ -5501,7 +5483,7 @@ void UnitTestImpl::ListTestsMatchingFilter() {
printf("\n"); printf("\n");
} }
printf(" %s", test_info->name()); printf(" %s", test_info->name());
if (test_info->value_param() != NULL) { if (test_info->value_param() != nullptr) {
printf(" # %s = ", kValueParamLabel); printf(" # %s = ", kValueParamLabel);
// We print the value parameter on a single line to make the // We print the value parameter on a single line to make the
// output easy to parse by a program. // output easy to parse by a program.
...@@ -5548,7 +5530,7 @@ void UnitTestImpl::set_os_stack_trace_getter( ...@@ -5548,7 +5530,7 @@ void UnitTestImpl::set_os_stack_trace_getter(
// otherwise, creates an OsStackTraceGetter, makes it the current // otherwise, creates an OsStackTraceGetter, makes it the current
// getter, and returns it. // getter, and returns it.
OsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() { OsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() {
if (os_stack_trace_getter_ == NULL) { if (os_stack_trace_getter_ == nullptr) {
#ifdef GTEST_OS_STACK_TRACE_GETTER_ #ifdef GTEST_OS_STACK_TRACE_GETTER_
os_stack_trace_getter_ = new GTEST_OS_STACK_TRACE_GETTER_; os_stack_trace_getter_ = new GTEST_OS_STACK_TRACE_GETTER_;
#else #else
...@@ -5561,10 +5543,10 @@ OsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() { ...@@ -5561,10 +5543,10 @@ OsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() {
// Returns the most specific TestResult currently running. // Returns the most specific TestResult currently running.
TestResult* UnitTestImpl::current_test_result() { TestResult* UnitTestImpl::current_test_result() {
if (current_test_info_ != NULL) { if (current_test_info_ != nullptr) {
return &current_test_info_->result_; return &current_test_info_->result_;
} }
if (current_test_case_ != NULL) { if (current_test_case_ != nullptr) {
return &current_test_case_->ad_hoc_test_result_; return &current_test_case_->ad_hoc_test_result_;
} }
return &ad_hoc_test_result_; return &ad_hoc_test_result_;
...@@ -5651,12 +5633,12 @@ bool SkipPrefix(const char* prefix, const char** pstr) { ...@@ -5651,12 +5633,12 @@ bool SkipPrefix(const char* prefix, const char** pstr) {
static const char* ParseFlagValue(const char* str, const char* flag, static const char* ParseFlagValue(const char* str, const char* flag,
bool def_optional) { bool def_optional) {
// str and flag must not be NULL. // str and flag must not be NULL.
if (str == NULL || flag == NULL) return NULL; if (str == nullptr || flag == nullptr) return nullptr;
// The flag must start with "--" followed by GTEST_FLAG_PREFIX_. // The flag must start with "--" followed by GTEST_FLAG_PREFIX_.
const std::string flag_str = std::string("--") + GTEST_FLAG_PREFIX_ + flag; const std::string flag_str = std::string("--") + GTEST_FLAG_PREFIX_ + flag;
const size_t flag_len = flag_str.length(); const size_t flag_len = flag_str.length();
if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL; if (strncmp(str, flag_str.c_str(), flag_len) != 0) return nullptr;
// Skips the flag name. // Skips the flag name.
const char* flag_end = str + flag_len; const char* flag_end = str + flag_len;
...@@ -5669,7 +5651,7 @@ static const char* ParseFlagValue(const char* str, const char* flag, ...@@ -5669,7 +5651,7 @@ static const char* ParseFlagValue(const char* str, const char* flag,
// If def_optional is true and there are more characters after the // If def_optional is true and there are more characters after the
// flag name, or if def_optional is false, there must be a '=' after // flag name, or if def_optional is false, there must be a '=' after
// the flag name. // the flag name.
if (flag_end[0] != '=') return NULL; if (flag_end[0] != '=') return nullptr;
// Returns the string after "=". // Returns the string after "=".
return flag_end + 1; return flag_end + 1;
...@@ -5690,7 +5672,7 @@ static bool ParseBoolFlag(const char* str, const char* flag, bool* value) { ...@@ -5690,7 +5672,7 @@ static bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
const char* const value_str = ParseFlagValue(str, flag, true); const char* const value_str = ParseFlagValue(str, flag, true);
// Aborts if the parsing failed. // Aborts if the parsing failed.
if (value_str == NULL) return false; if (value_str == nullptr) return false;
// Converts the string value to a bool. // Converts the string value to a bool.
*value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F'); *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');
...@@ -5707,7 +5689,7 @@ bool ParseInt32Flag(const char* str, const char* flag, Int32* value) { ...@@ -5707,7 +5689,7 @@ bool ParseInt32Flag(const char* str, const char* flag, Int32* value) {
const char* const value_str = ParseFlagValue(str, flag, false); const char* const value_str = ParseFlagValue(str, flag, false);
// Aborts if the parsing failed. // Aborts if the parsing failed.
if (value_str == NULL) return false; if (value_str == nullptr) return false;
// Sets *value to the value of the flag. // Sets *value to the value of the flag.
return ParseInt32(Message() << "The value of flag --" << flag, return ParseInt32(Message() << "The value of flag --" << flag,
...@@ -5725,7 +5707,7 @@ static bool ParseStringFlag(const char* str, const char* flag, String* value) { ...@@ -5725,7 +5707,7 @@ static bool ParseStringFlag(const char* str, const char* flag, String* value) {
const char* const value_str = ParseFlagValue(str, flag, false); const char* const value_str = ParseFlagValue(str, flag, false);
// Aborts if the parsing failed. // Aborts if the parsing failed.
if (value_str == NULL) return false; if (value_str == nullptr) return false;
// Sets *value to the value of the flag. // Sets *value to the value of the flag.
*value = value_str; *value = value_str;
...@@ -5767,7 +5749,7 @@ static void PrintColorEncoded(const char* str) { ...@@ -5767,7 +5749,7 @@ static void PrintColorEncoded(const char* str) {
// next segment. // next segment.
for (;;) { for (;;) {
const char* p = strchr(str, '@'); const char* p = strchr(str, '@');
if (p == NULL) { if (p == nullptr) {
ColoredPrintf(color, "%s", str); ColoredPrintf(color, "%s", str);
return; return;
} }
......
...@@ -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, "
......
...@@ -86,8 +86,8 @@ class StreamingListenerTest : public Test { ...@@ -86,8 +86,8 @@ class StreamingListenerTest : public Test {
StreamingListenerTest() StreamingListenerTest()
: fake_sock_writer_(new FakeSocketWriter), : fake_sock_writer_(new FakeSocketWriter),
streamer_(fake_sock_writer_), streamer_(fake_sock_writer_),
test_info_obj_("FooTest", "Bar", NULL, NULL, test_info_obj_("FooTest", "Bar", nullptr, nullptr,
CodeLocation(__FILE__, __LINE__), 0, NULL) {} CodeLocation(__FILE__, __LINE__), nullptr, nullptr) {}
protected: protected:
std::string* output() { return &(fake_sock_writer_->output_); } std::string* output() { return &(fake_sock_writer_->output_); }
...@@ -112,13 +112,13 @@ TEST_F(StreamingListenerTest, OnTestIterationEnd) { ...@@ -112,13 +112,13 @@ TEST_F(StreamingListenerTest, OnTestIterationEnd) {
TEST_F(StreamingListenerTest, OnTestCaseStart) { TEST_F(StreamingListenerTest, OnTestCaseStart) {
*output() = ""; *output() = "";
streamer_.OnTestCaseStart(TestCase("FooTest", "Bar", NULL, NULL)); streamer_.OnTestCaseStart(TestCase("FooTest", "Bar", nullptr, nullptr));
EXPECT_EQ("event=TestCaseStart&name=FooTest\n", *output()); EXPECT_EQ("event=TestCaseStart&name=FooTest\n", *output());
} }
TEST_F(StreamingListenerTest, OnTestCaseEnd) { TEST_F(StreamingListenerTest, OnTestCaseEnd) {
*output() = ""; *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()); EXPECT_EQ("event=TestCaseEnd&passed=1&elapsed_time=0ms\n", *output());
} }
...@@ -439,7 +439,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { ...@@ -439,7 +439,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
private: private:
virtual void SetUp() { virtual void SetUp() {
saved_tz_ = NULL; saved_tz_ = nullptr;
GTEST_DISABLE_MSC_DEPRECATED_PUSH_(/* getenv, strdup: deprecated */) GTEST_DISABLE_MSC_DEPRECATED_PUSH_(/* getenv, strdup: deprecated */)
if (getenv("TZ")) if (getenv("TZ"))
...@@ -455,7 +455,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { ...@@ -455,7 +455,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
virtual void TearDown() { virtual void TearDown() {
SetTimeZone(saved_tz_); SetTimeZone(saved_tz_);
free(const_cast<char*>(saved_tz_)); free(const_cast<char*>(saved_tz_));
saved_tz_ = NULL; saved_tz_ = nullptr;
} }
static void SetTimeZone(const char* time_zone) { static void SetTimeZone(const char* time_zone) {
...@@ -521,10 +521,10 @@ TEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsEpochStart) { ...@@ -521,10 +521,10 @@ TEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsEpochStart) {
// Tests that GTEST_IS_NULL_LITERAL_(x) is true when x is a null // Tests that GTEST_IS_NULL_LITERAL_(x) is true when x is a null
// pointer literal. // pointer literal.
TEST(NullLiteralTest, IsTrueForNullLiterals) { TEST(NullLiteralTest, IsTrueForNullLiterals) {
EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(NULL)); EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(nullptr));
EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0)); EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(nullptr));
EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0U)); EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(nullptr));
EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0L)); EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(nullptr));
} }
// Tests that GTEST_IS_NULL_LITERAL_(x) is false when x is not a null // Tests that GTEST_IS_NULL_LITERAL_(x) is false when x is not a null
...@@ -533,7 +533,7 @@ TEST(NullLiteralTest, IsFalseForNonNullLiterals) { ...@@ -533,7 +533,7 @@ TEST(NullLiteralTest, IsFalseForNonNullLiterals) {
EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(1)); EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(1));
EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(0.0)); EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(0.0));
EXPECT_FALSE(GTEST_IS_NULL_LITERAL_('a')); 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__ # ifdef __BORLANDC__
...@@ -1032,11 +1032,11 @@ TEST(StringTest, EndsWithCaseInsensitive) { ...@@ -1032,11 +1032,11 @@ TEST(StringTest, EndsWithCaseInsensitive) {
// C++Builder's preprocessor is buggy; it fails to expand macros that // C++Builder's preprocessor is buggy; it fails to expand macros that
// appear in macro parameters after wide char literals. Provide an alias // appear in macro parameters after wide char literals. Provide an alias
// for NULL as a workaround. // for NULL as a workaround.
static const wchar_t* const kNull = NULL; static const wchar_t* const kNull = nullptr;
// Tests String::CaseInsensitiveWideCStringEquals // Tests String::CaseInsensitiveWideCStringEquals
TEST(StringTest, 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(kNull, L""));
EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(L"", kNull)); EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(L"", kNull));
EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(kNull, L"foobar")); EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(kNull, L"foobar"));
...@@ -1157,7 +1157,7 @@ class ScopedFakeTestPartResultReporterWithThreadsTest ...@@ -1157,7 +1157,7 @@ class ScopedFakeTestPartResultReporterWithThreadsTest
: public ScopedFakeTestPartResultReporterTest { : public ScopedFakeTestPartResultReporterTest {
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();
} }
}; };
...@@ -1578,7 +1578,7 @@ class GTestFlagSaverTest : public Test { ...@@ -1578,7 +1578,7 @@ class GTestFlagSaverTest : public Test {
// be called after the last test in this test case is run. // be called after the last test in this test case is run.
static void TearDownTestCase() { static void TearDownTestCase() {
delete saver_; delete saver_;
saver_ = NULL; saver_ = nullptr;
} }
// Verifies that the Google Test flags have their default values, and then // Verifies that the Google Test flags have their default values, and then
...@@ -1622,7 +1622,7 @@ class GTestFlagSaverTest : public Test { ...@@ -1622,7 +1622,7 @@ class GTestFlagSaverTest : public Test {
static GTestFlagSaver* saver_; static GTestFlagSaver* saver_;
}; };
GTestFlagSaver* GTestFlagSaverTest::saver_ = NULL; GTestFlagSaver* GTestFlagSaverTest::saver_ = nullptr;
// Google Test doesn't guarantee the order of tests. The following two // Google Test doesn't guarantee the order of tests. The following two
// tests are designed to work regardless of their order. // tests are designed to work regardless of their order.
...@@ -1947,7 +1947,7 @@ TEST(ShouldRunTestOnShardTest, IsPartitionWhenThereAreFiveShards) { ...@@ -1947,7 +1947,7 @@ TEST(ShouldRunTestOnShardTest, IsPartitionWhenThereAreFiveShards) {
// TEST, TEST_F, RUN_ALL_TESTS // TEST, TEST_F, RUN_ALL_TESTS
TEST(UnitTestTest, CanGetOriginalWorkingDir) { 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(), ""); EXPECT_STRNE(UnitTest::GetInstance()->original_working_dir(), "");
} }
...@@ -1969,7 +1969,7 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKey( ...@@ -1969,7 +1969,7 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKey(
void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest( void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
const char* key) { const char* key) {
const TestInfo* test_info = UnitTest::GetInstance()->current_test_info(); const TestInfo* test_info = UnitTest::GetInstance()->current_test_info();
ASSERT_TRUE(test_info != NULL); ASSERT_TRUE(test_info != nullptr);
ExpectNonFatalFailureRecordingPropertyWithReservedKey(*test_info->result(), ExpectNonFatalFailureRecordingPropertyWithReservedKey(*test_info->result(),
key); key);
} }
...@@ -1977,7 +1977,7 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest( ...@@ -1977,7 +1977,7 @@ void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(
void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase( void ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(
const char* key) { const char* key) {
const TestCase* test_case = UnitTest::GetInstance()->current_test_case(); const TestCase* test_case = UnitTest::GetInstance()->current_test_case();
ASSERT_TRUE(test_case != NULL); ASSERT_TRUE(test_case != nullptr);
ExpectNonFatalFailureRecordingPropertyWithReservedKey( ExpectNonFatalFailureRecordingPropertyWithReservedKey(
test_case->ad_hoc_test_result(), key); test_case->ad_hoc_test_result(), key);
} }
...@@ -2010,7 +2010,7 @@ class UnitTestRecordPropertyTest : ...@@ -2010,7 +2010,7 @@ class UnitTestRecordPropertyTest :
Test::RecordProperty("test_case_key_1", "1"); Test::RecordProperty("test_case_key_1", "1");
const TestCase* test_case = UnitTest::GetInstance()->current_test_case(); 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()); ASSERT_EQ(1, test_case->ad_hoc_test_result().test_property_count());
EXPECT_STREQ("test_case_key_1", EXPECT_STREQ("test_case_key_1",
...@@ -2454,24 +2454,22 @@ TEST(StringAssertionTest, ASSERT_STREQ) { ...@@ -2454,24 +2454,22 @@ TEST(StringAssertionTest, ASSERT_STREQ) {
// Tests ASSERT_STREQ with NULL arguments. // Tests ASSERT_STREQ with NULL arguments.
TEST(StringAssertionTest, ASSERT_STREQ_Null) { TEST(StringAssertionTest, ASSERT_STREQ_Null) {
ASSERT_STREQ(static_cast<const char *>(NULL), NULL); ASSERT_STREQ(static_cast<const char*>(nullptr), nullptr);
EXPECT_FATAL_FAILURE(ASSERT_STREQ(NULL, "non-null"), EXPECT_FATAL_FAILURE(ASSERT_STREQ(nullptr, "non-null"), "non-null");
"non-null");
} }
// Tests ASSERT_STREQ with NULL arguments. // Tests ASSERT_STREQ with NULL arguments.
TEST(StringAssertionTest, ASSERT_STREQ_Null2) { TEST(StringAssertionTest, ASSERT_STREQ_Null2) {
EXPECT_FATAL_FAILURE(ASSERT_STREQ("non-null", NULL), EXPECT_FATAL_FAILURE(ASSERT_STREQ("non-null", nullptr), "non-null");
"non-null");
} }
// Tests ASSERT_STRNE. // Tests ASSERT_STRNE.
TEST(StringAssertionTest, ASSERT_STRNE) { TEST(StringAssertionTest, ASSERT_STRNE) {
ASSERT_STRNE("hi", "Hi"); ASSERT_STRNE("hi", "Hi");
ASSERT_STRNE("Hi", NULL); ASSERT_STRNE("Hi", nullptr);
ASSERT_STRNE(NULL, "Hi"); ASSERT_STRNE(nullptr, "Hi");
ASSERT_STRNE("", NULL); ASSERT_STRNE("", nullptr);
ASSERT_STRNE(NULL, ""); ASSERT_STRNE(nullptr, "");
ASSERT_STRNE("", "Hi"); ASSERT_STRNE("", "Hi");
ASSERT_STRNE("Hi", ""); ASSERT_STRNE("Hi", "");
EXPECT_FATAL_FAILURE(ASSERT_STRNE("Hi", "Hi"), EXPECT_FATAL_FAILURE(ASSERT_STRNE("Hi", "Hi"),
...@@ -2481,7 +2479,7 @@ TEST(StringAssertionTest, ASSERT_STRNE) { ...@@ -2481,7 +2479,7 @@ TEST(StringAssertionTest, ASSERT_STRNE) {
// Tests ASSERT_STRCASEEQ. // Tests ASSERT_STRCASEEQ.
TEST(StringAssertionTest, ASSERT_STRCASEEQ) { TEST(StringAssertionTest, ASSERT_STRCASEEQ) {
ASSERT_STRCASEEQ("hi", "Hi"); ASSERT_STRCASEEQ("hi", "Hi");
ASSERT_STRCASEEQ(static_cast<const char *>(NULL), NULL); ASSERT_STRCASEEQ(static_cast<const char*>(nullptr), nullptr);
ASSERT_STRCASEEQ("", ""); ASSERT_STRCASEEQ("", "");
EXPECT_FATAL_FAILURE(ASSERT_STRCASEEQ("Hi", "hi2"), EXPECT_FATAL_FAILURE(ASSERT_STRCASEEQ("Hi", "hi2"),
...@@ -2491,10 +2489,10 @@ TEST(StringAssertionTest, ASSERT_STRCASEEQ) { ...@@ -2491,10 +2489,10 @@ TEST(StringAssertionTest, ASSERT_STRCASEEQ) {
// Tests ASSERT_STRCASENE. // Tests ASSERT_STRCASENE.
TEST(StringAssertionTest, ASSERT_STRCASENE) { TEST(StringAssertionTest, ASSERT_STRCASENE) {
ASSERT_STRCASENE("hi1", "Hi2"); ASSERT_STRCASENE("hi1", "Hi2");
ASSERT_STRCASENE("Hi", NULL); ASSERT_STRCASENE("Hi", nullptr);
ASSERT_STRCASENE(NULL, "Hi"); ASSERT_STRCASENE(nullptr, "Hi");
ASSERT_STRCASENE("", NULL); ASSERT_STRCASENE("", nullptr);
ASSERT_STRCASENE(NULL, ""); ASSERT_STRCASENE(nullptr, "");
ASSERT_STRCASENE("", "Hi"); ASSERT_STRCASENE("", "Hi");
ASSERT_STRCASENE("Hi", ""); ASSERT_STRCASENE("Hi", "");
EXPECT_FATAL_FAILURE(ASSERT_STRCASENE("Hi", "hi"), EXPECT_FATAL_FAILURE(ASSERT_STRCASENE("Hi", "hi"),
...@@ -2504,14 +2502,13 @@ TEST(StringAssertionTest, ASSERT_STRCASENE) { ...@@ -2504,14 +2502,13 @@ TEST(StringAssertionTest, ASSERT_STRCASENE) {
// Tests *_STREQ on wide strings. // Tests *_STREQ on wide strings.
TEST(StringAssertionTest, STREQ_Wide) { TEST(StringAssertionTest, STREQ_Wide) {
// NULL strings. // NULL strings.
ASSERT_STREQ(static_cast<const wchar_t *>(NULL), NULL); ASSERT_STREQ(static_cast<const wchar_t*>(nullptr), nullptr);
// Empty strings. // Empty strings.
ASSERT_STREQ(L"", L""); ASSERT_STREQ(L"", L"");
// Non-null vs NULL. // Non-null vs NULL.
EXPECT_NONFATAL_FAILURE(EXPECT_STREQ(L"non-null", NULL), EXPECT_NONFATAL_FAILURE(EXPECT_STREQ(L"non-null", nullptr), "non-null");
"non-null");
// Equal strings. // Equal strings.
EXPECT_STREQ(L"Hi", L"Hi"); EXPECT_STREQ(L"Hi", L"Hi");
...@@ -2533,16 +2530,18 @@ TEST(StringAssertionTest, STREQ_Wide) { ...@@ -2533,16 +2530,18 @@ TEST(StringAssertionTest, STREQ_Wide) {
// Tests *_STRNE on wide strings. // Tests *_STRNE on wide strings.
TEST(StringAssertionTest, STRNE_Wide) { TEST(StringAssertionTest, STRNE_Wide) {
// NULL strings. // NULL strings.
EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_NONFATAL_FAILURE(
EXPECT_STRNE(static_cast<const wchar_t *>(NULL), NULL); { // NOLINT
}, ""); EXPECT_STRNE(static_cast<const wchar_t*>(nullptr), nullptr);
},
"");
// Empty strings. // Empty strings.
EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(L"", L""), EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(L"", L""),
"L\"\""); "L\"\"");
// Non-null vs NULL. // Non-null vs NULL.
ASSERT_STRNE(L"non-null", NULL); ASSERT_STRNE(L"non-null", nullptr);
// Equal strings. // Equal strings.
EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(L"Hi", L"Hi"), EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(L"Hi", L"Hi"),
...@@ -2564,11 +2563,11 @@ TEST(StringAssertionTest, STRNE_Wide) { ...@@ -2564,11 +2563,11 @@ TEST(StringAssertionTest, STRNE_Wide) {
// Tests that IsSubstring() returns the correct result when the input // Tests that IsSubstring() returns the correct result when the input
// argument type is const char*. // argument type is const char*.
TEST(IsSubstringTest, ReturnsCorrectResultForCString) { TEST(IsSubstringTest, ReturnsCorrectResultForCString) {
EXPECT_FALSE(IsSubstring("", "", NULL, "a")); EXPECT_FALSE(IsSubstring("", "", nullptr, "a"));
EXPECT_FALSE(IsSubstring("", "", "b", NULL)); EXPECT_FALSE(IsSubstring("", "", "b", nullptr));
EXPECT_FALSE(IsSubstring("", "", "needle", "haystack")); 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")); EXPECT_TRUE(IsSubstring("", "", "needle", "two needles"));
} }
...@@ -2579,7 +2578,8 @@ TEST(IsSubstringTest, ReturnsCorrectResultForWideCString) { ...@@ -2579,7 +2578,8 @@ TEST(IsSubstringTest, ReturnsCorrectResultForWideCString) {
EXPECT_FALSE(IsSubstring("", "", L"b", kNull)); EXPECT_FALSE(IsSubstring("", "", L"b", kNull));
EXPECT_FALSE(IsSubstring("", "", L"needle", L"haystack")); 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")); EXPECT_TRUE(IsSubstring("", "", L"needle", L"two needles"));
} }
...@@ -3714,17 +3714,16 @@ TEST(AssertionTest, ASSERT_EQ) { ...@@ -3714,17 +3714,16 @@ TEST(AssertionTest, ASSERT_EQ) {
#if GTEST_CAN_COMPARE_NULL #if GTEST_CAN_COMPARE_NULL
TEST(AssertionTest, ASSERT_EQ_NULL) { TEST(AssertionTest, ASSERT_EQ_NULL) {
// A success. // A success.
const char* p = NULL; const char* p = nullptr;
// Some older GCC versions may issue a spurious warning in this or the next // Some older GCC versions may issue a spurious warning in this or the next
// assertion statement. This warning should not be suppressed with // assertion statement. This warning should not be suppressed with
// static_cast since the test verifies the ability to use bare NULL as the // static_cast since the test verifies the ability to use bare NULL as the
// expected parameter to the macro. // expected parameter to the macro.
ASSERT_EQ(NULL, p); ASSERT_EQ(nullptr, p);
// A failure. // A failure.
static int n = 0; static int n = 0;
EXPECT_FATAL_FAILURE(ASSERT_EQ(NULL, &n), EXPECT_FATAL_FAILURE(ASSERT_EQ(nullptr, &n), " &n\n Which is:");
" &n\n Which is:");
} }
#endif // GTEST_CAN_COMPARE_NULL #endif // GTEST_CAN_COMPARE_NULL
...@@ -4330,10 +4329,12 @@ TEST(AssertionWithMessageTest, SUCCEED) { ...@@ -4330,10 +4329,12 @@ TEST(AssertionWithMessageTest, SUCCEED) {
TEST(AssertionWithMessageTest, ASSERT_TRUE) { TEST(AssertionWithMessageTest, ASSERT_TRUE) {
ASSERT_TRUE(true) << "This should succeed."; ASSERT_TRUE(true) << "This should succeed.";
ASSERT_TRUE(true) << true; ASSERT_TRUE(true) << true;
EXPECT_FATAL_FAILURE({ // NOLINT EXPECT_FATAL_FAILURE(
ASSERT_TRUE(false) << static_cast<const char *>(NULL) { // NOLINT
<< static_cast<char *>(NULL); ASSERT_TRUE(false) << static_cast<const char*>(nullptr)
}, "(null)(null)"); << static_cast<char*>(nullptr);
},
"(null)(null)");
} }
#if GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
...@@ -4442,17 +4443,16 @@ TEST(ExpectTest, EXPECT_EQ_Double) { ...@@ -4442,17 +4443,16 @@ TEST(ExpectTest, EXPECT_EQ_Double) {
// Tests EXPECT_EQ(NULL, pointer). // Tests EXPECT_EQ(NULL, pointer).
TEST(ExpectTest, EXPECT_EQ_NULL) { TEST(ExpectTest, EXPECT_EQ_NULL) {
// A success. // A success.
const char* p = NULL; const char* p = nullptr;
// Some older GCC versions may issue a spurious warning in this or the next // Some older GCC versions may issue a spurious warning in this or the next
// assertion statement. This warning should not be suppressed with // assertion statement. This warning should not be suppressed with
// static_cast since the test verifies the ability to use bare NULL as the // static_cast since the test verifies the ability to use bare NULL as the
// expected parameter to the macro. // expected parameter to the macro.
EXPECT_EQ(NULL, p); EXPECT_EQ(nullptr, p);
// A failure. // A failure.
int n = 0; int n = 0;
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(NULL, &n), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(nullptr, &n), " &n\n Which is:");
" &n\n Which is:");
} }
#endif // GTEST_CAN_COMPARE_NULL #endif // GTEST_CAN_COMPARE_NULL
...@@ -4480,7 +4480,7 @@ TEST(ExpectTest, EXPECT_NE) { ...@@ -4480,7 +4480,7 @@ TEST(ExpectTest, EXPECT_NE) {
"actual: 'a' (97, 0x61) vs 'a' (97, 0x61)"); "actual: 'a' (97, 0x61) vs 'a' (97, 0x61)");
EXPECT_NONFATAL_FAILURE(EXPECT_NE(2, 2), EXPECT_NONFATAL_FAILURE(EXPECT_NE(2, 2),
"2"); "2");
char* const p0 = NULL; char* const p0 = nullptr;
EXPECT_NONFATAL_FAILURE(EXPECT_NE(p0, p0), EXPECT_NONFATAL_FAILURE(EXPECT_NE(p0, p0),
"p0"); "p0");
// Only way to get the Nokia compiler to compile the cast // Only way to get the Nokia compiler to compile the cast
...@@ -4588,7 +4588,7 @@ TEST(StreamableToStringTest, Pointer) { ...@@ -4588,7 +4588,7 @@ TEST(StreamableToStringTest, Pointer) {
// Tests using StreamableToString() on a NULL non-char pointer. // Tests using StreamableToString() on a NULL non-char pointer.
TEST(StreamableToStringTest, NullPointer) { TEST(StreamableToStringTest, NullPointer) {
int* p = NULL; int* p = nullptr;
EXPECT_STREQ("(null)", StreamableToString(p).c_str()); EXPECT_STREQ("(null)", StreamableToString(p).c_str());
} }
...@@ -4599,7 +4599,7 @@ TEST(StreamableToStringTest, CString) { ...@@ -4599,7 +4599,7 @@ TEST(StreamableToStringTest, CString) {
// Tests using StreamableToString() on a NULL C string. // Tests using StreamableToString() on a NULL C string.
TEST(StreamableToStringTest, NullCString) { TEST(StreamableToStringTest, NullCString) {
char* p = NULL; char* p = nullptr;
EXPECT_STREQ("(null)", StreamableToString(p).c_str()); EXPECT_STREQ("(null)", StreamableToString(p).c_str());
} }
...@@ -4644,8 +4644,7 @@ TEST(StreamableTest, int) { ...@@ -4644,8 +4644,7 @@ TEST(StreamableTest, int) {
// implemented a workaround (substituting "(null)" for NULL). This // implemented a workaround (substituting "(null)" for NULL). This
// tests whether the workaround works. // tests whether the workaround works.
TEST(StreamableTest, NullCharPtr) { TEST(StreamableTest, NullCharPtr) {
EXPECT_FATAL_FAILURE(FAIL() << static_cast<const char*>(NULL), EXPECT_FATAL_FAILURE(FAIL() << static_cast<const char*>(nullptr), "(null)");
"(null)");
} }
// Tests that basic IO manipulators (endl, ends, and flush) can be // Tests that basic IO manipulators (endl, ends, and flush) can be
...@@ -4898,7 +4897,7 @@ TEST(EqAssertionTest, GlobalWideString) { ...@@ -4898,7 +4897,7 @@ TEST(EqAssertionTest, GlobalWideString) {
// Tests using char pointers in {EXPECT|ASSERT}_EQ. // Tests using char pointers in {EXPECT|ASSERT}_EQ.
TEST(EqAssertionTest, CharPointer) { TEST(EqAssertionTest, CharPointer) {
char* const p0 = NULL; char* const p0 = nullptr;
// Only way to get the Nokia compiler to compile the cast // Only way to get the Nokia compiler to compile the cast
// is to have a separate void* variable first. Putting // is to have a separate void* variable first. Putting
// the two casts on the same line doesn't work, neither does // the two casts on the same line doesn't work, neither does
...@@ -4920,7 +4919,7 @@ TEST(EqAssertionTest, CharPointer) { ...@@ -4920,7 +4919,7 @@ TEST(EqAssertionTest, CharPointer) {
// Tests using wchar_t pointers in {EXPECT|ASSERT}_EQ. // Tests using wchar_t pointers in {EXPECT|ASSERT}_EQ.
TEST(EqAssertionTest, WideCharPointer) { TEST(EqAssertionTest, WideCharPointer) {
wchar_t* const p0 = NULL; wchar_t* const p0 = nullptr;
// Only way to get the Nokia compiler to compile the cast // Only way to get the Nokia compiler to compile the cast
// is to have a separate void* variable first. Putting // is to have a separate void* variable first. Putting
// the two casts on the same line doesn't work, neither does // the two casts on the same line doesn't work, neither does
...@@ -4945,9 +4944,8 @@ TEST(EqAssertionTest, WideCharPointer) { ...@@ -4945,9 +4944,8 @@ TEST(EqAssertionTest, WideCharPointer) {
// Tests using other types of pointers in {EXPECT|ASSERT}_EQ. // Tests using other types of pointers in {EXPECT|ASSERT}_EQ.
TEST(EqAssertionTest, OtherPointer) { TEST(EqAssertionTest, OtherPointer) {
ASSERT_EQ(static_cast<const int*>(NULL), ASSERT_EQ(static_cast<const int*>(nullptr), static_cast<const int*>(nullptr));
static_cast<const int*>(NULL)); EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<const int*>(nullptr),
EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<const int*>(NULL),
reinterpret_cast<const int*>(0x1234)), reinterpret_cast<const int*>(0x1234)),
"0x1234"); "0x1234");
} }
...@@ -5280,12 +5278,12 @@ TEST(MessageTest, CanStreamUserTypeInUserNameSpaceWithStreamOperatorInGlobal) { ...@@ -5280,12 +5278,12 @@ TEST(MessageTest, CanStreamUserTypeInUserNameSpaceWithStreamOperatorInGlobal) {
// Tests streaming NULL pointers to testing::Message. // Tests streaming NULL pointers to testing::Message.
TEST(MessageTest, NullPointers) { TEST(MessageTest, NullPointers) {
Message msg; Message msg;
char* const p1 = NULL; char* const p1 = nullptr;
unsigned char* const p2 = NULL; unsigned char* const p2 = nullptr;
int* p3 = NULL; int* p3 = nullptr;
double* p4 = NULL; double* p4 = nullptr;
bool* p5 = NULL; bool* p5 = nullptr;
Message* p6 = NULL; Message* p6 = nullptr;
msg << p1 << p2 << p3 << p4 << p5 << p6; msg << p1 << p2 << p3 << p4 << p5 << p6;
ASSERT_STREQ("(null)(null)(null)(null)(null)(null)", ASSERT_STREQ("(null)(null)(null)(null)(null)(null)",
...@@ -5295,12 +5293,12 @@ TEST(MessageTest, NullPointers) { ...@@ -5295,12 +5293,12 @@ TEST(MessageTest, NullPointers) {
// Tests streaming wide strings to testing::Message. // Tests streaming wide strings to testing::Message.
TEST(MessageTest, WideStrings) { TEST(MessageTest, WideStrings) {
// Streams a NULL of type const wchar_t*. // Streams a NULL of type const wchar_t*.
const wchar_t* const_wstr = NULL; const wchar_t* const_wstr = nullptr;
EXPECT_STREQ("(null)", EXPECT_STREQ("(null)",
(Message() << const_wstr).GetString().c_str()); (Message() << const_wstr).GetString().c_str());
// Streams a NULL of type wchar_t*. // Streams a NULL of type wchar_t*.
wchar_t* wstr = NULL; wchar_t* wstr = nullptr;
EXPECT_STREQ("(null)", EXPECT_STREQ("(null)",
(Message() << wstr).GetString().c_str()); (Message() << wstr).GetString().c_str());
...@@ -5324,15 +5322,15 @@ namespace testing { ...@@ -5324,15 +5322,15 @@ namespace testing {
class TestInfoTest : public Test { class TestInfoTest : public Test {
protected: protected:
static const TestInfo* GetTestInfo(const char* test_name) { static const TestInfo* GetTestInfo(const char* test_name) {
const TestCase* const test_case = GetUnitTestImpl()-> const TestCase* const test_case =
GetTestCase("TestInfoTest", "", NULL, NULL); GetUnitTestImpl()->GetTestCase("TestInfoTest", "", nullptr, nullptr);
for (int i = 0; i < test_case->total_test_count(); ++i) { for (int i = 0; i < test_case->total_test_count(); ++i) {
const TestInfo* const test_info = test_case->GetTestInfo(i); const TestInfo* const test_info = test_case->GetTestInfo(i);
if (strcmp(test_name, test_info->name()) == 0) if (strcmp(test_name, test_info->name()) == 0)
return test_info; return test_info;
} }
return NULL; return nullptr;
} }
static const TestResult* GetTestResult( static const TestResult* GetTestResult(
...@@ -5446,7 +5444,7 @@ class SetUpTestCaseTest : public Test { ...@@ -5446,7 +5444,7 @@ class SetUpTestCaseTest : public Test {
EXPECT_EQ(0, counter_); EXPECT_EQ(0, counter_);
// Cleans up the shared resource. // Cleans up the shared resource.
shared_resource_ = NULL; shared_resource_ = nullptr;
} }
// This will be called before each test in this test case. // This will be called before each test in this test case.
...@@ -5464,12 +5462,10 @@ class SetUpTestCaseTest : public Test { ...@@ -5464,12 +5462,10 @@ class SetUpTestCaseTest : public Test {
}; };
int SetUpTestCaseTest::counter_ = 0; int SetUpTestCaseTest::counter_ = 0;
const char* SetUpTestCaseTest::shared_resource_ = NULL; const char* SetUpTestCaseTest::shared_resource_ = nullptr;
// A test that uses the shared resource. // A test that uses the shared resource.
TEST_F(SetUpTestCaseTest, Test1) { TEST_F(SetUpTestCaseTest, Test1) { EXPECT_STRNE(nullptr, shared_resource_); }
EXPECT_STRNE(NULL, shared_resource_);
}
// Another test that uses the shared resource. // Another test that uses the shared resource.
TEST_F(SetUpTestCaseTest, Test2) { TEST_F(SetUpTestCaseTest, Test2) {
...@@ -5737,141 +5733,81 @@ class ParseFlagsTest : public Test { ...@@ -5737,141 +5733,81 @@ class ParseFlagsTest : public Test {
// Tests parsing an empty command line. // Tests parsing an empty command line.
TEST_F(ParseFlagsTest, Empty) { TEST_F(ParseFlagsTest, Empty) {
const char* argv[] = { const char* argv[] = {nullptr};
NULL
};
const char* argv2[] = { const char* argv2[] = {nullptr};
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), false);
} }
// Tests parsing a command line that has no flag. // Tests parsing a command line that has no flag.
TEST_F(ParseFlagsTest, NoFlag) { TEST_F(ParseFlagsTest, NoFlag) {
const char* argv[] = { const char* argv[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), false);
} }
// Tests parsing a bad --gtest_filter flag. // Tests parsing a bad --gtest_filter flag.
TEST_F(ParseFlagsTest, FilterBad) { TEST_F(ParseFlagsTest, FilterBad) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_filter", nullptr};
"foo.exe",
"--gtest_filter",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", "--gtest_filter", nullptr};
"foo.exe",
"--gtest_filter",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), true); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), true);
} }
// Tests parsing an empty --gtest_filter flag. // Tests parsing an empty --gtest_filter flag.
TEST_F(ParseFlagsTest, FilterEmpty) { TEST_F(ParseFlagsTest, FilterEmpty) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_filter=", nullptr};
"foo.exe",
"--gtest_filter=",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), false);
} }
// Tests parsing a non-empty --gtest_filter flag. // Tests parsing a non-empty --gtest_filter flag.
TEST_F(ParseFlagsTest, FilterNonEmpty) { TEST_F(ParseFlagsTest, FilterNonEmpty) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_filter=abc", nullptr};
"foo.exe",
"--gtest_filter=abc",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter("abc"), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter("abc"), false);
} }
// Tests parsing --gtest_break_on_failure. // Tests parsing --gtest_break_on_failure.
TEST_F(ParseFlagsTest, BreakOnFailureWithoutValue) { TEST_F(ParseFlagsTest, BreakOnFailureWithoutValue) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_break_on_failure", nullptr};
"foo.exe",
"--gtest_break_on_failure",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(true), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(true), false);
} }
// Tests parsing --gtest_break_on_failure=0. // Tests parsing --gtest_break_on_failure=0.
TEST_F(ParseFlagsTest, BreakOnFailureFalse_0) { TEST_F(ParseFlagsTest, BreakOnFailureFalse_0) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_break_on_failure=0", nullptr};
"foo.exe",
"--gtest_break_on_failure=0",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false);
} }
// Tests parsing --gtest_break_on_failure=f. // Tests parsing --gtest_break_on_failure=f.
TEST_F(ParseFlagsTest, BreakOnFailureFalse_f) { TEST_F(ParseFlagsTest, BreakOnFailureFalse_f) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_break_on_failure=f", nullptr};
"foo.exe",
"--gtest_break_on_failure=f",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false);
} }
// Tests parsing --gtest_break_on_failure=F. // Tests parsing --gtest_break_on_failure=F.
TEST_F(ParseFlagsTest, BreakOnFailureFalse_F) { TEST_F(ParseFlagsTest, BreakOnFailureFalse_F) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_break_on_failure=F", nullptr};
"foo.exe",
"--gtest_break_on_failure=F",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false);
} }
...@@ -5879,48 +5815,27 @@ TEST_F(ParseFlagsTest, BreakOnFailureFalse_F) { ...@@ -5879,48 +5815,27 @@ TEST_F(ParseFlagsTest, BreakOnFailureFalse_F) {
// Tests parsing a --gtest_break_on_failure flag that has a "true" // Tests parsing a --gtest_break_on_failure flag that has a "true"
// definition. // definition.
TEST_F(ParseFlagsTest, BreakOnFailureTrue) { TEST_F(ParseFlagsTest, BreakOnFailureTrue) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_break_on_failure=1", nullptr};
"foo.exe",
"--gtest_break_on_failure=1",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(true), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(true), false);
} }
// Tests parsing --gtest_catch_exceptions. // Tests parsing --gtest_catch_exceptions.
TEST_F(ParseFlagsTest, CatchExceptions) { TEST_F(ParseFlagsTest, CatchExceptions) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_catch_exceptions", nullptr};
"foo.exe",
"--gtest_catch_exceptions",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::CatchExceptions(true), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::CatchExceptions(true), false);
} }
// Tests parsing --gtest_death_test_use_fork. // Tests parsing --gtest_death_test_use_fork.
TEST_F(ParseFlagsTest, DeathTestUseFork) { TEST_F(ParseFlagsTest, DeathTestUseFork) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_death_test_use_fork", nullptr};
"foo.exe",
"--gtest_death_test_use_fork",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::DeathTestUseFork(true), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::DeathTestUseFork(true), false);
} }
...@@ -5928,36 +5843,21 @@ TEST_F(ParseFlagsTest, DeathTestUseFork) { ...@@ -5928,36 +5843,21 @@ TEST_F(ParseFlagsTest, DeathTestUseFork) {
// Tests having the same flag twice with different values. The // Tests having the same flag twice with different values. The
// expected behavior is that the one coming last takes precedence. // expected behavior is that the one coming last takes precedence.
TEST_F(ParseFlagsTest, DuplicatedFlags) { TEST_F(ParseFlagsTest, DuplicatedFlags) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_filter=a", "--gtest_filter=b",
"foo.exe", nullptr};
"--gtest_filter=a",
"--gtest_filter=b",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter("b"), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter("b"), false);
} }
// Tests having an unrecognized flag on the command line. // Tests having an unrecognized flag on the command line.
TEST_F(ParseFlagsTest, UnrecognizedFlag) { TEST_F(ParseFlagsTest, UnrecognizedFlag) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_break_on_failure",
"foo.exe", "bar", // Unrecognized by Google Test.
"--gtest_break_on_failure", "--gtest_filter=b", nullptr};
"bar", // Unrecognized by Google Test.
"--gtest_filter=b",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", "bar", nullptr};
"foo.exe",
"bar",
NULL
};
Flags flags; Flags flags;
flags.break_on_failure = true; flags.break_on_failure = true;
...@@ -5967,145 +5867,82 @@ TEST_F(ParseFlagsTest, UnrecognizedFlag) { ...@@ -5967,145 +5867,82 @@ TEST_F(ParseFlagsTest, UnrecognizedFlag) {
// Tests having a --gtest_list_tests flag // Tests having a --gtest_list_tests flag
TEST_F(ParseFlagsTest, ListTestsFlag) { TEST_F(ParseFlagsTest, ListTestsFlag) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_list_tests", nullptr};
"foo.exe",
"--gtest_list_tests",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
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 // Tests having a --gtest_list_tests flag with a "true" value
TEST_F(ParseFlagsTest, ListTestsTrue) { TEST_F(ParseFlagsTest, ListTestsTrue) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_list_tests=1", nullptr};
"foo.exe",
"--gtest_list_tests=1",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
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 // Tests having a --gtest_list_tests flag with a "false" value
TEST_F(ParseFlagsTest, ListTestsFalse) { TEST_F(ParseFlagsTest, ListTestsFalse) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_list_tests=0", nullptr};
"foo.exe",
"--gtest_list_tests=0",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
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. // Tests parsing --gtest_list_tests=f.
TEST_F(ParseFlagsTest, ListTestsFalse_f) { TEST_F(ParseFlagsTest, ListTestsFalse_f) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_list_tests=f", nullptr};
"foo.exe",
"--gtest_list_tests=f",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
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. // Tests parsing --gtest_list_tests=F.
TEST_F(ParseFlagsTest, ListTestsFalse_F) { TEST_F(ParseFlagsTest, ListTestsFalse_F) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_list_tests=F", nullptr};
"foo.exe",
"--gtest_list_tests=F",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(false), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(false), false);
} }
// Tests parsing --gtest_output (invalid). // Tests parsing --gtest_output (invalid).
TEST_F(ParseFlagsTest, OutputEmpty) { TEST_F(ParseFlagsTest, OutputEmpty) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_output", nullptr};
"foo.exe",
"--gtest_output",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", "--gtest_output", nullptr};
"foo.exe",
"--gtest_output",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true);
} }
// Tests parsing --gtest_output=xml // Tests parsing --gtest_output=xml
TEST_F(ParseFlagsTest, OutputXml) { TEST_F(ParseFlagsTest, OutputXml) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_output=xml", nullptr};
"foo.exe",
"--gtest_output=xml",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Output("xml"), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Output("xml"), false);
} }
// Tests parsing --gtest_output=xml:file // Tests parsing --gtest_output=xml:file
TEST_F(ParseFlagsTest, OutputXmlFile) { TEST_F(ParseFlagsTest, OutputXmlFile) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_output=xml:file", nullptr};
"foo.exe",
"--gtest_output=xml:file",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Output("xml:file"), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Output("xml:file"), false);
} }
// Tests parsing --gtest_output=xml:directory/path/ // Tests parsing --gtest_output=xml:directory/path/
TEST_F(ParseFlagsTest, OutputXmlDirectory) { TEST_F(ParseFlagsTest, OutputXmlDirectory) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_output=xml:directory/path/",
"foo.exe", nullptr};
"--gtest_output=xml:directory/path/",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, GTEST_TEST_PARSING_FLAGS_(argv, argv2,
Flags::Output("xml:directory/path/"), false); Flags::Output("xml:directory/path/"), false);
...@@ -6113,242 +5950,140 @@ TEST_F(ParseFlagsTest, OutputXmlDirectory) { ...@@ -6113,242 +5950,140 @@ TEST_F(ParseFlagsTest, OutputXmlDirectory) {
// Tests having a --gtest_print_time flag // Tests having a --gtest_print_time flag
TEST_F(ParseFlagsTest, PrintTimeFlag) { TEST_F(ParseFlagsTest, PrintTimeFlag) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_print_time", nullptr};
"foo.exe",
"--gtest_print_time",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
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 // Tests having a --gtest_print_time flag with a "true" value
TEST_F(ParseFlagsTest, PrintTimeTrue) { TEST_F(ParseFlagsTest, PrintTimeTrue) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_print_time=1", nullptr};
"foo.exe",
"--gtest_print_time=1",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
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 // Tests having a --gtest_print_time flag with a "false" value
TEST_F(ParseFlagsTest, PrintTimeFalse) { TEST_F(ParseFlagsTest, PrintTimeFalse) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_print_time=0", nullptr};
"foo.exe",
"--gtest_print_time=0",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
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. // Tests parsing --gtest_print_time=f.
TEST_F(ParseFlagsTest, PrintTimeFalse_f) { TEST_F(ParseFlagsTest, PrintTimeFalse_f) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_print_time=f", nullptr};
"foo.exe",
"--gtest_print_time=f",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
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. // Tests parsing --gtest_print_time=F.
TEST_F(ParseFlagsTest, PrintTimeFalse_F) { TEST_F(ParseFlagsTest, PrintTimeFalse_F) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_print_time=F", nullptr};
"foo.exe",
"--gtest_print_time=F",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(false), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(false), false);
} }
// Tests parsing --gtest_random_seed=number // Tests parsing --gtest_random_seed=number
TEST_F(ParseFlagsTest, RandomSeed) { TEST_F(ParseFlagsTest, RandomSeed) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_random_seed=1000", nullptr};
"foo.exe",
"--gtest_random_seed=1000",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::RandomSeed(1000), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::RandomSeed(1000), false);
} }
// Tests parsing --gtest_repeat=number // Tests parsing --gtest_repeat=number
TEST_F(ParseFlagsTest, Repeat) { TEST_F(ParseFlagsTest, Repeat) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_repeat=1000", nullptr};
"foo.exe",
"--gtest_repeat=1000",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Repeat(1000), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Repeat(1000), false);
} }
// Tests having a --gtest_also_run_disabled_tests flag // Tests having a --gtest_also_run_disabled_tests flag
TEST_F(ParseFlagsTest, AlsoRunDisabledTestsFlag) { TEST_F(ParseFlagsTest, AlsoRunDisabledTestsFlag) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_also_run_disabled_tests", nullptr};
"foo.exe",
"--gtest_also_run_disabled_tests",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::AlsoRunDisabledTests(true),
Flags::AlsoRunDisabledTests(true), false); false);
} }
// Tests having a --gtest_also_run_disabled_tests flag with a "true" value // Tests having a --gtest_also_run_disabled_tests flag with a "true" value
TEST_F(ParseFlagsTest, AlsoRunDisabledTestsTrue) { TEST_F(ParseFlagsTest, AlsoRunDisabledTestsTrue) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_also_run_disabled_tests=1",
"foo.exe", nullptr};
"--gtest_also_run_disabled_tests=1",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::AlsoRunDisabledTests(true),
Flags::AlsoRunDisabledTests(true), false); false);
} }
// Tests having a --gtest_also_run_disabled_tests flag with a "false" value // Tests having a --gtest_also_run_disabled_tests flag with a "false" value
TEST_F(ParseFlagsTest, AlsoRunDisabledTestsFalse) { TEST_F(ParseFlagsTest, AlsoRunDisabledTestsFalse) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_also_run_disabled_tests=0",
"foo.exe", nullptr};
"--gtest_also_run_disabled_tests=0",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::AlsoRunDisabledTests(false),
Flags::AlsoRunDisabledTests(false), false); false);
} }
// Tests parsing --gtest_shuffle. // Tests parsing --gtest_shuffle.
TEST_F(ParseFlagsTest, ShuffleWithoutValue) { TEST_F(ParseFlagsTest, ShuffleWithoutValue) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_shuffle", nullptr};
"foo.exe",
"--gtest_shuffle",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(true), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(true), false);
} }
// Tests parsing --gtest_shuffle=0. // Tests parsing --gtest_shuffle=0.
TEST_F(ParseFlagsTest, ShuffleFalse_0) { TEST_F(ParseFlagsTest, ShuffleFalse_0) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_shuffle=0", nullptr};
"foo.exe",
"--gtest_shuffle=0",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(false), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(false), false);
} }
// Tests parsing a --gtest_shuffle flag that has a "true" definition. // Tests parsing a --gtest_shuffle flag that has a "true" definition.
TEST_F(ParseFlagsTest, ShuffleTrue) { TEST_F(ParseFlagsTest, ShuffleTrue) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_shuffle=1", nullptr};
"foo.exe",
"--gtest_shuffle=1",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(true), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(true), false);
} }
// Tests parsing --gtest_stack_trace_depth=number. // Tests parsing --gtest_stack_trace_depth=number.
TEST_F(ParseFlagsTest, StackTraceDepth) { TEST_F(ParseFlagsTest, StackTraceDepth) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_stack_trace_depth=5", nullptr};
"foo.exe",
"--gtest_stack_trace_depth=5",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::StackTraceDepth(5), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::StackTraceDepth(5), false);
} }
TEST_F(ParseFlagsTest, StreamResultTo) { TEST_F(ParseFlagsTest, StreamResultTo) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_stream_result_to=localhost:1234",
"foo.exe", nullptr};
"--gtest_stream_result_to=localhost:1234",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_( GTEST_TEST_PARSING_FLAGS_(
argv, argv2, Flags::StreamResultTo("localhost:1234"), false); argv, argv2, Flags::StreamResultTo("localhost:1234"), false);
...@@ -6356,32 +6091,18 @@ TEST_F(ParseFlagsTest, StreamResultTo) { ...@@ -6356,32 +6091,18 @@ TEST_F(ParseFlagsTest, StreamResultTo) {
// Tests parsing --gtest_throw_on_failure. // Tests parsing --gtest_throw_on_failure.
TEST_F(ParseFlagsTest, ThrowOnFailureWithoutValue) { TEST_F(ParseFlagsTest, ThrowOnFailureWithoutValue) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_throw_on_failure", nullptr};
"foo.exe",
"--gtest_throw_on_failure",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(true), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(true), false);
} }
// Tests parsing --gtest_throw_on_failure=0. // Tests parsing --gtest_throw_on_failure=0.
TEST_F(ParseFlagsTest, ThrowOnFailureFalse_0) { TEST_F(ParseFlagsTest, ThrowOnFailureFalse_0) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_throw_on_failure=0", nullptr};
"foo.exe",
"--gtest_throw_on_failure=0",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(false), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(false), false);
} }
...@@ -6389,16 +6110,9 @@ TEST_F(ParseFlagsTest, ThrowOnFailureFalse_0) { ...@@ -6389,16 +6110,9 @@ TEST_F(ParseFlagsTest, ThrowOnFailureFalse_0) {
// Tests parsing a --gtest_throw_on_failure flag that has a "true" // Tests parsing a --gtest_throw_on_failure flag that has a "true"
// definition. // definition.
TEST_F(ParseFlagsTest, ThrowOnFailureTrue) { TEST_F(ParseFlagsTest, ThrowOnFailureTrue) {
const char* argv[] = { const char* argv[] = {"foo.exe", "--gtest_throw_on_failure=1", nullptr};
"foo.exe",
"--gtest_throw_on_failure=1",
NULL
};
const char* argv2[] = { const char* argv2[] = {"foo.exe", nullptr};
"foo.exe",
NULL
};
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(true), false); GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(true), false);
} }
...@@ -6540,7 +6254,7 @@ class CurrentTestInfoTest : public Test { ...@@ -6540,7 +6254,7 @@ class CurrentTestInfoTest : public Test {
// There should be no tests running at this point. // There should be no tests running at this point.
const TestInfo* test_info = const TestInfo* test_info =
UnitTest::GetInstance()->current_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."; << "There should be no tests running at this point.";
} }
...@@ -6549,7 +6263,7 @@ class CurrentTestInfoTest : public Test { ...@@ -6549,7 +6263,7 @@ class CurrentTestInfoTest : public Test {
static void TearDownTestCase() { static void TearDownTestCase() {
const TestInfo* test_info = const TestInfo* test_info =
UnitTest::GetInstance()->current_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."; << "There should be no tests running at this point.";
} }
}; };
...@@ -6559,7 +6273,7 @@ class CurrentTestInfoTest : public Test { ...@@ -6559,7 +6273,7 @@ class CurrentTestInfoTest : public Test {
TEST_F(CurrentTestInfoTest, WorksForFirstTestInATestCase) { TEST_F(CurrentTestInfoTest, WorksForFirstTestInATestCase) {
const TestInfo* test_info = const TestInfo* test_info =
UnitTest::GetInstance()->current_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."; << "There is a test running so we should have a valid TestInfo.";
EXPECT_STREQ("CurrentTestInfoTest", test_info->test_case_name()) EXPECT_STREQ("CurrentTestInfoTest", test_info->test_case_name())
<< "Expected the name of the currently running test case."; << "Expected the name of the currently running test case.";
...@@ -6574,7 +6288,7 @@ TEST_F(CurrentTestInfoTest, WorksForFirstTestInATestCase) { ...@@ -6574,7 +6288,7 @@ TEST_F(CurrentTestInfoTest, WorksForFirstTestInATestCase) {
TEST_F(CurrentTestInfoTest, WorksForSecondTestInATestCase) { TEST_F(CurrentTestInfoTest, WorksForSecondTestInATestCase) {
const TestInfo* test_info = const TestInfo* test_info =
UnitTest::GetInstance()->current_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."; << "There is a test running so we should have a valid TestInfo.";
EXPECT_STREQ("CurrentTestInfoTest", test_info->test_case_name()) EXPECT_STREQ("CurrentTestInfoTest", test_info->test_case_name())
<< "Expected the name of the currently running test case."; << "Expected the name of the currently running test case.";
...@@ -7001,7 +6715,7 @@ TEST(HasFailureTest, WorksOutsideOfTestBody2) { ...@@ -7001,7 +6715,7 @@ TEST(HasFailureTest, WorksOutsideOfTestBody2) {
class TestListener : public EmptyTestEventListener { class TestListener : public EmptyTestEventListener {
public: 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) TestListener(int* on_start_counter, bool* is_destroyed)
: on_start_counter_(on_start_counter), : on_start_counter_(on_start_counter),
is_destroyed_(is_destroyed) {} is_destroyed_(is_destroyed) {}
...@@ -7013,8 +6727,7 @@ class TestListener : public EmptyTestEventListener { ...@@ -7013,8 +6727,7 @@ class TestListener : public EmptyTestEventListener {
protected: protected:
virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) { virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {
if (on_start_counter_ != NULL) if (on_start_counter_ != nullptr) (*on_start_counter_)++;
(*on_start_counter_)++;
} }
private: private:
...@@ -7026,9 +6739,9 @@ class TestListener : public EmptyTestEventListener { ...@@ -7026,9 +6739,9 @@ class TestListener : public EmptyTestEventListener {
TEST(TestEventListenersTest, ConstructionWorks) { TEST(TestEventListenersTest, ConstructionWorks) {
TestEventListeners listeners; TestEventListeners listeners;
EXPECT_TRUE(TestEventListenersAccessor::GetRepeater(&listeners) != NULL); EXPECT_TRUE(TestEventListenersAccessor::GetRepeater(&listeners) != nullptr);
EXPECT_TRUE(listeners.default_result_printer() == NULL); EXPECT_TRUE(listeners.default_result_printer() == nullptr);
EXPECT_TRUE(listeners.default_xml_generator() == NULL); EXPECT_TRUE(listeners.default_xml_generator() == nullptr);
} }
// Tests that the TestEventListeners destructor deletes all the listeners it // Tests that the TestEventListeners destructor deletes all the listeners it
...@@ -7037,12 +6750,12 @@ TEST(TestEventListenersTest, DestructionWorks) { ...@@ -7037,12 +6750,12 @@ TEST(TestEventListenersTest, DestructionWorks) {
bool default_result_printer_is_destroyed = false; bool default_result_printer_is_destroyed = false;
bool default_xml_printer_is_destroyed = false; bool default_xml_printer_is_destroyed = false;
bool extra_listener_is_destroyed = false; bool extra_listener_is_destroyed = false;
TestListener* default_result_printer = new TestListener( TestListener* default_result_printer =
NULL, &default_result_printer_is_destroyed); new TestListener(nullptr, &default_result_printer_is_destroyed);
TestListener* default_xml_printer = new TestListener( TestListener* default_xml_printer =
NULL, &default_xml_printer_is_destroyed); new TestListener(nullptr, &default_xml_printer_is_destroyed);
TestListener* extra_listener = new TestListener( TestListener* extra_listener =
NULL, &extra_listener_is_destroyed); new TestListener(nullptr, &extra_listener_is_destroyed);
{ {
TestEventListeners listeners; TestEventListeners listeners;
...@@ -7167,7 +6880,7 @@ TEST(TestEventListenersTest, Release) { ...@@ -7167,7 +6880,7 @@ TEST(TestEventListenersTest, Release) {
EXPECT_EQ(listener, listeners.Release(listener)); EXPECT_EQ(listener, listeners.Release(listener));
TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart( TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(
*UnitTest::GetInstance()); *UnitTest::GetInstance());
EXPECT_TRUE(listeners.Release(listener) == NULL); EXPECT_TRUE(listeners.Release(listener) == nullptr);
} }
EXPECT_EQ(0, on_start_counter); EXPECT_EQ(0, on_start_counter);
EXPECT_FALSE(is_destroyed); EXPECT_FALSE(is_destroyed);
...@@ -7177,7 +6890,7 @@ TEST(TestEventListenersTest, Release) { ...@@ -7177,7 +6890,7 @@ TEST(TestEventListenersTest, Release) {
// Tests that no events are forwarded when event forwarding is disabled. // Tests that no events are forwarded when event forwarding is disabled.
TEST(EventListenerTest, SuppressEventForwarding) { TEST(EventListenerTest, SuppressEventForwarding) {
int on_start_counter = 0; int on_start_counter = 0;
TestListener* listener = new TestListener(&on_start_counter, NULL); TestListener* listener = new TestListener(&on_start_counter, nullptr);
TestEventListeners listeners; TestEventListeners listeners;
listeners.Append(listener); listeners.Append(listener);
...@@ -7218,9 +6931,9 @@ TEST(EventListenerTest, default_result_printer) { ...@@ -7218,9 +6931,9 @@ TEST(EventListenerTest, default_result_printer) {
// Replacing default_result_printer with something else should remove it // Replacing default_result_printer with something else should remove it
// from the list and destroy 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); EXPECT_TRUE(is_destroyed);
// After broadcasting an event the counter is still the same, indicating // After broadcasting an event the counter is still the same, indicating
...@@ -7244,7 +6957,7 @@ TEST(EventListenerTest, RemovingDefaultResultPrinterWorks) { ...@@ -7244,7 +6957,7 @@ TEST(EventListenerTest, RemovingDefaultResultPrinterWorks) {
TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, listener); TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, listener);
EXPECT_EQ(listener, listeners.Release(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); EXPECT_FALSE(is_destroyed);
// Broadcasting events now should not affect default_result_printer. // Broadcasting events now should not affect default_result_printer.
...@@ -7277,9 +6990,9 @@ TEST(EventListenerTest, default_xml_generator) { ...@@ -7277,9 +6990,9 @@ TEST(EventListenerTest, default_xml_generator) {
// Replacing default_xml_generator with something else should remove it // Replacing default_xml_generator with something else should remove it
// from the list and destroy 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); EXPECT_TRUE(is_destroyed);
// After broadcasting an event the counter is still the same, indicating // After broadcasting an event the counter is still the same, indicating
...@@ -7303,7 +7016,7 @@ TEST(EventListenerTest, RemovingDefaultXmlGeneratorWorks) { ...@@ -7303,7 +7016,7 @@ TEST(EventListenerTest, RemovingDefaultXmlGeneratorWorks) {
TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, listener); TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, listener);
EXPECT_EQ(listener, listeners.Release(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); EXPECT_FALSE(is_destroyed);
// Broadcasting events now should not affect default_xml_generator. // Broadcasting events now should not affect default_xml_generator.
......
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