Commit ffeb11d1 authored by zhanyong.wan's avatar zhanyong.wan
Browse files

Indents preprocessor directives.

parent 0980b4bd
...@@ -41,12 +41,12 @@ ...@@ -41,12 +41,12 @@
// part of Google Test's implementation; otherwise it's undefined. // part of Google Test's implementation; otherwise it's undefined.
#if !GTEST_IMPLEMENTATION_ #if !GTEST_IMPLEMENTATION_
// A user is trying to include this from his code - just say no. // A user is trying to include this from his code - just say no.
#error "gtest-internal-inl.h is part of Google Test's internal implementation." # error "gtest-internal-inl.h is part of Google Test's internal implementation."
#error "It must not be included except by Google Test itself." # error "It must not be included except by Google Test itself."
#endif // GTEST_IMPLEMENTATION_ #endif // GTEST_IMPLEMENTATION_
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
#include <errno.h> # include <errno.h>
#endif // !_WIN32_WCE #endif // !_WIN32_WCE
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> // For strtoll/_strtoul64/malloc/free. #include <stdlib.h> // For strtoll/_strtoul64/malloc/free.
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
#include "gtest/internal/gtest-port.h" #include "gtest/internal/gtest-port.h"
#if GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
#include <windows.h> // For DWORD. # include <windows.h> // NOLINT
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
#include "gtest/gtest.h" // NOLINT #include "gtest/gtest.h" // NOLINT
...@@ -930,7 +930,7 @@ GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv); ...@@ -930,7 +930,7 @@ GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv);
// platform. // platform.
GTEST_API_ String GetLastErrnoDescription(); GTEST_API_ String GetLastErrnoDescription();
#if GTEST_OS_WINDOWS # if GTEST_OS_WINDOWS
// Provides leak-safe Windows kernel handle ownership. // Provides leak-safe Windows kernel handle ownership.
class AutoHandle { class AutoHandle {
public: public:
...@@ -954,7 +954,7 @@ class AutoHandle { ...@@ -954,7 +954,7 @@ class AutoHandle {
GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle); GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle);
}; };
#endif // GTEST_OS_WINDOWS # endif // GTEST_OS_WINDOWS
// Attempts to parse a string into a positive integer pointed to by the // Attempts to parse a string into a positive integer pointed to by the
// number parameter. Returns true if that is possible. // number parameter. Returns true if that is possible.
...@@ -973,14 +973,20 @@ bool ParseNaturalNumber(const ::std::string& str, Integer* number) { ...@@ -973,14 +973,20 @@ bool ParseNaturalNumber(const ::std::string& str, Integer* number) {
char* end; char* end;
// BiggestConvertible is the largest integer type that system-provided // BiggestConvertible is the largest integer type that system-provided
// string-to-number conversion routines can return. // string-to-number conversion routines can return.
#if GTEST_OS_WINDOWS && !defined(__GNUC__)
# if GTEST_OS_WINDOWS && !defined(__GNUC__)
// MSVC and C++ Builder define __int64 instead of the standard long long. // MSVC and C++ Builder define __int64 instead of the standard long long.
typedef unsigned __int64 BiggestConvertible; typedef unsigned __int64 BiggestConvertible;
const BiggestConvertible parsed = _strtoui64(str.c_str(), &end, 10); const BiggestConvertible parsed = _strtoui64(str.c_str(), &end, 10);
#else
# else
typedef unsigned long long BiggestConvertible; // NOLINT typedef unsigned long long BiggestConvertible; // NOLINT
const BiggestConvertible parsed = strtoull(str.c_str(), &end, 10); const BiggestConvertible parsed = strtoull(str.c_str(), &end, 10);
#endif // GTEST_OS_WINDOWS && !defined(__GNUC__)
# endif // GTEST_OS_WINDOWS && !defined(__GNUC__)
const bool parse_success = *end == '\0' && errno == 0; const bool parse_success = *end == '\0' && errno == 0;
// TODO(vladl@google.com): Convert this to compile time assertion when it is // TODO(vladl@google.com): Convert this to compile time assertion when it is
......
...@@ -37,18 +37,18 @@ ...@@ -37,18 +37,18 @@
#include <string.h> #include <string.h>
#if GTEST_OS_WINDOWS_MOBILE #if GTEST_OS_WINDOWS_MOBILE
#include <windows.h> // For TerminateProcess() # include <windows.h> // For TerminateProcess()
#elif GTEST_OS_WINDOWS #elif GTEST_OS_WINDOWS
#include <io.h> # include <io.h>
#include <sys/stat.h> # include <sys/stat.h>
#else #else
#include <unistd.h> # include <unistd.h>
#endif // GTEST_OS_WINDOWS_MOBILE #endif // GTEST_OS_WINDOWS_MOBILE
#if GTEST_OS_MAC #if GTEST_OS_MAC
#include <mach/mach_init.h> # include <mach/mach_init.h>
#include <mach/task.h> # include <mach/task.h>
#include <mach/vm_map.h> # include <mach/vm_map.h>
#endif // GTEST_OS_MAC #endif // GTEST_OS_MAC
#include "gtest/gtest-spi.h" #include "gtest/gtest-spi.h"
...@@ -478,8 +478,8 @@ GTestLog::~GTestLog() { ...@@ -478,8 +478,8 @@ GTestLog::~GTestLog() {
// Disable Microsoft deprecation warnings for POSIX functions called from // Disable Microsoft deprecation warnings for POSIX functions called from
// this class (creat, dup, dup2, and close) // this class (creat, dup, dup2, and close)
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) # pragma warning(push)
#pragma warning(disable: 4996) # pragma warning(disable: 4996)
#endif // _MSC_VER #endif // _MSC_VER
#if GTEST_HAS_STREAM_REDIRECTION #if GTEST_HAS_STREAM_REDIRECTION
...@@ -489,7 +489,8 @@ class CapturedStream { ...@@ -489,7 +489,8 @@ class CapturedStream {
public: public:
// The ctor redirects the stream to a temporary file. // The ctor redirects the stream to a temporary file.
CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) { CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) {
#if GTEST_OS_WINDOWS
# if GTEST_OS_WINDOWS
char temp_dir_path[MAX_PATH + 1] = { '\0' }; // NOLINT char temp_dir_path[MAX_PATH + 1] = { '\0' }; // NOLINT
char temp_file_path[MAX_PATH + 1] = { '\0' }; // NOLINT char temp_file_path[MAX_PATH + 1] = { '\0' }; // NOLINT
...@@ -504,14 +505,14 @@ class CapturedStream { ...@@ -504,14 +505,14 @@ class CapturedStream {
GTEST_CHECK_(captured_fd != -1) << "Unable to open temporary file " GTEST_CHECK_(captured_fd != -1) << "Unable to open temporary file "
<< temp_file_path; << temp_file_path;
filename_ = temp_file_path; filename_ = temp_file_path;
#else # else
// There's no guarantee that a test has write access to the // There's no guarantee that a test has write access to the
// current directory, so we create the temporary file in the /tmp // current directory, so we create the temporary file in the /tmp
// directory instead. // directory instead.
char name_template[] = "/tmp/captured_stream.XXXXXX"; char name_template[] = "/tmp/captured_stream.XXXXXX";
const int captured_fd = mkstemp(name_template); const int captured_fd = mkstemp(name_template);
filename_ = name_template; filename_ = name_template;
#endif // GTEST_OS_WINDOWS # endif // GTEST_OS_WINDOWS
fflush(NULL); fflush(NULL);
dup2(captured_fd, fd_); dup2(captured_fd, fd_);
close(captured_fd); close(captured_fd);
...@@ -580,9 +581,9 @@ String CapturedStream::ReadEntireFile(FILE* file) { ...@@ -580,9 +581,9 @@ String CapturedStream::ReadEntireFile(FILE* file) {
return content; return content;
} }
#ifdef _MSC_VER # ifdef _MSC_VER
#pragma warning(pop) # pragma warning(pop)
#endif // _MSC_VER # endif // _MSC_VER
static CapturedStream* g_captured_stderr = NULL; static CapturedStream* g_captured_stderr = NULL;
static CapturedStream* g_captured_stdout = NULL; static CapturedStream* g_captured_stdout = NULL;
......
...@@ -56,11 +56,11 @@ namespace { ...@@ -56,11 +56,11 @@ namespace {
using ::std::ostream; using ::std::ostream;
#if GTEST_OS_WINDOWS_MOBILE // Windows CE does not define _snprintf_s. #if GTEST_OS_WINDOWS_MOBILE // Windows CE does not define _snprintf_s.
#define snprintf _snprintf # define snprintf _snprintf
#elif _MSC_VER >= 1400 // VC 8.0 and later deprecate snprintf and _snprintf. #elif _MSC_VER >= 1400 // VC 8.0 and later deprecate snprintf and _snprintf.
#define snprintf _snprintf_s # define snprintf _snprintf_s
#elif _MSC_VER #elif _MSC_VER
#define snprintf _snprintf # define snprintf _snprintf
#endif // GTEST_OS_WINDOWS_MOBILE #endif // GTEST_OS_WINDOWS_MOBILE
// Prints a segment of bytes in the given object. // Prints a segment of bytes in the given object.
......
...@@ -51,76 +51,76 @@ ...@@ -51,76 +51,76 @@
// 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_ 1 # define GTEST_HAS_GETTIMEOFDAY_ 1
#include <fcntl.h> // NOLINT # include <fcntl.h> // NOLINT
#include <limits.h> // NOLINT # include <limits.h> // NOLINT
#include <sched.h> // NOLINT # include <sched.h> // NOLINT
// Declares vsnprintf(). This header is not available on Windows. // Declares vsnprintf(). This header is not available on Windows.
#include <strings.h> // NOLINT # include <strings.h> // NOLINT
#include <sys/mman.h> // NOLINT # include <sys/mman.h> // NOLINT
#include <sys/time.h> // NOLINT # include <sys/time.h> // NOLINT
#include <unistd.h> // NOLINT # include <unistd.h> // NOLINT
#include <string> # include <string>
#elif GTEST_OS_SYMBIAN #elif GTEST_OS_SYMBIAN
#define GTEST_HAS_GETTIMEOFDAY_ 1 # define GTEST_HAS_GETTIMEOFDAY_ 1
#include <sys/time.h> // NOLINT # include <sys/time.h> // NOLINT
#elif GTEST_OS_ZOS #elif GTEST_OS_ZOS
#define GTEST_HAS_GETTIMEOFDAY_ 1 # 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.
#include <strings.h> // NOLINT # include <strings.h> // NOLINT
#elif GTEST_OS_WINDOWS_MOBILE // We are on Windows CE. #elif GTEST_OS_WINDOWS_MOBILE // We are on Windows CE.
#include <windows.h> // NOLINT # include <windows.h> // NOLINT
#elif 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
#include <sys/types.h> // NOLINT # include <sys/types.h> // NOLINT
#include <sys/stat.h> // NOLINT # include <sys/stat.h> // NOLINT
#if GTEST_OS_WINDOWS_MINGW # if GTEST_OS_WINDOWS_MINGW
// MinGW has gettimeofday() but not _ftime64(). // MinGW has gettimeofday() but not _ftime64().
// TODO(kenton@google.com): Use autoconf to detect availability of // TODO(kenton@google.com): Use autoconf to detect availability of
// gettimeofday(). // gettimeofday().
// 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_ 1 # define GTEST_HAS_GETTIMEOFDAY_ 1
#include <sys/time.h> // NOLINT # include <sys/time.h> // NOLINT
#endif // GTEST_OS_WINDOWS_MINGW # endif // GTEST_OS_WINDOWS_MINGW
// 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 <windows.h> // NOLINT # include <windows.h> // NOLINT
#else #else
// 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_ 1 # 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 // GTEST_OS_LINUX #endif // GTEST_OS_LINUX
#if GTEST_HAS_EXCEPTIONS #if GTEST_HAS_EXCEPTIONS
#include <stdexcept> # include <stdexcept>
#endif #endif
#if GTEST_CAN_STREAM_RESULTS_ #if GTEST_CAN_STREAM_RESULTS_
#include <arpa/inet.h> // NOLINT # include <arpa/inet.h> // NOLINT
#include <netdb.h> // NOLINT # include <netdb.h> // NOLINT
#endif #endif
// Indicates that this translation unit is part of Google Test's // Indicates that this translation unit is part of Google Test's
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
#undef GTEST_IMPLEMENTATION_ #undef GTEST_IMPLEMENTATION_
#if GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
#define vsnprintf _vsnprintf # define vsnprintf _vsnprintf
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
namespace testing { namespace testing {
...@@ -786,25 +786,30 @@ TimeInMillis GetTimeInMillis() { ...@@ -786,25 +786,30 @@ TimeInMillis GetTimeInMillis() {
return 0; return 0;
#elif GTEST_OS_WINDOWS && !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
// (deprecated function) there. // (deprecated function) there.
// TODO(kenton@google.com): Use GetTickCount()? Or use // TODO(kenton@google.com): Use GetTickCount()? Or use
// SystemTimeToFileTime() // SystemTimeToFileTime()
#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.
_ftime64(&now); _ftime64(&now);
#pragma warning(pop) // Restores the warning state. # pragma warning(pop) // Restores the warning state.
#else # else
_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 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;
#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."
#endif #endif
} }
...@@ -1332,10 +1337,13 @@ namespace { ...@@ -1332,10 +1337,13 @@ namespace {
AssertionResult HRESULTFailureHelper(const char* expr, AssertionResult HRESULTFailureHelper(const char* expr,
const char* expected, const char* expected,
long hr) { // NOLINT long hr) { // NOLINT
#if GTEST_OS_WINDOWS_MOBILE # if GTEST_OS_WINDOWS_MOBILE
// Windows CE doesn't support FormatMessage. // Windows CE doesn't support FormatMessage.
const char error_text[] = ""; const char error_text[] = "";
#else
# else
// Looks up the human-readable system message for the HRESULT code // Looks up the human-readable system message for the HRESULT code
// and since we're not passing any params to FormatMessage, we don't // and since we're not passing any params to FormatMessage, we don't
// want inserts expanded. // want inserts expanded.
...@@ -1356,7 +1364,8 @@ AssertionResult HRESULTFailureHelper(const char* expr, ...@@ -1356,7 +1364,8 @@ AssertionResult HRESULTFailureHelper(const char* expr,
--message_length) { --message_length) {
error_text[message_length - 1] = '\0'; error_text[message_length - 1] = '\0';
} }
#endif // GTEST_OS_WINDOWS_MOBILE
# endif // GTEST_OS_WINDOWS_MOBILE
const String error_hex(String::Format("0x%08X ", hr)); const String error_hex(String::Format("0x%08X ", hr));
return ::testing::AssertionFailure() return ::testing::AssertionFailure()
...@@ -1698,10 +1707,12 @@ String String::Format(const char * format, ...) { ...@@ -1698,10 +1707,12 @@ String String::Format(const char * format, ...) {
// 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 _MSC_VER // We are using MSVC. #ifdef _MSC_VER // We are using MSVC.
#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 = vsnprintf(buffer, kBufferSize, format, args); const int size = vsnprintf(buffer, kBufferSize, format, args);
#pragma warning(pop) // Restores the warning state.
# pragma warning(pop) // Restores the warning state.
#else // We are not using MSVC. #else // We are not using MSVC.
const int size = vsnprintf(buffer, kBufferSize, format, args); const int size = vsnprintf(buffer, kBufferSize, format, args);
#endif // _MSC_VER #endif // _MSC_VER
...@@ -3826,20 +3837,21 @@ int UnitTest::Run() { ...@@ -3826,20 +3837,21 @@ int UnitTest::Run() {
// process. In either case the user does not want to see pop-up dialogs // process. In either case the user does not want to see pop-up dialogs
// about crashes - they are expected. // about crashes - they are expected.
if (impl()->catch_exceptions() || in_death_test_child_process) { if (impl()->catch_exceptions() || in_death_test_child_process) {
#if !GTEST_OS_WINDOWS_MOBILE
# if !GTEST_OS_WINDOWS_MOBILE
// SetErrorMode doesn't exist on CE. // SetErrorMode doesn't exist on CE.
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
#endif // !GTEST_OS_WINDOWS_MOBILE # endif // !GTEST_OS_WINDOWS_MOBILE
#if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE # if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE
// Death test children can be terminated with _abort(). On Windows, // Death test children can be terminated with _abort(). On Windows,
// _abort() can show a dialog with a warning message. This forces the // _abort() can show a dialog with a warning message. This forces the
// abort message to go to stderr instead. // abort message to go to stderr instead.
_set_error_mode(_OUT_TO_STDERR); _set_error_mode(_OUT_TO_STDERR);
#endif # endif
#if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE # if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE
// In the debug version, Visual Studio pops up a separate dialog // In the debug version, Visual Studio pops up a separate dialog
// offering a choice to debug the aborted program. We need to suppress // offering a choice to debug the aborted program. We need to suppress
// this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement // this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement
...@@ -3855,7 +3867,8 @@ int UnitTest::Run() { ...@@ -3855,7 +3867,8 @@ int UnitTest::Run() {
_set_abort_behavior( _set_abort_behavior(
0x0, // Clear the following flags: 0x0, // Clear the following flags:
_WRITE_ABORT_MSG | _CALL_REPORTFAULT); // pop-up window, core dump. _WRITE_ABORT_MSG | _CALL_REPORTFAULT); // pop-up window, core dump.
#endif # endif
} }
#endif // GTEST_HAS_SEH #endif // GTEST_HAS_SEH
...@@ -3930,12 +3943,12 @@ namespace internal { ...@@ -3930,12 +3943,12 @@ namespace internal {
UnitTestImpl::UnitTestImpl(UnitTest* parent) UnitTestImpl::UnitTestImpl(UnitTest* parent)
: parent_(parent), : parent_(parent),
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) // Saves the current warning state. # pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4355) // Temporarily disables warning 4355 # pragma warning(disable:4355) // Temporarily disables warning 4355
// (using this in initializer). // (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),
#pragma warning(pop) // Restores the warning state again. # pragma warning(pop) // Restores the warning state again.
#else #else
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),
...@@ -4853,10 +4866,12 @@ void InitGoogleTestImpl(int* argc, CharType** argv) { ...@@ -4853,10 +4866,12 @@ void InitGoogleTestImpl(int* argc, CharType** argv) {
internal::g_executable_path = internal::StreamableToString(argv[0]); internal::g_executable_path = internal::StreamableToString(argv[0]);
#if 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]));
} }
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
ParseGoogleTestFlagsOnly(argc, argv); ParseGoogleTestFlagsOnly(argc, argv);
......
...@@ -36,15 +36,15 @@ ...@@ -36,15 +36,15 @@
#if GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
#if GTEST_HAS_SEH # if GTEST_HAS_SEH
#include <windows.h> // For RaiseException(). # include <windows.h> // For RaiseException().
#endif # endif
#include "gtest/gtest-spi.h" # include "gtest/gtest-spi.h"
#if GTEST_HAS_EXCEPTIONS # if GTEST_HAS_EXCEPTIONS
#include <exception> // For std::exception. # include <exception> // For std::exception.
// Tests that death tests report thrown exceptions as failures and that the // Tests that death tests report thrown exceptions as failures and that the
// exceptions do not escape death test macros. // exceptions do not escape death test macros.
...@@ -71,9 +71,9 @@ TEST(CxxExceptionDeathTest, PrintsMessageForStdExceptions) { ...@@ -71,9 +71,9 @@ TEST(CxxExceptionDeathTest, PrintsMessageForStdExceptions) {
EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(throw TestException(), ""), EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(throw TestException(), ""),
"gtest-death-test_ex_test.cc"); "gtest-death-test_ex_test.cc");
} }
#endif // GTEST_HAS_EXCEPTIONS # endif // GTEST_HAS_EXCEPTIONS
#if GTEST_HAS_SEH # if GTEST_HAS_SEH
// Tests that enabling interception of SEH exceptions with the // Tests that enabling interception of SEH exceptions with the
// catch_exceptions flag does not interfere with SEH exceptions being // catch_exceptions flag does not interfere with SEH exceptions being
// treated as death by death tests. // treated as death by death tests.
...@@ -82,7 +82,7 @@ TEST(SehExceptionDeasTest, CatchExceptionsDoesNotInterfere) { ...@@ -82,7 +82,7 @@ TEST(SehExceptionDeasTest, CatchExceptionsDoesNotInterfere) {
<< "with catch_exceptions " << "with catch_exceptions "
<< (testing::GTEST_FLAG(catch_exceptions) ? "enabled" : "disabled"); << (testing::GTEST_FLAG(catch_exceptions) ? "enabled" : "disabled");
} }
#endif # endif
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
......
...@@ -40,28 +40,28 @@ using testing::internal::AlwaysTrue; ...@@ -40,28 +40,28 @@ using testing::internal::AlwaysTrue;
#if GTEST_HAS_DEATH_TEST #if GTEST_HAS_DEATH_TEST
#if GTEST_OS_WINDOWS # if GTEST_OS_WINDOWS
#include <direct.h> // For chdir(). # include <direct.h> // For chdir().
#else # else
#include <unistd.h> # include <unistd.h>
#include <sys/wait.h> // For waitpid. # include <sys/wait.h> // For waitpid.
#include <limits> // For std::numeric_limits. # include <limits> // For std::numeric_limits.
#endif // GTEST_OS_WINDOWS # endif // GTEST_OS_WINDOWS
#include <limits.h> # include <limits.h>
#include <signal.h> # include <signal.h>
#include <stdio.h> # include <stdio.h>
#include "gtest/gtest-spi.h" # include "gtest/gtest-spi.h"
// 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_ 1 # define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" # include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_ # undef GTEST_IMPLEMENTATION_
namespace posix = ::testing::internal::posix; namespace posix = ::testing::internal::posix;
...@@ -195,13 +195,17 @@ void DeathTestSubroutine() { ...@@ -195,13 +195,17 @@ void DeathTestSubroutine() {
// Death in dbg, not opt. // Death in dbg, not opt.
int DieInDebugElse12(int* sideeffect) { int DieInDebugElse12(int* sideeffect) {
if (sideeffect) *sideeffect = 12; if (sideeffect) *sideeffect = 12;
#ifndef NDEBUG
# ifndef NDEBUG
DieInside("DieInDebugElse12"); DieInside("DieInDebugElse12");
#endif // NDEBUG
# endif // NDEBUG
return 12; return 12;
} }
#if GTEST_OS_WINDOWS # if GTEST_OS_WINDOWS
// Tests the ExitedWithCode predicate. // Tests the ExitedWithCode predicate.
TEST(ExitStatusPredicateTest, ExitedWithCode) { TEST(ExitStatusPredicateTest, ExitedWithCode) {
...@@ -214,7 +218,7 @@ TEST(ExitStatusPredicateTest, ExitedWithCode) { ...@@ -214,7 +218,7 @@ TEST(ExitStatusPredicateTest, ExitedWithCode) {
EXPECT_FALSE(testing::ExitedWithCode(1)(0)); EXPECT_FALSE(testing::ExitedWithCode(1)(0));
} }
#else # else
// Returns the exit status of a process that calls _exit(2) with a // Returns the exit status of a process that calls _exit(2) with a
// given exit code. This is a helper function for the // given exit code. This is a helper function for the
...@@ -273,7 +277,7 @@ TEST(ExitStatusPredicateTest, KilledBySignal) { ...@@ -273,7 +277,7 @@ TEST(ExitStatusPredicateTest, KilledBySignal) {
EXPECT_FALSE(pred_kill(status_segv)); EXPECT_FALSE(pred_kill(status_segv));
} }
#endif // GTEST_OS_WINDOWS # endif // GTEST_OS_WINDOWS
// Tests that the death test macros expand to code which may or may not // Tests that the death test macros expand to code which may or may not
// be followed by operator<<, and that in either case the complete text // be followed by operator<<, and that in either case the complete text
...@@ -305,7 +309,7 @@ void DieWithEmbeddedNul() { ...@@ -305,7 +309,7 @@ void DieWithEmbeddedNul() {
_exit(1); _exit(1);
} }
#if GTEST_USES_PCRE # if GTEST_USES_PCRE
// Tests that EXPECT_DEATH and ASSERT_DEATH work when the error // Tests that EXPECT_DEATH and ASSERT_DEATH work when the error
// message has a NUL character in it. // message has a NUL character in it.
TEST_F(TestForDeathTest, EmbeddedNulInMessage) { TEST_F(TestForDeathTest, EmbeddedNulInMessage) {
...@@ -314,17 +318,17 @@ TEST_F(TestForDeathTest, EmbeddedNulInMessage) { ...@@ -314,17 +318,17 @@ TEST_F(TestForDeathTest, EmbeddedNulInMessage) {
EXPECT_DEATH(DieWithEmbeddedNul(), "my null world"); EXPECT_DEATH(DieWithEmbeddedNul(), "my null world");
ASSERT_DEATH(DieWithEmbeddedNul(), "my null world"); ASSERT_DEATH(DieWithEmbeddedNul(), "my null world");
} }
#endif // GTEST_USES_PCRE # endif // GTEST_USES_PCRE
// Tests that death test macros expand to code which interacts well with switch // Tests that death test macros expand to code which interacts well with switch
// statements. // statements.
TEST_F(TestForDeathTest, SwitchStatement) { TEST_F(TestForDeathTest, SwitchStatement) {
// Microsoft compiler usually complains about switch statements without // Microsoft compiler usually complains about switch statements without
// case labels. We suppress that warning for this test. // case labels. We suppress that warning for this test.
#ifdef _MSC_VER # ifdef _MSC_VER
#pragma warning(push) # pragma warning(push)
#pragma warning(disable: 4065) # pragma warning(disable: 4065)
#endif // _MSC_VER # endif // _MSC_VER
switch (0) switch (0)
default: default:
...@@ -334,9 +338,9 @@ TEST_F(TestForDeathTest, SwitchStatement) { ...@@ -334,9 +338,9 @@ TEST_F(TestForDeathTest, SwitchStatement) {
case 0: case 0:
EXPECT_DEATH(_exit(1), "") << "exit in switch case"; EXPECT_DEATH(_exit(1), "") << "exit in switch case";
#ifdef _MSC_VER # ifdef _MSC_VER
#pragma warning(pop) # pragma warning(pop)
#endif // _MSC_VER # endif // _MSC_VER
} }
// Tests that a static member function can be used in a "fast" style // Tests that a static member function can be used in a "fast" style
...@@ -415,7 +419,7 @@ void SetPthreadFlag() { ...@@ -415,7 +419,7 @@ void SetPthreadFlag() {
} // namespace } // namespace
#if GTEST_HAS_CLONE && GTEST_HAS_PTHREAD # if GTEST_HAS_CLONE && GTEST_HAS_PTHREAD
TEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) { TEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) {
if (!testing::GTEST_FLAG(death_test_use_fork)) { if (!testing::GTEST_FLAG(death_test_use_fork)) {
...@@ -427,7 +431,7 @@ TEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) { ...@@ -427,7 +431,7 @@ TEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) {
} }
} }
#endif // GTEST_HAS_CLONE && GTEST_HAS_PTHREAD # endif // GTEST_HAS_CLONE && GTEST_HAS_PTHREAD
// Tests that a method of another class can be used in a death test. // Tests that a method of another class can be used in a death test.
TEST_F(TestForDeathTest, MethodOfAnotherClass) { TEST_F(TestForDeathTest, MethodOfAnotherClass) {
...@@ -449,10 +453,12 @@ TEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) { ...@@ -449,10 +453,12 @@ TEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) {
const testing::internal::RE regex(regex_c_str); const testing::internal::RE regex(regex_c_str);
EXPECT_DEATH(GlobalFunction(), regex); EXPECT_DEATH(GlobalFunction(), regex);
#if GTEST_HAS_GLOBAL_STRING # if GTEST_HAS_GLOBAL_STRING
const string regex_str(regex_c_str); const string regex_str(regex_c_str);
EXPECT_DEATH(GlobalFunction(), regex_str); EXPECT_DEATH(GlobalFunction(), regex_str);
#endif // GTEST_HAS_GLOBAL_STRING
# endif // GTEST_HAS_GLOBAL_STRING
const ::std::string regex_std_str(regex_c_str); const ::std::string regex_std_str(regex_c_str);
EXPECT_DEATH(GlobalFunction(), regex_std_str); EXPECT_DEATH(GlobalFunction(), regex_std_str);
...@@ -568,13 +574,17 @@ TEST_F(TestForDeathTest, TestExpectDebugDeath) { ...@@ -568,13 +574,17 @@ TEST_F(TestForDeathTest, TestExpectDebugDeath) {
EXPECT_DEBUG_DEATH(DieInDebugElse12(&sideeffect), EXPECT_DEBUG_DEATH(DieInDebugElse12(&sideeffect),
"death.*DieInDebugElse12"); "death.*DieInDebugElse12");
#ifdef NDEBUG # ifdef NDEBUG
// Checks that the assignment occurs in opt mode (sideeffect). // Checks that the assignment occurs in opt mode (sideeffect).
EXPECT_EQ(12, sideeffect); EXPECT_EQ(12, sideeffect);
#else
# else
// Checks that the assignment does not occur in dbg mode (no sideeffect). // Checks that the assignment does not occur in dbg mode (no sideeffect).
EXPECT_EQ(0, sideeffect); EXPECT_EQ(0, sideeffect);
#endif
# endif
} }
// Tests that ASSERT_DEBUG_DEATH works as expected // Tests that ASSERT_DEBUG_DEATH works as expected
...@@ -594,16 +604,20 @@ TEST_F(TestForDeathTest, TestAssertDebugDeath) { ...@@ -594,16 +604,20 @@ TEST_F(TestForDeathTest, TestAssertDebugDeath) {
EXPECT_EQ(12, sideeffect); EXPECT_EQ(12, sideeffect);
}, "death.*DieInDebugElse12"); }, "death.*DieInDebugElse12");
#ifdef NDEBUG # ifdef NDEBUG
// Checks that the assignment occurs in opt mode (sideeffect). // Checks that the assignment occurs in opt mode (sideeffect).
EXPECT_EQ(12, sideeffect); EXPECT_EQ(12, sideeffect);
#else
# else
// Checks that the assignment does not occur in dbg mode (no sideeffect). // Checks that the assignment does not occur in dbg mode (no sideeffect).
EXPECT_EQ(0, sideeffect); EXPECT_EQ(0, sideeffect);
#endif
# endif
} }
#ifndef NDEBUG # ifndef NDEBUG
void ExpectDebugDeathHelper(bool* aborted) { void ExpectDebugDeathHelper(bool* aborted) {
*aborted = true; *aborted = true;
...@@ -611,7 +625,7 @@ void ExpectDebugDeathHelper(bool* aborted) { ...@@ -611,7 +625,7 @@ void ExpectDebugDeathHelper(bool* aborted) {
*aborted = false; *aborted = false;
} }
#if GTEST_OS_WINDOWS # if GTEST_OS_WINDOWS
TEST(PopUpDeathTest, DoesNotShowPopUpOnAbort) { TEST(PopUpDeathTest, DoesNotShowPopUpOnAbort) {
printf("This test should be considered failing if it shows " printf("This test should be considered failing if it shows "
"any pop-up dialogs.\n"); "any pop-up dialogs.\n");
...@@ -622,7 +636,7 @@ TEST(PopUpDeathTest, DoesNotShowPopUpOnAbort) { ...@@ -622,7 +636,7 @@ TEST(PopUpDeathTest, DoesNotShowPopUpOnAbort) {
abort(); abort();
}, ""); }, "");
} }
#endif // GTEST_OS_WINDOWS # endif // GTEST_OS_WINDOWS
// Tests that EXPECT_DEBUG_DEATH in debug mode does not abort // Tests that EXPECT_DEBUG_DEATH in debug mode does not abort
// the function. // the function.
...@@ -647,19 +661,22 @@ TEST_F(TestForDeathTest, AssertDebugDeathAborts) { ...@@ -647,19 +661,22 @@ TEST_F(TestForDeathTest, AssertDebugDeathAborts) {
EXPECT_TRUE(aborted); EXPECT_TRUE(aborted);
} }
#endif // _NDEBUG # endif // _NDEBUG
// Tests the *_EXIT family of macros, using a variety of predicates. // Tests the *_EXIT family of macros, using a variety of predicates.
static void TestExitMacros() { static void TestExitMacros() {
EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), ""); EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), "");
ASSERT_EXIT(_exit(42), testing::ExitedWithCode(42), ""); ASSERT_EXIT(_exit(42), testing::ExitedWithCode(42), "");
#if GTEST_OS_WINDOWS # if GTEST_OS_WINDOWS
// Of all signals effects on the process exit code, only those of SIGABRT // Of all signals effects on the process exit code, only those of SIGABRT
// are documented on Windows. // are documented on Windows.
// See http://msdn.microsoft.com/en-us/library/dwwzkt4c(VS.71).aspx. // See http://msdn.microsoft.com/en-us/library/dwwzkt4c(VS.71).aspx.
EXPECT_EXIT(raise(SIGABRT), testing::ExitedWithCode(3), ""); EXPECT_EXIT(raise(SIGABRT), testing::ExitedWithCode(3), "");
#else
# else
EXPECT_EXIT(raise(SIGKILL), testing::KilledBySignal(SIGKILL), "") << "foo"; EXPECT_EXIT(raise(SIGKILL), testing::KilledBySignal(SIGKILL), "") << "foo";
ASSERT_EXIT(raise(SIGUSR2), testing::KilledBySignal(SIGUSR2), "") << "bar"; ASSERT_EXIT(raise(SIGUSR2), testing::KilledBySignal(SIGUSR2), "") << "bar";
...@@ -667,7 +684,8 @@ static void TestExitMacros() { ...@@ -667,7 +684,8 @@ static void TestExitMacros() {
ASSERT_EXIT(_exit(0), testing::KilledBySignal(SIGSEGV), "") ASSERT_EXIT(_exit(0), testing::KilledBySignal(SIGSEGV), "")
<< "This failure is expected, too."; << "This failure is expected, too.";
}, "This failure is expected, too."); }, "This failure is expected, too.");
#endif // GTEST_OS_WINDOWS
# endif // GTEST_OS_WINDOWS
EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_NONFATAL_FAILURE({ // NOLINT
EXPECT_EXIT(raise(SIGSEGV), testing::ExitedWithCode(0), "") EXPECT_EXIT(raise(SIGSEGV), testing::ExitedWithCode(0), "")
...@@ -1022,7 +1040,7 @@ TEST(GetLastErrnoDescription, GetLastErrnoDescriptionWorks) { ...@@ -1022,7 +1040,7 @@ TEST(GetLastErrnoDescription, GetLastErrnoDescriptionWorks) {
EXPECT_STREQ("", GetLastErrnoDescription().c_str()); EXPECT_STREQ("", GetLastErrnoDescription().c_str());
} }
#if GTEST_OS_WINDOWS # if GTEST_OS_WINDOWS
TEST(AutoHandleTest, AutoHandleWorks) { TEST(AutoHandleTest, AutoHandleWorks) {
HANDLE handle = ::CreateEvent(NULL, FALSE, FALSE, NULL); HANDLE handle = ::CreateEvent(NULL, FALSE, FALSE, NULL);
ASSERT_NE(INVALID_HANDLE_VALUE, handle); ASSERT_NE(INVALID_HANDLE_VALUE, handle);
...@@ -1047,21 +1065,21 @@ TEST(AutoHandleTest, AutoHandleWorks) { ...@@ -1047,21 +1065,21 @@ TEST(AutoHandleTest, AutoHandleWorks) {
testing::internal::AutoHandle auto_handle2; testing::internal::AutoHandle auto_handle2;
EXPECT_EQ(INVALID_HANDLE_VALUE, auto_handle2.Get()); EXPECT_EQ(INVALID_HANDLE_VALUE, auto_handle2.Get());
} }
#endif // GTEST_OS_WINDOWS # endif // GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS # if GTEST_OS_WINDOWS
typedef unsigned __int64 BiggestParsable; typedef unsigned __int64 BiggestParsable;
typedef signed __int64 BiggestSignedParsable; typedef signed __int64 BiggestSignedParsable;
const BiggestParsable kBiggestParsableMax = ULLONG_MAX; const BiggestParsable kBiggestParsableMax = ULLONG_MAX;
const BiggestSignedParsable kBiggestSignedParsableMax = LLONG_MAX; const BiggestSignedParsable kBiggestSignedParsableMax = LLONG_MAX;
#else # else
typedef unsigned long long BiggestParsable; typedef unsigned long long BiggestParsable;
typedef signed long long BiggestSignedParsable; typedef signed long long BiggestSignedParsable;
const BiggestParsable kBiggestParsableMax = const BiggestParsable kBiggestParsableMax =
::std::numeric_limits<BiggestParsable>::max(); ::std::numeric_limits<BiggestParsable>::max();
const BiggestSignedParsable kBiggestSignedParsableMax = const BiggestSignedParsable kBiggestSignedParsableMax =
::std::numeric_limits<BiggestSignedParsable>::max(); ::std::numeric_limits<BiggestSignedParsable>::max();
#endif // GTEST_OS_WINDOWS # endif // GTEST_OS_WINDOWS
TEST(ParseNaturalNumberTest, RejectsInvalidFormat) { TEST(ParseNaturalNumberTest, RejectsInvalidFormat) {
BiggestParsable result = 0; BiggestParsable result = 0;
...@@ -1147,14 +1165,14 @@ TEST(ParseNaturalNumberTest, WorksForShorterIntegers) { ...@@ -1147,14 +1165,14 @@ TEST(ParseNaturalNumberTest, WorksForShorterIntegers) {
EXPECT_EQ(123, char_result); EXPECT_EQ(123, char_result);
} }
#if GTEST_OS_WINDOWS # if GTEST_OS_WINDOWS
TEST(EnvironmentTest, HandleFitsIntoSizeT) { TEST(EnvironmentTest, HandleFitsIntoSizeT) {
// TODO(vladl@google.com): Remove this test after this condition is verified // TODO(vladl@google.com): Remove this test after this condition is verified
// in a static assertion in gtest-death-test.cc in the function // in a static assertion in gtest-death-test.cc in the function
// GetStatusFileDescriptor. // GetStatusFileDescriptor.
ASSERT_TRUE(sizeof(HANDLE) <= sizeof(size_t)); ASSERT_TRUE(sizeof(HANDLE) <= sizeof(size_t));
} }
#endif // GTEST_OS_WINDOWS # endif // GTEST_OS_WINDOWS
// Tests that EXPECT_DEATH_IF_SUPPORTED/ASSERT_DEATH_IF_SUPPORTED trigger // Tests that EXPECT_DEATH_IF_SUPPORTED/ASSERT_DEATH_IF_SUPPORTED trigger
// failures when death tests are available on the system. // failures when death tests are available on the system.
...@@ -1253,8 +1271,8 @@ TEST(ConditionalDeathMacrosSyntaxDeathTest, SwitchStatement) { ...@@ -1253,8 +1271,8 @@ TEST(ConditionalDeathMacrosSyntaxDeathTest, SwitchStatement) {
// Microsoft compiler usually complains about switch statements without // Microsoft compiler usually complains about switch statements without
// case labels. We suppress that warning for this test. // case labels. We suppress that warning for this test.
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) # pragma warning(push)
#pragma warning(disable: 4065) # pragma warning(disable: 4065)
#endif // _MSC_VER #endif // _MSC_VER
switch (0) switch (0)
...@@ -1267,7 +1285,7 @@ TEST(ConditionalDeathMacrosSyntaxDeathTest, SwitchStatement) { ...@@ -1267,7 +1285,7 @@ TEST(ConditionalDeathMacrosSyntaxDeathTest, SwitchStatement) {
EXPECT_DEATH_IF_SUPPORTED(_exit(1), "") << "exit in switch case"; EXPECT_DEATH_IF_SUPPORTED(_exit(1), "") << "exit in switch case";
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) # pragma warning(pop)
#endif // _MSC_VER #endif // _MSC_VER
} }
......
...@@ -51,9 +51,9 @@ ...@@ -51,9 +51,9 @@
#undef GTEST_IMPLEMENTATION_ #undef GTEST_IMPLEMENTATION_
#if GTEST_OS_WINDOWS_MOBILE #if GTEST_OS_WINDOWS_MOBILE
#include <windows.h> // NOLINT # include <windows.h> // NOLINT
#elif GTEST_OS_WINDOWS #elif GTEST_OS_WINDOWS
#include <direct.h> // NOLINT # include <direct.h> // NOLINT
#endif // GTEST_OS_WINDOWS_MOBILE #endif // GTEST_OS_WINDOWS_MOBILE
namespace testing { namespace testing {
...@@ -91,14 +91,18 @@ TEST(GetCurrentDirTest, ReturnsCurrentDir) { ...@@ -91,14 +91,18 @@ TEST(GetCurrentDirTest, ReturnsCurrentDir) {
const FilePath cwd = FilePath::GetCurrentDir(); const FilePath cwd = FilePath::GetCurrentDir();
posix::ChDir(original_dir.c_str()); posix::ChDir(original_dir.c_str());
#if GTEST_OS_WINDOWS # if GTEST_OS_WINDOWS
// 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(GTEST_PATH_SEP_, cwd_without_drive + 1); EXPECT_STREQ(GTEST_PATH_SEP_, cwd_without_drive + 1);
#else
# else
EXPECT_STREQ(GTEST_PATH_SEP_, cwd.c_str()); EXPECT_STREQ(GTEST_PATH_SEP_, cwd.c_str());
#endif
# endif
} }
#endif // GTEST_OS_WINDOWS_MOBILE #endif // GTEST_OS_WINDOWS_MOBILE
...@@ -415,10 +419,12 @@ TEST(DirectoryTest, EmptyPathDirectoryDoesNotExist) { ...@@ -415,10 +419,12 @@ TEST(DirectoryTest, EmptyPathDirectoryDoesNotExist) {
TEST(DirectoryTest, CurrentDirectoryExists) { TEST(DirectoryTest, CurrentDirectoryExists) {
#if 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());
#endif // _WIN32_CE
# endif // _WIN32_CE
#else #else
EXPECT_TRUE(FilePath(".").DirectoryExists()); EXPECT_TRUE(FilePath(".").DirectoryExists());
EXPECT_TRUE(FilePath("./").DirectoryExists()); EXPECT_TRUE(FilePath("./").DirectoryExists());
......
...@@ -41,9 +41,9 @@ ...@@ -41,9 +41,9 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#if GTEST_OS_WINDOWS_MOBILE #if GTEST_OS_WINDOWS_MOBILE
#include <windows.h> # include <windows.h>
#elif GTEST_OS_WINDOWS #elif GTEST_OS_WINDOWS
#include <direct.h> # include <direct.h>
#endif // GTEST_OS_WINDOWS_MOBILE #endif // GTEST_OS_WINDOWS_MOBILE
// Indicates that this translation unit is part of Google Test's // Indicates that this translation unit is part of Google Test's
......
...@@ -37,19 +37,19 @@ ...@@ -37,19 +37,19 @@
#if GTEST_HAS_PARAM_TEST #if GTEST_HAS_PARAM_TEST
#include <algorithm> # include <algorithm>
#include <iostream> # include <iostream>
#include <list> # include <list>
#include <sstream> # include <sstream>
#include <string> # include <string>
#include <vector> # include <vector>
// To include gtest-internal-inl.h. // To include gtest-internal-inl.h.
#define GTEST_IMPLEMENTATION_ 1 # 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"
using ::std::vector; using ::std::vector;
using ::std::sort; using ::std::sort;
...@@ -62,12 +62,12 @@ using ::testing::TestWithParam; ...@@ -62,12 +62,12 @@ using ::testing::TestWithParam;
using ::testing::Values; using ::testing::Values;
using ::testing::ValuesIn; using ::testing::ValuesIn;
#if 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;
using ::std::tr1::tuple; using ::std::tr1::tuple;
#endif // GTEST_HAS_COMBINE # endif // GTEST_HAS_COMBINE
using ::testing::internal::ParamGenerator; using ::testing::internal::ParamGenerator;
using ::testing::internal::UnitTestOptions; using ::testing::internal::UnitTestOptions;
...@@ -85,7 +85,7 @@ template <typename T> ...@@ -85,7 +85,7 @@ template <typename T>
return stream.str(); return stream.str();
} }
#if GTEST_HAS_COMBINE # if GTEST_HAS_COMBINE
// These overloads allow printing tuples in our tests. We cannot // These overloads allow printing tuples in our tests. We cannot
// define an operator<< for tuples, as that definition needs to be in // define an operator<< for tuples, as that definition needs to be in
...@@ -121,7 +121,7 @@ template <typename T1, typename T2, typename T3, typename T4, typename T5, ...@@ -121,7 +121,7 @@ template <typename T1, typename T2, typename T3, typename T4, typename T5,
return stream.str(); return stream.str();
} }
#endif // GTEST_HAS_COMBINE # endif // GTEST_HAS_COMBINE
// Verifies that a sequence generated by the generator and accessed // Verifies that a sequence generated by the generator and accessed
// via the iterator object matches the expected one using Google Test // via the iterator object matches the expected one using Google Test
...@@ -457,7 +457,7 @@ TEST(BoolTest, BoolWorks) { ...@@ -457,7 +457,7 @@ TEST(BoolTest, BoolWorks) {
VerifyGenerator(gen, expected_values); VerifyGenerator(gen, expected_values);
} }
#if GTEST_HAS_COMBINE # if GTEST_HAS_COMBINE
// Tests that Combine() with two parameters generates the expected sequence. // Tests that Combine() with two parameters generates the expected sequence.
TEST(CombineTest, CombineWithTwoParameters) { TEST(CombineTest, CombineWithTwoParameters) {
...@@ -542,7 +542,7 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) { ...@@ -542,7 +542,7 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) {
VerifyGenerator(gen, expected_values); VerifyGenerator(gen, expected_values);
} }
#endif // GTEST_HAS_COMBINE # endif // GTEST_HAS_COMBINE
// Tests that an generator produces correct sequence after being // Tests that an generator produces correct sequence after being
// assigned from another generator. // assigned from another generator.
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include <stdio.h> #include <stdio.h>
#if GTEST_OS_MAC #if GTEST_OS_MAC
#include <time.h> # include <time.h>
#endif // GTEST_OS_MAC #endif // GTEST_OS_MAC
#include <utility> // For std::pair and std::make_pair. #include <utility> // For std::pair and std::make_pair.
...@@ -328,15 +328,19 @@ TEST(GtestCheckDeathTest, LivesSilentlyOnSuccess) { ...@@ -328,15 +328,19 @@ TEST(GtestCheckDeathTest, LivesSilentlyOnSuccess) {
// For simplicity, we only cover the most important platforms here. // For simplicity, we only cover the most important platforms here.
TEST(RegexEngineSelectionTest, SelectsCorrectRegexEngine) { TEST(RegexEngineSelectionTest, SelectsCorrectRegexEngine) {
#if GTEST_HAS_POSIX_RE #if GTEST_HAS_POSIX_RE
EXPECT_TRUE(GTEST_USES_POSIX_RE); EXPECT_TRUE(GTEST_USES_POSIX_RE);
#else #else
EXPECT_TRUE(GTEST_USES_SIMPLE_RE); EXPECT_TRUE(GTEST_USES_SIMPLE_RE);
#endif #endif
} }
#if GTEST_USES_POSIX_RE #if GTEST_USES_POSIX_RE
#if GTEST_HAS_TYPED_TEST # if GTEST_HAS_TYPED_TEST
template <typename Str> template <typename Str>
class RETest : public ::testing::Test {}; class RETest : public ::testing::Test {};
...@@ -345,9 +349,9 @@ class RETest : public ::testing::Test {}; ...@@ -345,9 +349,9 @@ class RETest : public ::testing::Test {};
// supports. // supports.
typedef testing::Types< typedef testing::Types<
::std::string, ::std::string,
#if GTEST_HAS_GLOBAL_STRING # if GTEST_HAS_GLOBAL_STRING
::string, ::string,
#endif // GTEST_HAS_GLOBAL_STRING # endif // GTEST_HAS_GLOBAL_STRING
const char*> StringTypes; const char*> StringTypes;
TYPED_TEST_CASE(RETest, StringTypes); TYPED_TEST_CASE(RETest, StringTypes);
...@@ -398,7 +402,7 @@ TYPED_TEST(RETest, PartialMatchWorks) { ...@@ -398,7 +402,7 @@ TYPED_TEST(RETest, PartialMatchWorks) {
EXPECT_FALSE(RE::PartialMatch(TypeParam("zza"), re)); EXPECT_FALSE(RE::PartialMatch(TypeParam("zza"), re));
} }
#endif // GTEST_HAS_TYPED_TEST # endif // GTEST_HAS_TYPED_TEST
#elif GTEST_USES_SIMPLE_RE #elif GTEST_USES_SIMPLE_RE
......
...@@ -52,10 +52,10 @@ ...@@ -52,10 +52,10 @@
// hash_map and hash_set are available under Visual C++. // hash_map and hash_set are available under Visual C++.
#if _MSC_VER #if _MSC_VER
#define GTEST_HAS_HASH_MAP_ 1 // Indicates that hash_map is available. # define GTEST_HAS_HASH_MAP_ 1 // Indicates that hash_map is available.
#include <hash_map> // NOLINT # include <hash_map> // NOLINT
#define GTEST_HAS_HASH_SET_ 1 // Indicates that hash_set is available. # define GTEST_HAS_HASH_SET_ 1 // Indicates that hash_set is available.
#include <hash_set> // NOLINT # include <hash_set> // NOLINT
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
// Some user-defined types for testing the universal value printer. // Some user-defined types for testing the universal value printer.
......
...@@ -42,8 +42,8 @@ ...@@ -42,8 +42,8 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#if GTEST_OS_WINDOWS #if GTEST_OS_WINDOWS
#include <windows.h> # include <windows.h>
#include <stdlib.h> # include <stdlib.h>
#endif #endif
namespace { namespace {
...@@ -69,7 +69,8 @@ int main(int argc, char **argv) { ...@@ -69,7 +69,8 @@ int main(int argc, char **argv) {
// a general protection fault (segment violation). // a general protection fault (segment violation).
SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS); SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS);
#if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE # if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE
// The default unhandled exception filter does not always exit // The default unhandled exception filter does not always exit
// with the exception code as exit code - for example it exits with // with the exception code as exit code - for example it exits with
// 0 for EXCEPTION_ACCESS_VIOLATION and 1 for EXCEPTION_BREAKPOINT // 0 for EXCEPTION_ACCESS_VIOLATION and 1 for EXCEPTION_BREAKPOINT
...@@ -77,7 +78,8 @@ int main(int argc, char **argv) { ...@@ -77,7 +78,8 @@ int main(int argc, char **argv) {
// filter which always exits with the exception code for unhandled // filter which always exits with the exception code for unhandled
// exceptions. // exceptions.
SetUnhandledExceptionFilter(ExitWithExceptionCode); SetUnhandledExceptionFilter(ExitWithExceptionCode);
#endif
# endif
#endif #endif
testing::InitGoogleTest(&argc, argv); testing::InitGoogleTest(&argc, argv);
......
...@@ -38,12 +38,12 @@ ...@@ -38,12 +38,12 @@
#include <stdlib.h> // For exit(). #include <stdlib.h> // For exit().
#if GTEST_HAS_SEH #if GTEST_HAS_SEH
#include <windows.h> # include <windows.h>
#endif #endif
#if GTEST_HAS_EXCEPTIONS #if GTEST_HAS_EXCEPTIONS
#include <exception> // For set_terminate(). # include <exception> // For set_terminate().
#include <stdexcept> # include <stdexcept>
#endif #endif
using testing::Test; using testing::Test;
......
...@@ -788,7 +788,7 @@ INSTANTIATE_TYPED_TEST_CASE_P(Unsigned, TypedTestP, UnsignedTypes); ...@@ -788,7 +788,7 @@ INSTANTIATE_TYPED_TEST_CASE_P(Unsigned, TypedTestP, UnsignedTypes);
TEST(ADeathTest, ShouldRunFirst) { TEST(ADeathTest, ShouldRunFirst) {
} }
#if 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.
...@@ -803,9 +803,9 @@ TYPED_TEST_CASE(ATypedDeathTest, NumericTypes); ...@@ -803,9 +803,9 @@ TYPED_TEST_CASE(ATypedDeathTest, NumericTypes);
TYPED_TEST(ATypedDeathTest, ShouldRunFirst) { TYPED_TEST(ATypedDeathTest, ShouldRunFirst) {
} }
#endif // GTEST_HAS_TYPED_TEST # endif // GTEST_HAS_TYPED_TEST
#if 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
...@@ -824,7 +824,7 @@ REGISTER_TYPED_TEST_CASE_P(ATypeParamDeathTest, ShouldRunFirst); ...@@ -824,7 +824,7 @@ REGISTER_TYPED_TEST_CASE_P(ATypeParamDeathTest, ShouldRunFirst);
INSTANTIATE_TYPED_TEST_CASE_P(My, ATypeParamDeathTest, NumericTypes); INSTANTIATE_TYPED_TEST_CASE_P(My, ATypeParamDeathTest, NumericTypes);
#endif // GTEST_HAS_TYPED_TEST_P # endif // GTEST_HAS_TYPED_TEST_P
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
...@@ -998,11 +998,11 @@ int main(int argc, char **argv) { ...@@ -998,11 +998,11 @@ int main(int argc, char **argv) {
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.
#if GTEST_OS_WINDOWS # if GTEST_OS_WINDOWS
posix::FReopen("nul:", "w", stdout); posix::FReopen("nul:", "w", stdout);
#else # else
posix::FReopen("/dev/null", "w", stdout); posix::FReopen("/dev/null", "w", stdout);
#endif // GTEST_OS_WINDOWS # endif // GTEST_OS_WINDOWS
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }
#endif // GTEST_HAS_DEATH_TEST #endif // GTEST_HAS_DEATH_TEST
......
...@@ -310,10 +310,10 @@ TEST(FormatTimeInMillisAsSecondsTest, FormatsNegativeNumber) { ...@@ -310,10 +310,10 @@ TEST(FormatTimeInMillisAsSecondsTest, FormatsNegativeNumber) {
#if GTEST_CAN_COMPARE_NULL #if GTEST_CAN_COMPARE_NULL
#ifdef __BORLANDC__ # ifdef __BORLANDC__
// Silences warnings: "Condition is always true", "Unreachable code" // Silences warnings: "Condition is always true", "Unreachable code"
#pragma option push -w-ccc -w-rch # pragma option push -w-ccc -w-rch
#endif # endif
// 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.
...@@ -322,12 +322,15 @@ TEST(NullLiteralTest, IsTrueForNullLiterals) { ...@@ -322,12 +322,15 @@ TEST(NullLiteralTest, IsTrueForNullLiterals) {
EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0)); EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0));
EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0U)); EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0U));
EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0L)); EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0L));
#ifndef __BORLANDC__
# ifndef __BORLANDC__
// Some compilers may fail to detect some null pointer literals; // Some compilers may fail to detect some null pointer literals;
// as long as users of the framework don't use such literals, this // as long as users of the framework don't use such literals, this
// is harmless. // is harmless.
EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(1 - 1)); EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(1 - 1));
#endif
# endif
} }
// 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
...@@ -339,10 +342,10 @@ TEST(NullLiteralTest, IsFalseForNonNullLiterals) { ...@@ -339,10 +342,10 @@ TEST(NullLiteralTest, IsFalseForNonNullLiterals) {
EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(static_cast<void*>(NULL))); EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(static_cast<void*>(NULL)));
} }
#ifdef __BORLANDC__ # ifdef __BORLANDC__
// Restores warnings after previous "#pragma option push" suppressed them. // Restores warnings after previous "#pragma option push" suppressed them.
#pragma option pop # pragma option pop
#endif # endif
#endif // GTEST_CAN_COMPARE_NULL #endif // GTEST_CAN_COMPARE_NULL
// //
...@@ -1211,7 +1214,7 @@ TEST(StringTest, ShowWideCStringQuoted) { ...@@ -1211,7 +1214,7 @@ TEST(StringTest, ShowWideCStringQuoted) {
String::ShowWideCStringQuoted(L"foo").c_str()); String::ShowWideCStringQuoted(L"foo").c_str());
} }
#if GTEST_OS_WINDOWS_MOBILE # if GTEST_OS_WINDOWS_MOBILE
TEST(StringTest, AnsiAndUtf16Null) { TEST(StringTest, AnsiAndUtf16Null) {
EXPECT_EQ(NULL, String::AnsiToUtf16(NULL)); EXPECT_EQ(NULL, String::AnsiToUtf16(NULL));
EXPECT_EQ(NULL, String::Utf16ToAnsi(NULL)); EXPECT_EQ(NULL, String::Utf16ToAnsi(NULL));
...@@ -1234,7 +1237,7 @@ TEST(StringTest, AnsiAndUtf16ConvertPathChars) { ...@@ -1234,7 +1237,7 @@ TEST(StringTest, AnsiAndUtf16ConvertPathChars) {
EXPECT_EQ(0, wcsncmp(L".:\\ \"*?", utf16, 3)); EXPECT_EQ(0, wcsncmp(L".:\\ \"*?", utf16, 3));
delete [] utf16; delete [] utf16;
} }
#endif // GTEST_OS_WINDOWS_MOBILE # endif // GTEST_OS_WINDOWS_MOBILE
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
...@@ -1368,7 +1371,7 @@ TEST_F(ExpectFatalFailureTest, CatchesFatalFailureOnAllThreads) { ...@@ -1368,7 +1371,7 @@ TEST_F(ExpectFatalFailureTest, CatchesFatalFailureOnAllThreads) {
#ifdef __BORLANDC__ #ifdef __BORLANDC__
// Silences warnings: "Condition is always true" // Silences warnings: "Condition is always true"
#pragma option push -w-ccc # pragma option push -w-ccc
#endif #endif
// Tests that EXPECT_FATAL_FAILURE() can be used in a non-void // Tests that EXPECT_FATAL_FAILURE() can be used in a non-void
...@@ -1396,7 +1399,7 @@ void DoesNotAbortHelper(bool* aborted) { ...@@ -1396,7 +1399,7 @@ void DoesNotAbortHelper(bool* aborted) {
#ifdef __BORLANDC__ #ifdef __BORLANDC__
// Restores warnings after previous "#pragma option push" suppressed them. // Restores warnings after previous "#pragma option push" suppressed them.
#pragma option pop # pragma option pop
#endif #endif
TEST_F(ExpectFatalFailureTest, DoesNotAbort) { TEST_F(ExpectFatalFailureTest, DoesNotAbort) {
...@@ -3534,7 +3537,7 @@ TEST(AssertionTest, AppendUserMessage) { ...@@ -3534,7 +3537,7 @@ TEST(AssertionTest, AppendUserMessage) {
#ifdef __BORLANDC__ #ifdef __BORLANDC__
// Silences warnings: "Condition is always true", "Unreachable code" // Silences warnings: "Condition is always true", "Unreachable code"
#pragma option push -w-ccc -w-rch # pragma option push -w-ccc -w-rch
#endif #endif
// Tests ASSERT_TRUE. // Tests ASSERT_TRUE.
...@@ -3589,7 +3592,7 @@ TEST(AssertionTest, AssertFalseWithAssertionResult) { ...@@ -3589,7 +3592,7 @@ TEST(AssertionTest, AssertFalseWithAssertionResult) {
#ifdef __BORLANDC__ #ifdef __BORLANDC__
// Restores warnings after previous "#pragma option push" supressed them // Restores warnings after previous "#pragma option push" supressed them
#pragma option pop # pragma option pop
#endif #endif
// Tests using ASSERT_EQ on double values. The purpose is to make // Tests using ASSERT_EQ on double values. The purpose is to make
...@@ -3692,13 +3695,14 @@ void ThrowNothing() {} ...@@ -3692,13 +3695,14 @@ void ThrowNothing() {}
TEST(AssertionTest, ASSERT_THROW) { TEST(AssertionTest, ASSERT_THROW) {
ASSERT_THROW(ThrowAnInteger(), int); ASSERT_THROW(ThrowAnInteger(), int);
#ifndef __BORLANDC__ # ifndef __BORLANDC__
// ICE's in C++Builder 2007 and 2009. // ICE's in C++Builder 2007 and 2009.
EXPECT_FATAL_FAILURE( EXPECT_FATAL_FAILURE(
ASSERT_THROW(ThrowAnInteger(), bool), ASSERT_THROW(ThrowAnInteger(), bool),
"Expected: ThrowAnInteger() throws an exception of type bool.\n" "Expected: ThrowAnInteger() throws an exception of type bool.\n"
" Actual: it throws a different type."); " Actual: it throws a different type.");
#endif # endif
EXPECT_FATAL_FAILURE( EXPECT_FATAL_FAILURE(
ASSERT_THROW(ThrowNothing(), bool), ASSERT_THROW(ThrowNothing(), bool),
...@@ -3826,7 +3830,9 @@ TEST(AssertionTest, NamedEnum) { ...@@ -3826,7 +3830,9 @@ TEST(AssertionTest, NamedEnum) {
// Tests using assertions with anonymous enums. // Tests using assertions with anonymous enums.
enum { enum {
kCaseA = -1, kCaseA = -1,
#if GTEST_OS_LINUX
# if GTEST_OS_LINUX
// We want to test the case where the size of the anonymous enum is // We want to test the case where the size of the anonymous enum is
// larger than sizeof(int), to make sure our implementation of the // larger than sizeof(int), to make sure our implementation of the
// assertions doesn't truncate the enums. However, MSVC // assertions doesn't truncate the enums. However, MSVC
...@@ -3837,16 +3843,22 @@ enum { ...@@ -3837,16 +3843,22 @@ enum {
// int size. We want to test whether this will confuse the // int size. We want to test whether this will confuse the
// assertions. // assertions.
kCaseB = testing::internal::kMaxBiggestInt, kCaseB = testing::internal::kMaxBiggestInt,
#else
# else
kCaseB = INT_MAX, kCaseB = INT_MAX,
#endif // GTEST_OS_LINUX
# endif // GTEST_OS_LINUX
kCaseC = 42, kCaseC = 42,
}; };
TEST(AssertionTest, AnonymousEnum) { TEST(AssertionTest, AnonymousEnum) {
#if GTEST_OS_LINUX # if GTEST_OS_LINUX
EXPECT_EQ(static_cast<int>(kCaseA), static_cast<int>(kCaseB)); EXPECT_EQ(static_cast<int>(kCaseA), static_cast<int>(kCaseB));
#endif // GTEST_OS_LINUX
# endif // GTEST_OS_LINUX
EXPECT_EQ(kCaseA, kCaseA); EXPECT_EQ(kCaseA, kCaseA);
EXPECT_NE(kCaseA, kCaseB); EXPECT_NE(kCaseA, kCaseB);
...@@ -3925,12 +3937,14 @@ TEST(HRESULTAssertionTest, EXPECT_HRESULT_FAILED) { ...@@ -3925,12 +3937,14 @@ TEST(HRESULTAssertionTest, EXPECT_HRESULT_FAILED) {
TEST(HRESULTAssertionTest, ASSERT_HRESULT_FAILED) { TEST(HRESULTAssertionTest, ASSERT_HRESULT_FAILED) {
ASSERT_HRESULT_FAILED(E_UNEXPECTED); ASSERT_HRESULT_FAILED(E_UNEXPECTED);
#ifndef __BORLANDC__ # ifndef __BORLANDC__
// ICE's in C++Builder 2007 and 2009. // ICE's in C++Builder 2007 and 2009.
EXPECT_FATAL_FAILURE(ASSERT_HRESULT_FAILED(OkHRESULTSuccess()), EXPECT_FATAL_FAILURE(ASSERT_HRESULT_FAILED(OkHRESULTSuccess()),
"Expected: (OkHRESULTSuccess()) fails.\n" "Expected: (OkHRESULTSuccess()) fails.\n"
" Actual: 0x00000000"); " Actual: 0x00000000");
#endif # endif
EXPECT_FATAL_FAILURE(ASSERT_HRESULT_FAILED(FalseHRESULTSuccess()), EXPECT_FATAL_FAILURE(ASSERT_HRESULT_FAILED(FalseHRESULTSuccess()),
"Expected: (FalseHRESULTSuccess()) fails.\n" "Expected: (FalseHRESULTSuccess()) fails.\n"
" Actual: 0x00000001"); " Actual: 0x00000001");
...@@ -3947,12 +3961,13 @@ TEST(HRESULTAssertionTest, Streaming) { ...@@ -3947,12 +3961,13 @@ TEST(HRESULTAssertionTest, Streaming) {
EXPECT_HRESULT_SUCCEEDED(E_UNEXPECTED) << "expected failure", EXPECT_HRESULT_SUCCEEDED(E_UNEXPECTED) << "expected failure",
"expected failure"); "expected failure");
#ifndef __BORLANDC__ # ifndef __BORLANDC__
// ICE's in C++Builder 2007 and 2009. // ICE's in C++Builder 2007 and 2009.
EXPECT_FATAL_FAILURE( EXPECT_FATAL_FAILURE(
ASSERT_HRESULT_SUCCEEDED(E_UNEXPECTED) << "expected failure", ASSERT_HRESULT_SUCCEEDED(E_UNEXPECTED) << "expected failure",
"expected failure"); "expected failure");
#endif # endif
EXPECT_NONFATAL_FAILURE( EXPECT_NONFATAL_FAILURE(
EXPECT_HRESULT_FAILED(S_OK) << "expected failure", EXPECT_HRESULT_FAILED(S_OK) << "expected failure",
...@@ -3967,7 +3982,7 @@ TEST(HRESULTAssertionTest, Streaming) { ...@@ -3967,7 +3982,7 @@ TEST(HRESULTAssertionTest, Streaming) {
#ifdef __BORLANDC__ #ifdef __BORLANDC__
// Silences warnings: "Condition is always true", "Unreachable code" // Silences warnings: "Condition is always true", "Unreachable code"
#pragma option push -w-ccc -w-rch # pragma option push -w-ccc -w-rch
#endif #endif
// Tests that the assertion macros behave like single statements. // Tests that the assertion macros behave like single statements.
...@@ -4188,7 +4203,7 @@ TEST(ExpectTest, ExpectFalseWithAssertionResult) { ...@@ -4188,7 +4203,7 @@ TEST(ExpectTest, ExpectFalseWithAssertionResult) {
#ifdef __BORLANDC__ #ifdef __BORLANDC__
// Restores warnings after previous "#pragma option push" supressed them // Restores warnings after previous "#pragma option push" supressed them
#pragma option pop # pragma option pop
#endif #endif
// Tests EXPECT_EQ. // Tests EXPECT_EQ.
...@@ -5426,6 +5441,7 @@ class InitGoogleTestTest : public Test { ...@@ -5426,6 +5441,7 @@ class InitGoogleTestTest : public Test {
// This macro wraps TestParsingFlags s.t. the user doesn't need // This macro wraps TestParsingFlags s.t. the user doesn't need
// to specify the array sizes. // to specify the array sizes.
#define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help) \ #define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help) \
TestParsingFlags(sizeof(argv1)/sizeof(*argv1) - 1, argv1, \ TestParsingFlags(sizeof(argv1)/sizeof(*argv1) - 1, argv1, \
sizeof(argv2)/sizeof(*argv2) - 1, argv2, \ sizeof(argv2)/sizeof(*argv2) - 1, argv2, \
...@@ -6239,7 +6255,7 @@ TEST(StreamingAssertionsTest, Unconditional) { ...@@ -6239,7 +6255,7 @@ TEST(StreamingAssertionsTest, Unconditional) {
#ifdef __BORLANDC__ #ifdef __BORLANDC__
// Silences warnings: "Condition is always true", "Unreachable code" // Silences warnings: "Condition is always true", "Unreachable code"
#pragma option push -w-ccc -w-rch # pragma option push -w-ccc -w-rch
#endif #endif
TEST(StreamingAssertionsTest, Truth) { TEST(StreamingAssertionsTest, Truth) {
...@@ -6262,7 +6278,7 @@ TEST(StreamingAssertionsTest, Truth2) { ...@@ -6262,7 +6278,7 @@ TEST(StreamingAssertionsTest, Truth2) {
#ifdef __BORLANDC__ #ifdef __BORLANDC__
// Restores warnings after previous "#pragma option push" supressed them // Restores warnings after previous "#pragma option push" supressed them
#pragma option pop # pragma option pop
#endif #endif
TEST(StreamingAssertionsTest, IntegerEquals) { TEST(StreamingAssertionsTest, IntegerEquals) {
......
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