Indents preprocessor directives.
This commit is contained in:
121
src/gtest.cc
121
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);
|
||||
|
||||
Reference in New Issue
Block a user