Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
ffeb11d1
Commit
ffeb11d1
authored
Feb 22, 2011
by
zhanyong.wan
Browse files
Indents preprocessor directives.
parent
0980b4bd
Changes
35
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
289 additions
and
221 deletions
+289
-221
src/gtest-internal-inl.h
src/gtest-internal-inl.h
+15
-9
src/gtest-port.cc
src/gtest-port.cc
+16
-15
src/gtest-printers.cc
src/gtest-printers.cc
+3
-3
src/gtest.cc
src/gtest.cc
+68
-53
test/gtest-death-test_ex_test.cc
test/gtest-death-test_ex_test.cc
+9
-9
test/gtest-death-test_test.cc
test/gtest-death-test_test.cc
+73
-55
test/gtest-filepath_test.cc
test/gtest-filepath_test.cc
+13
-7
test/gtest-options_test.cc
test/gtest-options_test.cc
+2
-2
test/gtest-param-test_test.cc
test/gtest-param-test_test.cc
+16
-16
test/gtest-port_test.cc
test/gtest-port_test.cc
+9
-5
test/gtest-printers_test.cc
test/gtest-printers_test.cc
+4
-4
test/gtest_break_on_failure_unittest_.cc
test/gtest_break_on_failure_unittest_.cc
+6
-4
test/gtest_catch_exceptions_test_.cc
test/gtest_catch_exceptions_test_.cc
+3
-3
test/gtest_output_test_.cc
test/gtest_output_test_.cc
+7
-7
test/gtest_unittest.cc
test/gtest_unittest.cc
+45
-29
No files found.
src/gtest-internal-inl.h
View file @
ffeb11d1
...
...
@@ -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
...
...
src/gtest-port.cc
View file @
ffeb11d1
...
...
@@ -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
;
...
...
src/gtest-printers.cc
View file @
ffeb11d1
...
...
@@ -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.
...
...
src/gtest.cc
View file @
ffeb11d1
...
...
@@ -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
);
...
...
test/gtest-death-test_ex_test.cc
View file @
ffeb11d1
...
...
@@ -36,15 +36,15 @@
#if GTEST_HAS_DEATH_TEST
#if GTEST_HAS_SEH
#include <windows.h> // For RaiseException().
#endif
#
if GTEST_HAS_SEH
#
include <windows.h> // For RaiseException().
#
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
// exceptions do not escape death test macros.
...
...
@@ -71,9 +71,9 @@ TEST(CxxExceptionDeathTest, PrintsMessageForStdExceptions) {
EXPECT_NONFATAL_FAILURE
(
EXPECT_DEATH
(
throw
TestException
(),
""
),
"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
// catch_exceptions flag does not interfere with SEH exceptions being
// treated as death by death tests.
...
...
@@ -82,7 +82,7 @@ TEST(SehExceptionDeasTest, CatchExceptionsDoesNotInterfere) {
<<
"with catch_exceptions "
<<
(
testing
::
GTEST_FLAG
(
catch_exceptions
)
?
"enabled"
:
"disabled"
);
}
#endif
#
endif
#endif // GTEST_HAS_DEATH_TEST
...
...
test/gtest-death-test_test.cc
View file @
ffeb11d1
...
...
@@ -40,28 +40,28 @@ using testing::internal::AlwaysTrue;
#if GTEST_HAS_DEATH_TEST
#if GTEST_OS_WINDOWS
#include <direct.h> // For chdir().
#else
#include <unistd.h>
#include <sys/wait.h> // For waitpid.
#include <limits> // For std::numeric_limits.
#endif // GTEST_OS_WINDOWS
#
if GTEST_OS_WINDOWS
#
include <direct.h> // For chdir().
#
else
#
include <unistd.h>
#
include <sys/wait.h> // For waitpid.
#
include <limits> // For std::numeric_limits.
#
endif // GTEST_OS_WINDOWS
#include <limits.h>
#include <signal.h>
#include <stdio.h>
#
include <limits.h>
#
include <signal.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
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
// his code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
#
define GTEST_IMPLEMENTATION_ 1
#
include "src/gtest-internal-inl.h"
#
undef GTEST_IMPLEMENTATION_
namespace
posix
=
::
testing
::
internal
::
posix
;
...
...
@@ -195,13 +195,17 @@ void DeathTestSubroutine() {
// Death in dbg, not opt.
int
DieInDebugElse12
(
int
*
sideeffect
)
{
if
(
sideeffect
)
*
sideeffect
=
12
;
#ifndef NDEBUG
# ifndef NDEBUG
DieInside
(
"DieInDebugElse12"
);
#endif // NDEBUG
# endif // NDEBUG
return
12
;
}
#if GTEST_OS_WINDOWS
#
if GTEST_OS_WINDOWS
// Tests the ExitedWithCode predicate.
TEST
(
ExitStatusPredicateTest
,
ExitedWithCode
)
{
...
...
@@ -214,7 +218,7 @@ TEST(ExitStatusPredicateTest, ExitedWithCode) {
EXPECT_FALSE
(
testing
::
ExitedWithCode
(
1
)(
0
));
}
#else
#
else
// Returns the exit status of a process that calls _exit(2) with a
// given exit code. This is a helper function for the
...
...
@@ -273,7 +277,7 @@ TEST(ExitStatusPredicateTest, KilledBySignal) {
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
// be followed by operator<<, and that in either case the complete text
...
...
@@ -305,7 +309,7 @@ void DieWithEmbeddedNul() {
_exit
(
1
);
}
#if GTEST_USES_PCRE
#
if GTEST_USES_PCRE
// Tests that EXPECT_DEATH and ASSERT_DEATH work when the error
// message has a NUL character in it.
TEST_F
(
TestForDeathTest
,
EmbeddedNulInMessage
)
{
...
...
@@ -314,17 +318,17 @@ TEST_F(TestForDeathTest, EmbeddedNulInMessage) {
EXPECT_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
// statements.
TEST_F
(
TestForDeathTest
,
SwitchStatement
)
{
// Microsoft compiler usually complains about switch statements without
// case labels. We suppress that warning for this test.
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4065)
#endif // _MSC_VER
#
ifdef _MSC_VER
#
pragma warning(push)
#
pragma warning(disable: 4065)
#
endif // _MSC_VER
switch
(
0
)
default:
...
...
@@ -334,9 +338,9 @@ TEST_F(TestForDeathTest, SwitchStatement) {
case
0
:
EXPECT_DEATH
(
_exit
(
1
),
""
)
<<
"exit in switch case"
;
#ifdef _MSC_VER
#pragma warning(pop)
#endif // _MSC_VER
#
ifdef _MSC_VER
#
pragma warning(pop)
#
endif // _MSC_VER
}
// Tests that a static member function can be used in a "fast" style
...
...
@@ -415,7 +419,7 @@ void SetPthreadFlag() {
}
// namespace
#if GTEST_HAS_CLONE && GTEST_HAS_PTHREAD
#
if GTEST_HAS_CLONE && GTEST_HAS_PTHREAD
TEST_F
(
TestForDeathTest
,
DoesNotExecuteAtforkHooks
)
{
if
(
!
testing
::
GTEST_FLAG
(
death_test_use_fork
))
{
...
...
@@ -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.
TEST_F
(
TestForDeathTest
,
MethodOfAnotherClass
)
{
...
...
@@ -449,10 +453,12 @@ TEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) {
const
testing
::
internal
::
RE
regex
(
regex_c_str
);
EXPECT_DEATH
(
GlobalFunction
(),
regex
);
#if GTEST_HAS_GLOBAL_STRING
# if GTEST_HAS_GLOBAL_STRING
const
string
regex_str
(
regex_c_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
);
EXPECT_DEATH
(
GlobalFunction
(),
regex_std_str
);
...
...
@@ -568,13 +574,17 @@ TEST_F(TestForDeathTest, TestExpectDebugDeath) {
EXPECT_DEBUG_DEATH
(
DieInDebugElse12
(
&
sideeffect
),
"death.*DieInDebugElse12"
);
#ifdef NDEBUG
# ifdef NDEBUG
// Checks that the assignment occurs in opt mode (sideeffect).
EXPECT_EQ
(
12
,
sideeffect
);
#else
# else
// Checks that the assignment does not occur in dbg mode (no sideeffect).
EXPECT_EQ
(
0
,
sideeffect
);
#endif
# endif
}
// Tests that ASSERT_DEBUG_DEATH works as expected
...
...
@@ -594,16 +604,20 @@ TEST_F(TestForDeathTest, TestAssertDebugDeath) {
EXPECT_EQ
(
12
,
sideeffect
);
},
"death.*DieInDebugElse12"
);
#ifdef NDEBUG
# ifdef NDEBUG
// Checks that the assignment occurs in opt mode (sideeffect).
EXPECT_EQ
(
12
,
sideeffect
);
#else
# else
// Checks that the assignment does not occur in dbg mode (no sideeffect).
EXPECT_EQ
(
0
,
sideeffect
);
#endif
# endif
}
#ifndef NDEBUG
#
ifndef NDEBUG
void
ExpectDebugDeathHelper
(
bool
*
aborted
)
{
*
aborted
=
true
;
...
...
@@ -611,7 +625,7 @@ void ExpectDebugDeathHelper(bool* aborted) {
*
aborted
=
false
;
}
#if GTEST_OS_WINDOWS
#
if GTEST_OS_WINDOWS
TEST
(
PopUpDeathTest
,
DoesNotShowPopUpOnAbort
)
{
printf
(
"This test should be considered failing if it shows "
"any pop-up dialogs.
\n
"
);
...
...
@@ -622,7 +636,7 @@ TEST(PopUpDeathTest, DoesNotShowPopUpOnAbort) {
abort
();
},
""
);
}
#endif // GTEST_OS_WINDOWS
#
endif // GTEST_OS_WINDOWS
// Tests that EXPECT_DEBUG_DEATH in debug mode does not abort
// the function.
...
...
@@ -647,19 +661,22 @@ TEST_F(TestForDeathTest, AssertDebugDeathAborts) {
EXPECT_TRUE
(
aborted
);
}
#endif // _NDEBUG
#
endif // _NDEBUG
// Tests the *_EXIT family of macros, using a variety of predicates.
static
void
TestExitMacros
()
{
EXPECT_EXIT
(
_exit
(
1
),
testing
::
ExitedWithCode
(
1
),
""
);
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
// are documented on Windows.
// See http://msdn.microsoft.com/en-us/library/dwwzkt4c(VS.71).aspx.
EXPECT_EXIT
(
raise
(
SIGABRT
),
testing
::
ExitedWithCode
(
3
),
""
);
#else
# else
EXPECT_EXIT
(
raise
(
SIGKILL
),
testing
::
KilledBySignal
(
SIGKILL
),
""
)
<<
"foo"
;
ASSERT_EXIT
(
raise
(
SIGUSR2
),
testing
::
KilledBySignal
(
SIGUSR2
),
""
)
<<
"bar"
;
...
...
@@ -667,7 +684,8 @@ static void TestExitMacros() {
ASSERT_EXIT
(
_exit
(
0
),
testing
::
KilledBySignal
(
SIGSEGV
),
""
)
<<
"This failure is expected, too."
;
},
"This failure is expected, too."
);
#endif // GTEST_OS_WINDOWS
# endif // GTEST_OS_WINDOWS
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_EXIT
(
raise
(
SIGSEGV
),
testing
::
ExitedWithCode
(
0
),
""
)
...
...
@@ -1022,7 +1040,7 @@ TEST(GetLastErrnoDescription, GetLastErrnoDescriptionWorks) {
EXPECT_STREQ
(
""
,
GetLastErrnoDescription
().
c_str
());
}
#if GTEST_OS_WINDOWS
#
if GTEST_OS_WINDOWS
TEST
(
AutoHandleTest
,
AutoHandleWorks
)
{
HANDLE
handle
=
::
CreateEvent
(
NULL
,
FALSE
,
FALSE
,
NULL
);
ASSERT_NE
(
INVALID_HANDLE_VALUE
,
handle
);
...
...
@@ -1047,21 +1065,21 @@ TEST(AutoHandleTest, AutoHandleWorks) {
testing
::
internal
::
AutoHandle
auto_handle2
;
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
signed
__int64
BiggestSignedParsable
;
const
BiggestParsable
kBiggestParsableMax
=
ULLONG_MAX
;
const
BiggestSignedParsable
kBiggestSignedParsableMax
=
LLONG_MAX
;
#else
#
else
typedef
unsigned
long
long
BiggestParsable
;
typedef
signed
long
long
BiggestSignedParsable
;
const
BiggestParsable
kBiggestParsableMax
=
::
std
::
numeric_limits
<
BiggestParsable
>::
max
();
const
BiggestSignedParsable
kBiggestSignedParsableMax
=
::
std
::
numeric_limits
<
BiggestSignedParsable
>::
max
();
#endif // GTEST_OS_WINDOWS
#
endif // GTEST_OS_WINDOWS
TEST
(
ParseNaturalNumberTest
,
RejectsInvalidFormat
)
{
BiggestParsable
result
=
0
;
...
...
@@ -1147,14 +1165,14 @@ TEST(ParseNaturalNumberTest, WorksForShorterIntegers) {
EXPECT_EQ
(
123
,
char_result
);
}
#if GTEST_OS_WINDOWS
#
if GTEST_OS_WINDOWS
TEST
(
EnvironmentTest
,
HandleFitsIntoSizeT
)
{
// TODO(vladl@google.com): Remove this test after this condition is verified
// in a static assertion in gtest-death-test.cc in the function
// GetStatusFileDescriptor.
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
// failures when death tests are available on the system.
...
...
@@ -1253,8 +1271,8 @@ TEST(ConditionalDeathMacrosSyntaxDeathTest, SwitchStatement) {
// Microsoft compiler usually complains about switch statements without
// case labels. We suppress that warning for this test.
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4065)
#
pragma warning(push)
#
pragma warning(disable: 4065)
#endif // _MSC_VER
switch
(
0
)
...
...
@@ -1267,7 +1285,7 @@ TEST(ConditionalDeathMacrosSyntaxDeathTest, SwitchStatement) {
EXPECT_DEATH_IF_SUPPORTED
(
_exit
(
1
),
""
)
<<
"exit in switch case"
;
#ifdef _MSC_VER
#pragma warning(pop)
#
pragma warning(pop)
#endif // _MSC_VER
}
...
...
test/gtest-filepath_test.cc
View file @
ffeb11d1
...
...
@@ -51,9 +51,9 @@
#undef GTEST_IMPLEMENTATION_
#if GTEST_OS_WINDOWS_MOBILE
#include <windows.h> // NOLINT
#
include <windows.h> // NOLINT
#elif GTEST_OS_WINDOWS
#include <direct.h> // NOLINT
#
include <direct.h> // NOLINT
#endif // GTEST_OS_WINDOWS_MOBILE
namespace
testing
{
...
...
@@ -91,14 +91,18 @@ TEST(GetCurrentDirTest, ReturnsCurrentDir) {
const
FilePath
cwd
=
FilePath
::
GetCurrentDir
();
posix
::
ChDir
(
original_dir
.
c_str
());
#if GTEST_OS_WINDOWS
# if GTEST_OS_WINDOWS
// Skips the ":".
const
char
*
const
cwd_without_drive
=
strchr
(
cwd
.
c_str
(),
':'
);
ASSERT_TRUE
(
cwd_without_drive
!=
NULL
);
EXPECT_STREQ
(
GTEST_PATH_SEP_
,
cwd_without_drive
+
1
);
#else
# else
EXPECT_STREQ
(
GTEST_PATH_SEP_
,
cwd
.
c_str
());
#endif
# endif
}
#endif // GTEST_OS_WINDOWS_MOBILE
...
...
@@ -415,10 +419,12 @@ TEST(DirectoryTest, EmptyPathDirectoryDoesNotExist) {
TEST
(
DirectoryTest
,
CurrentDirectoryExists
)
{
#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
());
#endif // _WIN32_CE
# endif // _WIN32_CE
#else
EXPECT_TRUE
(
FilePath
(
"."
).
DirectoryExists
());
EXPECT_TRUE
(
FilePath
(
"./"
).
DirectoryExists
());
...
...
test/gtest-options_test.cc
View file @
ffeb11d1
...
...
@@ -41,9 +41,9 @@
#include "gtest/gtest.h"
#if GTEST_OS_WINDOWS_MOBILE
#include <windows.h>
#
include <windows.h>
#elif GTEST_OS_WINDOWS
#include <direct.h>
#
include <direct.h>
#endif // GTEST_OS_WINDOWS_MOBILE
// Indicates that this translation unit is part of Google Test's
...
...
test/gtest-param-test_test.cc
View file @
ffeb11d1
...
...
@@ -37,19 +37,19 @@
#if GTEST_HAS_PARAM_TEST
#include <algorithm>
#include <iostream>
#include <list>
#include <sstream>
#include <string>
#include <vector>
#
include <algorithm>
#
include <iostream>
#
include <list>
#
include <sstream>
#
include <string>
#
include <vector>
// To include gtest-internal-inl.h.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" // for UnitTestOptions
#undef GTEST_IMPLEMENTATION_
#
define GTEST_IMPLEMENTATION_ 1
#
include "src/gtest-internal-inl.h" // for UnitTestOptions
#
undef GTEST_IMPLEMENTATION_
#include "test/gtest-param-test_test.h"
#
include "test/gtest-param-test_test.h"
using
::
std
::
vector
;
using
::
std
::
sort
;
...
...
@@ -62,12 +62,12 @@ using ::testing::TestWithParam;
using
::
testing
::
Values
;
using
::
testing
::
ValuesIn
;
#if GTEST_HAS_COMBINE
#
if GTEST_HAS_COMBINE
using
::
testing
::
Combine
;
using
::
std
::
tr1
::
get
;
using
::
std
::
tr1
::
make_tuple
;
using
::
std
::
tr1
::
tuple
;
#endif // GTEST_HAS_COMBINE
#
endif // GTEST_HAS_COMBINE
using
::
testing
::
internal
::
ParamGenerator
;
using
::
testing
::
internal
::
UnitTestOptions
;
...
...
@@ -85,7 +85,7 @@ template <typename T>
return
stream
.
str
();
}
#if GTEST_HAS_COMBINE
#
if GTEST_HAS_COMBINE
// These overloads allow printing tuples in our tests. We cannot
// 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,
return
stream
.
str
();
}
#endif // GTEST_HAS_COMBINE
#
endif // GTEST_HAS_COMBINE
// Verifies that a sequence generated by the generator and accessed
// via the iterator object matches the expected one using Google Test
...
...
@@ -457,7 +457,7 @@ TEST(BoolTest, BoolWorks) {
VerifyGenerator
(
gen
,
expected_values
);
}
#if GTEST_HAS_COMBINE
#
if GTEST_HAS_COMBINE
// Tests that Combine() with two parameters generates the expected sequence.
TEST
(
CombineTest
,
CombineWithTwoParameters
)
{
...
...
@@ -542,7 +542,7 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) {
VerifyGenerator
(
gen
,
expected_values
);
}
#endif // GTEST_HAS_COMBINE
#
endif // GTEST_HAS_COMBINE
// Tests that an generator produces correct sequence after being
// assigned from another generator.
...
...
test/gtest-port_test.cc
View file @
ffeb11d1
...
...
@@ -36,7 +36,7 @@
#include <stdio.h>
#if GTEST_OS_MAC
#include <time.h>
#
include <time.h>
#endif // GTEST_OS_MAC
#include <utility> // For std::pair and std::make_pair.
...
...
@@ -328,15 +328,19 @@ TEST(GtestCheckDeathTest, LivesSilentlyOnSuccess) {
// For simplicity, we only cover the most important platforms here.
TEST
(
RegexEngineSelectionTest
,
SelectsCorrectRegexEngine
)
{
#if GTEST_HAS_POSIX_RE
EXPECT_TRUE
(
GTEST_USES_POSIX_RE
);
#else
EXPECT_TRUE
(
GTEST_USES_SIMPLE_RE
);
#endif
}
#if GTEST_USES_POSIX_RE
#if GTEST_HAS_TYPED_TEST
#
if GTEST_HAS_TYPED_TEST
template
<
typename
Str
>
class
RETest
:
public
::
testing
::
Test
{};
...
...
@@ -345,9 +349,9 @@ class RETest : public ::testing::Test {};
// supports.
typedef
testing
::
Types
<
::
std
::
string
,
#if GTEST_HAS_GLOBAL_STRING
#
if GTEST_HAS_GLOBAL_STRING
::
string
,
#endif // GTEST_HAS_GLOBAL_STRING
#
endif // GTEST_HAS_GLOBAL_STRING
const
char
*>
StringTypes
;
TYPED_TEST_CASE
(
RETest
,
StringTypes
);
...
...
@@ -398,7 +402,7 @@ TYPED_TEST(RETest, PartialMatchWorks) {
EXPECT_FALSE
(
RE
::
PartialMatch
(
TypeParam
(
"zza"
),
re
));
}
#endif // GTEST_HAS_TYPED_TEST
#
endif // GTEST_HAS_TYPED_TEST
#elif GTEST_USES_SIMPLE_RE
...
...
test/gtest-printers_test.cc
View file @
ffeb11d1
...
...
@@ -52,10 +52,10 @@
// hash_map and hash_set are available under Visual C++.
#if _MSC_VER
#define GTEST_HAS_HASH_MAP_ 1 // Indicates that hash_map is available.
#include <hash_map> // NOLINT
#define GTEST_HAS_HASH_SET_ 1 // Indicates that hash_set is available.
#include <hash_set> // NOLINT
#
define GTEST_HAS_HASH_MAP_ 1 // Indicates that hash_map is available.
#
include <hash_map> // NOLINT
#
define GTEST_HAS_HASH_SET_ 1 // Indicates that hash_set is available.
#
include <hash_set> // NOLINT
#endif // GTEST_OS_WINDOWS
// Some user-defined types for testing the universal value printer.
...
...
test/gtest_break_on_failure_unittest_.cc
View file @
ffeb11d1
...
...
@@ -42,8 +42,8 @@
#include "gtest/gtest.h"
#if GTEST_OS_WINDOWS
#include <windows.h>
#include <stdlib.h>
#
include <windows.h>
#
include <stdlib.h>
#endif
namespace
{
...
...
@@ -69,7 +69,8 @@ int main(int argc, char **argv) {
// a general protection fault (segment violation).
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
// with the exception code as exit code - for example it exits with
// 0 for EXCEPTION_ACCESS_VIOLATION and 1 for EXCEPTION_BREAKPOINT
...
...
@@ -77,7 +78,8 @@ int main(int argc, char **argv) {
// filter which always exits with the exception code for unhandled
// exceptions.
SetUnhandledExceptionFilter
(
ExitWithExceptionCode
);
#endif
# endif
#endif
testing
::
InitGoogleTest
(
&
argc
,
argv
);
...
...
test/gtest_catch_exceptions_test_.cc
View file @
ffeb11d1
...
...
@@ -38,12 +38,12 @@
#include <stdlib.h> // For exit().
#if GTEST_HAS_SEH
#include <windows.h>
#
include <windows.h>
#endif
#if GTEST_HAS_EXCEPTIONS
#include <exception> // For set_terminate().
#include <stdexcept>
#
include <exception> // For set_terminate().
#
include <stdexcept>
#endif
using
testing
::
Test
;
...
...
test/gtest_output_test_.cc
View file @
ffeb11d1
...
...
@@ -788,7 +788,7 @@ INSTANTIATE_TYPED_TEST_CASE_P(Unsigned, TypedTestP, UnsignedTypes);
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
// case name ends with DeathTest are run first.
...
...
@@ -803,9 +803,9 @@ TYPED_TEST_CASE(ATypedDeathTest, NumericTypes);
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
...
...
@@ -824,7 +824,7 @@ REGISTER_TYPED_TEST_CASE_P(ATypeParamDeathTest, ShouldRunFirst);
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
...
...
@@ -998,11 +998,11 @@ int main(int argc, char **argv) {
if
(
testing
::
internal
::
GTEST_FLAG
(
internal_run_death_test
)
!=
""
)
{
// Skip the usual output capturing if we're running as the child
// process of an threadsafe-style death test.
#if GTEST_OS_WINDOWS
#
if GTEST_OS_WINDOWS
posix
::
FReopen
(
"nul:"
,
"w"
,
stdout
);
#else
#
else
posix
::
FReopen
(
"/dev/null"
,
"w"
,
stdout
);
#endif // GTEST_OS_WINDOWS
#
endif // GTEST_OS_WINDOWS
return
RUN_ALL_TESTS
();
}
#endif // GTEST_HAS_DEATH_TEST
...
...
test/gtest_unittest.cc
View file @
ffeb11d1
...
...
@@ -310,10 +310,10 @@ TEST(FormatTimeInMillisAsSecondsTest, FormatsNegativeNumber) {
#if GTEST_CAN_COMPARE_NULL
#ifdef __BORLANDC__
#
ifdef __BORLANDC__
// Silences warnings: "Condition is always true", "Unreachable code"
#pragma option push -w-ccc -w-rch
#endif
#
pragma option push -w-ccc -w-rch
#
endif
// Tests that GTEST_IS_NULL_LITERAL_(x) is true when x is a null
// pointer literal.
...
...
@@ -322,12 +322,15 @@ TEST(NullLiteralTest, IsTrueForNullLiterals) {
EXPECT_TRUE
(
GTEST_IS_NULL_LITERAL_
(
0
));
EXPECT_TRUE
(
GTEST_IS_NULL_LITERAL_
(
0U
));
EXPECT_TRUE
(
GTEST_IS_NULL_LITERAL_
(
0L
));
#ifndef __BORLANDC__
# ifndef __BORLANDC__
// Some compilers may fail to detect some null pointer literals;
// as long as users of the framework don't use such literals, this
// is harmless.
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
...
...
@@ -339,10 +342,10 @@ TEST(NullLiteralTest, IsFalseForNonNullLiterals) {
EXPECT_FALSE
(
GTEST_IS_NULL_LITERAL_
(
static_cast
<
void
*>
(
NULL
)));
}
#ifdef __BORLANDC__
#
ifdef __BORLANDC__
// Restores warnings after previous "#pragma option push" suppressed them.
#pragma option pop
#endif
#
pragma option pop
#
endif
#endif // GTEST_CAN_COMPARE_NULL
//
...
...
@@ -1211,7 +1214,7 @@ TEST(StringTest, ShowWideCStringQuoted) {
String
::
ShowWideCStringQuoted
(
L"foo"
).
c_str
());
}
#if GTEST_OS_WINDOWS_MOBILE
#
if GTEST_OS_WINDOWS_MOBILE
TEST
(
StringTest
,
AnsiAndUtf16Null
)
{
EXPECT_EQ
(
NULL
,
String
::
AnsiToUtf16
(
NULL
));
EXPECT_EQ
(
NULL
,
String
::
Utf16ToAnsi
(
NULL
));
...
...
@@ -1234,7 +1237,7 @@ TEST(StringTest, AnsiAndUtf16ConvertPathChars) {
EXPECT_EQ
(
0
,
wcsncmp
(
L".:
\\
\"
*?"
,
utf16
,
3
));
delete
[]
utf16
;
}
#endif // GTEST_OS_WINDOWS_MOBILE
#
endif // GTEST_OS_WINDOWS_MOBILE
#endif // GTEST_OS_WINDOWS
...
...
@@ -1368,7 +1371,7 @@ TEST_F(ExpectFatalFailureTest, CatchesFatalFailureOnAllThreads) {
#ifdef __BORLANDC__
// Silences warnings: "Condition is always true"
#pragma option push -w-ccc
#
pragma option push -w-ccc
#endif
// Tests that EXPECT_FATAL_FAILURE() can be used in a non-void
...
...
@@ -1396,7 +1399,7 @@ void DoesNotAbortHelper(bool* aborted) {
#ifdef __BORLANDC__
// Restores warnings after previous "#pragma option push" suppressed them.
#pragma option pop
#
pragma option pop
#endif
TEST_F
(
ExpectFatalFailureTest
,
DoesNotAbort
)
{
...
...
@@ -3534,7 +3537,7 @@ TEST(AssertionTest, AppendUserMessage) {
#ifdef __BORLANDC__
// Silences warnings: "Condition is always true", "Unreachable code"
#pragma option push -w-ccc -w-rch
#
pragma option push -w-ccc -w-rch
#endif
// Tests ASSERT_TRUE.
...
...
@@ -3589,7 +3592,7 @@ TEST(AssertionTest, AssertFalseWithAssertionResult) {
#ifdef __BORLANDC__
// Restores warnings after previous "#pragma option push" supressed them
#pragma option pop
#
pragma option pop
#endif
// Tests using ASSERT_EQ on double values. The purpose is to make
...
...
@@ -3692,13 +3695,14 @@ void ThrowNothing() {}
TEST
(
AssertionTest
,
ASSERT_THROW
)
{
ASSERT_THROW
(
ThrowAnInteger
(),
int
);
#ifndef __BORLANDC__
# ifndef __BORLANDC__
// ICE's in C++Builder 2007 and 2009.
EXPECT_FATAL_FAILURE
(
ASSERT_THROW
(
ThrowAnInteger
(),
bool
),
"Expected: ThrowAnInteger() throws an exception of type bool.
\n
"
" Actual: it throws a different type."
);
#endif
#
endif
EXPECT_FATAL_FAILURE
(
ASSERT_THROW
(
ThrowNothing
(),
bool
),
...
...
@@ -3826,7 +3830,9 @@ TEST(AssertionTest, NamedEnum) {
// Tests using assertions with anonymous enums.
enum
{
kCaseA
=
-
1
,
#if GTEST_OS_LINUX
# if GTEST_OS_LINUX
// 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
// assertions doesn't truncate the enums. However, MSVC
...
...
@@ -3837,16 +3843,22 @@ enum {
// int size. We want to test whether this will confuse the
// assertions.
kCaseB
=
testing
::
internal
::
kMaxBiggestInt
,
#else
# else
kCaseB
=
INT_MAX
,
#endif // GTEST_OS_LINUX
# endif // GTEST_OS_LINUX
kCaseC
=
42
,
};
TEST
(
AssertionTest
,
AnonymousEnum
)
{
#if GTEST_OS_LINUX
# if GTEST_OS_LINUX
EXPECT_EQ
(
static_cast
<
int
>
(
kCaseA
),
static_cast
<
int
>
(
kCaseB
));
#endif // GTEST_OS_LINUX
# endif // GTEST_OS_LINUX
EXPECT_EQ
(
kCaseA
,
kCaseA
);
EXPECT_NE
(
kCaseA
,
kCaseB
);
...
...
@@ -3925,12 +3937,14 @@ TEST(HRESULTAssertionTest, EXPECT_HRESULT_FAILED) {
TEST
(
HRESULTAssertionTest
,
ASSERT_HRESULT_FAILED
)
{
ASSERT_HRESULT_FAILED
(
E_UNEXPECTED
);
#ifndef __BORLANDC__
# ifndef __BORLANDC__
// ICE's in C++Builder 2007 and 2009.
EXPECT_FATAL_FAILURE
(
ASSERT_HRESULT_FAILED
(
OkHRESULTSuccess
()),
"Expected: (OkHRESULTSuccess()) fails.
\n
"
" Actual: 0x00000000"
);
#endif
# endif
EXPECT_FATAL_FAILURE
(
ASSERT_HRESULT_FAILED
(
FalseHRESULTSuccess
()),
"Expected: (FalseHRESULTSuccess()) fails.
\n
"
" Actual: 0x00000001"
);
...
...
@@ -3947,12 +3961,13 @@ TEST(HRESULTAssertionTest, Streaming) {
EXPECT_HRESULT_SUCCEEDED
(
E_UNEXPECTED
)
<<
"expected failure"
,
"expected failure"
);
#ifndef __BORLANDC__
# ifndef __BORLANDC__
// ICE's in C++Builder 2007 and 2009.
EXPECT_FATAL_FAILURE
(
ASSERT_HRESULT_SUCCEEDED
(
E_UNEXPECTED
)
<<
"expected failure"
,
"expected failure"
);
#endif
#
endif
EXPECT_NONFATAL_FAILURE
(
EXPECT_HRESULT_FAILED
(
S_OK
)
<<
"expected failure"
,
...
...
@@ -3967,7 +3982,7 @@ TEST(HRESULTAssertionTest, Streaming) {
#ifdef __BORLANDC__
// Silences warnings: "Condition is always true", "Unreachable code"
#pragma option push -w-ccc -w-rch
#
pragma option push -w-ccc -w-rch
#endif
// Tests that the assertion macros behave like single statements.
...
...
@@ -4188,7 +4203,7 @@ TEST(ExpectTest, ExpectFalseWithAssertionResult) {
#ifdef __BORLANDC__
// Restores warnings after previous "#pragma option push" supressed them
#pragma option pop
#
pragma option pop
#endif
// Tests EXPECT_EQ.
...
...
@@ -5426,6 +5441,7 @@ class InitGoogleTestTest : public Test {
// This macro wraps TestParsingFlags s.t. the user doesn't need
// to specify the array sizes.
#define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help) \
TestParsingFlags(sizeof(argv1)/sizeof(*argv1) - 1, argv1, \
sizeof(argv2)/sizeof(*argv2) - 1, argv2, \
...
...
@@ -6239,7 +6255,7 @@ TEST(StreamingAssertionsTest, Unconditional) {
#ifdef __BORLANDC__
// Silences warnings: "Condition is always true", "Unreachable code"
#pragma option push -w-ccc -w-rch
#
pragma option push -w-ccc -w-rch
#endif
TEST
(
StreamingAssertionsTest
,
Truth
)
{
...
...
@@ -6262,7 +6278,7 @@ TEST(StreamingAssertionsTest, Truth2) {
#ifdef __BORLANDC__
// Restores warnings after previous "#pragma option push" supressed them
#pragma option pop
#
pragma option pop
#endif
TEST
(
StreamingAssertionsTest
,
IntegerEquals
)
{
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment