diff options
| author | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2011-02-22 22:08:59 +0000 | 
|---|---|---|
| committer | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2011-02-22 22:08:59 +0000 | 
| commit | ffeb11d14a890b902dbb26ff2296cda7bf2d31df (patch) | |
| tree | fd0c02c85dbd0a7a96f6791f00bf11a3f0e5eba2 /src | |
| parent | 0980b4bd66b496074d9e34d9f05244e700e9406d (diff) | |
| download | googletest-ffeb11d14a890b902dbb26ff2296cda7bf2d31df.tar.gz googletest-ffeb11d14a890b902dbb26ff2296cda7bf2d31df.tar.bz2 googletest-ffeb11d14a890b902dbb26ff2296cda7bf2d31df.zip  | |
Indents preprocessor directives.
Diffstat (limited to 'src')
| -rw-r--r-- | src/gtest-death-test.cc | 110 | ||||
| -rw-r--r-- | src/gtest-filepath.cc | 26 | ||||
| -rw-r--r-- | src/gtest-internal-inl.h | 24 | ||||
| -rw-r--r-- | src/gtest-port.cc | 31 | ||||
| -rw-r--r-- | src/gtest-printers.cc | 6 | ||||
| -rw-r--r-- | src/gtest.cc | 121 | 
6 files changed, 179 insertions, 139 deletions
diff --git a/src/gtest-death-test.cc b/src/gtest-death-test.cc index 3e651939..a0ed80d1 100644 --- a/src/gtest-death-test.cc +++ b/src/gtest-death-test.cc @@ -36,21 +36,21 @@  #if GTEST_HAS_DEATH_TEST -#if GTEST_OS_MAC -#include <crt_externs.h> -#endif  // GTEST_OS_MAC - -#include <errno.h> -#include <fcntl.h> -#include <limits.h> -#include <stdarg.h> - -#if GTEST_OS_WINDOWS -#include <windows.h> -#else -#include <sys/mman.h> -#include <sys/wait.h> -#endif  // GTEST_OS_WINDOWS +# if GTEST_OS_MAC +#  include <crt_externs.h> +# endif  // GTEST_OS_MAC + +# include <errno.h> +# include <fcntl.h> +# include <limits.h> +# include <stdarg.h> + +# if GTEST_OS_WINDOWS +#  include <windows.h> +# else +#  include <sys/mman.h> +#  include <sys/wait.h> +# endif  // GTEST_OS_WINDOWS  #endif  // GTEST_HAS_DEATH_TEST @@ -113,14 +113,18 @@ ExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) {  // ExitedWithCode function-call operator.  bool ExitedWithCode::operator()(int exit_status) const { -#if GTEST_OS_WINDOWS +# if GTEST_OS_WINDOWS +    return exit_status == exit_code_; -#else + +# else +    return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_; -#endif  // GTEST_OS_WINDOWS + +# endif  // GTEST_OS_WINDOWS  } -#if !GTEST_OS_WINDOWS +# if !GTEST_OS_WINDOWS  // KilledBySignal constructor.  KilledBySignal::KilledBySignal(int signum) : signum_(signum) {  } @@ -129,7 +133,7 @@ KilledBySignal::KilledBySignal(int signum) : signum_(signum) {  bool KilledBySignal::operator()(int exit_status) const {    return WIFSIGNALED(exit_status) && WTERMSIG(exit_status) == signum_;  } -#endif  // !GTEST_OS_WINDOWS +# endif  // !GTEST_OS_WINDOWS  namespace internal { @@ -139,20 +143,25 @@ namespace internal {  // specified by wait(2).  static String ExitSummary(int exit_code) {    Message m; -#if GTEST_OS_WINDOWS + +# if GTEST_OS_WINDOWS +    m << "Exited with exit status " << exit_code; -#else + +# else +    if (WIFEXITED(exit_code)) {      m << "Exited with exit status " << WEXITSTATUS(exit_code);    } else if (WIFSIGNALED(exit_code)) {      m << "Terminated by signal " << WTERMSIG(exit_code);    } -#ifdef WCOREDUMP +#  ifdef WCOREDUMP    if (WCOREDUMP(exit_code)) {      m << " (core dumped)";    } -#endif -#endif  // GTEST_OS_WINDOWS +#  endif +# endif  // GTEST_OS_WINDOWS +    return m.GetString();  } @@ -162,7 +171,7 @@ bool ExitedUnsuccessfully(int exit_status) {    return !ExitedWithCode(0)(exit_status);  } -#if !GTEST_OS_WINDOWS +# if !GTEST_OS_WINDOWS  // Generates a textual failure message when a death test finds more than  // one thread running, or cannot determine the number of threads, prior  // to executing the given statement.  It is the responsibility of the @@ -177,7 +186,7 @@ static String DeathTestThreadWarning(size_t thread_count) {      msg << "detected " << thread_count << " threads.";    return msg.GetString();  } -#endif  // !GTEST_OS_WINDOWS +# endif  // !GTEST_OS_WINDOWS  // Flag characters for reporting a death test that did not die.  static const char kDeathTestLived = 'L'; @@ -222,7 +231,7 @@ void DeathTestAbort(const String& message) {  // A replacement for CHECK that calls DeathTestAbort if the assertion  // fails. -#define GTEST_DEATH_TEST_CHECK_(expression) \ +# define GTEST_DEATH_TEST_CHECK_(expression) \    do { \      if (!::testing::internal::IsTrue(expression)) { \        DeathTestAbort(::testing::internal::String::Format( \ @@ -238,7 +247,7 @@ void DeathTestAbort(const String& message) {  // evaluates the expression as long as it evaluates to -1 and sets  // errno to EINTR.  If the expression evaluates to -1 but errno is  // something other than EINTR, DeathTestAbort is called. -#define GTEST_DEATH_TEST_CHECK_SYSCALL_(expression) \ +# define GTEST_DEATH_TEST_CHECK_SYSCALL_(expression) \    do { \      int gtest_retval; \      do { \ @@ -527,7 +536,7 @@ bool DeathTestImpl::Passed(bool status_ok) {    return success;  } -#if GTEST_OS_WINDOWS +# if GTEST_OS_WINDOWS  // WindowsDeathTest implements death tests on Windows. Due to the  // specifics of starting new processes on Windows, death tests there are  // always threadsafe, and Google Test considers the @@ -723,7 +732,7 @@ DeathTest::TestRole WindowsDeathTest::AssumeRole() {    set_spawned(true);    return OVERSEE_TEST;  } -#else  // We are not on Windows. +# else  // We are not on Windows.  // ForkingDeathTest provides implementations for most of the abstract  // methods of the DeathTest interface.  Only the AssumeRole method is @@ -871,19 +880,19 @@ struct ExecDeathTestArgs {    int close_fd;       // File descriptor to close; the read end of a pipe  }; -#if GTEST_OS_MAC +#  if GTEST_OS_MAC  inline char** GetEnviron() {    // When Google Test is built as a framework on MacOS X, the environ variable    // is unavailable. Apple's documentation (man environ) recommends using    // _NSGetEnviron() instead.    return *_NSGetEnviron();  } -#else +#  else  // Some POSIX platforms expect you to declare environ. extern "C" makes  // it reside in the global namespace.  extern "C" char** environ;  inline char** GetEnviron() { return environ; } -#endif  // GTEST_OS_MAC +#  endif  // GTEST_OS_MAC  // The main function for a threadsafe-style death test child process.  // This function is called in a clone()-ed process and thus must avoid @@ -940,7 +949,7 @@ static pid_t ExecDeathTestFork(char* const* argv, int close_fd) {    ExecDeathTestArgs args = { argv, close_fd };    pid_t child_pid = -1; -#if GTEST_HAS_CLONE +#  if GTEST_HAS_CLONE    const bool use_fork = GTEST_FLAG(death_test_use_fork);    if (!use_fork) { @@ -957,9 +966,9 @@ static pid_t ExecDeathTestFork(char* const* argv, int close_fd) {      GTEST_DEATH_TEST_CHECK_(munmap(stack, stack_size) != -1);    } -#else +#  else    const bool use_fork = true; -#endif  // GTEST_HAS_CLONE +#  endif  // GTEST_HAS_CLONE    if (use_fork && (child_pid = fork()) == 0) {        ExecDeathTestChildMain(&args); @@ -1020,7 +1029,7 @@ DeathTest::TestRole ExecDeathTest::AssumeRole() {    return OVERSEE_TEST;  } -#endif  // !GTEST_OS_WINDOWS +# endif  // !GTEST_OS_WINDOWS  // Creates a concrete DeathTest-derived class that depends on the  // --gtest_death_test_style flag, and sets the pointer pointed to @@ -1051,18 +1060,23 @@ bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,      }    } -#if GTEST_OS_WINDOWS +# if GTEST_OS_WINDOWS +    if (GTEST_FLAG(death_test_style) == "threadsafe" ||        GTEST_FLAG(death_test_style) == "fast") {      *test = new WindowsDeathTest(statement, regex, file, line);    } -#else + +# else +    if (GTEST_FLAG(death_test_style) == "threadsafe") {      *test = new ExecDeathTest(statement, regex, file, line);    } else if (GTEST_FLAG(death_test_style) == "fast") {      *test = new NoExecDeathTest(statement, regex);    } -#endif  // GTEST_OS_WINDOWS + +# endif  // GTEST_OS_WINDOWS +    else {  // NOLINT - this is more readable than unbalanced brackets inside #if.      DeathTest::set_last_death_test_message(String::Format(          "Unknown death test style \"%s\" encountered", @@ -1093,7 +1107,7 @@ static void SplitString(const ::std::string& str, char delimiter,    dest->swap(parsed);  } -#if GTEST_OS_WINDOWS +# if GTEST_OS_WINDOWS  // Recreates the pipe and event handles from the provided parameters,  // signals the event, and returns a file descriptor wrapped around the pipe  // handle. This function is called in the child process only. @@ -1157,7 +1171,7 @@ int GetStatusFileDescriptor(unsigned int parent_process_id,    return write_fd;  } -#endif  // GTEST_OS_WINDOWS +# endif  // GTEST_OS_WINDOWS  // Returns a newly created InternalRunDeathTestFlag object with fields  // initialized from the GTEST_FLAG(internal_run_death_test) flag if @@ -1173,7 +1187,8 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {    SplitString(GTEST_FLAG(internal_run_death_test).c_str(), '|', &fields);    int write_fd = -1; -#if GTEST_OS_WINDOWS +# if GTEST_OS_WINDOWS +    unsigned int parent_process_id = 0;    size_t write_handle_as_size_t = 0;    size_t event_handle_as_size_t = 0; @@ -1191,7 +1206,8 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {    write_fd = GetStatusFileDescriptor(parent_process_id,                                       write_handle_as_size_t,                                       event_handle_as_size_t); -#else +# else +    if (fields.size() != 4        || !ParseNaturalNumber(fields[1], &line)        || !ParseNaturalNumber(fields[2], &index) @@ -1200,7 +1216,9 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {          "Bad --gtest_internal_run_death_test flag: %s",          GTEST_FLAG(internal_run_death_test).c_str()));    } -#endif  // GTEST_OS_WINDOWS + +# endif  // GTEST_OS_WINDOWS +    return new InternalRunDeathTestFlag(fields[0], line, index, write_fd);  } diff --git a/src/gtest-filepath.cc b/src/gtest-filepath.cc index 118848a7..91b25713 100644 --- a/src/gtest-filepath.cc +++ b/src/gtest-filepath.cc @@ -35,26 +35,26 @@  #include <stdlib.h>  #if GTEST_OS_WINDOWS_MOBILE -#include <windows.h> +# include <windows.h>  #elif GTEST_OS_WINDOWS -#include <direct.h> -#include <io.h> +# include <direct.h> +# include <io.h>  #elif GTEST_OS_SYMBIAN || GTEST_OS_NACL  // Symbian OpenC and NaCl have PATH_MAX in sys/syslimits.h -#include <sys/syslimits.h> +# include <sys/syslimits.h>  #else -#include <limits.h> -#include <climits>  // Some Linux distributions define PATH_MAX here. +# include <limits.h> +# include <climits>  // Some Linux distributions define PATH_MAX here.  #endif  // GTEST_OS_WINDOWS_MOBILE  #if GTEST_OS_WINDOWS -#define GTEST_PATH_MAX_ _MAX_PATH +# define GTEST_PATH_MAX_ _MAX_PATH  #elif defined(PATH_MAX) -#define GTEST_PATH_MAX_ PATH_MAX +# define GTEST_PATH_MAX_ PATH_MAX  #elif defined(_XOPEN_PATH_MAX) -#define GTEST_PATH_MAX_ _XOPEN_PATH_MAX +# define GTEST_PATH_MAX_ _XOPEN_PATH_MAX  #else -#define GTEST_PATH_MAX_ _POSIX_PATH_MAX +# define GTEST_PATH_MAX_ _POSIX_PATH_MAX  #endif  // GTEST_OS_WINDOWS  #include "gtest/internal/gtest-string.h" @@ -71,16 +71,16 @@ const char kPathSeparator = '\\';  const char kAlternatePathSeparator = '/';  const char kPathSeparatorString[] = "\\";  const char kAlternatePathSeparatorString[] = "/"; -#if GTEST_OS_WINDOWS_MOBILE +# if GTEST_OS_WINDOWS_MOBILE  // Windows CE doesn't have a current directory. You should not use  // the current directory in tests on Windows CE, but this at least  // provides a reasonable fallback.  const char kCurrentDirectoryString[] = "\\";  // Windows CE doesn't define INVALID_FILE_ATTRIBUTES  const DWORD kInvalidFileAttributes = 0xffffffff; -#else +# else  const char kCurrentDirectoryString[] = ".\\"; -#endif  // GTEST_OS_WINDOWS_MOBILE +# endif  // GTEST_OS_WINDOWS_MOBILE  #else  const char kPathSeparator = '/';  const char kPathSeparatorString[] = "/"; diff --git a/src/gtest-internal-inl.h b/src/gtest-internal-inl.h index 8629c6fb..e45f452a 100644 --- a/src/gtest-internal-inl.h +++ b/src/gtest-internal-inl.h @@ -41,12 +41,12 @@  // part of Google Test's implementation; otherwise it's undefined.  #if !GTEST_IMPLEMENTATION_  // 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 "It must not be included except by Google Test itself." +# error "gtest-internal-inl.h is part of Google Test's internal implementation." +# error "It must not be included except by Google Test itself."  #endif  // GTEST_IMPLEMENTATION_  #ifndef _WIN32_WCE -#include <errno.h> +# include <errno.h>  #endif  // !_WIN32_WCE  #include <stddef.h>  #include <stdlib.h>  // For strtoll/_strtoul64/malloc/free. @@ -59,7 +59,7 @@  #include "gtest/internal/gtest-port.h"  #if GTEST_OS_WINDOWS -#include <windows.h>  // For DWORD. +# include <windows.h>  // NOLINT  #endif  // GTEST_OS_WINDOWS  #include "gtest/gtest.h"  // NOLINT @@ -930,7 +930,7 @@ GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv);  // platform.  GTEST_API_ String GetLastErrnoDescription(); -#if GTEST_OS_WINDOWS +# if GTEST_OS_WINDOWS  // Provides leak-safe Windows kernel handle ownership.  class AutoHandle {   public: @@ -954,7 +954,7 @@ class 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  // number parameter.  Returns true if that is possible. @@ -973,14 +973,20 @@ bool ParseNaturalNumber(const ::std::string& str, Integer* number) {    char* end;    // BiggestConvertible is the largest integer type that system-provided    // 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.    typedef unsigned __int64 BiggestConvertible;    const BiggestConvertible parsed = _strtoui64(str.c_str(), &end, 10); -#else + +# else +    typedef unsigned long long BiggestConvertible;  // NOLINT    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;    // TODO(vladl@google.com): Convert this to compile time assertion when it is diff --git a/src/gtest-port.cc b/src/gtest-port.cc index 4310a735..b860d481 100644 --- a/src/gtest-port.cc +++ b/src/gtest-port.cc @@ -37,18 +37,18 @@  #include <string.h>  #if GTEST_OS_WINDOWS_MOBILE -#include <windows.h>  // For TerminateProcess() +# include <windows.h>  // For TerminateProcess()  #elif GTEST_OS_WINDOWS -#include <io.h> -#include <sys/stat.h> +# include <io.h> +# include <sys/stat.h>  #else -#include <unistd.h> +# include <unistd.h>  #endif  // GTEST_OS_WINDOWS_MOBILE  #if GTEST_OS_MAC -#include <mach/mach_init.h> -#include <mach/task.h> -#include <mach/vm_map.h> +# include <mach/mach_init.h> +# include <mach/task.h> +# include <mach/vm_map.h>  #endif  // GTEST_OS_MAC  #include "gtest/gtest-spi.h" @@ -478,8 +478,8 @@ GTestLog::~GTestLog() {  // Disable Microsoft deprecation warnings for POSIX functions called from  // this class (creat, dup, dup2, and close)  #ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4996) +# pragma warning(push) +# pragma warning(disable: 4996)  #endif  // _MSC_VER  #if GTEST_HAS_STREAM_REDIRECTION @@ -489,7 +489,8 @@ class CapturedStream {   public:    // The ctor redirects the stream to a temporary file.    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_file_path[MAX_PATH + 1] = { '\0' };  // NOLINT @@ -504,14 +505,14 @@ class CapturedStream {      GTEST_CHECK_(captured_fd != -1) << "Unable to open temporary file "                                      << temp_file_path;      filename_ = temp_file_path; -#else +# else      // There's no guarantee that a test has write access to the      // current directory, so we create the temporary file in the /tmp      // directory instead.      char name_template[] = "/tmp/captured_stream.XXXXXX";      const int captured_fd = mkstemp(name_template);      filename_ = name_template; -#endif  // GTEST_OS_WINDOWS +# endif  // GTEST_OS_WINDOWS      fflush(NULL);      dup2(captured_fd, fd_);      close(captured_fd); @@ -580,9 +581,9 @@ String CapturedStream::ReadEntireFile(FILE* file) {    return content;  } -#ifdef _MSC_VER -#pragma warning(pop) -#endif  // _MSC_VER +# ifdef _MSC_VER +#  pragma warning(pop) +# endif  // _MSC_VER  static CapturedStream* g_captured_stderr = NULL;  static CapturedStream* g_captured_stdout = NULL; diff --git a/src/gtest-printers.cc b/src/gtest-printers.cc index bfbca9c8..84a04ab5 100644 --- a/src/gtest-printers.cc +++ b/src/gtest-printers.cc @@ -56,11 +56,11 @@ namespace {  using ::std::ostream;  #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. -#define snprintf _snprintf_s +# define snprintf _snprintf_s  #elif _MSC_VER -#define snprintf _snprintf +# define snprintf _snprintf  #endif  // GTEST_OS_WINDOWS_MOBILE  // Prints a segment of bytes in the given object. diff --git a/src/gtest.cc b/src/gtest.cc index 53a52fbf..91057124 100644 --- a/src/gtest.cc +++ b/src/gtest.cc @@ -51,76 +51,76 @@  // TODO(kenton@google.com): Use autoconf to detect availability of  // gettimeofday(). -#define GTEST_HAS_GETTIMEOFDAY_ 1 +# define GTEST_HAS_GETTIMEOFDAY_ 1 -#include <fcntl.h>  // NOLINT -#include <limits.h>  // NOLINT -#include <sched.h>  // NOLINT +# include <fcntl.h>  // NOLINT +# include <limits.h>  // NOLINT +# include <sched.h>  // NOLINT  // Declares vsnprintf().  This header is not available on Windows. -#include <strings.h>  // NOLINT -#include <sys/mman.h>  // NOLINT -#include <sys/time.h>  // NOLINT -#include <unistd.h>  // NOLINT -#include <string> +# include <strings.h>  // NOLINT +# include <sys/mman.h>  // NOLINT +# include <sys/time.h>  // NOLINT +# include <unistd.h>  // NOLINT +# include <string>  #elif GTEST_OS_SYMBIAN -#define GTEST_HAS_GETTIMEOFDAY_ 1 -#include <sys/time.h>  // NOLINT +# define GTEST_HAS_GETTIMEOFDAY_ 1 +# include <sys/time.h>  // NOLINT  #elif GTEST_OS_ZOS -#define GTEST_HAS_GETTIMEOFDAY_ 1 -#include <sys/time.h>  // NOLINT +# define GTEST_HAS_GETTIMEOFDAY_ 1 +# include <sys/time.h>  // NOLINT  // 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. -#include <windows.h>  // NOLINT +# include <windows.h>  // NOLINT  #elif GTEST_OS_WINDOWS  // We are on Windows proper. -#include <io.h>  // NOLINT -#include <sys/timeb.h>  // NOLINT -#include <sys/types.h>  // NOLINT -#include <sys/stat.h>  // NOLINT +# include <io.h>  // NOLINT +# include <sys/timeb.h>  // NOLINT +# include <sys/types.h>  // NOLINT +# include <sys/stat.h>  // NOLINT -#if GTEST_OS_WINDOWS_MINGW +# if GTEST_OS_WINDOWS_MINGW  // MinGW has gettimeofday() but not _ftime64().  // TODO(kenton@google.com): Use autoconf to detect availability of  //   gettimeofday().  // TODO(kenton@google.com): There are other ways to get the time on  //   Windows, like GetTickCount() or GetSystemTimeAsFileTime().  MinGW  //   supports these.  consider using them instead. -#define GTEST_HAS_GETTIMEOFDAY_ 1 -#include <sys/time.h>  // NOLINT -#endif  // GTEST_OS_WINDOWS_MINGW +#  define GTEST_HAS_GETTIMEOFDAY_ 1 +#  include <sys/time.h>  // NOLINT +# endif  // GTEST_OS_WINDOWS_MINGW  // cpplint thinks that the header is already included, so we want to  // silence it. -#include <windows.h>  // NOLINT +# include <windows.h>  // NOLINT  #else  // Assume other platforms have gettimeofday().  // TODO(kenton@google.com): Use autoconf to detect availability of  //   gettimeofday(). -#define GTEST_HAS_GETTIMEOFDAY_ 1 +# define GTEST_HAS_GETTIMEOFDAY_ 1  // cpplint thinks that the header is already included, so we want to  // silence it. -#include <sys/time.h>  // NOLINT -#include <unistd.h>  // NOLINT +# include <sys/time.h>  // NOLINT +# include <unistd.h>  // NOLINT  #endif  // GTEST_OS_LINUX  #if GTEST_HAS_EXCEPTIONS -#include <stdexcept> +# include <stdexcept>  #endif  #if GTEST_CAN_STREAM_RESULTS_ -#include <arpa/inet.h>  // NOLINT -#include <netdb.h>  // NOLINT +# include <arpa/inet.h>  // NOLINT +# include <netdb.h>  // NOLINT  #endif  // Indicates that this translation unit is part of Google Test's @@ -133,7 +133,7 @@  #undef GTEST_IMPLEMENTATION_  #if GTEST_OS_WINDOWS -#define vsnprintf _vsnprintf +# define vsnprintf _vsnprintf  #endif  // GTEST_OS_WINDOWS  namespace testing { @@ -786,25 +786,30 @@ TimeInMillis GetTimeInMillis() {    return 0;  #elif GTEST_OS_WINDOWS && !GTEST_HAS_GETTIMEOFDAY_    __timeb64 now; -#ifdef _MSC_VER + +# ifdef _MSC_VER +    // MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996    // (deprecated function) there.    // TODO(kenton@google.com): Use GetTickCount()?  Or use    //   SystemTimeToFileTime() -#pragma warning(push)          // Saves the current warning state. -#pragma warning(disable:4996)  // Temporarily disables warning 4996. +#  pragma warning(push)          // Saves the current warning state. +#  pragma warning(disable:4996)  // Temporarily disables warning 4996.    _ftime64(&now); -#pragma warning(pop)           // Restores the warning state. -#else +#  pragma warning(pop)           // Restores the warning state. +# else +    _ftime64(&now); -#endif  // _MSC_VER + +# endif  // _MSC_VER +    return static_cast<TimeInMillis>(now.time) * 1000 + now.millitm;  #elif GTEST_HAS_GETTIMEOFDAY_    struct timeval now;    gettimeofday(&now, NULL);    return static_cast<TimeInMillis>(now.tv_sec) * 1000 + now.tv_usec / 1000;  #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  } @@ -1332,10 +1337,13 @@ namespace {  AssertionResult HRESULTFailureHelper(const char* expr,                                       const char* expected,                                       long hr) {  // NOLINT -#if GTEST_OS_WINDOWS_MOBILE +# if GTEST_OS_WINDOWS_MOBILE +    // Windows CE doesn't support FormatMessage.    const char error_text[] = ""; -#else + +# else +    // Looks up the human-readable system message for the HRESULT code    // and since we're not passing any params to FormatMessage, we don't    // want inserts expanded. @@ -1356,7 +1364,8 @@ AssertionResult HRESULTFailureHelper(const char* expr,            --message_length) {      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));    return ::testing::AssertionFailure() @@ -1698,10 +1707,12 @@ String String::Format(const char * format, ...) {    // MSVC 8 deprecates vsnprintf(), so we want to suppress warning    // 4996 (deprecated function) there.  #ifdef _MSC_VER  // We are using MSVC. -#pragma warning(push)          // Saves the current warning state. -#pragma warning(disable:4996)  // Temporarily disables warning 4996. +# pragma warning(push)          // Saves the current warning state. +# pragma warning(disable:4996)  // Temporarily disables warning 4996. +    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.    const int size = vsnprintf(buffer, kBufferSize, format, args);  #endif  // _MSC_VER @@ -3826,20 +3837,21 @@ int UnitTest::Run() {    // process. In either case the user does not want to see pop-up dialogs    // about crashes - they are expected.    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(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |                   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,      // _abort() can show a dialog with a warning message.  This forces the      // abort message to go to stderr instead.      _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      // 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 @@ -3855,7 +3867,8 @@ int UnitTest::Run() {        _set_abort_behavior(            0x0,                                    // Clear the following flags:            _WRITE_ABORT_MSG | _CALL_REPORTFAULT);  // pop-up window, core dump. -#endif +# endif +    }  #endif  // GTEST_HAS_SEH @@ -3930,12 +3943,12 @@ namespace internal {  UnitTestImpl::UnitTestImpl(UnitTest* parent)      : parent_(parent),  #ifdef _MSC_VER -#pragma warning(push)                    // Saves the current warning state. -#pragma warning(disable:4355)            // Temporarily disables warning 4355 +# pragma warning(push)                    // Saves the current warning state. +# pragma warning(disable:4355)            // Temporarily disables warning 4355                                           // (using this in initializer).        default_global_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        default_global_test_part_result_reporter_(this),        default_per_thread_test_part_result_reporter_(this), @@ -4853,10 +4866,12 @@ void InitGoogleTestImpl(int* argc, CharType** argv) {    internal::g_executable_path = internal::StreamableToString(argv[0]);  #if GTEST_HAS_DEATH_TEST +    g_argvs.clear();    for (int i = 0; i != *argc; i++) {      g_argvs.push_back(StreamableToString(argv[i]));    } +  #endif  // GTEST_HAS_DEATH_TEST    ParseGoogleTestFlagsOnly(argc, argv);  | 
