Commit 0af0709b authored by zhanyong.wan's avatar zhanyong.wan
Browse files

Cleans up macro definitions.

parent 3c7868a9
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
#include <regex.h> #include <regex.h>
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
...@@ -56,9 +56,9 @@ ...@@ -56,9 +56,9 @@
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // his code.
#define GTEST_IMPLEMENTATION #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION #undef GTEST_IMPLEMENTATION_
namespace testing { namespace testing {
namespace internal { namespace internal {
...@@ -334,7 +334,7 @@ bool RE::PartialMatch(const char* str, const RE& re) { ...@@ -334,7 +334,7 @@ bool RE::PartialMatch(const char* str, const RE& re) {
void RE::Init(const char* regex) { void RE::Init(const char* regex) {
pattern_ = full_pattern_ = NULL; pattern_ = full_pattern_ = NULL;
if (regex != NULL) { if (regex != NULL) {
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
pattern_ = _strdup(regex); pattern_ = _strdup(regex);
#else #else
pattern_ = strdup(regex); pattern_ = strdup(regex);
...@@ -383,7 +383,7 @@ void GTestLog(GTestLogSeverity severity, const char* file, ...@@ -383,7 +383,7 @@ void GTestLog(GTestLogSeverity severity, const char* file,
} }
} }
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
// Defines the stderr capturer. // Defines the stderr capturer.
...@@ -502,7 +502,8 @@ void abort() { ...@@ -502,7 +502,8 @@ void abort() {
// given flag. For example, FlagToEnvVar("foo") will return // given flag. For example, FlagToEnvVar("foo") will return
// "GTEST_FOO" in the open-source version. // "GTEST_FOO" in the open-source version.
static String FlagToEnvVar(const char* flag) { static String FlagToEnvVar(const char* flag) {
const String full_flag = (Message() << GTEST_FLAG_PREFIX << flag).GetString(); const String full_flag =
(Message() << GTEST_FLAG_PREFIX_ << flag).GetString();
Message env_var; Message env_var;
for (int i = 0; i != full_flag.GetLength(); i++) { for (int i = 0; i != full_flag.GetLength(); i++) {
......
...@@ -38,9 +38,9 @@ ...@@ -38,9 +38,9 @@
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // his code.
#define GTEST_IMPLEMENTATION #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION #undef GTEST_IMPLEMENTATION_
namespace testing { namespace testing {
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
namespace testing { namespace testing {
namespace internal { namespace internal {
#ifdef GTEST_HAS_TYPED_TEST_P #if GTEST_HAS_TYPED_TEST_P
// Verifies that registered_tests match the test names in // Verifies that registered_tests match the test names in
// defined_test_names_; returns registered_tests if successful, or // defined_test_names_; returns registered_tests if successful, or
......
...@@ -43,11 +43,11 @@ ...@@ -43,11 +43,11 @@
#include <wchar.h> #include <wchar.h>
#include <wctype.h> #include <wctype.h>
#ifdef GTEST_OS_LINUX #if GTEST_OS_LINUX
// TODO(kenton@google.com): Use autoconf to detect availability of // TODO(kenton@google.com): Use autoconf to detect availability of
// gettimeofday(). // gettimeofday().
#define GTEST_HAS_GETTIMEOFDAY #define GTEST_HAS_GETTIMEOFDAY_ 1
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <limits.h>
...@@ -60,12 +60,12 @@ ...@@ -60,12 +60,12 @@
#include <string> #include <string>
#include <vector> #include <vector>
#elif defined(GTEST_OS_SYMBIAN) #elif GTEST_OS_SYMBIAN
#define GTEST_HAS_GETTIMEOFDAY #define GTEST_HAS_GETTIMEOFDAY_ 1
#include <sys/time.h> // NOLINT #include <sys/time.h> // NOLINT
#elif defined(GTEST_OS_ZOS) #elif GTEST_OS_ZOS
#define GTEST_HAS_GETTIMEOFDAY #define GTEST_HAS_GETTIMEOFDAY_ 1
#include <sys/time.h> // NOLINT #include <sys/time.h> // NOLINT
// On z/OS we additionally need strings.h for strcasecmp. // On z/OS we additionally need strings.h for strcasecmp.
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
#include <windows.h> // NOLINT #include <windows.h> // NOLINT
#elif defined(GTEST_OS_WINDOWS) // We are on Windows proper. #elif GTEST_OS_WINDOWS // We are on Windows proper.
#include <io.h> // NOLINT #include <io.h> // NOLINT
#include <sys/timeb.h> // NOLINT #include <sys/timeb.h> // NOLINT
...@@ -89,9 +89,9 @@ ...@@ -89,9 +89,9 @@
// TODO(kenton@google.com): There are other ways to get the time on // TODO(kenton@google.com): There are other ways to get the time on
// Windows, like GetTickCount() or GetSystemTimeAsFileTime(). MinGW // Windows, like GetTickCount() or GetSystemTimeAsFileTime(). MinGW
// supports these. consider using them instead. // supports these. consider using them instead.
#define GTEST_HAS_GETTIMEOFDAY #define GTEST_HAS_GETTIMEOFDAY_ 1
#include <sys/time.h> // NOLINT #include <sys/time.h> // NOLINT
#endif #endif // defined(__MINGW__) || defined(__MINGW32__)
// cpplint thinks that the header is already included, so we want to // cpplint thinks that the header is already included, so we want to
// silence it. // silence it.
...@@ -102,25 +102,25 @@ ...@@ -102,25 +102,25 @@
// Assume other platforms have gettimeofday(). // Assume other platforms have gettimeofday().
// TODO(kenton@google.com): Use autoconf to detect availability of // TODO(kenton@google.com): Use autoconf to detect availability of
// gettimeofday(). // gettimeofday().
#define GTEST_HAS_GETTIMEOFDAY #define GTEST_HAS_GETTIMEOFDAY_ 1
// cpplint thinks that the header is already included, so we want to // cpplint thinks that the header is already included, so we want to
// silence it. // silence it.
#include <sys/time.h> // NOLINT #include <sys/time.h> // NOLINT
#include <unistd.h> // NOLINT #include <unistd.h> // NOLINT
#endif #endif // GTEST_OS_LINUX
// Indicates that this translation unit is part of Google Test's // Indicates that this translation unit is part of Google Test's
// implementation. It must come before gtest-internal-inl.h is // implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // his code.
#define GTEST_IMPLEMENTATION #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION #undef GTEST_IMPLEMENTATION_
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
#define fileno _fileno #define fileno _fileno
#define isatty _isatty #define isatty _isatty
#define vsnprintf _vsnprintf #define vsnprintf _vsnprintf
...@@ -173,7 +173,7 @@ GTEST_DEFINE_bool_( ...@@ -173,7 +173,7 @@ GTEST_DEFINE_bool_(
GTEST_DEFINE_bool_( GTEST_DEFINE_bool_(
catch_exceptions, catch_exceptions,
internal::BoolFromGTestEnv("catch_exceptions", false), internal::BoolFromGTestEnv("catch_exceptions", false),
"True iff " GTEST_NAME "True iff " GTEST_NAME_
" should catch exceptions and treat them as test failures."); " should catch exceptions and treat them as test failures.");
GTEST_DEFINE_string_( GTEST_DEFINE_string_(
...@@ -211,7 +211,7 @@ GTEST_DEFINE_string_( ...@@ -211,7 +211,7 @@ GTEST_DEFINE_string_(
GTEST_DEFINE_bool_( GTEST_DEFINE_bool_(
print_time, print_time,
internal::BoolFromGTestEnv("print_time", false), internal::BoolFromGTestEnv("print_time", false),
"True iff " GTEST_NAME "True iff " GTEST_NAME_
" should display elapsed time in text output."); " should display elapsed time in text output.");
GTEST_DEFINE_int32_( GTEST_DEFINE_int32_(
...@@ -228,7 +228,7 @@ GTEST_DEFINE_int32_( ...@@ -228,7 +228,7 @@ GTEST_DEFINE_int32_(
GTEST_DEFINE_bool_( GTEST_DEFINE_bool_(
show_internal_stack_frames, false, show_internal_stack_frames, false,
"True iff " GTEST_NAME " should include internal stack frames when " "True iff " GTEST_NAME_ " should include internal stack frames when "
"printing test failure stack traces."); "printing test failure stack traces.");
namespace internal { namespace internal {
...@@ -302,7 +302,7 @@ String g_executable_path; ...@@ -302,7 +302,7 @@ String g_executable_path;
FilePath GetCurrentExecutableName() { FilePath GetCurrentExecutableName() {
FilePath result; FilePath result;
#if defined(_WIN32_WCE) || defined(GTEST_OS_WINDOWS) #if defined(_WIN32_WCE) || GTEST_OS_WINDOWS
result.Set(FilePath(g_executable_path).RemoveExtension("exe")); result.Set(FilePath(g_executable_path).RemoveExtension("exe"));
#else #else
result.Set(FilePath(g_executable_path)); result.Set(FilePath(g_executable_path));
...@@ -433,7 +433,7 @@ bool UnitTestOptions::FilterMatchesTest(const String &test_case_name, ...@@ -433,7 +433,7 @@ bool UnitTestOptions::FilterMatchesTest(const String &test_case_name,
!MatchesFilter(full_name, negative.c_str())); !MatchesFilter(full_name, negative.c_str()));
} }
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
// given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise. // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
// This function is useful as an __except condition. // This function is useful as an __except condition.
...@@ -743,7 +743,7 @@ static TimeInMillis GetTimeInMillis() { ...@@ -743,7 +743,7 @@ static TimeInMillis GetTimeInMillis() {
return now_int64.QuadPart; return now_int64.QuadPart;
} }
return 0; return 0;
#elif defined(GTEST_OS_WINDOWS) && !defined(GTEST_HAS_GETTIMEOFDAY) #elif GTEST_OS_WINDOWS && !GTEST_HAS_GETTIMEOFDAY_
__timeb64 now; __timeb64 now;
#ifdef _MSC_VER #ifdef _MSC_VER
// MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996 // MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996
...@@ -758,7 +758,7 @@ static TimeInMillis GetTimeInMillis() { ...@@ -758,7 +758,7 @@ static TimeInMillis GetTimeInMillis() {
_ftime64(&now); _ftime64(&now);
#endif // _MSC_VER #endif // _MSC_VER
return static_cast<TimeInMillis>(now.time) * 1000 + now.millitm; return static_cast<TimeInMillis>(now.time) * 1000 + now.millitm;
#elif defined(GTEST_HAS_GETTIMEOFDAY) #elif GTEST_HAS_GETTIMEOFDAY_
struct timeval now; struct timeval now;
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
return static_cast<TimeInMillis>(now.tv_sec) * 1000 + now.tv_usec / 1000; return static_cast<TimeInMillis>(now.tv_sec) * 1000 + now.tv_usec / 1000;
...@@ -793,7 +793,7 @@ static char* CloneString(const char* str, size_t length) { ...@@ -793,7 +793,7 @@ static char* CloneString(const char* str, size_t length) {
char* const clone = new char[length + 1]; char* const clone = new char[length + 1];
// MSVC 8 deprecates strncpy(), so we want to suppress warning // MSVC 8 deprecates strncpy(), so we want to suppress warning
// 4996 (deprecated function) there. // 4996 (deprecated function) there.
#ifdef GTEST_OS_WINDOWS // We are on Windows. #if GTEST_OS_WINDOWS // We are on Windows.
#pragma warning(push) // Saves the current warning state. #pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4996) // Temporarily disables warning 4996. #pragma warning(disable:4996) // Temporarily disables warning 4996.
strncpy(clone, str, length); strncpy(clone, str, length);
...@@ -1314,7 +1314,7 @@ AssertionResult IsNotSubstring( ...@@ -1314,7 +1314,7 @@ AssertionResult IsNotSubstring(
namespace internal { namespace internal {
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
namespace { namespace {
...@@ -1442,14 +1442,14 @@ char* CodePointToUtf8(UInt32 code_point, char* str) { ...@@ -1442,14 +1442,14 @@ char* CodePointToUtf8(UInt32 code_point, char* str) {
// null-terminate the destination string. // null-terminate the destination string.
// MSVC 8 deprecates strncpy(), so we want to suppress warning // MSVC 8 deprecates strncpy(), so we want to suppress warning
// 4996 (deprecated function) there. // 4996 (deprecated function) there.
#ifdef GTEST_OS_WINDOWS // We are on Windows. #if GTEST_OS_WINDOWS // We are on Windows.
#pragma warning(push) // Saves the current warning state. #pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4996) // Temporarily disables warning 4996. #pragma warning(disable:4996) // Temporarily disables warning 4996.
#endif #endif
strncpy(str, String::Format("(Invalid Unicode 0x%X)", code_point).c_str(), strncpy(str, String::Format("(Invalid Unicode 0x%X)", code_point).c_str(),
32); 32);
#ifdef GTEST_OS_WINDOWS // We are on Windows. #if GTEST_OS_WINDOWS // We are on Windows.
#pragma warning(pop) // Restores the warning state. #pragma warning(pop) // Restores the warning state.
#endif #endif
str[31] = '\0'; // Makes sure no change in the format to strncpy leaves str[31] = '\0'; // Makes sure no change in the format to strncpy leaves
// the result unterminated. // the result unterminated.
...@@ -1592,7 +1592,7 @@ bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) { ...@@ -1592,7 +1592,7 @@ bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) {
if ( rhs == NULL ) return false; if ( rhs == NULL ) return false;
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
return _stricmp(lhs, rhs) == 0; return _stricmp(lhs, rhs) == 0;
#else // GTEST_OS_WINDOWS #else // GTEST_OS_WINDOWS
return strcasecmp(lhs, rhs) == 0; return strcasecmp(lhs, rhs) == 0;
...@@ -1617,9 +1617,9 @@ bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs, ...@@ -1617,9 +1617,9 @@ bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
if ( rhs == NULL ) return false; if ( rhs == NULL ) return false;
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
return _wcsicmp(lhs, rhs) == 0; return _wcsicmp(lhs, rhs) == 0;
#elif defined(GTEST_OS_LINUX) #elif GTEST_OS_LINUX
return wcscasecmp(lhs, rhs) == 0; return wcscasecmp(lhs, rhs) == 0;
#else #else
// Mac OS X and Cygwin don't define wcscasecmp. Other unknown OSes // Mac OS X and Cygwin don't define wcscasecmp. Other unknown OSes
...@@ -1720,7 +1720,7 @@ String String::Format(const char * format, ...) { ...@@ -1720,7 +1720,7 @@ String String::Format(const char * format, ...) {
char buffer[4096]; char buffer[4096];
// MSVC 8 deprecates vsnprintf(), so we want to suppress warning // MSVC 8 deprecates vsnprintf(), so we want to suppress warning
// 4996 (deprecated function) there. // 4996 (deprecated function) there.
#ifdef GTEST_OS_WINDOWS // We are on Windows. #if GTEST_OS_WINDOWS // We are on Windows.
#pragma warning(push) // Saves the current warning state. #pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4996) // Temporarily disables warning 4996. #pragma warning(disable:4996) // Temporarily disables warning 4996.
const int size = const int size =
...@@ -1827,7 +1827,7 @@ bool TestResult::ValidateTestProperty(const TestProperty& test_property) { ...@@ -1827,7 +1827,7 @@ bool TestResult::ValidateTestProperty(const TestProperty& test_property) {
<< "Reserved key used in RecordProperty(): " << "Reserved key used in RecordProperty(): "
<< key << key
<< " ('name', 'status', 'time', and 'classname' are reserved by " << " ('name', 'status', 'time', and 'classname' are reserved by "
<< GTEST_NAME << ")"; << GTEST_NAME_ << ")";
return false; return false;
} }
return true; return true;
...@@ -1917,7 +1917,7 @@ void Test::RecordProperty(const char* key, int value) { ...@@ -1917,7 +1917,7 @@ void Test::RecordProperty(const char* key, int value) {
RecordProperty(key, value_message.GetString().c_str()); RecordProperty(key, value_message.GetString().c_str());
} }
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
// We are on Windows. // We are on Windows.
// Adds an "exception thrown" fatal failure to the current test. // Adds an "exception thrown" fatal failure to the current test.
...@@ -2013,7 +2013,7 @@ void Test::Run() { ...@@ -2013,7 +2013,7 @@ void Test::Run() {
if (!HasSameFixtureClass()) return; if (!HasSameFixtureClass()) return;
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
// We are on Windows. // We are on Windows.
impl->os_stack_trace_getter()->UponLeavingGTest(); impl->os_stack_trace_getter()->UponLeavingGTest();
__try { __try {
...@@ -2122,7 +2122,7 @@ TestInfo* MakeAndRegisterTestInfo( ...@@ -2122,7 +2122,7 @@ TestInfo* MakeAndRegisterTestInfo(
return test_info; return test_info;
} }
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
void ReportInvalidTestCaseType(const char* test_case_name, void ReportInvalidTestCaseType(const char* test_case_name,
const char* file, int line) { const char* file, int line) {
Message errors; Message errors;
...@@ -2221,7 +2221,7 @@ namespace internal { ...@@ -2221,7 +2221,7 @@ namespace internal {
// and INSTANTIATE_TEST_CASE_P into regular tests and registers those. // and INSTANTIATE_TEST_CASE_P into regular tests and registers those.
// This will be done just once during the program runtime. // This will be done just once during the program runtime.
void UnitTestImpl::RegisterParameterizedTests() { void UnitTestImpl::RegisterParameterizedTests() {
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
if (!parameterized_tests_registered_) { if (!parameterized_tests_registered_) {
parameterized_test_registry_.RegisterTests(); parameterized_test_registry_.RegisterTests();
parameterized_tests_registered_ = true; parameterized_tests_registered_ = true;
...@@ -2247,7 +2247,7 @@ void TestInfoImpl::Run() { ...@@ -2247,7 +2247,7 @@ void TestInfoImpl::Run() {
const TimeInMillis start = GetTimeInMillis(); const TimeInMillis start = GetTimeInMillis();
impl->os_stack_trace_getter()->UponLeavingGTest(); impl->os_stack_trace_getter()->UponLeavingGTest();
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
// We are on Windows. // We are on Windows.
Test* test = NULL; Test* test = NULL;
...@@ -2459,7 +2459,7 @@ enum GTestColor { ...@@ -2459,7 +2459,7 @@ enum GTestColor {
COLOR_YELLOW COLOR_YELLOW
}; };
#if defined(GTEST_OS_WINDOWS) && !defined(_WIN32_WCE) #if GTEST_OS_WINDOWS && !defined(_WIN32_WCE)
// Returns the character attribute for the given color. // Returns the character attribute for the given color.
WORD GetColorAttribute(GTestColor color) { WORD GetColorAttribute(GTestColor color) {
...@@ -2490,7 +2490,7 @@ bool ShouldUseColor(bool stdout_is_tty) { ...@@ -2490,7 +2490,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
const char* const gtest_color = GTEST_FLAG(color).c_str(); const char* const gtest_color = GTEST_FLAG(color).c_str();
if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) { if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) {
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
// On Windows the TERM variable is usually not set, but the // On Windows the TERM variable is usually not set, but the
// console there does support colors. // console there does support colors.
return stdout_is_tty; return stdout_is_tty;
...@@ -2522,11 +2522,11 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) { ...@@ -2522,11 +2522,11 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
#if defined(_WIN32_WCE) || defined(GTEST_OS_SYMBIAN) || defined(GTEST_OS_ZOS) #if defined(_WIN32_WCE) || GTEST_OS_SYMBIAN || GTEST_OS_ZOS
static const bool use_color = false; static const bool use_color = false;
#else #else
static const bool use_color = ShouldUseColor(isatty(fileno(stdout)) != 0); static const bool use_color = ShouldUseColor(isatty(fileno(stdout)) != 0);
#endif // !_WIN32_WCE #endif // defined(_WIN32_WCE) || GTEST_OS_SYMBIAN || GTEST_OS_ZOS
// The '!= 0' comparison is necessary to satisfy MSVC 7.1. // The '!= 0' comparison is necessary to satisfy MSVC 7.1.
if (!use_color) { if (!use_color) {
...@@ -2535,7 +2535,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) { ...@@ -2535,7 +2535,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
return; return;
} }
#if defined(GTEST_OS_WINDOWS) && !defined(_WIN32_WCE) #if GTEST_OS_WINDOWS && !defined(_WIN32_WCE)
const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE); const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
// Gets the current text color. // Gets the current text color.
...@@ -2553,7 +2553,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) { ...@@ -2553,7 +2553,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
printf("\033[0;3%sm", GetAnsiColorCode(color)); printf("\033[0;3%sm", GetAnsiColorCode(color));
vprintf(fmt, args); vprintf(fmt, args);
printf("\033[m"); // Resets the terminal to default. printf("\033[m"); // Resets the terminal to default.
#endif // GTEST_OS_WINDOWS && !_WIN32_WCE #endif // GTEST_OS_WINDOWS && !defined(_WIN32_WCE)
va_end(args); va_end(args);
} }
...@@ -2599,7 +2599,7 @@ void PrettyUnitTestResultPrinter::OnUnitTestStart( ...@@ -2599,7 +2599,7 @@ void PrettyUnitTestResultPrinter::OnUnitTestStart(
// tests may be skipped. // tests may be skipped.
if (!internal::String::CStringEquals(filter, kUniversalFilter)) { if (!internal::String::CStringEquals(filter, kUniversalFilter)) {
ColoredPrintf(COLOR_YELLOW, ColoredPrintf(COLOR_YELLOW,
"Note: %s filter = %s\n", GTEST_NAME, filter); "Note: %s filter = %s\n", GTEST_NAME_, filter);
} }
if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) { if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {
...@@ -2926,7 +2926,7 @@ void XmlUnitTestResultPrinter::OnUnitTestEnd(const UnitTest* unit_test) { ...@@ -2926,7 +2926,7 @@ void XmlUnitTestResultPrinter::OnUnitTestEnd(const UnitTest* unit_test) {
if (output_dir.CreateDirectoriesRecursively()) { if (output_dir.CreateDirectoriesRecursively()) {
// MSVC 8 deprecates fopen(), so we want to suppress warning 4996 // MSVC 8 deprecates fopen(), so we want to suppress warning 4996
// (deprecated function) there. // (deprecated function) there.
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
// We are on Windows. // We are on Windows.
#pragma warning(push) // Saves the current warning state. #pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4996) // Temporarily disables warning 4996. #pragma warning(disable:4996) // Temporarily disables warning 4996.
...@@ -3191,7 +3191,7 @@ void OsStackTraceGetter::UponLeavingGTest() { ...@@ -3191,7 +3191,7 @@ void OsStackTraceGetter::UponLeavingGTest() {
const char* const const char* const
OsStackTraceGetter::kElidedFramesMarker = OsStackTraceGetter::kElidedFramesMarker =
"... " GTEST_NAME " internal frames ..."; "... " GTEST_NAME_ " internal frames ...";
} // namespace internal } // namespace internal
...@@ -3255,7 +3255,7 @@ void UnitTest::AddTestPartResult(TestPartResultType result_type, ...@@ -3255,7 +3255,7 @@ void UnitTest::AddTestPartResult(TestPartResultType result_type,
internal::MutexLock lock(&mutex_); internal::MutexLock lock(&mutex_);
if (impl_->gtest_trace_stack()->size() > 0) { if (impl_->gtest_trace_stack()->size() > 0) {
msg << "\n" << GTEST_NAME << " trace:"; msg << "\n" << GTEST_NAME_ << " trace:";
for (internal::ListNode<internal::TraceInfo>* node = for (internal::ListNode<internal::TraceInfo>* node =
impl_->gtest_trace_stack()->Head(); impl_->gtest_trace_stack()->Head();
...@@ -3298,7 +3298,7 @@ void UnitTest::RecordPropertyForCurrentTest(const char* key, ...@@ -3298,7 +3298,7 @@ void UnitTest::RecordPropertyForCurrentTest(const char* key,
// 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.
int UnitTest::Run() { int UnitTest::Run() {
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
#if !defined(_WIN32_WCE) #if !defined(_WIN32_WCE)
// SetErrorMode doesn't exist on CE. // SetErrorMode doesn't exist on CE.
...@@ -3349,7 +3349,7 @@ const TestInfo* UnitTest::current_test_info() const { ...@@ -3349,7 +3349,7 @@ const TestInfo* UnitTest::current_test_info() const {
return impl_->current_test_info(); return impl_->current_test_info();
} }
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
// Returns ParameterizedTestCaseRegistry object used to keep track of // Returns ParameterizedTestCaseRegistry object used to keep track of
// value-parameterized tests and instantiate and register them. // value-parameterized tests and instantiate and register them.
// L < mutex_ // L < mutex_
...@@ -3404,7 +3404,7 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent) ...@@ -3404,7 +3404,7 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent)
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_),
test_cases_(), test_cases_(),
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
parameterized_test_registry_(), parameterized_test_registry_(),
parameterized_tests_registered_(false), parameterized_tests_registered_(false),
#endif // GTEST_HAS_PARAM_TEST #endif // GTEST_HAS_PARAM_TEST
...@@ -3414,7 +3414,7 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent) ...@@ -3414,7 +3414,7 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent)
ad_hoc_test_result_(), ad_hoc_test_result_(),
result_printer_(NULL), result_printer_(NULL),
os_stack_trace_getter_(NULL), os_stack_trace_getter_(NULL),
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
elapsed_time_(0), elapsed_time_(0),
internal_run_death_test_flag_(NULL), internal_run_death_test_flag_(NULL),
death_test_factory_(new DefaultDeathTestFactory) { death_test_factory_(new DefaultDeathTestFactory) {
...@@ -3540,7 +3540,7 @@ int UnitTestImpl::RunAllTests() { ...@@ -3540,7 +3540,7 @@ int UnitTestImpl::RunAllTests() {
// death test. // death test.
bool in_subprocess_for_death_test = false; bool in_subprocess_for_death_test = false;
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
internal_run_death_test_flag_.reset(ParseInternalRunDeathTestFlag()); internal_run_death_test_flag_.reset(ParseInternalRunDeathTestFlag());
in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL); in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL);
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
...@@ -3817,7 +3817,7 @@ UnitTestEventListenerInterface* UnitTestImpl::result_printer() { ...@@ -3817,7 +3817,7 @@ UnitTestEventListenerInterface* UnitTestImpl::result_printer() {
return result_printer_; return result_printer_;
} }
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
if (internal_run_death_test_flag_.get() != NULL) { if (internal_run_death_test_flag_.get() != NULL) {
result_printer_ = new NullUnitTestResultPrinter; result_printer_ = new NullUnitTestResultPrinter;
return result_printer_; return result_printer_;
...@@ -3943,8 +3943,8 @@ const char* ParseFlagValue(const char* str, ...@@ -3943,8 +3943,8 @@ const char* ParseFlagValue(const char* str,
// str and flag must not be NULL. // str and flag must not be NULL.
if (str == NULL || flag == NULL) return NULL; if (str == NULL || flag == NULL) return NULL;
// The flag must start with "--" followed by GTEST_FLAG_PREFIX. // The flag must start with "--" followed by GTEST_FLAG_PREFIX_.
const String flag_str = String::Format("--%s%s", GTEST_FLAG_PREFIX, flag); const String flag_str = String::Format("--%s%s", GTEST_FLAG_PREFIX_, flag);
const size_t flag_len = flag_str.GetLength(); const size_t flag_len = flag_str.GetLength();
if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL; if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL;
...@@ -4096,7 +4096,7 @@ void InitGoogleTestImpl(int* argc, CharType** argv) { ...@@ -4096,7 +4096,7 @@ void InitGoogleTestImpl(int* argc, CharType** argv) {
internal::g_executable_path = internal::StreamableToString(argv[0]); internal::g_executable_path = internal::StreamableToString(argv[0]);
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
g_argvs.clear(); g_argvs.clear();
for (int i = 0; i != *argc; i++) { for (int i = 0; i != *argc; i++) {
g_argvs.push_back(StreamableToString(argv[i])); g_argvs.push_back(StreamableToString(argv[i]));
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <gtest/gtest-death-test.h> #include <gtest/gtest-death-test.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
...@@ -45,9 +45,9 @@ ...@@ -45,9 +45,9 @@
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // his code.
#define GTEST_IMPLEMENTATION #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION #undef GTEST_IMPLEMENTATION_
using testing::internal::DeathTest; using testing::internal::DeathTest;
using testing::internal::DeathTestFactory; using testing::internal::DeathTestFactory;
......
...@@ -46,19 +46,19 @@ ...@@ -46,19 +46,19 @@
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // his code.
#define GTEST_IMPLEMENTATION #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION #undef GTEST_IMPLEMENTATION_
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
#include <windows.h> // NOLINT #include <windows.h> // NOLINT
#else #else
#include <direct.h> // NOLINT #include <direct.h> // NOLINT
#endif // _WIN32_WCE #endif // _WIN32_WCE
#define PATH_SEP "\\" #define GTEST_PATH_SEP_ "\\"
#else #else
#define PATH_SEP "/" #define GTEST_PATH_SEP_ "/"
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
namespace testing { namespace testing {
...@@ -90,16 +90,16 @@ int _rmdir(const char* path) { ...@@ -90,16 +90,16 @@ int _rmdir(const char* path) {
TEST(GetCurrentDirTest, ReturnsCurrentDir) { TEST(GetCurrentDirTest, ReturnsCurrentDir) {
EXPECT_FALSE(FilePath::GetCurrentDir().IsEmpty()); EXPECT_FALSE(FilePath::GetCurrentDir().IsEmpty());
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
_chdir(PATH_SEP); _chdir(GTEST_PATH_SEP_);
const FilePath cwd = FilePath::GetCurrentDir(); const FilePath cwd = FilePath::GetCurrentDir();
// Skips the ":". // Skips the ":".
const char* const cwd_without_drive = strchr(cwd.c_str(), ':'); const char* const cwd_without_drive = strchr(cwd.c_str(), ':');
ASSERT_TRUE(cwd_without_drive != NULL); ASSERT_TRUE(cwd_without_drive != NULL);
EXPECT_STREQ(PATH_SEP, cwd_without_drive + 1); EXPECT_STREQ(GTEST_PATH_SEP_, cwd_without_drive + 1);
#else #else
chdir(PATH_SEP); chdir(GTEST_PATH_SEP_);
EXPECT_STREQ(PATH_SEP, FilePath::GetCurrentDir().c_str()); EXPECT_STREQ(GTEST_PATH_SEP_, FilePath::GetCurrentDir().c_str());
#endif #endif
} }
...@@ -131,25 +131,25 @@ TEST(RemoveDirectoryNameTest, ButNoDirectory) { ...@@ -131,25 +131,25 @@ TEST(RemoveDirectoryNameTest, ButNoDirectory) {
// RemoveDirectoryName "/afile" -> "afile" // RemoveDirectoryName "/afile" -> "afile"
TEST(RemoveDirectoryNameTest, RootFileShouldGiveFileName) { TEST(RemoveDirectoryNameTest, RootFileShouldGiveFileName) {
EXPECT_STREQ("afile", EXPECT_STREQ("afile",
FilePath(PATH_SEP "afile").RemoveDirectoryName().c_str()); FilePath(GTEST_PATH_SEP_ "afile").RemoveDirectoryName().c_str());
} }
// RemoveDirectoryName "adir/" -> "" // RemoveDirectoryName "adir/" -> ""
TEST(RemoveDirectoryNameTest, WhereThereIsNoFileName) { TEST(RemoveDirectoryNameTest, WhereThereIsNoFileName) {
EXPECT_STREQ("", EXPECT_STREQ("",
FilePath("adir" PATH_SEP).RemoveDirectoryName().c_str()); FilePath("adir" GTEST_PATH_SEP_).RemoveDirectoryName().c_str());
} }
// RemoveDirectoryName "adir/afile" -> "afile" // RemoveDirectoryName "adir/afile" -> "afile"
TEST(RemoveDirectoryNameTest, ShouldGiveFileName) { TEST(RemoveDirectoryNameTest, ShouldGiveFileName) {
EXPECT_STREQ("afile", EXPECT_STREQ("afile",
FilePath("adir" PATH_SEP "afile").RemoveDirectoryName().c_str()); FilePath("adir" GTEST_PATH_SEP_ "afile").RemoveDirectoryName().c_str());
} }
// RemoveDirectoryName "adir/subdir/afile" -> "afile" // RemoveDirectoryName "adir/subdir/afile" -> "afile"
TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileName) { TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileName) {
EXPECT_STREQ("afile", EXPECT_STREQ("afile",
FilePath("adir" PATH_SEP "subdir" PATH_SEP "afile") FilePath("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_ "afile")
.RemoveDirectoryName().c_str()); .RemoveDirectoryName().c_str());
} }
...@@ -158,63 +158,63 @@ TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileName) { ...@@ -158,63 +158,63 @@ TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileName) {
TEST(RemoveFileNameTest, EmptyName) { TEST(RemoveFileNameTest, EmptyName) {
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
// On Windows CE, we use the root as the current directory. // On Windows CE, we use the root as the current directory.
EXPECT_STREQ(PATH_SEP, EXPECT_STREQ(GTEST_PATH_SEP_,
FilePath("").RemoveFileName().c_str()); FilePath("").RemoveFileName().c_str());
#else #else
EXPECT_STREQ("." PATH_SEP, EXPECT_STREQ("." GTEST_PATH_SEP_,
FilePath("").RemoveFileName().c_str()); FilePath("").RemoveFileName().c_str());
#endif #endif
} }
// RemoveFileName "adir/" -> "adir/" // RemoveFileName "adir/" -> "adir/"
TEST(RemoveFileNameTest, ButNoFile) { TEST(RemoveFileNameTest, ButNoFile) {
EXPECT_STREQ("adir" PATH_SEP, EXPECT_STREQ("adir" GTEST_PATH_SEP_,
FilePath("adir" PATH_SEP).RemoveFileName().c_str()); FilePath("adir" GTEST_PATH_SEP_).RemoveFileName().c_str());
} }
// RemoveFileName "adir/afile" -> "adir/" // RemoveFileName "adir/afile" -> "adir/"
TEST(RemoveFileNameTest, GivesDirName) { TEST(RemoveFileNameTest, GivesDirName) {
EXPECT_STREQ("adir" PATH_SEP, EXPECT_STREQ("adir" GTEST_PATH_SEP_,
FilePath("adir" PATH_SEP "afile") FilePath("adir" GTEST_PATH_SEP_ "afile")
.RemoveFileName().c_str()); .RemoveFileName().c_str());
} }
// RemoveFileName "adir/subdir/afile" -> "adir/subdir/" // RemoveFileName "adir/subdir/afile" -> "adir/subdir/"
TEST(RemoveFileNameTest, GivesDirAndSubDirName) { TEST(RemoveFileNameTest, GivesDirAndSubDirName) {
EXPECT_STREQ("adir" PATH_SEP "subdir" PATH_SEP, EXPECT_STREQ("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_,
FilePath("adir" PATH_SEP "subdir" PATH_SEP "afile") FilePath("adir" GTEST_PATH_SEP_ "subdir" GTEST_PATH_SEP_ "afile")
.RemoveFileName().c_str()); .RemoveFileName().c_str());
} }
// RemoveFileName "/afile" -> "/" // RemoveFileName "/afile" -> "/"
TEST(RemoveFileNameTest, GivesRootDir) { TEST(RemoveFileNameTest, GivesRootDir) {
EXPECT_STREQ(PATH_SEP, EXPECT_STREQ(GTEST_PATH_SEP_,
FilePath(PATH_SEP "afile").RemoveFileName().c_str()); FilePath(GTEST_PATH_SEP_ "afile").RemoveFileName().c_str());
} }
TEST(MakeFileNameTest, GenerateWhenNumberIsZero) { TEST(MakeFileNameTest, GenerateWhenNumberIsZero) {
FilePath actual = FilePath::MakeFileName(FilePath("foo"), FilePath("bar"), FilePath actual = FilePath::MakeFileName(FilePath("foo"), FilePath("bar"),
0, "xml"); 0, "xml");
EXPECT_STREQ("foo" PATH_SEP "bar.xml", actual.c_str()); EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.c_str());
} }
TEST(MakeFileNameTest, GenerateFileNameNumberGtZero) { TEST(MakeFileNameTest, GenerateFileNameNumberGtZero) {
FilePath actual = FilePath::MakeFileName(FilePath("foo"), FilePath("bar"), FilePath actual = FilePath::MakeFileName(FilePath("foo"), FilePath("bar"),
12, "xml"); 12, "xml");
EXPECT_STREQ("foo" PATH_SEP "bar_12.xml", actual.c_str()); EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar_12.xml", actual.c_str());
} }
TEST(MakeFileNameTest, GenerateFileNameWithSlashNumberIsZero) { TEST(MakeFileNameTest, GenerateFileNameWithSlashNumberIsZero) {
FilePath actual = FilePath::MakeFileName(FilePath("foo" PATH_SEP), FilePath actual = FilePath::MakeFileName(FilePath("foo" GTEST_PATH_SEP_),
FilePath("bar"), 0, "xml"); FilePath("bar"), 0, "xml");
EXPECT_STREQ("foo" PATH_SEP "bar.xml", actual.c_str()); EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.c_str());
} }
TEST(MakeFileNameTest, GenerateFileNameWithSlashNumberGtZero) { TEST(MakeFileNameTest, GenerateFileNameWithSlashNumberGtZero) {
FilePath actual = FilePath::MakeFileName(FilePath("foo" PATH_SEP), FilePath actual = FilePath::MakeFileName(FilePath("foo" GTEST_PATH_SEP_),
FilePath("bar"), 12, "xml"); FilePath("bar"), 12, "xml");
EXPECT_STREQ("foo" PATH_SEP "bar_12.xml", actual.c_str()); EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar_12.xml", actual.c_str());
} }
TEST(MakeFileNameTest, GenerateWhenNumberIsZeroAndDirIsEmpty) { TEST(MakeFileNameTest, GenerateWhenNumberIsZeroAndDirIsEmpty) {
...@@ -232,13 +232,13 @@ TEST(MakeFileNameTest, GenerateWhenNumberIsNotZeroAndDirIsEmpty) { ...@@ -232,13 +232,13 @@ TEST(MakeFileNameTest, GenerateWhenNumberIsNotZeroAndDirIsEmpty) {
TEST(ConcatPathsTest, WorksWhenDirDoesNotEndWithPathSep) { TEST(ConcatPathsTest, WorksWhenDirDoesNotEndWithPathSep) {
FilePath actual = FilePath::ConcatPaths(FilePath("foo"), FilePath actual = FilePath::ConcatPaths(FilePath("foo"),
FilePath("bar.xml")); FilePath("bar.xml"));
EXPECT_STREQ("foo" PATH_SEP "bar.xml", actual.c_str()); EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.c_str());
} }
TEST(ConcatPathsTest, WorksWhenPath1EndsWithPathSep) { TEST(ConcatPathsTest, WorksWhenPath1EndsWithPathSep) {
FilePath actual = FilePath::ConcatPaths(FilePath("foo" PATH_SEP), FilePath actual = FilePath::ConcatPaths(FilePath("foo" GTEST_PATH_SEP_),
FilePath("bar.xml")); FilePath("bar.xml"));
EXPECT_STREQ("foo" PATH_SEP "bar.xml", actual.c_str()); EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar.xml", actual.c_str());
} }
TEST(ConcatPathsTest, Path1BeingEmpty) { TEST(ConcatPathsTest, Path1BeingEmpty) {
...@@ -250,7 +250,7 @@ TEST(ConcatPathsTest, Path1BeingEmpty) { ...@@ -250,7 +250,7 @@ TEST(ConcatPathsTest, Path1BeingEmpty) {
TEST(ConcatPathsTest, Path2BeingEmpty) { TEST(ConcatPathsTest, Path2BeingEmpty) {
FilePath actual = FilePath::ConcatPaths(FilePath("foo"), FilePath actual = FilePath::ConcatPaths(FilePath("foo"),
FilePath("")); FilePath(""));
EXPECT_STREQ("foo" PATH_SEP, actual.c_str()); EXPECT_STREQ("foo" GTEST_PATH_SEP_, actual.c_str());
} }
TEST(ConcatPathsTest, BothPathBeingEmpty) { TEST(ConcatPathsTest, BothPathBeingEmpty) {
...@@ -260,21 +260,24 @@ TEST(ConcatPathsTest, BothPathBeingEmpty) { ...@@ -260,21 +260,24 @@ TEST(ConcatPathsTest, BothPathBeingEmpty) {
} }
TEST(ConcatPathsTest, Path1ContainsPathSep) { TEST(ConcatPathsTest, Path1ContainsPathSep) {
FilePath actual = FilePath::ConcatPaths(FilePath("foo" PATH_SEP "bar"), FilePath actual = FilePath::ConcatPaths(FilePath("foo" GTEST_PATH_SEP_ "bar"),
FilePath("foobar.xml")); FilePath("foobar.xml"));
EXPECT_STREQ("foo" PATH_SEP "bar" PATH_SEP "foobar.xml", actual.c_str()); EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_ "foobar.xml",
actual.c_str());
} }
TEST(ConcatPathsTest, Path2ContainsPathSep) { TEST(ConcatPathsTest, Path2ContainsPathSep) {
FilePath actual = FilePath::ConcatPaths(FilePath("foo" PATH_SEP), FilePath actual = FilePath::ConcatPaths(
FilePath("bar" PATH_SEP "bar.xml")); FilePath("foo" GTEST_PATH_SEP_),
EXPECT_STREQ("foo" PATH_SEP "bar" PATH_SEP "bar.xml", actual.c_str()); FilePath("bar" GTEST_PATH_SEP_ "bar.xml"));
EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_ "bar.xml",
actual.c_str());
} }
TEST(ConcatPathsTest, Path2EndsWithPathSep) { TEST(ConcatPathsTest, Path2EndsWithPathSep) {
FilePath actual = FilePath::ConcatPaths(FilePath("foo"), FilePath actual = FilePath::ConcatPaths(FilePath("foo"),
FilePath("bar" PATH_SEP)); FilePath("bar" GTEST_PATH_SEP_));
EXPECT_STREQ("foo" PATH_SEP "bar" PATH_SEP, actual.c_str()); EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_, actual.c_str());
} }
// RemoveTrailingPathSeparator "" -> "" // RemoveTrailingPathSeparator "" -> ""
...@@ -291,25 +294,27 @@ TEST(RemoveTrailingPathSeparatorTest, FileNoSlashString) { ...@@ -291,25 +294,27 @@ TEST(RemoveTrailingPathSeparatorTest, FileNoSlashString) {
// RemoveTrailingPathSeparator "foo/" -> "foo" // RemoveTrailingPathSeparator "foo/" -> "foo"
TEST(RemoveTrailingPathSeparatorTest, ShouldRemoveTrailingSeparator) { TEST(RemoveTrailingPathSeparatorTest, ShouldRemoveTrailingSeparator) {
EXPECT_STREQ("foo", EXPECT_STREQ(
FilePath("foo" PATH_SEP).RemoveTrailingPathSeparator().c_str()); "foo",
FilePath("foo" GTEST_PATH_SEP_).RemoveTrailingPathSeparator().c_str());
} }
// RemoveTrailingPathSeparator "foo/bar/" -> "foo/bar/" // RemoveTrailingPathSeparator "foo/bar/" -> "foo/bar/"
TEST(RemoveTrailingPathSeparatorTest, ShouldRemoveLastSeparator) { TEST(RemoveTrailingPathSeparatorTest, ShouldRemoveLastSeparator) {
EXPECT_STREQ("foo" PATH_SEP "bar", EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar",
FilePath("foo" PATH_SEP "bar" PATH_SEP).RemoveTrailingPathSeparator() FilePath("foo" GTEST_PATH_SEP_ "bar" GTEST_PATH_SEP_)
.c_str()); .RemoveTrailingPathSeparator().c_str());
} }
// RemoveTrailingPathSeparator "foo/bar" -> "foo/bar" // RemoveTrailingPathSeparator "foo/bar" -> "foo/bar"
TEST(RemoveTrailingPathSeparatorTest, ShouldReturnUnmodified) { TEST(RemoveTrailingPathSeparatorTest, ShouldReturnUnmodified) {
EXPECT_STREQ("foo" PATH_SEP "bar", EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar",
FilePath("foo" PATH_SEP "bar").RemoveTrailingPathSeparator().c_str()); FilePath("foo" GTEST_PATH_SEP_ "bar")
.RemoveTrailingPathSeparator().c_str());
} }
TEST(DirectoryTest, RootDirectoryExists) { TEST(DirectoryTest, RootDirectoryExists) {
#ifdef GTEST_OS_WINDOWS // We are on Windows. #if GTEST_OS_WINDOWS // We are on Windows.
char current_drive[_MAX_PATH]; // NOLINT char current_drive[_MAX_PATH]; // NOLINT
current_drive[0] = static_cast<char>(_getdrive() + 'A' - 1); current_drive[0] = static_cast<char>(_getdrive() + 'A' - 1);
current_drive[1] = ':'; current_drive[1] = ':';
...@@ -321,7 +326,7 @@ TEST(DirectoryTest, RootDirectoryExists) { ...@@ -321,7 +326,7 @@ TEST(DirectoryTest, RootDirectoryExists) {
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
} }
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
TEST(DirectoryTest, RootOfWrongDriveDoesNotExists) { TEST(DirectoryTest, RootOfWrongDriveDoesNotExists) {
const int saved_drive_ = _getdrive(); const int saved_drive_ = _getdrive();
// Find a drive that doesn't exist. Start with 'Z' to avoid common ones. // Find a drive that doesn't exist. Start with 'Z' to avoid common ones.
...@@ -347,7 +352,7 @@ TEST(DirectoryTest, EmptyPathDirectoryDoesNotExist) { ...@@ -347,7 +352,7 @@ TEST(DirectoryTest, EmptyPathDirectoryDoesNotExist) {
#endif // ! _WIN32_WCE #endif // ! _WIN32_WCE
TEST(DirectoryTest, CurrentDirectoryExists) { TEST(DirectoryTest, CurrentDirectoryExists) {
#ifdef GTEST_OS_WINDOWS // We are on Windows. #if GTEST_OS_WINDOWS // We are on Windows.
#ifndef _WIN32_CE // Windows CE doesn't have a current directory. #ifndef _WIN32_CE // Windows CE doesn't have a current directory.
EXPECT_TRUE(FilePath(".").DirectoryExists()); EXPECT_TRUE(FilePath(".").DirectoryExists());
EXPECT_TRUE(FilePath(".\\").DirectoryExists()); EXPECT_TRUE(FilePath(".\\").DirectoryExists());
...@@ -365,32 +370,33 @@ TEST(NormalizeTest, NullStringsEqualEmptyDirectory) { ...@@ -365,32 +370,33 @@ TEST(NormalizeTest, NullStringsEqualEmptyDirectory) {
// "foo/bar" == foo//bar" == "foo///bar" // "foo/bar" == foo//bar" == "foo///bar"
TEST(NormalizeTest, MultipleConsecutiveSepaparatorsInMidstring) { TEST(NormalizeTest, MultipleConsecutiveSepaparatorsInMidstring) {
EXPECT_STREQ("foo" PATH_SEP "bar", EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar",
FilePath("foo" PATH_SEP "bar").c_str()); FilePath("foo" GTEST_PATH_SEP_ "bar").c_str());
EXPECT_STREQ("foo" PATH_SEP "bar", EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar",
FilePath("foo" PATH_SEP PATH_SEP "bar").c_str()); FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").c_str());
EXPECT_STREQ("foo" PATH_SEP "bar", EXPECT_STREQ("foo" GTEST_PATH_SEP_ "bar",
FilePath("foo" PATH_SEP PATH_SEP PATH_SEP "bar").c_str()); FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_
GTEST_PATH_SEP_ "bar").c_str());
} }
// "/bar" == //bar" == "///bar" // "/bar" == //bar" == "///bar"
TEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringStart) { TEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringStart) {
EXPECT_STREQ(PATH_SEP "bar", EXPECT_STREQ(GTEST_PATH_SEP_ "bar",
FilePath(PATH_SEP "bar").c_str()); FilePath(GTEST_PATH_SEP_ "bar").c_str());
EXPECT_STREQ(PATH_SEP "bar", EXPECT_STREQ(GTEST_PATH_SEP_ "bar",
FilePath(PATH_SEP PATH_SEP "bar").c_str()); FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").c_str());
EXPECT_STREQ(PATH_SEP "bar", EXPECT_STREQ(GTEST_PATH_SEP_ "bar",
FilePath(PATH_SEP PATH_SEP PATH_SEP "bar").c_str()); FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").c_str());
} }
// "foo/" == foo//" == "foo///" // "foo/" == foo//" == "foo///"
TEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringEnd) { TEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringEnd) {
EXPECT_STREQ("foo" PATH_SEP, EXPECT_STREQ("foo" GTEST_PATH_SEP_,
FilePath("foo" PATH_SEP).c_str()); FilePath("foo" GTEST_PATH_SEP_).c_str());
EXPECT_STREQ("foo" PATH_SEP, EXPECT_STREQ("foo" GTEST_PATH_SEP_,
FilePath("foo" PATH_SEP PATH_SEP).c_str()); FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_).c_str());
EXPECT_STREQ("foo" PATH_SEP, EXPECT_STREQ("foo" GTEST_PATH_SEP_,
FilePath("foo" PATH_SEP PATH_SEP PATH_SEP).c_str()); FilePath("foo" GTEST_PATH_SEP_ GTEST_PATH_SEP_ GTEST_PATH_SEP_).c_str());
} }
TEST(AssignmentOperatorTest, DefaultAssignedToNonDefault) { TEST(AssignmentOperatorTest, DefaultAssignedToNonDefault) {
...@@ -421,7 +427,7 @@ class DirectoryCreationTest : public Test { ...@@ -421,7 +427,7 @@ class DirectoryCreationTest : public Test {
virtual void SetUp() { virtual void SetUp() {
testdata_path_.Set(FilePath(String::Format("%s%s%s", testdata_path_.Set(FilePath(String::Format("%s%s%s",
TempDir().c_str(), GetCurrentExecutableName().c_str(), TempDir().c_str(), GetCurrentExecutableName().c_str(),
"_directory_creation" PATH_SEP "test" PATH_SEP))); "_directory_creation" GTEST_PATH_SEP_ "test" GTEST_PATH_SEP_)));
testdata_file_.Set(testdata_path_.RemoveTrailingPathSeparator()); testdata_file_.Set(testdata_path_.RemoveTrailingPathSeparator());
unique_file0_.Set(FilePath::MakeFileName(testdata_path_, FilePath("unique"), unique_file0_.Set(FilePath::MakeFileName(testdata_path_, FilePath("unique"),
...@@ -432,7 +438,7 @@ class DirectoryCreationTest : public Test { ...@@ -432,7 +438,7 @@ class DirectoryCreationTest : public Test {
remove(testdata_file_.c_str()); remove(testdata_file_.c_str());
remove(unique_file0_.c_str()); remove(unique_file0_.c_str());
remove(unique_file1_.c_str()); remove(unique_file1_.c_str());
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
_rmdir(testdata_path_.c_str()); _rmdir(testdata_path_.c_str());
#else #else
rmdir(testdata_path_.c_str()); rmdir(testdata_path_.c_str());
...@@ -443,7 +449,7 @@ class DirectoryCreationTest : public Test { ...@@ -443,7 +449,7 @@ class DirectoryCreationTest : public Test {
remove(testdata_file_.c_str()); remove(testdata_file_.c_str());
remove(unique_file0_.c_str()); remove(unique_file0_.c_str());
remove(unique_file1_.c_str()); remove(unique_file1_.c_str());
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
_rmdir(testdata_path_.c_str()); _rmdir(testdata_path_.c_str());
#else #else
rmdir(testdata_path_.c_str()); rmdir(testdata_path_.c_str());
...@@ -454,7 +460,7 @@ class DirectoryCreationTest : public Test { ...@@ -454,7 +460,7 @@ class DirectoryCreationTest : public Test {
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
return String("\\temp\\"); return String("\\temp\\");
#elif defined(GTEST_OS_WINDOWS) #elif GTEST_OS_WINDOWS
// MSVC 8 deprecates getenv(), so we want to suppress warning 4996 // MSVC 8 deprecates getenv(), so we want to suppress warning 4996
// (deprecated function) there. // (deprecated function) there.
#pragma warning(push) // Saves the current warning state. #pragma warning(push) // Saves the current warning state.
...@@ -474,7 +480,7 @@ class DirectoryCreationTest : public Test { ...@@ -474,7 +480,7 @@ class DirectoryCreationTest : public Test {
} }
void CreateTextFile(const char* filename) { void CreateTextFile(const char* filename) {
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
// MSVC 8 deprecates fopen(), so we want to suppress warning 4996 // MSVC 8 deprecates fopen(), so we want to suppress warning 4996
// (deprecated function) there.#pragma warning(push) // (deprecated function) there.#pragma warning(push)
#pragma warning(push) // Saves the current warning state. #pragma warning(push) // Saves the current warning state.
...@@ -585,18 +591,18 @@ TEST(FilePathTest, RemoveExtensionWhenThereIsNoExtension) { ...@@ -585,18 +591,18 @@ TEST(FilePathTest, RemoveExtensionWhenThereIsNoExtension) {
TEST(FilePathTest, IsDirectory) { TEST(FilePathTest, IsDirectory) {
EXPECT_FALSE(FilePath("cola").IsDirectory()); EXPECT_FALSE(FilePath("cola").IsDirectory());
EXPECT_TRUE(FilePath("koala" PATH_SEP).IsDirectory()); EXPECT_TRUE(FilePath("koala" GTEST_PATH_SEP_).IsDirectory());
} }
TEST(FilePathTest, IsAbsolutePath) { TEST(FilePathTest, IsAbsolutePath) {
EXPECT_FALSE(FilePath("is" PATH_SEP "relative").IsAbsolutePath()); EXPECT_FALSE(FilePath("is" GTEST_PATH_SEP_ "relative").IsAbsolutePath());
EXPECT_FALSE(FilePath("").IsAbsolutePath()); EXPECT_FALSE(FilePath("").IsAbsolutePath());
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
EXPECT_TRUE(FilePath("c:\\" PATH_SEP "is_not" PATH_SEP "relative") EXPECT_TRUE(FilePath("c:\\" GTEST_PATH_SEP_ "is_not"
.IsAbsolutePath()); GTEST_PATH_SEP_ "relative").IsAbsolutePath());
EXPECT_FALSE(FilePath("c:foo" PATH_SEP "bar").IsAbsolutePath()); EXPECT_FALSE(FilePath("c:foo" GTEST_PATH_SEP_ "bar").IsAbsolutePath());
#else #else
EXPECT_TRUE(FilePath(PATH_SEP "is_not" PATH_SEP "relative") EXPECT_TRUE(FilePath(GTEST_PATH_SEP_ "is_not" GTEST_PATH_SEP_ "relative")
.IsAbsolutePath()); .IsAbsolutePath());
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
} }
...@@ -605,4 +611,4 @@ TEST(FilePathTest, IsAbsolutePath) { ...@@ -605,4 +611,4 @@ TEST(FilePathTest, IsAbsolutePath) {
} // namespace internal } // namespace internal
} // namespace testing } // namespace testing
#undef PATH_SEP #undef GTEST_PATH_SEP_
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
#include <windows.h> #include <windows.h>
#elif defined(GTEST_OS_WINDOWS) #elif GTEST_OS_WINDOWS
#include <direct.h> #include <direct.h>
#endif // _WIN32_WCE #endif // _WIN32_WCE
...@@ -51,9 +51,9 @@ ...@@ -51,9 +51,9 @@
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // his code.
#define GTEST_IMPLEMENTATION #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION #undef GTEST_IMPLEMENTATION_
namespace testing { namespace testing {
namespace internal { namespace internal {
...@@ -89,7 +89,7 @@ TEST(XmlOutputTest, GetOutputFileSingleFile) { ...@@ -89,7 +89,7 @@ TEST(XmlOutputTest, GetOutputFileSingleFile) {
} }
TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) { TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) {
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
GTEST_FLAG(output) = "xml:path\\"; GTEST_FLAG(output) = "xml:path\\";
const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile(); const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -121,7 +121,7 @@ TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) { ...@@ -121,7 +121,7 @@ TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) {
TEST(OutputFileHelpersTest, GetCurrentExecutableName) { TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
const FilePath executable = GetCurrentExecutableName(); const FilePath executable = GetCurrentExecutableName();
const char* const exe_str = executable.c_str(); const char* const exe_str = executable.c_str();
#if defined(_WIN32_WCE) || defined(GTEST_OS_WINDOWS) #if defined(_WIN32_WCE) || GTEST_OS_WINDOWS
ASSERT_TRUE(_strcmpi("gtest-options_test", exe_str) == 0 || ASSERT_TRUE(_strcmpi("gtest-options_test", exe_str) == 0 ||
_strcmpi("gtest-options-ex_test", exe_str) == 0) _strcmpi("gtest-options-ex_test", exe_str) == 0)
<< "GetCurrentExecutableName() returns " << exe_str; << "GetCurrentExecutableName() returns " << exe_str;
...@@ -149,7 +149,7 @@ class XmlOutputChangeDirTest : public Test { ...@@ -149,7 +149,7 @@ class XmlOutputChangeDirTest : public Test {
} }
void ChDir(const char* dir) { void ChDir(const char* dir) {
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
_chdir(dir); _chdir(dir);
#else #else
chdir(dir); chdir(dir);
...@@ -181,7 +181,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativeFile) { ...@@ -181,7 +181,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativeFile) {
} }
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) { TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
GTEST_FLAG(output) = "xml:path\\"; GTEST_FLAG(output) = "xml:path\\";
const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile(); const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -211,7 +211,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) { ...@@ -211,7 +211,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {
} }
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) { TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) {
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
GTEST_FLAG(output) = "xml:c:\\tmp\\filename.abc"; GTEST_FLAG(output) = "xml:c:\\tmp\\filename.abc";
EXPECT_STREQ(FilePath("c:\\tmp\\filename.abc").c_str(), EXPECT_STREQ(FilePath("c:\\tmp\\filename.abc").c_str(),
UnitTestOptions::GetAbsolutePathToOutputFile().c_str()); UnitTestOptions::GetAbsolutePathToOutputFile().c_str());
...@@ -223,7 +223,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) { ...@@ -223,7 +223,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) {
} }
TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) { TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) {
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
GTEST_FLAG(output) = "xml:c:\\tmp\\"; GTEST_FLAG(output) = "xml:c:\\tmp\\";
const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile(); const String& output_file = UnitTestOptions::GetAbsolutePathToOutputFile();
EXPECT_TRUE( EXPECT_TRUE(
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "test/gtest-param-test_test.h" #include "test/gtest-param-test_test.h"
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
using ::testing::Values; using ::testing::Values;
using ::testing::internal::ParamGenerator; using ::testing::internal::ParamGenerator;
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
...@@ -43,9 +43,9 @@ ...@@ -43,9 +43,9 @@
#include <vector> #include <vector>
// To include gtest-internal-inl.h. // To include gtest-internal-inl.h.
#define GTEST_IMPLEMENTATION #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" // for UnitTestOptions #include "src/gtest-internal-inl.h" // for UnitTestOptions
#undef GTEST_IMPLEMENTATION #undef GTEST_IMPLEMENTATION_
#include "test/gtest-param-test_test.h" #include "test/gtest-param-test_test.h"
...@@ -60,7 +60,7 @@ using ::testing::TestWithParam; ...@@ -60,7 +60,7 @@ using ::testing::TestWithParam;
using ::testing::Values; using ::testing::Values;
using ::testing::ValuesIn; using ::testing::ValuesIn;
#ifdef GTEST_HAS_COMBINE #if GTEST_HAS_COMBINE
using ::testing::Combine; using ::testing::Combine;
using ::std::tr1::get; using ::std::tr1::get;
using ::std::tr1::make_tuple; using ::std::tr1::make_tuple;
...@@ -398,7 +398,7 @@ TEST(BoolTest, BoolWorks) { ...@@ -398,7 +398,7 @@ TEST(BoolTest, BoolWorks) {
VerifyGenerator(gen, expected_values); VerifyGenerator(gen, expected_values);
} }
#ifdef GTEST_HAS_COMBINE #if GTEST_HAS_COMBINE
template <typename T1, typename T2> template <typename T1, typename T2>
::std::ostream& operator<<(::std::ostream& stream, const tuple<T1, T2>& value) { ::std::ostream& operator<<(::std::ostream& stream, const tuple<T1, T2>& value) {
...@@ -774,13 +774,13 @@ INSTANTIATE_TEST_CASE_P(ZeroToFiveSequence, NamingTest, Range(0, 5)); ...@@ -774,13 +774,13 @@ INSTANTIATE_TEST_CASE_P(ZeroToFiveSequence, NamingTest, Range(0, 5));
#endif // GTEST_HAS_PARAM_TEST #endif // GTEST_HAS_PARAM_TEST
TEST(CompileTest, CombineIsDefinedOnlyWhenGtestHasParamTestIsDefined) { TEST(CompileTest, CombineIsDefinedOnlyWhenGtestHasParamTestIsDefined) {
#if defined(GTEST_HAS_COMBINE) && !defined(GTEST_HAS_PARAM_TEST) #if GTEST_HAS_COMBINE && !GTEST_HAS_PARAM_TEST
FAIL() << "GTEST_HAS_COMBINE is defined while GTEST_HAS_PARAM_TEST is not\n" FAIL() << "GTEST_HAS_COMBINE is defined while GTEST_HAS_PARAM_TEST is not\n"
#endif #endif
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
// Used in TestGenerationTest test case. // Used in TestGenerationTest test case.
AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance()); AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance());
// Used in GeneratorEvaluationTest test case. // Used in GeneratorEvaluationTest test case.
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
// Test fixture for testing definition and instantiation of a test // Test fixture for testing definition and instantiation of a test
// in separate translation units. // in separate translation units.
......
...@@ -40,9 +40,9 @@ ...@@ -40,9 +40,9 @@
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // his code.
#define GTEST_IMPLEMENTATION #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION #undef GTEST_IMPLEMENTATION_
namespace testing { namespace testing {
namespace internal { namespace internal {
...@@ -76,7 +76,7 @@ TEST(GtestCheckSyntaxTest, WorksWithSwitch) { ...@@ -76,7 +76,7 @@ TEST(GtestCheckSyntaxTest, WorksWithSwitch) {
GTEST_CHECK_(true) << "Check failed in switch case"; GTEST_CHECK_(true) << "Check failed in switch case";
} }
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
TEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) { TEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) {
const bool a_false_condition = false; const bool a_false_condition = false;
......
...@@ -117,7 +117,7 @@ TEST_F(TestPartResultArrayTest, ContainsGivenResultsAfterTwoAppends) { ...@@ -117,7 +117,7 @@ TEST_F(TestPartResultArrayTest, ContainsGivenResultsAfterTwoAppends) {
EXPECT_STREQ("Failure 2", results.GetTestPartResult(1).message()); EXPECT_STREQ("Failure 2", results.GetTestPartResult(1).message());
} }
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
typedef TestPartResultArrayTest TestPartResultArrayDeathTest; typedef TestPartResultArrayTest TestPartResultArrayDeathTest;
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "test/gtest-typed-test_test.h" #include "test/gtest-typed-test_test.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
#ifdef GTEST_HAS_TYPED_TEST_P #if GTEST_HAS_TYPED_TEST_P
// Tests that the same type-parameterized test case can be // Tests that the same type-parameterized test case can be
// instantiated in different translation units linked together. // instantiated in different translation units linked together.
......
...@@ -82,7 +82,7 @@ template <typename T> ...@@ -82,7 +82,7 @@ template <typename T>
T* CommonTest<T>::shared_ = NULL; T* CommonTest<T>::shared_ = NULL;
// This #ifdef block tests typed tests. // This #ifdef block tests typed tests.
#ifdef GTEST_HAS_TYPED_TEST #if GTEST_HAS_TYPED_TEST
using testing::Types; using testing::Types;
...@@ -166,7 +166,7 @@ TYPED_TEST(NumericTest, DefaultIsZero) { ...@@ -166,7 +166,7 @@ TYPED_TEST(NumericTest, DefaultIsZero) {
#endif // GTEST_HAS_TYPED_TEST #endif // GTEST_HAS_TYPED_TEST
// This #ifdef block tests type-parameterized tests. // This #ifdef block tests type-parameterized tests.
#ifdef GTEST_HAS_TYPED_TEST_P #if GTEST_HAS_TYPED_TEST_P
using testing::Types; using testing::Types;
using testing::internal::TypedTestCasePState; using testing::internal::TypedTestCasePState;
...@@ -198,7 +198,7 @@ TEST_F(TypedTestCasePStateTest, IgnoresOrderAndSpaces) { ...@@ -198,7 +198,7 @@ TEST_F(TypedTestCasePStateTest, IgnoresOrderAndSpaces) {
state_.VerifyRegisteredTestNames("foo.cc", 1, tests)); state_.VerifyRegisteredTestNames("foo.cc", 1, tests));
} }
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
typedef TypedTestCasePStateTest TypedTestCasePStateDeathTest; typedef TypedTestCasePStateTest TypedTestCasePStateDeathTest;
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#ifdef GTEST_HAS_TYPED_TEST_P #if GTEST_HAS_TYPED_TEST_P
using testing::Test; using testing::Test;
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
#include <windows.h> #include <windows.h>
#endif #endif
...@@ -56,7 +56,7 @@ TEST(Foo, Bar) { ...@@ -56,7 +56,7 @@ TEST(Foo, Bar) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
// Suppresses display of the Windows error dialog upon encountering // Suppresses display of the Windows error dialog upon encountering
// a general protection fault (segment violation). // a general protection fault (segment violation).
SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS); SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS);
......
...@@ -36,9 +36,9 @@ ...@@ -36,9 +36,9 @@
#include <iostream> #include <iostream>
#define GTEST_IMPLEMENTATION #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION #undef GTEST_IMPLEMENTATION_
using ::std::cout; using ::std::cout;
......
...@@ -94,7 +94,7 @@ TEST(BazTest, DISABLED_TestC) { ...@@ -94,7 +94,7 @@ TEST(BazTest, DISABLED_TestC) {
// Test case HasDeathTest // Test case HasDeathTest
TEST(HasDeathTest, Test1) { TEST(HasDeathTest, Test1) {
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
EXPECT_DEATH({exit(1);}, EXPECT_DEATH({exit(1);},
".*"); ".*");
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
...@@ -103,7 +103,7 @@ TEST(HasDeathTest, Test1) { ...@@ -103,7 +103,7 @@ TEST(HasDeathTest, Test1) {
// We need at least two death tests to make sure that the all death tests // We need at least two death tests to make sure that the all death tests
// aren't on the first shard. // aren't on the first shard.
TEST(HasDeathTest, Test2) { TEST(HasDeathTest, Test2) {
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
EXPECT_DEATH({exit(1);}, EXPECT_DEATH({exit(1);},
".*"); ".*");
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
...@@ -126,7 +126,7 @@ TEST(DISABLED_FoobarbazTest, TestA) { ...@@ -126,7 +126,7 @@ TEST(DISABLED_FoobarbazTest, TestA) {
FAIL() << "Expected failure."; FAIL() << "Expected failure.";
} }
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
class ParamTest : public testing::TestWithParam<int> { class ParamTest : public testing::TestWithParam<int> {
}; };
......
...@@ -40,9 +40,9 @@ ...@@ -40,9 +40,9 @@
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // his code.
#define GTEST_IMPLEMENTATION #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION #undef GTEST_IMPLEMENTATION_
#include <stdlib.h> #include <stdlib.h>
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#include <pthread.h> #include <pthread.h>
#endif // GTEST_HAS_PTHREAD #endif // GTEST_HAS_PTHREAD
#ifdef GTEST_OS_LINUX #if GTEST_OS_LINUX
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <string> #include <string>
...@@ -355,7 +355,7 @@ TEST_F(FatalFailureInSetUpTest, FailureInSetUp) { ...@@ -355,7 +355,7 @@ TEST_F(FatalFailureInSetUpTest, FailureInSetUp) {
<< "We should never get here, as SetUp() failed."; << "We should never get here, as SetUp() failed.";
} }
#ifdef GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
// This group of tests verifies that Google Test handles SEH and C++ // This group of tests verifies that Google Test handles SEH and C++
// exceptions correctly. // exceptions correctly.
...@@ -722,7 +722,7 @@ TEST(ExpectFatalFailureTest, FailsWhenStatementThrows) { ...@@ -722,7 +722,7 @@ TEST(ExpectFatalFailureTest, FailsWhenStatementThrows) {
#endif // GTEST_HAS_EXCEPTIONS #endif // GTEST_HAS_EXCEPTIONS
// This #ifdef block tests the output of typed tests. // This #ifdef block tests the output of typed tests.
#ifdef GTEST_HAS_TYPED_TEST #if GTEST_HAS_TYPED_TEST
template <typename T> template <typename T>
class TypedTest : public testing::Test { class TypedTest : public testing::Test {
...@@ -741,7 +741,7 @@ TYPED_TEST(TypedTest, Failure) { ...@@ -741,7 +741,7 @@ TYPED_TEST(TypedTest, Failure) {
#endif // GTEST_HAS_TYPED_TEST #endif // GTEST_HAS_TYPED_TEST
// This #ifdef block tests the output of type-parameterized tests. // This #ifdef block tests the output of type-parameterized tests.
#ifdef GTEST_HAS_TYPED_TEST_P #if GTEST_HAS_TYPED_TEST_P
template <typename T> template <typename T>
class TypedTestP : public testing::Test { class TypedTestP : public testing::Test {
...@@ -764,7 +764,7 @@ INSTANTIATE_TYPED_TEST_CASE_P(Unsigned, TypedTestP, UnsignedTypes); ...@@ -764,7 +764,7 @@ INSTANTIATE_TYPED_TEST_CASE_P(Unsigned, TypedTestP, UnsignedTypes);
#endif // GTEST_HAS_TYPED_TEST_P #endif // GTEST_HAS_TYPED_TEST_P
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
// We rely on the golden file to verify that tests whose test case // We rely on the golden file to verify that tests whose test case
// name ends with DeathTest are run first. // name ends with DeathTest are run first.
...@@ -772,7 +772,7 @@ INSTANTIATE_TYPED_TEST_CASE_P(Unsigned, TypedTestP, UnsignedTypes); ...@@ -772,7 +772,7 @@ INSTANTIATE_TYPED_TEST_CASE_P(Unsigned, TypedTestP, UnsignedTypes);
TEST(ADeathTest, ShouldRunFirst) { TEST(ADeathTest, ShouldRunFirst) {
} }
#ifdef GTEST_HAS_TYPED_TEST #if GTEST_HAS_TYPED_TEST
// We rely on the golden file to verify that typed tests whose test // We rely on the golden file to verify that typed tests whose test
// case name ends with DeathTest are run first. // case name ends with DeathTest are run first.
...@@ -789,7 +789,7 @@ TYPED_TEST(ATypedDeathTest, ShouldRunFirst) { ...@@ -789,7 +789,7 @@ TYPED_TEST(ATypedDeathTest, ShouldRunFirst) {
#endif // GTEST_HAS_TYPED_TEST #endif // GTEST_HAS_TYPED_TEST
#ifdef GTEST_HAS_TYPED_TEST_P #if GTEST_HAS_TYPED_TEST_P
// We rely on the golden file to verify that type-parameterized tests // We rely on the golden file to verify that type-parameterized tests
...@@ -984,7 +984,7 @@ int main(int argc, char **argv) { ...@@ -984,7 +984,7 @@ int main(int argc, char **argv) {
String(argv[1]) == "--gtest_internal_skip_environment_and_ad_hoc_tests") String(argv[1]) == "--gtest_internal_skip_environment_and_ad_hoc_tests")
GTEST_FLAG(internal_skip_environment_and_ad_hoc_tests) = true; GTEST_FLAG(internal_skip_environment_and_ad_hoc_tests) = true;
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
if (testing::internal::GTEST_FLAG(internal_run_death_test) != "") { if (testing::internal::GTEST_FLAG(internal_run_death_test) != "") {
// Skip the usual output capturing if we're running as the child // Skip the usual output capturing if we're running as the child
// process of an threadsafe-style death test. // process of an threadsafe-style death test.
......
...@@ -40,9 +40,9 @@ ...@@ -40,9 +40,9 @@
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // his code.
#define GTEST_IMPLEMENTATION #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION #undef GTEST_IMPLEMENTATION_
namespace testing { namespace testing {
...@@ -112,7 +112,7 @@ int g_death_test_count = 0; ...@@ -112,7 +112,7 @@ int g_death_test_count = 0;
TEST(BarDeathTest, ThreadSafeAndFast) { TEST(BarDeathTest, ThreadSafeAndFast) {
g_death_test_count++; g_death_test_count++;
#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
GTEST_FLAG(death_test_style) = "threadsafe"; GTEST_FLAG(death_test_style) = "threadsafe";
EXPECT_DEATH(abort(), ""); EXPECT_DEATH(abort(), "");
...@@ -121,7 +121,7 @@ TEST(BarDeathTest, ThreadSafeAndFast) { ...@@ -121,7 +121,7 @@ TEST(BarDeathTest, ThreadSafeAndFast) {
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
} }
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
int g_param_test_count = 0; int g_param_test_count = 0;
const int kNumberOfParamTests = 10; const int kNumberOfParamTests = 10;
...@@ -146,7 +146,7 @@ void ResetCounts() { ...@@ -146,7 +146,7 @@ void ResetCounts() {
g_should_fail_count = 0; g_should_fail_count = 0;
g_should_pass_count = 0; g_should_pass_count = 0;
g_death_test_count = 0; g_death_test_count = 0;
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
g_param_test_count = 0; g_param_test_count = 0;
#endif // GTEST_HAS_PARAM_TEST #endif // GTEST_HAS_PARAM_TEST
} }
...@@ -158,7 +158,7 @@ void CheckCounts(int expected) { ...@@ -158,7 +158,7 @@ void CheckCounts(int expected) {
GTEST_CHECK_INT_EQ_(expected, g_should_fail_count); GTEST_CHECK_INT_EQ_(expected, g_should_fail_count);
GTEST_CHECK_INT_EQ_(expected, g_should_pass_count); GTEST_CHECK_INT_EQ_(expected, g_should_pass_count);
GTEST_CHECK_INT_EQ_(expected, g_death_test_count); GTEST_CHECK_INT_EQ_(expected, g_death_test_count);
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
GTEST_CHECK_INT_EQ_(expected * kNumberOfParamTests, g_param_test_count); GTEST_CHECK_INT_EQ_(expected * kNumberOfParamTests, g_param_test_count);
#endif // GTEST_HAS_PARAM_TEST #endif // GTEST_HAS_PARAM_TEST
} }
...@@ -203,7 +203,7 @@ void TestRepeatWithFilterForSuccessfulTests(int repeat) { ...@@ -203,7 +203,7 @@ void TestRepeatWithFilterForSuccessfulTests(int repeat) {
GTEST_CHECK_INT_EQ_(0, g_should_fail_count); GTEST_CHECK_INT_EQ_(0, g_should_fail_count);
GTEST_CHECK_INT_EQ_(repeat, g_should_pass_count); GTEST_CHECK_INT_EQ_(repeat, g_should_pass_count);
GTEST_CHECK_INT_EQ_(repeat, g_death_test_count); GTEST_CHECK_INT_EQ_(repeat, g_death_test_count);
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
GTEST_CHECK_INT_EQ_(repeat * kNumberOfParamTests, g_param_test_count); GTEST_CHECK_INT_EQ_(repeat * kNumberOfParamTests, g_param_test_count);
#endif // GTEST_HAS_PARAM_TEST #endif // GTEST_HAS_PARAM_TEST
} }
...@@ -221,7 +221,7 @@ void TestRepeatWithFilterForFailedTests(int repeat) { ...@@ -221,7 +221,7 @@ void TestRepeatWithFilterForFailedTests(int repeat) {
GTEST_CHECK_INT_EQ_(repeat, g_should_fail_count); GTEST_CHECK_INT_EQ_(repeat, g_should_fail_count);
GTEST_CHECK_INT_EQ_(0, g_should_pass_count); GTEST_CHECK_INT_EQ_(0, g_should_pass_count);
GTEST_CHECK_INT_EQ_(0, g_death_test_count); GTEST_CHECK_INT_EQ_(0, g_death_test_count);
#ifdef GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
GTEST_CHECK_INT_EQ_(0, g_param_test_count); GTEST_CHECK_INT_EQ_(0, g_param_test_count);
#endif // GTEST_HAS_PARAM_TEST #endif // GTEST_HAS_PARAM_TEST
} }
......
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