Indents preprocessor directives.
This commit is contained in:
parent
0980b4bd66
commit
ffeb11d14a
@ -192,6 +192,7 @@ class GTEST_API_ Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#if GTEST_OS_SYMBIAN
|
#if GTEST_OS_SYMBIAN
|
||||||
// These are needed as the Nokia Symbian Compiler cannot decide between
|
// These are needed as the Nokia Symbian Compiler cannot decide between
|
||||||
// const T& and const T* in a function template. The Nokia compiler _can_
|
// const T& and const T* in a function template. The Nokia compiler _can_
|
||||||
|
@ -672,6 +672,7 @@ class GTEST_API_ TestInfo {
|
|||||||
const TestResult* result() const { return &result_; }
|
const TestResult* result() const { return &result_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#if GTEST_HAS_DEATH_TEST
|
#if GTEST_HAS_DEATH_TEST
|
||||||
friend class internal::DefaultDeathTestFactory;
|
friend class internal::DefaultDeathTestFactory;
|
||||||
#endif // GTEST_HAS_DEATH_TEST
|
#endif // GTEST_HAS_DEATH_TEST
|
||||||
|
@ -173,9 +173,11 @@ GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
|
|||||||
} catch (...) { \
|
} catch (...) { \
|
||||||
death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
|
death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
|
||||||
}
|
}
|
||||||
|
|
||||||
# else
|
# else
|
||||||
# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
|
# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
|
||||||
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
|
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
|
// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
|
||||||
|
@ -869,6 +869,7 @@ class ImplicitlyConvertible {
|
|||||||
#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:4244) // Temporarily disables warning 4244.
|
# pragma warning(disable:4244) // Temporarily disables warning 4244.
|
||||||
|
|
||||||
static const bool value =
|
static const bool value =
|
||||||
sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1;
|
sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1;
|
||||||
# pragma warning(pop) // Restores the warning state.
|
# pragma warning(pop) // Restores the warning state.
|
||||||
|
@ -794,7 +794,9 @@ class GTEST_API_ RE {
|
|||||||
RE(const ::std::string& regex) { Init(regex.c_str()); } // NOLINT
|
RE(const ::std::string& regex) { Init(regex.c_str()); } // NOLINT
|
||||||
|
|
||||||
#if GTEST_HAS_GLOBAL_STRING
|
#if GTEST_HAS_GLOBAL_STRING
|
||||||
|
|
||||||
RE(const ::string& regex) { Init(regex.c_str()); } // NOLINT
|
RE(const ::string& regex) { Init(regex.c_str()); } // NOLINT
|
||||||
|
|
||||||
#endif // GTEST_HAS_GLOBAL_STRING
|
#endif // GTEST_HAS_GLOBAL_STRING
|
||||||
|
|
||||||
RE(const char* regex) { Init(regex); } // NOLINT
|
RE(const char* regex) { Init(regex); } // NOLINT
|
||||||
@ -818,12 +820,14 @@ class GTEST_API_ RE {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if GTEST_HAS_GLOBAL_STRING
|
#if GTEST_HAS_GLOBAL_STRING
|
||||||
|
|
||||||
static bool FullMatch(const ::string& str, const RE& re) {
|
static bool FullMatch(const ::string& str, const RE& re) {
|
||||||
return FullMatch(str.c_str(), re);
|
return FullMatch(str.c_str(), re);
|
||||||
}
|
}
|
||||||
static bool PartialMatch(const ::string& str, const RE& re) {
|
static bool PartialMatch(const ::string& str, const RE& re) {
|
||||||
return PartialMatch(str.c_str(), re);
|
return PartialMatch(str.c_str(), re);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // GTEST_HAS_GLOBAL_STRING
|
#endif // GTEST_HAS_GLOBAL_STRING
|
||||||
|
|
||||||
static bool FullMatch(const char* str, const RE& re);
|
static bool FullMatch(const char* str, const RE& re);
|
||||||
@ -838,11 +842,16 @@ class GTEST_API_ RE {
|
|||||||
// files.
|
// files.
|
||||||
const char* pattern_;
|
const char* pattern_;
|
||||||
bool is_valid_;
|
bool is_valid_;
|
||||||
|
|
||||||
#if GTEST_USES_POSIX_RE
|
#if GTEST_USES_POSIX_RE
|
||||||
|
|
||||||
regex_t full_regex_; // For FullMatch().
|
regex_t full_regex_; // For FullMatch().
|
||||||
regex_t partial_regex_; // For PartialMatch().
|
regex_t partial_regex_; // For PartialMatch().
|
||||||
|
|
||||||
#else // GTEST_USES_SIMPLE_RE
|
#else // GTEST_USES_SIMPLE_RE
|
||||||
|
|
||||||
const char* full_pattern_; // For FullMatch();
|
const char* full_pattern_; // For FullMatch();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GTEST_DISALLOW_ASSIGN_(RE);
|
GTEST_DISALLOW_ASSIGN_(RE);
|
||||||
@ -1672,6 +1681,7 @@ class TypeWithSize<4> {
|
|||||||
template <>
|
template <>
|
||||||
class TypeWithSize<8> {
|
class TypeWithSize<8> {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
#if GTEST_OS_WINDOWS
|
#if GTEST_OS_WINDOWS
|
||||||
typedef __int64 Int;
|
typedef __int64 Int;
|
||||||
typedef unsigned __int64 UInt;
|
typedef unsigned __int64 UInt;
|
||||||
|
@ -89,7 +89,9 @@ String GetTypeName() {
|
|||||||
# endif // __GLIBCXX__
|
# endif // __GLIBCXX__
|
||||||
|
|
||||||
# else
|
# else
|
||||||
|
|
||||||
return "<type>";
|
return "<type>";
|
||||||
|
|
||||||
# endif // GTEST_HAS_RTTI
|
# endif // GTEST_HAS_RTTI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,9 @@ String GetTypeName() {
|
|||||||
# endif // __GLIBCXX__
|
# endif // __GLIBCXX__
|
||||||
|
|
||||||
# else
|
# else
|
||||||
|
|
||||||
return "<type>";
|
return "<type>";
|
||||||
|
|
||||||
# endif // GTEST_HAS_RTTI
|
# endif // GTEST_HAS_RTTI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,9 +114,13 @@ ExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) {
|
|||||||
// ExitedWithCode function-call operator.
|
// ExitedWithCode function-call operator.
|
||||||
bool ExitedWithCode::operator()(int exit_status) const {
|
bool ExitedWithCode::operator()(int exit_status) const {
|
||||||
# if GTEST_OS_WINDOWS
|
# if GTEST_OS_WINDOWS
|
||||||
|
|
||||||
return exit_status == exit_code_;
|
return exit_status == exit_code_;
|
||||||
|
|
||||||
# else
|
# else
|
||||||
|
|
||||||
return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_;
|
return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_;
|
||||||
|
|
||||||
# endif // GTEST_OS_WINDOWS
|
# endif // GTEST_OS_WINDOWS
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,9 +143,13 @@ namespace internal {
|
|||||||
// specified by wait(2).
|
// specified by wait(2).
|
||||||
static String ExitSummary(int exit_code) {
|
static String ExitSummary(int exit_code) {
|
||||||
Message m;
|
Message m;
|
||||||
|
|
||||||
# if GTEST_OS_WINDOWS
|
# if GTEST_OS_WINDOWS
|
||||||
|
|
||||||
m << "Exited with exit status " << exit_code;
|
m << "Exited with exit status " << exit_code;
|
||||||
|
|
||||||
# else
|
# else
|
||||||
|
|
||||||
if (WIFEXITED(exit_code)) {
|
if (WIFEXITED(exit_code)) {
|
||||||
m << "Exited with exit status " << WEXITSTATUS(exit_code);
|
m << "Exited with exit status " << WEXITSTATUS(exit_code);
|
||||||
} else if (WIFSIGNALED(exit_code)) {
|
} else if (WIFSIGNALED(exit_code)) {
|
||||||
@ -153,6 +161,7 @@ static String ExitSummary(int exit_code) {
|
|||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
# endif // GTEST_OS_WINDOWS
|
# endif // GTEST_OS_WINDOWS
|
||||||
|
|
||||||
return m.GetString();
|
return m.GetString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1052,17 +1061,22 @@ bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,
|
|||||||
}
|
}
|
||||||
|
|
||||||
# if GTEST_OS_WINDOWS
|
# if GTEST_OS_WINDOWS
|
||||||
|
|
||||||
if (GTEST_FLAG(death_test_style) == "threadsafe" ||
|
if (GTEST_FLAG(death_test_style) == "threadsafe" ||
|
||||||
GTEST_FLAG(death_test_style) == "fast") {
|
GTEST_FLAG(death_test_style) == "fast") {
|
||||||
*test = new WindowsDeathTest(statement, regex, file, line);
|
*test = new WindowsDeathTest(statement, regex, file, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
# else
|
# else
|
||||||
|
|
||||||
if (GTEST_FLAG(death_test_style) == "threadsafe") {
|
if (GTEST_FLAG(death_test_style) == "threadsafe") {
|
||||||
*test = new ExecDeathTest(statement, regex, file, line);
|
*test = new ExecDeathTest(statement, regex, file, line);
|
||||||
} else if (GTEST_FLAG(death_test_style) == "fast") {
|
} else if (GTEST_FLAG(death_test_style) == "fast") {
|
||||||
*test = new NoExecDeathTest(statement, regex);
|
*test = new NoExecDeathTest(statement, regex);
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif // GTEST_OS_WINDOWS
|
# endif // GTEST_OS_WINDOWS
|
||||||
|
|
||||||
else { // NOLINT - this is more readable than unbalanced brackets inside #if.
|
else { // NOLINT - this is more readable than unbalanced brackets inside #if.
|
||||||
DeathTest::set_last_death_test_message(String::Format(
|
DeathTest::set_last_death_test_message(String::Format(
|
||||||
"Unknown death test style \"%s\" encountered",
|
"Unknown death test style \"%s\" encountered",
|
||||||
@ -1174,6 +1188,7 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
|
|||||||
int write_fd = -1;
|
int write_fd = -1;
|
||||||
|
|
||||||
# if GTEST_OS_WINDOWS
|
# if GTEST_OS_WINDOWS
|
||||||
|
|
||||||
unsigned int parent_process_id = 0;
|
unsigned int parent_process_id = 0;
|
||||||
size_t write_handle_as_size_t = 0;
|
size_t write_handle_as_size_t = 0;
|
||||||
size_t event_handle_as_size_t = 0;
|
size_t event_handle_as_size_t = 0;
|
||||||
@ -1192,6 +1207,7 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
|
|||||||
write_handle_as_size_t,
|
write_handle_as_size_t,
|
||||||
event_handle_as_size_t);
|
event_handle_as_size_t);
|
||||||
# else
|
# else
|
||||||
|
|
||||||
if (fields.size() != 4
|
if (fields.size() != 4
|
||||||
|| !ParseNaturalNumber(fields[1], &line)
|
|| !ParseNaturalNumber(fields[1], &line)
|
||||||
|| !ParseNaturalNumber(fields[2], &index)
|
|| !ParseNaturalNumber(fields[2], &index)
|
||||||
@ -1200,7 +1216,9 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
|
|||||||
"Bad --gtest_internal_run_death_test flag: %s",
|
"Bad --gtest_internal_run_death_test flag: %s",
|
||||||
GTEST_FLAG(internal_run_death_test).c_str()));
|
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);
|
return new InternalRunDeathTestFlag(fields[0], line, index, write_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
@ -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
|
||||||
|
@ -489,6 +489,7 @@ 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
|
||||||
|
15
src/gtest.cc
15
src/gtest.cc
@ -786,7 +786,9 @@ 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
|
||||||
@ -796,8 +798,11 @@ TimeInMillis GetTimeInMillis() {
|
|||||||
_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;
|
||||||
@ -1333,9 +1338,12 @@ 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,6 +1364,7 @@ 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));
|
||||||
@ -1700,7 +1709,9 @@ String String::Format(const char * format, ...) {
|
|||||||
#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);
|
||||||
@ -3826,6 +3837,7 @@ 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 |
|
||||||
@ -3856,6 +3868,7 @@ int UnitTest::Run() {
|
|||||||
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
|
||||||
|
|
||||||
@ -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);
|
||||||
|
@ -195,9 +195,13 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,8 +454,10 @@ TEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) {
|
|||||||
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);
|
||||||
@ -569,11 +575,15 @@ TEST_F(TestForDeathTest, TestExpectDebugDeath) {
|
|||||||
"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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -595,11 +605,15 @@ TEST_F(TestForDeathTest, TestAssertDebugDeath) {
|
|||||||
}, "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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,11 +669,14 @@ static void TestExitMacros() {
|
|||||||
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,6 +684,7 @@ 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
|
||||||
|
@ -92,12 +92,16 @@ TEST(GetCurrentDirTest, ReturnsCurrentDir) {
|
|||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,8 +420,10 @@ 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());
|
||||||
|
@ -328,9 +328,13 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ int main(int argc, char **argv) {
|
|||||||
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,6 +78,7 @@ 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
|
||||||
|
|
||||||
|
@ -322,11 +322,14 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3693,6 +3696,7 @@ 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),
|
||||||
@ -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,15 +3843,21 @@ 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);
|
||||||
@ -3926,11 +3938,13 @@ 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");
|
||||||
@ -3948,6 +3962,7 @@ TEST(HRESULTAssertionTest, Streaming) {
|
|||||||
"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",
|
||||||
@ -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, \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user