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
0af0709b
Commit
0af0709b
authored
Feb 23, 2009
by
zhanyong.wan
Browse files
Cleans up macro definitions.
parent
3c7868a9
Changes
42
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
208 additions
and
201 deletions
+208
-201
src/gtest-port.cc
src/gtest-port.cc
+7
-6
src/gtest-test-part.cc
src/gtest-test-part.cc
+2
-2
src/gtest-typed-test.cc
src/gtest-typed-test.cc
+1
-1
src/gtest.cc
src/gtest.cc
+55
-55
test/gtest-death-test_test.cc
test/gtest-death-test_test.cc
+3
-3
test/gtest-filepath_test.cc
test/gtest-filepath_test.cc
+88
-82
test/gtest-options_test.cc
test/gtest-options_test.cc
+9
-9
test/gtest-param-test2_test.cc
test/gtest-param-test2_test.cc
+1
-1
test/gtest-param-test_test.cc
test/gtest-param-test_test.cc
+7
-7
test/gtest-param-test_test.h
test/gtest-param-test_test.h
+1
-1
test/gtest-port_test.cc
test/gtest-port_test.cc
+3
-3
test/gtest-test-part_test.cc
test/gtest-test-part_test.cc
+1
-1
test/gtest-typed-test2_test.cc
test/gtest-typed-test2_test.cc
+1
-1
test/gtest-typed-test_test.cc
test/gtest-typed-test_test.cc
+3
-3
test/gtest-typed-test_test.h
test/gtest-typed-test_test.h
+1
-1
test/gtest_break_on_failure_unittest_.cc
test/gtest_break_on_failure_unittest_.cc
+2
-2
test/gtest_env_var_test_.cc
test/gtest_env_var_test_.cc
+2
-2
test/gtest_filter_unittest_.cc
test/gtest_filter_unittest_.cc
+3
-3
test/gtest_output_test_.cc
test/gtest_output_test_.cc
+10
-10
test/gtest_repeat_test.cc
test/gtest_repeat_test.cc
+8
-8
No files found.
src/gtest-port.cc
View file @
0af0709b
...
...
@@ -35,7 +35,7 @@
#include <stdlib.h>
#include <stdio.h>
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
#include <regex.h>
#endif // GTEST_HAS_DEATH_TEST
...
...
@@ -56,9 +56,9 @@
// 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
#define GTEST_IMPLEMENTATION
_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION
#undef GTEST_IMPLEMENTATION
_
namespace
testing
{
namespace
internal
{
...
...
@@ -334,7 +334,7 @@ bool RE::PartialMatch(const char* str, const RE& re) {
void
RE
::
Init
(
const
char
*
regex
)
{
pattern_
=
full_pattern_
=
NULL
;
if
(
regex
!=
NULL
)
{
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
pattern_
=
_strdup
(
regex
);
#else
pattern_
=
strdup
(
regex
);
...
...
@@ -383,7 +383,7 @@ void GTestLog(GTestLogSeverity severity, const char* file,
}
}
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
// Defines the stderr capturer.
...
...
@@ -502,7 +502,8 @@ void abort() {
// given flag. For example, FlagToEnvVar("foo") will return
// "GTEST_FOO" in the open-source version.
static
String
FlagToEnvVar
(
const
char
*
flag
)
{
const
String
full_flag
=
(
Message
()
<<
GTEST_FLAG_PREFIX
<<
flag
).
GetString
();
const
String
full_flag
=
(
Message
()
<<
GTEST_FLAG_PREFIX_
<<
flag
).
GetString
();
Message
env_var
;
for
(
int
i
=
0
;
i
!=
full_flag
.
GetLength
();
i
++
)
{
...
...
src/gtest-test-part.cc
View file @
0af0709b
...
...
@@ -38,9 +38,9 @@
// 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
#define GTEST_IMPLEMENTATION
_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION
#undef GTEST_IMPLEMENTATION
_
namespace
testing
{
...
...
src/gtest-typed-test.cc
View file @
0af0709b
...
...
@@ -35,7 +35,7 @@
namespace
testing
{
namespace
internal
{
#if
def
GTEST_HAS_TYPED_TEST_P
#if GTEST_HAS_TYPED_TEST_P
// Verifies that registered_tests match the test names in
// defined_test_names_; returns registered_tests if successful, or
...
...
src/gtest.cc
View file @
0af0709b
...
...
@@ -43,11 +43,11 @@
#include <wchar.h>
#include <wctype.h>
#if
def
GTEST_OS_LINUX
#if GTEST_OS_LINUX
// TODO(kenton@google.com): Use autoconf to detect availability of
// gettimeofday().
#define GTEST_HAS_GETTIMEOFDAY
#define GTEST_HAS_GETTIMEOFDAY
_ 1
#include <fcntl.h>
#include <limits.h>
...
...
@@ -60,12 +60,12 @@
#include <string>
#include <vector>
#elif
defined(
GTEST_OS_SYMBIAN
)
#define GTEST_HAS_GETTIMEOFDAY
#elif GTEST_OS_SYMBIAN
#define GTEST_HAS_GETTIMEOFDAY
_ 1
#include <sys/time.h> // NOLINT
#elif
defined(
GTEST_OS_ZOS
)
#define GTEST_HAS_GETTIMEOFDAY
#elif GTEST_OS_ZOS
#define GTEST_HAS_GETTIMEOFDAY
_ 1
#include <sys/time.h> // NOLINT
// On z/OS we additionally need strings.h for strcasecmp.
...
...
@@ -75,7 +75,7 @@
#include <windows.h> // NOLINT
#elif
defined(
GTEST_OS_WINDOWS
)
// We are on Windows proper.
#elif GTEST_OS_WINDOWS // We are on Windows proper.
#include <io.h> // NOLINT
#include <sys/timeb.h> // NOLINT
...
...
@@ -89,9 +89,9 @@
// 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
#define GTEST_HAS_GETTIMEOFDAY
_ 1
#include <sys/time.h> // NOLINT
#endif
#endif
// defined(__MINGW__) || defined(__MINGW32__)
// cpplint thinks that the header is already included, so we want to
// silence it.
...
...
@@ -102,25 +102,25 @@
// Assume other platforms have gettimeofday().
// TODO(kenton@google.com): Use autoconf to detect availability of
// gettimeofday().
#define GTEST_HAS_GETTIMEOFDAY
#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
#endif
#endif
// GTEST_OS_LINUX
// 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
#define GTEST_IMPLEMENTATION
_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION
#undef GTEST_IMPLEMENTATION
_
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
#define fileno _fileno
#define isatty _isatty
#define vsnprintf _vsnprintf
...
...
@@ -173,7 +173,7 @@ GTEST_DEFINE_bool_(
GTEST_DEFINE_bool_
(
catch_exceptions
,
internal
::
BoolFromGTestEnv
(
"catch_exceptions"
,
false
),
"True iff "
GTEST_NAME
"True iff "
GTEST_NAME
_
" should catch exceptions and treat them as test failures."
);
GTEST_DEFINE_string_
(
...
...
@@ -211,7 +211,7 @@ GTEST_DEFINE_string_(
GTEST_DEFINE_bool_
(
print_time
,
internal
::
BoolFromGTestEnv
(
"print_time"
,
false
),
"True iff "
GTEST_NAME
"True iff "
GTEST_NAME
_
" should display elapsed time in text output."
);
GTEST_DEFINE_int32_
(
...
...
@@ -228,7 +228,7 @@ GTEST_DEFINE_int32_(
GTEST_DEFINE_bool_
(
show_internal_stack_frames
,
false
,
"True iff "
GTEST_NAME
" should include internal stack frames when "
"True iff "
GTEST_NAME
_
" should include internal stack frames when "
"printing test failure stack traces."
);
namespace
internal
{
...
...
@@ -302,7 +302,7 @@ String g_executable_path;
FilePath
GetCurrentExecutableName
()
{
FilePath
result
;
#if defined(_WIN32_WCE) ||
defined(
GTEST_OS_WINDOWS
)
#if defined(_WIN32_WCE) || GTEST_OS_WINDOWS
result
.
Set
(
FilePath
(
g_executable_path
).
RemoveExtension
(
"exe"
));
#else
result
.
Set
(
FilePath
(
g_executable_path
));
...
...
@@ -433,7 +433,7 @@ bool UnitTestOptions::FilterMatchesTest(const String &test_case_name,
!
MatchesFilter
(
full_name
,
negative
.
c_str
()));
}
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
// given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
// This function is useful as an __except condition.
...
...
@@ -743,7 +743,7 @@ static TimeInMillis GetTimeInMillis() {
return
now_int64
.
QuadPart
;
}
return
0
;
#elif
defined(
GTEST_OS_WINDOWS
)
&& !
defined(
GTEST_HAS_GETTIMEOFDAY
)
#elif GTEST_OS_WINDOWS && !GTEST_HAS_GETTIMEOFDAY
_
__timeb64
now
;
#ifdef _MSC_VER
// MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996
...
...
@@ -758,7 +758,7 @@ static TimeInMillis GetTimeInMillis() {
_ftime64
(
&
now
);
#endif // _MSC_VER
return
static_cast
<
TimeInMillis
>
(
now
.
time
)
*
1000
+
now
.
millitm
;
#elif
defined(
GTEST_HAS_GETTIMEOFDAY
)
#elif GTEST_HAS_GETTIMEOFDAY
_
struct
timeval
now
;
gettimeofday
(
&
now
,
NULL
);
return
static_cast
<
TimeInMillis
>
(
now
.
tv_sec
)
*
1000
+
now
.
tv_usec
/
1000
;
...
...
@@ -793,7 +793,7 @@ static char* CloneString(const char* str, size_t length) {
char
*
const
clone
=
new
char
[
length
+
1
];
// MSVC 8 deprecates strncpy(), so we want to suppress warning
// 4996 (deprecated function) there.
#if
def
GTEST_OS_WINDOWS // We are on Windows.
#if GTEST_OS_WINDOWS // We are on Windows.
#pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4996) // Temporarily disables warning 4996.
strncpy
(
clone
,
str
,
length
);
...
...
@@ -1314,7 +1314,7 @@ AssertionResult IsNotSubstring(
namespace
internal
{
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
namespace
{
...
...
@@ -1442,14 +1442,14 @@ char* CodePointToUtf8(UInt32 code_point, char* str) {
// null-terminate the destination string.
// MSVC 8 deprecates strncpy(), so we want to suppress warning
// 4996 (deprecated function) there.
#if
def
GTEST_OS_WINDOWS // We are on Windows.
#if GTEST_OS_WINDOWS // We are on Windows.
#pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4996) // Temporarily disables warning 4996.
#endif
strncpy
(
str
,
String
::
Format
(
"(Invalid Unicode 0x%X)"
,
code_point
).
c_str
(),
32
);
#if
def
GTEST_OS_WINDOWS // We are on Windows.
#pragma warning(pop)
// Restores the warning state.
#if GTEST_OS_WINDOWS // We are on Windows.
#pragma warning(pop) // Restores the warning state.
#endif
str
[
31
]
=
'\0'
;
// Makes sure no change in the format to strncpy leaves
// the result unterminated.
...
...
@@ -1592,7 +1592,7 @@ bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) {
if
(
rhs
==
NULL
)
return
false
;
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
return
_stricmp
(
lhs
,
rhs
)
==
0
;
#else // GTEST_OS_WINDOWS
return
strcasecmp
(
lhs
,
rhs
)
==
0
;
...
...
@@ -1617,9 +1617,9 @@ bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
if
(
rhs
==
NULL
)
return
false
;
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
return
_wcsicmp
(
lhs
,
rhs
)
==
0
;
#elif
defined(
GTEST_OS_LINUX
)
#elif GTEST_OS_LINUX
return
wcscasecmp
(
lhs
,
rhs
)
==
0
;
#else
// Mac OS X and Cygwin don't define wcscasecmp. Other unknown OSes
...
...
@@ -1720,7 +1720,7 @@ String String::Format(const char * format, ...) {
char
buffer
[
4096
];
// MSVC 8 deprecates vsnprintf(), so we want to suppress warning
// 4996 (deprecated function) there.
#if
def
GTEST_OS_WINDOWS // We are on Windows.
#if GTEST_OS_WINDOWS // We are on Windows.
#pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4996) // Temporarily disables warning 4996.
const
int
size
=
...
...
@@ -1827,7 +1827,7 @@ bool TestResult::ValidateTestProperty(const TestProperty& test_property) {
<<
"Reserved key used in RecordProperty(): "
<<
key
<<
" ('name', 'status', 'time', and 'classname' are reserved by "
<<
GTEST_NAME
<<
")"
;
<<
GTEST_NAME
_
<<
")"
;
return
false
;
}
return
true
;
...
...
@@ -1917,7 +1917,7 @@ void Test::RecordProperty(const char* key, int value) {
RecordProperty
(
key
,
value_message
.
GetString
().
c_str
());
}
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
// We are on Windows.
// Adds an "exception thrown" fatal failure to the current test.
...
...
@@ -2013,7 +2013,7 @@ void Test::Run() {
if
(
!
HasSameFixtureClass
())
return
;
internal
::
UnitTestImpl
*
const
impl
=
internal
::
GetUnitTestImpl
();
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
// We are on Windows.
impl
->
os_stack_trace_getter
()
->
UponLeavingGTest
();
__try
{
...
...
@@ -2122,7 +2122,7 @@ TestInfo* MakeAndRegisterTestInfo(
return
test_info
;
}
#if
def
GTEST_HAS_PARAM_TEST
#if GTEST_HAS_PARAM_TEST
void
ReportInvalidTestCaseType
(
const
char
*
test_case_name
,
const
char
*
file
,
int
line
)
{
Message
errors
;
...
...
@@ -2221,7 +2221,7 @@ namespace internal {
// and INSTANTIATE_TEST_CASE_P into regular tests and registers those.
// This will be done just once during the program runtime.
void
UnitTestImpl
::
RegisterParameterizedTests
()
{
#if
def
GTEST_HAS_PARAM_TEST
#if GTEST_HAS_PARAM_TEST
if
(
!
parameterized_tests_registered_
)
{
parameterized_test_registry_
.
RegisterTests
();
parameterized_tests_registered_
=
true
;
...
...
@@ -2247,7 +2247,7 @@ void TestInfoImpl::Run() {
const
TimeInMillis
start
=
GetTimeInMillis
();
impl
->
os_stack_trace_getter
()
->
UponLeavingGTest
();
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
// We are on Windows.
Test
*
test
=
NULL
;
...
...
@@ -2459,7 +2459,7 @@ enum GTestColor {
COLOR_YELLOW
};
#if
defined(
GTEST_OS_WINDOWS
)
&& !defined(_WIN32_WCE)
#if GTEST_OS_WINDOWS && !defined(_WIN32_WCE)
// Returns the character attribute for the given color.
WORD
GetColorAttribute
(
GTestColor
color
)
{
...
...
@@ -2490,7 +2490,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
const
char
*
const
gtest_color
=
GTEST_FLAG
(
color
).
c_str
();
if
(
String
::
CaseInsensitiveCStringEquals
(
gtest_color
,
"auto"
))
{
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
// On Windows the TERM variable is usually not set, but the
// console there does support colors.
return
stdout_is_tty
;
...
...
@@ -2522,11 +2522,11 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
va_list
args
;
va_start
(
args
,
fmt
);
#if defined(_WIN32_WCE) ||
defined(
GTEST_OS_SYMBIAN
)
||
defined(
GTEST_OS_ZOS
)
#if defined(_WIN32_WCE) || GTEST_OS_SYMBIAN || GTEST_OS_ZOS
static
const
bool
use_color
=
false
;
#else
static
const
bool
use_color
=
ShouldUseColor
(
isatty
(
fileno
(
stdout
))
!=
0
);
#endif //
!
_WIN32_WCE
#endif //
defined(
_WIN32_WCE
) || GTEST_OS_SYMBIAN || GTEST_OS_ZOS
// The '!= 0' comparison is necessary to satisfy MSVC 7.1.
if
(
!
use_color
)
{
...
...
@@ -2535,7 +2535,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
return
;
}
#if
defined(
GTEST_OS_WINDOWS
)
&& !defined(_WIN32_WCE)
#if GTEST_OS_WINDOWS && !defined(_WIN32_WCE)
const
HANDLE
stdout_handle
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
// Gets the current text color.
...
...
@@ -2553,7 +2553,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
printf
(
"
\033
[0;3%sm"
,
GetAnsiColorCode
(
color
));
vprintf
(
fmt
,
args
);
printf
(
"
\033
[m"
);
// Resets the terminal to default.
#endif // GTEST_OS_WINDOWS && !_WIN32_WCE
#endif // GTEST_OS_WINDOWS && !
defined(
_WIN32_WCE
)
va_end
(
args
);
}
...
...
@@ -2599,7 +2599,7 @@ void PrettyUnitTestResultPrinter::OnUnitTestStart(
// tests may be skipped.
if
(
!
internal
::
String
::
CStringEquals
(
filter
,
kUniversalFilter
))
{
ColoredPrintf
(
COLOR_YELLOW
,
"Note: %s filter = %s
\n
"
,
GTEST_NAME
,
filter
);
"Note: %s filter = %s
\n
"
,
GTEST_NAME
_
,
filter
);
}
if
(
internal
::
ShouldShard
(
kTestTotalShards
,
kTestShardIndex
,
false
))
{
...
...
@@ -2926,7 +2926,7 @@ void XmlUnitTestResultPrinter::OnUnitTestEnd(const UnitTest* unit_test) {
if
(
output_dir
.
CreateDirectoriesRecursively
())
{
// MSVC 8 deprecates fopen(), so we want to suppress warning 4996
// (deprecated function) there.
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
// We are on Windows.
#pragma warning(push) // Saves the current warning state.
#pragma warning(disable:4996) // Temporarily disables warning 4996.
...
...
@@ -3191,7 +3191,7 @@ void OsStackTraceGetter::UponLeavingGTest() {
const
char
*
const
OsStackTraceGetter
::
kElidedFramesMarker
=
"... "
GTEST_NAME
" internal frames ..."
;
"... "
GTEST_NAME
_
" internal frames ..."
;
}
// namespace internal
...
...
@@ -3255,7 +3255,7 @@ void UnitTest::AddTestPartResult(TestPartResultType result_type,
internal
::
MutexLock
lock
(
&
mutex_
);
if
(
impl_
->
gtest_trace_stack
()
->
size
()
>
0
)
{
msg
<<
"
\n
"
<<
GTEST_NAME
<<
" trace:"
;
msg
<<
"
\n
"
<<
GTEST_NAME
_
<<
" trace:"
;
for
(
internal
::
ListNode
<
internal
::
TraceInfo
>*
node
=
impl_
->
gtest_trace_stack
()
->
Head
();
...
...
@@ -3298,7 +3298,7 @@ void UnitTest::RecordPropertyForCurrentTest(const char* key,
// We don't protect this under mutex_, as we only support calling it
// from the main thread.
int
UnitTest
::
Run
()
{
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
#if !defined(_WIN32_WCE)
// SetErrorMode doesn't exist on CE.
...
...
@@ -3349,7 +3349,7 @@ const TestInfo* UnitTest::current_test_info() const {
return
impl_
->
current_test_info
();
}
#if
def
GTEST_HAS_PARAM_TEST
#if GTEST_HAS_PARAM_TEST
// Returns ParameterizedTestCaseRegistry object used to keep track of
// value-parameterized tests and instantiate and register them.
// L < mutex_
...
...
@@ -3404,7 +3404,7 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent)
per_thread_test_part_result_reporter_
(
&
default_per_thread_test_part_result_reporter_
),
test_cases_
(),
#if
def
GTEST_HAS_PARAM_TEST
#if GTEST_HAS_PARAM_TEST
parameterized_test_registry_
(),
parameterized_tests_registered_
(
false
),
#endif // GTEST_HAS_PARAM_TEST
...
...
@@ -3414,7 +3414,7 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent)
ad_hoc_test_result_
(),
result_printer_
(
NULL
),
os_stack_trace_getter_
(
NULL
),
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
elapsed_time_
(
0
),
internal_run_death_test_flag_
(
NULL
),
death_test_factory_
(
new
DefaultDeathTestFactory
)
{
...
...
@@ -3540,7 +3540,7 @@ int UnitTestImpl::RunAllTests() {
// death test.
bool
in_subprocess_for_death_test
=
false
;
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
internal_run_death_test_flag_
.
reset
(
ParseInternalRunDeathTestFlag
());
in_subprocess_for_death_test
=
(
internal_run_death_test_flag_
.
get
()
!=
NULL
);
#endif // GTEST_HAS_DEATH_TEST
...
...
@@ -3817,7 +3817,7 @@ UnitTestEventListenerInterface* UnitTestImpl::result_printer() {
return
result_printer_
;
}
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
if
(
internal_run_death_test_flag_
.
get
()
!=
NULL
)
{
result_printer_
=
new
NullUnitTestResultPrinter
;
return
result_printer_
;
...
...
@@ -3943,8 +3943,8 @@ const char* ParseFlagValue(const char* str,
// str and flag must not be NULL.
if
(
str
==
NULL
||
flag
==
NULL
)
return
NULL
;
// The flag must start with "--" followed by GTEST_FLAG_PREFIX.
const
String
flag_str
=
String
::
Format
(
"--%s%s"
,
GTEST_FLAG_PREFIX
,
flag
);
// The flag must start with "--" followed by GTEST_FLAG_PREFIX
_
.
const
String
flag_str
=
String
::
Format
(
"--%s%s"
,
GTEST_FLAG_PREFIX
_
,
flag
);
const
size_t
flag_len
=
flag_str
.
GetLength
();
if
(
strncmp
(
str
,
flag_str
.
c_str
(),
flag_len
)
!=
0
)
return
NULL
;
...
...
@@ -4096,7 +4096,7 @@ void InitGoogleTestImpl(int* argc, CharType** argv) {
internal
::
g_executable_path
=
internal
::
StreamableToString
(
argv
[
0
]);
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
g_argvs
.
clear
();
for
(
int
i
=
0
;
i
!=
*
argc
;
i
++
)
{
g_argvs
.
push_back
(
StreamableToString
(
argv
[
i
]));
...
...
test/gtest-death-test_test.cc
View file @
0af0709b
...
...
@@ -34,7 +34,7 @@
#include <gtest/gtest-death-test.h>
#include <gtest/gtest.h>
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
#include <stdio.h>
#include <unistd.h>
...
...
@@ -45,9 +45,9 @@
// 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
#define GTEST_IMPLEMENTATION
_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION
#undef GTEST_IMPLEMENTATION
_
using
testing
::
internal
::
DeathTest
;
using
testing
::
internal
::
DeathTestFactory
;
...
...
test/gtest-filepath_test.cc
View file @
0af0709b
...
...
@@ -46,19 +46,19 @@
// 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
#define GTEST_IMPLEMENTATION
_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION
#undef GTEST_IMPLEMENTATION
_
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
#ifdef _WIN32_WCE
#include <windows.h> // NOLINT
#else
#include <direct.h> // NOLINT
#endif // _WIN32_WCE
#define PATH_SEP "\\"
#define
GTEST_
PATH_SEP
_
"\\"
#else
#define PATH_SEP "/"
#define
GTEST_
PATH_SEP
_
"/"
#endif // GTEST_OS_WINDOWS
namespace
testing
{
...
...
@@ -90,16 +90,16 @@ int _rmdir(const char* path) {
TEST
(
GetCurrentDirTest
,
ReturnsCurrentDir
)
{
EXPECT_FALSE
(
FilePath
::
GetCurrentDir
().
IsEmpty
());
#if
def
GTEST_OS_WINDOWS
_chdir
(
PATH_SEP
);
#if GTEST_OS_WINDOWS
_chdir
(
GTEST_
PATH_SEP
_
);
const
FilePath
cwd
=
FilePath
::
GetCurrentDir
();
// Skips the ":".
const
char
*
const
cwd_without_drive
=
strchr
(
cwd
.
c_str
(),
':'
);
ASSERT_TRUE
(
cwd_without_drive
!=
NULL
);
EXPECT_STREQ
(
PATH_SEP
,
cwd_without_drive
+
1
);
EXPECT_STREQ
(
GTEST_
PATH_SEP
_
,
cwd_without_drive
+
1
);
#else
chdir
(
PATH_SEP
);
EXPECT_STREQ
(
PATH_SEP
,
FilePath
::
GetCurrentDir
().
c_str
());
chdir
(
GTEST_
PATH_SEP
_
);
EXPECT_STREQ
(
GTEST_
PATH_SEP
_
,
FilePath
::
GetCurrentDir
().
c_str
());
#endif
}
...
...
@@ -131,25 +131,25 @@ TEST(RemoveDirectoryNameTest, ButNoDirectory) {
// RemoveDirectoryName "/afile" -> "afile"
TEST
(
RemoveDirectoryNameTest
,
RootFileShouldGiveFileName
)
{
EXPECT_STREQ
(
"afile"
,
FilePath
(
PATH_SEP
"afile"
).
RemoveDirectoryName
().
c_str
());
FilePath
(
GTEST_
PATH_SEP
_
"afile"
).
RemoveDirectoryName
().
c_str
());
}
// RemoveDirectoryName "adir/" -> ""
TEST
(
RemoveDirectoryNameTest
,
WhereThereIsNoFileName
)
{
EXPECT_STREQ
(
""
,
FilePath
(
"adir"
PATH_SEP
).
RemoveDirectoryName
().
c_str
());
FilePath
(
"adir"
GTEST_
PATH_SEP
_
).
RemoveDirectoryName
().
c_str
());
}
// RemoveDirectoryName "adir/afile" -> "afile"
TEST
(
RemoveDirectoryNameTest
,
ShouldGiveFileName
)
{
EXPECT_STREQ
(
"afile"
,
FilePath
(
"adir"
PATH_SEP
"afile"
).
RemoveDirectoryName
().
c_str
());
FilePath
(
"adir"
GTEST_
PATH_SEP
_
"afile"
).
RemoveDirectoryName
().
c_str
());
}
// RemoveDirectoryName "adir/subdir/afile" -> "afile"
TEST
(
RemoveDirectoryNameTest
,
ShouldAlsoGiveFileName
)
{
EXPECT_STREQ
(
"afile"
,
FilePath
(
"adir"
PATH_SEP
"subdir"
PATH_SEP
"afile"
)
FilePath
(
"adir"
GTEST_
PATH_SEP
_
"subdir"
GTEST_
PATH_SEP
_
"afile"
)
.
RemoveDirectoryName
().
c_str
());
}
...
...
@@ -158,63 +158,63 @@ TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileName) {
TEST
(
RemoveFileNameTest
,
EmptyName
)
{
#ifdef _WIN32_WCE
// On Windows CE, we use the root as the current directory.
EXPECT_STREQ
(
PATH_SEP
,
EXPECT_STREQ
(
GTEST_
PATH_SEP
_
,
FilePath
(
""
).
RemoveFileName
().
c_str
());
#else
EXPECT_STREQ
(
"."
PATH_SEP
,
EXPECT_STREQ
(
"."
GTEST_
PATH_SEP
_
,
FilePath
(
""
).
RemoveFileName
().
c_str
());
#endif
}
// RemoveFileName "adir/" -> "adir/"
TEST
(
RemoveFileNameTest
,
ButNoFile
)
{
EXPECT_STREQ
(
"adir"
PATH_SEP
,
FilePath
(
"adir"
PATH_SEP
).
RemoveFileName
().
c_str
());
EXPECT_STREQ
(
"adir"
GTEST_
PATH_SEP
_
,
FilePath
(
"adir"
GTEST_
PATH_SEP
_
).
RemoveFileName
().
c_str
());
}
// RemoveFileName "adir/afile" -> "adir/"
TEST
(
RemoveFileNameTest
,
GivesDirName
)
{
EXPECT_STREQ
(
"adir"
PATH_SEP
,
FilePath
(
"adir"
PATH_SEP
"afile"
)
EXPECT_STREQ
(
"adir"
GTEST_
PATH_SEP
_
,
FilePath
(
"adir"
GTEST_
PATH_SEP
_
"afile"
)
.
RemoveFileName
().
c_str
());
}
// RemoveFileName "adir/subdir/afile" -> "adir/subdir/"
TEST
(
RemoveFileNameTest
,
GivesDirAndSubDirName
)
{
EXPECT_STREQ
(
"adir"
PATH_SEP
"subdir"
PATH_SEP
,
FilePath
(
"adir"
PATH_SEP
"subdir"
PATH_SEP
"afile"
)
EXPECT_STREQ
(
"adir"
GTEST_
PATH_SEP
_
"subdir"
GTEST_
PATH_SEP
_
,
FilePath
(
"adir"
GTEST_
PATH_SEP
_
"subdir"
GTEST_
PATH_SEP
_
"afile"
)
.
RemoveFileName
().
c_str
());
}
// RemoveFileName "/afile" -> "/"
TEST
(
RemoveFileNameTest
,
GivesRootDir
)
{
EXPECT_STREQ
(
PATH_SEP
,
FilePath
(
PATH_SEP
"afile"
).
RemoveFileName
().
c_str
());
EXPECT_STREQ
(
GTEST_
PATH_SEP
_
,
FilePath
(
GTEST_
PATH_SEP
_
"afile"
).
RemoveFileName
().
c_str
());
}
TEST
(
MakeFileNameTest
,
GenerateWhenNumberIsZero
)
{
FilePath
actual
=
FilePath
::
MakeFileName
(
FilePath
(
"foo"
),
FilePath
(
"bar"
),
0
,
"xml"
);
EXPECT_STREQ
(
"foo"
PATH_SEP
"bar.xml"
,
actual
.
c_str
());
EXPECT_STREQ
(
"foo"
GTEST_
PATH_SEP
_
"bar.xml"
,
actual
.
c_str
());
}
TEST
(
MakeFileNameTest
,
GenerateFileNameNumberGtZero
)
{
FilePath
actual
=
FilePath
::
MakeFileName
(
FilePath
(
"foo"
),
FilePath
(
"bar"
),
12
,
"xml"
);
EXPECT_STREQ
(
"foo"
PATH_SEP
"bar_12.xml"
,
actual
.
c_str
());
EXPECT_STREQ
(
"foo"
GTEST_
PATH_SEP
_
"bar_12.xml"
,
actual
.
c_str
());
}
TEST
(
MakeFileNameTest
,
GenerateFileNameWithSlashNumberIsZero
)
{
FilePath
actual
=
FilePath
::
MakeFileName
(
FilePath
(
"foo"
PATH_SEP
),
FilePath
actual
=
FilePath
::
MakeFileName
(
FilePath
(
"foo"
GTEST_
PATH_SEP
_
),
FilePath
(
"bar"
),
0
,
"xml"
);
EXPECT_STREQ
(
"foo"
PATH_SEP
"bar.xml"
,
actual
.
c_str
());
EXPECT_STREQ
(
"foo"
GTEST_
PATH_SEP
_
"bar.xml"
,
actual
.
c_str
());
}
TEST
(
MakeFileNameTest
,
GenerateFileNameWithSlashNumberGtZero
)
{
FilePath
actual
=
FilePath
::
MakeFileName
(
FilePath
(
"foo"
PATH_SEP
),
FilePath
actual
=
FilePath
::
MakeFileName
(
FilePath
(
"foo"
GTEST_
PATH_SEP
_
),
FilePath
(
"bar"
),
12
,
"xml"
);
EXPECT_STREQ
(
"foo"
PATH_SEP
"bar_12.xml"
,
actual
.
c_str
());
EXPECT_STREQ
(
"foo"
GTEST_
PATH_SEP
_
"bar_12.xml"
,
actual
.
c_str
());
}
TEST
(
MakeFileNameTest
,
GenerateWhenNumberIsZeroAndDirIsEmpty
)
{
...
...
@@ -232,13 +232,13 @@ TEST(MakeFileNameTest, GenerateWhenNumberIsNotZeroAndDirIsEmpty) {
TEST
(
ConcatPathsTest
,
WorksWhenDirDoesNotEndWithPathSep
)
{
FilePath
actual
=
FilePath
::
ConcatPaths
(
FilePath
(
"foo"
),
FilePath
(
"bar.xml"
));
EXPECT_STREQ
(
"foo"
PATH_SEP
"bar.xml"
,
actual
.
c_str
());
EXPECT_STREQ
(
"foo"
GTEST_
PATH_SEP
_
"bar.xml"
,
actual
.
c_str
());
}
TEST
(
ConcatPathsTest
,
WorksWhenPath1EndsWithPathSep
)
{
FilePath
actual
=
FilePath
::
ConcatPaths
(
FilePath
(
"foo"
PATH_SEP
),
FilePath
actual
=
FilePath
::
ConcatPaths
(
FilePath
(
"foo"
GTEST_
PATH_SEP
_
),
FilePath
(
"bar.xml"
));
EXPECT_STREQ
(
"foo"
PATH_SEP
"bar.xml"
,
actual
.
c_str
());
EXPECT_STREQ
(
"foo"
GTEST_
PATH_SEP
_
"bar.xml"
,
actual
.
c_str
());
}
TEST
(
ConcatPathsTest
,
Path1BeingEmpty
)
{
...
...
@@ -250,7 +250,7 @@ TEST(ConcatPathsTest, Path1BeingEmpty) {
TEST
(
ConcatPathsTest
,
Path2BeingEmpty
)
{
FilePath
actual
=
FilePath
::
ConcatPaths
(
FilePath
(
"foo"
),
FilePath
(
""
));
EXPECT_STREQ
(
"foo"
PATH_SEP
,
actual
.
c_str
());
EXPECT_STREQ
(
"foo"
GTEST_
PATH_SEP
_
,
actual
.
c_str
());
}
TEST
(
ConcatPathsTest
,
BothPathBeingEmpty
)
{
...
...
@@ -260,21 +260,24 @@ TEST(ConcatPathsTest, BothPathBeingEmpty) {
}
TEST
(
ConcatPathsTest
,
Path1ContainsPathSep
)
{
FilePath
actual
=
FilePath
::
ConcatPaths
(
FilePath
(
"foo"
PATH_SEP
"bar"
),
FilePath
actual
=
FilePath
::
ConcatPaths
(
FilePath
(
"foo"
GTEST_
PATH_SEP
_
"bar"
),
FilePath
(
"foobar.xml"
));
EXPECT_STREQ
(
"foo"
PATH_SEP
"bar"
PATH_SEP
"foobar.xml"
,
actual
.
c_str
());
EXPECT_STREQ
(
"foo"
GTEST_PATH_SEP_
"bar"
GTEST_PATH_SEP_
"foobar.xml"
,
actual
.
c_str
());
}
TEST
(
ConcatPathsTest
,
Path2ContainsPathSep
)
{
FilePath
actual
=
FilePath
::
ConcatPaths
(
FilePath
(
"foo"
PATH_SEP
),
FilePath
(
"bar"
PATH_SEP
"bar.xml"
));
EXPECT_STREQ
(
"foo"
PATH_SEP
"bar"
PATH_SEP
"bar.xml"
,
actual
.
c_str
());
FilePath
actual
=
FilePath
::
ConcatPaths
(
FilePath
(
"foo"
GTEST_PATH_SEP_
),
FilePath
(
"bar"
GTEST_PATH_SEP_
"bar.xml"
));
EXPECT_STREQ
(
"foo"
GTEST_PATH_SEP_
"bar"
GTEST_PATH_SEP_
"bar.xml"
,
actual
.
c_str
());
}
TEST
(
ConcatPathsTest
,
Path2EndsWithPathSep
)
{
FilePath
actual
=
FilePath
::
ConcatPaths
(
FilePath
(
"foo"
),
FilePath
(
"bar"
PATH_SEP
));
EXPECT_STREQ
(
"foo"
PATH_SEP
"bar"
PATH_SEP
,
actual
.
c_str
());
FilePath
(
"bar"
GTEST_
PATH_SEP
_
));
EXPECT_STREQ
(
"foo"
GTEST_
PATH_SEP
_
"bar"
GTEST_
PATH_SEP
_
,
actual
.
c_str
());
}
// RemoveTrailingPathSeparator "" -> ""
...
...
@@ -291,25 +294,27 @@ TEST(RemoveTrailingPathSeparatorTest, FileNoSlashString) {
// RemoveTrailingPathSeparator "foo/" -> "foo"
TEST
(
RemoveTrailingPathSeparatorTest
,
ShouldRemoveTrailingSeparator
)
{
EXPECT_STREQ
(
"foo"
,
FilePath
(
"foo"
PATH_SEP
).
RemoveTrailingPathSeparator
().
c_str
());
EXPECT_STREQ
(
"foo"
,
FilePath
(
"foo"
GTEST_PATH_SEP_
).
RemoveTrailingPathSeparator
().
c_str
());
}
// RemoveTrailingPathSeparator "foo/bar/" -> "foo/bar/"
TEST
(
RemoveTrailingPathSeparatorTest
,
ShouldRemoveLastSeparator
)
{
EXPECT_STREQ
(
"foo"
PATH_SEP
"bar"
,
FilePath
(
"foo"
PATH_SEP
"bar"
PATH_SEP
).
RemoveTrailingPathSeparator
(
)
.
c_str
());
EXPECT_STREQ
(
"foo"
GTEST_
PATH_SEP
_
"bar"
,
FilePath
(
"foo"
GTEST_
PATH_SEP
_
"bar"
GTEST_
PATH_SEP
_
)
.
RemoveTrailingPathSeparator
()
.
c_str
());
}
// RemoveTrailingPathSeparator "foo/bar" -> "foo/bar"
TEST
(
RemoveTrailingPathSeparatorTest
,
ShouldReturnUnmodified
)
{
EXPECT_STREQ
(
"foo"
PATH_SEP
"bar"
,
FilePath
(
"foo"
PATH_SEP
"bar"
).
RemoveTrailingPathSeparator
().
c_str
());
EXPECT_STREQ
(
"foo"
GTEST_PATH_SEP_
"bar"
,
FilePath
(
"foo"
GTEST_PATH_SEP_
"bar"
)
.
RemoveTrailingPathSeparator
().
c_str
());
}
TEST
(
DirectoryTest
,
RootDirectoryExists
)
{
#if
def
GTEST_OS_WINDOWS // We are on Windows.
#if GTEST_OS_WINDOWS // We are on Windows.
char
current_drive
[
_MAX_PATH
];
// NOLINT
current_drive
[
0
]
=
static_cast
<
char
>
(
_getdrive
()
+
'A'
-
1
);
current_drive
[
1
]
=
':'
;
...
...
@@ -321,7 +326,7 @@ TEST(DirectoryTest, RootDirectoryExists) {
#endif // GTEST_OS_WINDOWS
}
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
TEST
(
DirectoryTest
,
RootOfWrongDriveDoesNotExists
)
{
const
int
saved_drive_
=
_getdrive
();
// Find a drive that doesn't exist. Start with 'Z' to avoid common ones.
...
...
@@ -347,7 +352,7 @@ TEST(DirectoryTest, EmptyPathDirectoryDoesNotExist) {
#endif // ! _WIN32_WCE
TEST
(
DirectoryTest
,
CurrentDirectoryExists
)
{
#if
def
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.
EXPECT_TRUE
(
FilePath
(
"."
).
DirectoryExists
());
EXPECT_TRUE
(
FilePath
(
".
\\
"
).
DirectoryExists
());
...
...
@@ -365,32 +370,33 @@ TEST(NormalizeTest, NullStringsEqualEmptyDirectory) {
// "foo/bar" == foo//bar" == "foo///bar"
TEST
(
NormalizeTest
,
MultipleConsecutiveSepaparatorsInMidstring
)
{
EXPECT_STREQ
(
"foo"
PATH_SEP
"bar"
,
FilePath
(
"foo"
PATH_SEP
"bar"
).
c_str
());
EXPECT_STREQ
(
"foo"
PATH_SEP
"bar"
,
FilePath
(
"foo"
PATH_SEP
PATH_SEP
"bar"
).
c_str
());
EXPECT_STREQ
(
"foo"
PATH_SEP
"bar"
,
FilePath
(
"foo"
PATH_SEP
PATH_SEP
PATH_SEP
"bar"
).
c_str
());
EXPECT_STREQ
(
"foo"
GTEST_PATH_SEP_
"bar"
,
FilePath
(
"foo"
GTEST_PATH_SEP_
"bar"
).
c_str
());
EXPECT_STREQ
(
"foo"
GTEST_PATH_SEP_
"bar"
,
FilePath
(
"foo"
GTEST_PATH_SEP_
GTEST_PATH_SEP_
"bar"
).
c_str
());
EXPECT_STREQ
(
"foo"
GTEST_PATH_SEP_
"bar"
,
FilePath
(
"foo"
GTEST_PATH_SEP_
GTEST_PATH_SEP_
GTEST_PATH_SEP_
"bar"
).
c_str
());
}
// "/bar" == //bar" == "///bar"
TEST
(
NormalizeTest
,
MultipleConsecutiveSepaparatorsAtStringStart
)
{
EXPECT_STREQ
(
PATH_SEP
"bar"
,
FilePath
(
PATH_SEP
"bar"
).
c_str
());
EXPECT_STREQ
(
PATH_SEP
"bar"
,
FilePath
(
PATH_SEP
PATH_SEP
"bar"
).
c_str
());
EXPECT_STREQ
(
PATH_SEP
"bar"
,
FilePath
(
PATH_SEP
PATH_SEP
PATH_SEP
"bar"
).
c_str
());
EXPECT_STREQ
(
GTEST_
PATH_SEP
_
"bar"
,
FilePath
(
GTEST_
PATH_SEP
_
"bar"
).
c_str
());
EXPECT_STREQ
(
GTEST_
PATH_SEP
_
"bar"
,
FilePath
(
GTEST_
PATH_SEP
_
GTEST_
PATH_SEP
_
"bar"
).
c_str
());
EXPECT_STREQ
(
GTEST_
PATH_SEP
_
"bar"
,
FilePath
(
GTEST_
PATH_SEP
_
GTEST_PATH_SEP_
GTEST_
PATH_SEP
_
"bar"
).
c_str
());
}
// "foo/" == foo//" == "foo///"
TEST
(
NormalizeTest
,
MultipleConsecutiveSepaparatorsAtStringEnd
)
{
EXPECT_STREQ
(
"foo"
PATH_SEP
,
FilePath
(
"foo"
PATH_SEP
).
c_str
());
EXPECT_STREQ
(
"foo"
PATH_SEP
,
FilePath
(
"foo"
PATH_SEP
PATH_SEP
).
c_str
());
EXPECT_STREQ
(
"foo"
PATH_SEP
,
FilePath
(
"foo"
PATH_SEP
PATH_SEP
PATH_SEP
).
c_str
());
EXPECT_STREQ
(
"foo"
GTEST_
PATH_SEP
_
,
FilePath
(
"foo"
GTEST_
PATH_SEP
_
).
c_str
());
EXPECT_STREQ
(
"foo"
GTEST_
PATH_SEP
_
,
FilePath
(
"foo"
GTEST_
PATH_SEP
_
GTEST_
PATH_SEP
_
).
c_str
());
EXPECT_STREQ
(
"foo"
GTEST_
PATH_SEP
_
,
FilePath
(
"foo"
GTEST_
PATH_SEP
_
GTEST_PATH_SEP_
GTEST_
PATH_SEP
_
).
c_str
());
}
TEST
(
AssignmentOperatorTest
,
DefaultAssignedToNonDefault
)
{
...
...
@@ -421,7 +427,7 @@ class DirectoryCreationTest : public Test {
virtual
void
SetUp
()
{
testdata_path_
.
Set
(
FilePath
(
String
::
Format
(
"%s%s%s"
,
TempDir
().
c_str
(),
GetCurrentExecutableName
().
c_str
(),
"_directory_creation"
PATH_SEP
"test"
PATH_SEP
)));
"_directory_creation"
GTEST_
PATH_SEP
_
"test"
GTEST_
PATH_SEP
_
)));
testdata_file_
.
Set
(
testdata_path_
.
RemoveTrailingPathSeparator
());
unique_file0_
.
Set
(
FilePath
::
MakeFileName
(
testdata_path_
,
FilePath
(
"unique"
),
...
...
@@ -432,7 +438,7 @@ class DirectoryCreationTest : public Test {
remove
(
testdata_file_
.
c_str
());
remove
(
unique_file0_
.
c_str
());
remove
(
unique_file1_
.
c_str
());
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
_rmdir
(
testdata_path_
.
c_str
());
#else
rmdir
(
testdata_path_
.
c_str
());
...
...
@@ -443,7 +449,7 @@ class DirectoryCreationTest : public Test {
remove
(
testdata_file_
.
c_str
());
remove
(
unique_file0_
.
c_str
());
remove
(
unique_file1_
.
c_str
());
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
_rmdir
(
testdata_path_
.
c_str
());
#else
rmdir
(
testdata_path_
.
c_str
());
...
...
@@ -454,7 +460,7 @@ class DirectoryCreationTest : public Test {
#ifdef _WIN32_WCE
return
String
(
"
\\
temp
\\
"
);
#elif
defined(
GTEST_OS_WINDOWS
)
#elif GTEST_OS_WINDOWS
// MSVC 8 deprecates getenv(), so we want to suppress warning 4996
// (deprecated function) there.
#pragma warning(push) // Saves the current warning state.
...
...
@@ -474,7 +480,7 @@ class DirectoryCreationTest : public Test {
}
void
CreateTextFile
(
const
char
*
filename
)
{
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
// MSVC 8 deprecates fopen(), so we want to suppress warning 4996
// (deprecated function) there.#pragma warning(push)
#pragma warning(push) // Saves the current warning state.
...
...
@@ -585,18 +591,18 @@ TEST(FilePathTest, RemoveExtensionWhenThereIsNoExtension) {
TEST
(
FilePathTest
,
IsDirectory
)
{
EXPECT_FALSE
(
FilePath
(
"cola"
).
IsDirectory
());
EXPECT_TRUE
(
FilePath
(
"koala"
PATH_SEP
).
IsDirectory
());
EXPECT_TRUE
(
FilePath
(
"koala"
GTEST_
PATH_SEP
_
).
IsDirectory
());
}
TEST
(
FilePathTest
,
IsAbsolutePath
)
{
EXPECT_FALSE
(
FilePath
(
"is"
PATH_SEP
"relative"
).
IsAbsolutePath
());
EXPECT_FALSE
(
FilePath
(
"is"
GTEST_
PATH_SEP
_
"relative"
).
IsAbsolutePath
());
EXPECT_FALSE
(
FilePath
(
""
).
IsAbsolutePath
());
#if
def
GTEST_OS_WINDOWS
EXPECT_TRUE
(
FilePath
(
"c:
\\
"
PATH_SEP
"is_not"
PATH_SEP
"relative"
)
.
IsAbsolutePath
());
EXPECT_FALSE
(
FilePath
(
"c:foo"
PATH_SEP
"bar"
).
IsAbsolutePath
());
#if GTEST_OS_WINDOWS
EXPECT_TRUE
(
FilePath
(
"c:
\\
"
GTEST_
PATH_SEP
_
"is_not"
GTEST_PATH_SEP_
"relative"
)
.
IsAbsolutePath
());
EXPECT_FALSE
(
FilePath
(
"c:foo"
GTEST_
PATH_SEP
_
"bar"
).
IsAbsolutePath
());
#else
EXPECT_TRUE
(
FilePath
(
PATH_SEP
"is_not"
PATH_SEP
"relative"
)
EXPECT_TRUE
(
FilePath
(
GTEST_
PATH_SEP
_
"is_not"
GTEST_
PATH_SEP
_
"relative"
)
.
IsAbsolutePath
());
#endif // GTEST_OS_WINDOWS
}
...
...
@@ -605,4 +611,4 @@ TEST(FilePathTest, IsAbsolutePath) {
}
// namespace internal
}
// namespace testing
#undef PATH_SEP
#undef
GTEST_
PATH_SEP
_
test/gtest-options_test.cc
View file @
0af0709b
...
...
@@ -42,7 +42,7 @@
#ifdef _WIN32_WCE
#include <windows.h>
#elif
defined(
GTEST_OS_WINDOWS
)
#elif GTEST_OS_WINDOWS
#include <direct.h>
#endif // _WIN32_WCE
...
...
@@ -51,9 +51,9 @@
// 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
#define GTEST_IMPLEMENTATION
_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION
#undef GTEST_IMPLEMENTATION
_
namespace
testing
{
namespace
internal
{
...
...
@@ -89,7 +89,7 @@ TEST(XmlOutputTest, GetOutputFileSingleFile) {
}
TEST
(
XmlOutputTest
,
GetOutputFileFromDirectoryPath
)
{
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
GTEST_FLAG
(
output
)
=
"xml:path
\\
"
;
const
String
&
output_file
=
UnitTestOptions
::
GetAbsolutePathToOutputFile
();
EXPECT_TRUE
(
...
...
@@ -121,7 +121,7 @@ TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) {
TEST
(
OutputFileHelpersTest
,
GetCurrentExecutableName
)
{
const
FilePath
executable
=
GetCurrentExecutableName
();
const
char
*
const
exe_str
=
executable
.
c_str
();
#if defined(_WIN32_WCE) ||
defined(
GTEST_OS_WINDOWS
)
#if defined(_WIN32_WCE) || GTEST_OS_WINDOWS
ASSERT_TRUE
(
_strcmpi
(
"gtest-options_test"
,
exe_str
)
==
0
||
_strcmpi
(
"gtest-options-ex_test"
,
exe_str
)
==
0
)
<<
"GetCurrentExecutableName() returns "
<<
exe_str
;
...
...
@@ -149,7 +149,7 @@ class XmlOutputChangeDirTest : public Test {
}
void
ChDir
(
const
char
*
dir
)
{
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
_chdir
(
dir
);
#else
chdir
(
dir
);
...
...
@@ -181,7 +181,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativeFile) {
}
TEST_F
(
XmlOutputChangeDirTest
,
PreserveOriginalWorkingDirWithRelativePath
)
{
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
GTEST_FLAG
(
output
)
=
"xml:path
\\
"
;
const
String
&
output_file
=
UnitTestOptions
::
GetAbsolutePathToOutputFile
();
EXPECT_TRUE
(
...
...
@@ -211,7 +211,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {
}
TEST_F
(
XmlOutputChangeDirTest
,
PreserveOriginalWorkingDirWithAbsoluteFile
)
{
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
GTEST_FLAG
(
output
)
=
"xml:c:
\\
tmp
\\
filename.abc"
;
EXPECT_STREQ
(
FilePath
(
"c:
\\
tmp
\\
filename.abc"
).
c_str
(),
UnitTestOptions
::
GetAbsolutePathToOutputFile
().
c_str
());
...
...
@@ -223,7 +223,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) {
}
TEST_F
(
XmlOutputChangeDirTest
,
PreserveOriginalWorkingDirWithAbsolutePath
)
{
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
GTEST_FLAG
(
output
)
=
"xml:c:
\\
tmp
\\
"
;
const
String
&
output_file
=
UnitTestOptions
::
GetAbsolutePathToOutputFile
();
EXPECT_TRUE
(
...
...
test/gtest-param-test2_test.cc
View file @
0af0709b
...
...
@@ -36,7 +36,7 @@
#include "test/gtest-param-test_test.h"
#if
def
GTEST_HAS_PARAM_TEST
#if GTEST_HAS_PARAM_TEST
using
::
testing
::
Values
;
using
::
testing
::
internal
::
ParamGenerator
;
...
...
test/gtest-param-test_test.cc
View file @
0af0709b
...
...
@@ -35,7 +35,7 @@
#include <gtest/gtest.h>
#if
def
GTEST_HAS_PARAM_TEST
#if GTEST_HAS_PARAM_TEST
#include <algorithm>
#include <iostream>
...
...
@@ -43,9 +43,9 @@
#include <vector>
// To include gtest-internal-inl.h.
#define GTEST_IMPLEMENTATION
#define GTEST_IMPLEMENTATION
_ 1
#include "src/gtest-internal-inl.h" // for UnitTestOptions
#undef GTEST_IMPLEMENTATION
#undef GTEST_IMPLEMENTATION
_
#include "test/gtest-param-test_test.h"
...
...
@@ -60,7 +60,7 @@ using ::testing::TestWithParam;
using
::
testing
::
Values
;
using
::
testing
::
ValuesIn
;
#if
def
GTEST_HAS_COMBINE
#if GTEST_HAS_COMBINE
using
::
testing
::
Combine
;
using
::
std
::
tr1
::
get
;
using
::
std
::
tr1
::
make_tuple
;
...
...
@@ -398,7 +398,7 @@ TEST(BoolTest, BoolWorks) {
VerifyGenerator
(
gen
,
expected_values
);
}
#if
def
GTEST_HAS_COMBINE
#if GTEST_HAS_COMBINE
template
<
typename
T1
,
typename
T2
>
::
std
::
ostream
&
operator
<<
(
::
std
::
ostream
&
stream
,
const
tuple
<
T1
,
T2
>&
value
)
{
...
...
@@ -774,13 +774,13 @@ INSTANTIATE_TEST_CASE_P(ZeroToFiveSequence, NamingTest, Range(0, 5));
#endif // GTEST_HAS_PARAM_TEST
TEST
(
CompileTest
,
CombineIsDefinedOnlyWhenGtestHasParamTestIsDefined
)
{
#if
defined(
GTEST_HAS_COMBINE
)
&& !
defined(
GTEST_HAS_PARAM_TEST
)
#if GTEST_HAS_COMBINE && !GTEST_HAS_PARAM_TEST
FAIL
()
<<
"GTEST_HAS_COMBINE is defined while GTEST_HAS_PARAM_TEST is not
\n
"
#endif
}
int
main
(
int
argc
,
char
**
argv
)
{
#if
def
GTEST_HAS_PARAM_TEST
#if GTEST_HAS_PARAM_TEST
// Used in TestGenerationTest test case.
AddGlobalTestEnvironment
(
TestGenerationTest
::
Environment
::
Instance
());
// Used in GeneratorEvaluationTest test case.
...
...
test/gtest-param-test_test.h
View file @
0af0709b
...
...
@@ -39,7 +39,7 @@
#include <gtest/gtest.h>
#if
def
GTEST_HAS_PARAM_TEST
#if GTEST_HAS_PARAM_TEST
// Test fixture for testing definition and instantiation of a test
// in separate translation units.
...
...
test/gtest-port_test.cc
View file @
0af0709b
...
...
@@ -40,9 +40,9 @@
// 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
#define GTEST_IMPLEMENTATION
_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION
#undef GTEST_IMPLEMENTATION
_
namespace
testing
{
namespace
internal
{
...
...
@@ -76,7 +76,7 @@ TEST(GtestCheckSyntaxTest, WorksWithSwitch) {
GTEST_CHECK_
(
true
)
<<
"Check failed in switch case"
;
}
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
TEST
(
GtestCheckDeathTest
,
DiesWithCorrectOutputOnFailure
)
{
const
bool
a_false_condition
=
false
;
...
...
test/gtest-test-part_test.cc
View file @
0af0709b
...
...
@@ -117,7 +117,7 @@ TEST_F(TestPartResultArrayTest, ContainsGivenResultsAfterTwoAppends) {
EXPECT_STREQ
(
"Failure 2"
,
results
.
GetTestPartResult
(
1
).
message
());
}
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
typedef
TestPartResultArrayTest
TestPartResultArrayDeathTest
;
...
...
test/gtest-typed-test2_test.cc
View file @
0af0709b
...
...
@@ -34,7 +34,7 @@
#include "test/gtest-typed-test_test.h"
#include <gtest/gtest.h>
#if
def
GTEST_HAS_TYPED_TEST_P
#if GTEST_HAS_TYPED_TEST_P
// Tests that the same type-parameterized test case can be
// instantiated in different translation units linked together.
...
...
test/gtest-typed-test_test.cc
View file @
0af0709b
...
...
@@ -82,7 +82,7 @@ template <typename T>
T
*
CommonTest
<
T
>::
shared_
=
NULL
;
// This #ifdef block tests typed tests.
#if
def
GTEST_HAS_TYPED_TEST
#if GTEST_HAS_TYPED_TEST
using
testing
::
Types
;
...
...
@@ -166,7 +166,7 @@ TYPED_TEST(NumericTest, DefaultIsZero) {
#endif // GTEST_HAS_TYPED_TEST
// This #ifdef block tests type-parameterized tests.
#if
def
GTEST_HAS_TYPED_TEST_P
#if GTEST_HAS_TYPED_TEST_P
using
testing
::
Types
;
using
testing
::
internal
::
TypedTestCasePState
;
...
...
@@ -198,7 +198,7 @@ TEST_F(TypedTestCasePStateTest, IgnoresOrderAndSpaces) {
state_
.
VerifyRegisteredTestNames
(
"foo.cc"
,
1
,
tests
));
}
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
typedef
TypedTestCasePStateTest
TypedTestCasePStateDeathTest
;
...
...
test/gtest-typed-test_test.h
View file @
0af0709b
...
...
@@ -34,7 +34,7 @@
#include <gtest/gtest.h>
#if
def
GTEST_HAS_TYPED_TEST_P
#if GTEST_HAS_TYPED_TEST_P
using
testing
::
Test
;
...
...
test/gtest_break_on_failure_unittest_.cc
View file @
0af0709b
...
...
@@ -41,7 +41,7 @@
#include <gtest/gtest.h>
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
#include <windows.h>
#endif
...
...
@@ -56,7 +56,7 @@ TEST(Foo, Bar) {
int
main
(
int
argc
,
char
**
argv
)
{
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
// Suppresses display of the Windows error dialog upon encountering
// a general protection fault (segment violation).
SetErrorMode
(
SEM_NOGPFAULTERRORBOX
|
SEM_FAILCRITICALERRORS
);
...
...
test/gtest_env_var_test_.cc
View file @
0af0709b
...
...
@@ -36,9 +36,9 @@
#include <iostream>
#define GTEST_IMPLEMENTATION
#define GTEST_IMPLEMENTATION
_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION
#undef GTEST_IMPLEMENTATION
_
using
::
std
::
cout
;
...
...
test/gtest_filter_unittest_.cc
View file @
0af0709b
...
...
@@ -94,7 +94,7 @@ TEST(BazTest, DISABLED_TestC) {
// Test case HasDeathTest
TEST
(
HasDeathTest
,
Test1
)
{
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
EXPECT_DEATH
({
exit
(
1
);},
".*"
);
#endif // GTEST_HAS_DEATH_TEST
...
...
@@ -103,7 +103,7 @@ TEST(HasDeathTest, Test1) {
// We need at least two death tests to make sure that the all death tests
// aren't on the first shard.
TEST
(
HasDeathTest
,
Test2
)
{
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
EXPECT_DEATH
({
exit
(
1
);},
".*"
);
#endif // GTEST_HAS_DEATH_TEST
...
...
@@ -126,7 +126,7 @@ TEST(DISABLED_FoobarbazTest, TestA) {
FAIL
()
<<
"Expected failure."
;
}
#if
def
GTEST_HAS_PARAM_TEST
#if GTEST_HAS_PARAM_TEST
class
ParamTest
:
public
testing
::
TestWithParam
<
int
>
{
};
...
...
test/gtest_output_test_.cc
View file @
0af0709b
...
...
@@ -40,9 +40,9 @@
// 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
#define GTEST_IMPLEMENTATION
_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION
#undef GTEST_IMPLEMENTATION
_
#include <stdlib.h>
...
...
@@ -50,7 +50,7 @@
#include <pthread.h>
#endif // GTEST_HAS_PTHREAD
#if
def
GTEST_OS_LINUX
#if GTEST_OS_LINUX
#include <string.h>
#include <signal.h>
#include <string>
...
...
@@ -355,7 +355,7 @@ TEST_F(FatalFailureInSetUpTest, FailureInSetUp) {
<<
"We should never get here, as SetUp() failed."
;
}
#if
def
GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
// This group of tests verifies that Google Test handles SEH and C++
// exceptions correctly.
...
...
@@ -722,7 +722,7 @@ TEST(ExpectFatalFailureTest, FailsWhenStatementThrows) {
#endif // GTEST_HAS_EXCEPTIONS
// This #ifdef block tests the output of typed tests.
#if
def
GTEST_HAS_TYPED_TEST
#if GTEST_HAS_TYPED_TEST
template
<
typename
T
>
class
TypedTest
:
public
testing
::
Test
{
...
...
@@ -741,7 +741,7 @@ TYPED_TEST(TypedTest, Failure) {
#endif // GTEST_HAS_TYPED_TEST
// This #ifdef block tests the output of type-parameterized tests.
#if
def
GTEST_HAS_TYPED_TEST_P
#if GTEST_HAS_TYPED_TEST_P
template
<
typename
T
>
class
TypedTestP
:
public
testing
::
Test
{
...
...
@@ -764,7 +764,7 @@ INSTANTIATE_TYPED_TEST_CASE_P(Unsigned, TypedTestP, UnsignedTypes);
#endif // GTEST_HAS_TYPED_TEST_P
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
// We rely on the golden file to verify that tests whose test case
// name ends with DeathTest are run first.
...
...
@@ -772,7 +772,7 @@ INSTANTIATE_TYPED_TEST_CASE_P(Unsigned, TypedTestP, UnsignedTypes);
TEST
(
ADeathTest
,
ShouldRunFirst
)
{
}
#if
def
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.
...
...
@@ -789,7 +789,7 @@ TYPED_TEST(ATypedDeathTest, ShouldRunFirst) {
#endif // GTEST_HAS_TYPED_TEST
#if
def
GTEST_HAS_TYPED_TEST_P
#if GTEST_HAS_TYPED_TEST_P
// We rely on the golden file to verify that type-parameterized tests
...
...
@@ -984,7 +984,7 @@ int main(int argc, char **argv) {
String
(
argv
[
1
])
==
"--gtest_internal_skip_environment_and_ad_hoc_tests"
)
GTEST_FLAG
(
internal_skip_environment_and_ad_hoc_tests
)
=
true
;
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
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.
...
...
test/gtest_repeat_test.cc
View file @
0af0709b
...
...
@@ -40,9 +40,9 @@
// 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
#define GTEST_IMPLEMENTATION
_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION
#undef GTEST_IMPLEMENTATION
_
namespace
testing
{
...
...
@@ -112,7 +112,7 @@ int g_death_test_count = 0;
TEST
(
BarDeathTest
,
ThreadSafeAndFast
)
{
g_death_test_count
++
;
#if
def
GTEST_HAS_DEATH_TEST
#if GTEST_HAS_DEATH_TEST
GTEST_FLAG
(
death_test_style
)
=
"threadsafe"
;
EXPECT_DEATH
(
abort
(),
""
);
...
...
@@ -121,7 +121,7 @@ TEST(BarDeathTest, ThreadSafeAndFast) {
#endif // GTEST_HAS_DEATH_TEST
}
#if
def
GTEST_HAS_PARAM_TEST
#if GTEST_HAS_PARAM_TEST
int
g_param_test_count
=
0
;
const
int
kNumberOfParamTests
=
10
;
...
...
@@ -146,7 +146,7 @@ void ResetCounts() {
g_should_fail_count
=
0
;
g_should_pass_count
=
0
;
g_death_test_count
=
0
;
#if
def
GTEST_HAS_PARAM_TEST
#if GTEST_HAS_PARAM_TEST
g_param_test_count
=
0
;
#endif // GTEST_HAS_PARAM_TEST
}
...
...
@@ -158,7 +158,7 @@ void CheckCounts(int expected) {
GTEST_CHECK_INT_EQ_
(
expected
,
g_should_fail_count
);
GTEST_CHECK_INT_EQ_
(
expected
,
g_should_pass_count
);
GTEST_CHECK_INT_EQ_
(
expected
,
g_death_test_count
);
#if
def
GTEST_HAS_PARAM_TEST
#if GTEST_HAS_PARAM_TEST
GTEST_CHECK_INT_EQ_
(
expected
*
kNumberOfParamTests
,
g_param_test_count
);
#endif // GTEST_HAS_PARAM_TEST
}
...
...
@@ -203,7 +203,7 @@ void TestRepeatWithFilterForSuccessfulTests(int repeat) {
GTEST_CHECK_INT_EQ_
(
0
,
g_should_fail_count
);
GTEST_CHECK_INT_EQ_
(
repeat
,
g_should_pass_count
);
GTEST_CHECK_INT_EQ_
(
repeat
,
g_death_test_count
);
#if
def
GTEST_HAS_PARAM_TEST
#if GTEST_HAS_PARAM_TEST
GTEST_CHECK_INT_EQ_
(
repeat
*
kNumberOfParamTests
,
g_param_test_count
);
#endif // GTEST_HAS_PARAM_TEST
}
...
...
@@ -221,7 +221,7 @@ void TestRepeatWithFilterForFailedTests(int repeat) {
GTEST_CHECK_INT_EQ_
(
repeat
,
g_should_fail_count
);
GTEST_CHECK_INT_EQ_
(
0
,
g_should_pass_count
);
GTEST_CHECK_INT_EQ_
(
0
,
g_death_test_count
);
#if
def
GTEST_HAS_PARAM_TEST
#if GTEST_HAS_PARAM_TEST
GTEST_CHECK_INT_EQ_
(
0
,
g_param_test_count
);
#endif // GTEST_HAS_PARAM_TEST
}
...
...
Prev
1
2
3
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