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
0e6da4ce
Unverified
Commit
0e6da4ce
authored
Jan 09, 2018
by
Gennadiy Civil
Committed by
GitHub
Jan 09, 2018
Browse files
Merge branch 'master' into fix-core-dump-shared
parents
cdedd189
e194f521
Changes
70
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
81 additions
and
201 deletions
+81
-201
googletest/include/gtest/internal/gtest-port.h
googletest/include/gtest/internal/gtest-port.h
+5
-12
googletest/samples/prime_tables.h
googletest/samples/prime_tables.h
+6
-2
googletest/samples/sample4_unittest.cc
googletest/samples/sample4_unittest.cc
+4
-1
googletest/samples/sample5_unittest.cc
googletest/samples/sample5_unittest.cc
+1
-1
googletest/samples/sample7_unittest.cc
googletest/samples/sample7_unittest.cc
+0
-12
googletest/src/gtest-death-test.cc
googletest/src/gtest-death-test.cc
+12
-17
googletest/src/gtest-internal-inl.h
googletest/src/gtest-internal-inl.h
+0
-12
googletest/src/gtest-port.cc
googletest/src/gtest-port.cc
+5
-11
googletest/src/gtest-test-part.cc
googletest/src/gtest-test-part.cc
+0
-8
googletest/src/gtest.cc
googletest/src/gtest.cc
+35
-47
googletest/test/BUILD.bazel
googletest/test/BUILD.bazel
+6
-3
googletest/test/gtest-death-test_test.cc
googletest/test/gtest-death-test_test.cc
+2
-10
googletest/test/gtest-filepath_test.cc
googletest/test/gtest-filepath_test.cc
+2
-12
googletest/test/gtest-options_test.cc
googletest/test/gtest-options_test.cc
+0
-8
googletest/test/gtest-param-test2_test.cc
googletest/test/gtest-param-test2_test.cc
+0
-3
googletest/test/gtest-param-test_test.cc
googletest/test/gtest-param-test_test.cc
+0
-18
googletest/test/gtest-param-test_test.h
googletest/test/gtest-param-test_test.h
+0
-4
googletest/test/gtest-port_test.cc
googletest/test/gtest-port_test.cc
+2
-10
googletest/test/gtest_break_on_failure_unittest_.cc
googletest/test/gtest_break_on_failure_unittest_.cc
+1
-2
googletest/test/gtest_color_test_.cc
googletest/test/gtest_color_test_.cc
+0
-8
No files found.
googletest/include/gtest/internal/gtest-port.h
View file @
0e6da4ce
...
@@ -171,7 +171,6 @@
...
@@ -171,7 +171,6 @@
// GTEST_HAS_COMBINE - the Combine() function (for value-parameterized
// GTEST_HAS_COMBINE - the Combine() function (for value-parameterized
// tests)
// tests)
// GTEST_HAS_DEATH_TEST - death tests
// GTEST_HAS_DEATH_TEST - death tests
// GTEST_HAS_PARAM_TEST - value-parameterized tests
// GTEST_HAS_TYPED_TEST - typed tests
// GTEST_HAS_TYPED_TEST - typed tests
// GTEST_HAS_TYPED_TEST_P - type-parameterized tests
// GTEST_HAS_TYPED_TEST_P - type-parameterized tests
// GTEST_IS_THREADSAFE - Google Test is thread-safe.
// GTEST_IS_THREADSAFE - Google Test is thread-safe.
...
@@ -815,11 +814,6 @@ using ::std::tuple_size;
...
@@ -815,11 +814,6 @@ using ::std::tuple_size;
# define GTEST_HAS_DEATH_TEST 1
# define GTEST_HAS_DEATH_TEST 1
#endif
#endif
// We don't support MSVC 7.1 with exceptions disabled now. Therefore
// all the compilers we care about are adequate for supporting
// value-parameterized tests.
#define GTEST_HAS_PARAM_TEST 1
// Determines whether to support type-driven tests.
// Determines whether to support type-driven tests.
// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
...
@@ -830,11 +824,10 @@ using ::std::tuple_size;
...
@@ -830,11 +824,10 @@ using ::std::tuple_size;
# define GTEST_HAS_TYPED_TEST_P 1
# define GTEST_HAS_TYPED_TEST_P 1
#endif
#endif
// Determines whether to support Combine(). This only makes sense when
// Determines whether to support Combine().
// value-parameterized tests are enabled. The implementation doesn't
// The implementation doesn't work on Sun Studio since it doesn't
// work on Sun Studio since it doesn't understand templated conversion
// understand templated conversion operators.
// operators.
#if (GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_) && !defined(__SUNPRO_CC)
#if GTEST_HAS_PARAM_TEST && GTEST_HAS_TR1_TUPLE && !defined(__SUNPRO_CC)
# define GTEST_HAS_COMBINE 1
# define GTEST_HAS_COMBINE 1
#endif
#endif
...
@@ -886,7 +879,7 @@ using ::std::tuple_size;
...
@@ -886,7 +879,7 @@ using ::std::tuple_size;
#endif
#endif
// Use this annotation before a function that takes a printf format string.
// Use this annotation before a function that takes a printf format string.
#if defined(__GNUC__) && !defined(COMPILER_ICC)
#if
(
defined(__GNUC__)
|| defined(__clang__))
&& !defined(COMPILER_ICC)
# if defined(__MINGW_PRINTF_FORMAT)
# if defined(__MINGW_PRINTF_FORMAT)
// MinGW has two different printf implementations. Ensure the format macro
// MinGW has two different printf implementations. Ensure the format macro
// matches the selected implementation. See
// matches the selected implementation. See
...
...
googletest/samples/prime_tables.h
View file @
0e6da4ce
...
@@ -103,11 +103,15 @@ class PreCalculatedPrimeTable : public PrimeTable {
...
@@ -103,11 +103,15 @@ class PreCalculatedPrimeTable : public PrimeTable {
::
std
::
fill
(
is_prime_
,
is_prime_
+
is_prime_size_
,
true
);
::
std
::
fill
(
is_prime_
,
is_prime_
+
is_prime_size_
,
true
);
is_prime_
[
0
]
=
is_prime_
[
1
]
=
false
;
is_prime_
[
0
]
=
is_prime_
[
1
]
=
false
;
for
(
int
i
=
2
;
i
<=
max
;
i
++
)
{
// Checks every candidate for prime number (we know that 2 is the only even
// prime).
for
(
int
i
=
2
;
i
*
i
<=
max
;
i
+=
i
%
2
+
1
)
{
if
(
!
is_prime_
[
i
])
continue
;
if
(
!
is_prime_
[
i
])
continue
;
// Marks all multiples of i (except i itself) as non-prime.
// Marks all multiples of i (except i itself) as non-prime.
for
(
int
j
=
2
*
i
;
j
<=
max
;
j
+=
i
)
{
// We are starting here from i-th multiplier, because all smaller
// complex numbers were already marked.
for
(
int
j
=
i
*
i
;
j
<=
max
;
j
+=
i
)
{
is_prime_
[
j
]
=
false
;
is_prime_
[
j
]
=
false
;
}
}
}
}
...
...
googletest/samples/sample4_unittest.cc
View file @
0e6da4ce
...
@@ -29,10 +29,12 @@
...
@@ -29,10 +29,12 @@
//
//
// Author: wan@google.com (Zhanyong Wan)
// Author: wan@google.com (Zhanyong Wan)
#include "gtest/gtest.h"
#include "sample4.h"
#include "sample4.h"
#include "gtest/gtest.h"
namespace
{
namespace
{
// Tests the Increment() method.
// Tests the Increment() method.
TEST
(
Counter
,
Increment
)
{
TEST
(
Counter
,
Increment
)
{
Counter
c
;
Counter
c
;
...
@@ -43,4 +45,5 @@ TEST(Counter, Increment) {
...
@@ -43,4 +45,5 @@ TEST(Counter, Increment) {
EXPECT_EQ
(
1
,
c
.
Increment
());
EXPECT_EQ
(
1
,
c
.
Increment
());
EXPECT_EQ
(
2
,
c
.
Increment
());
EXPECT_EQ
(
2
,
c
.
Increment
());
}
}
}
// namespace
}
// namespace
googletest/samples/sample5_unittest.cc
View file @
0e6da4ce
...
@@ -46,9 +46,9 @@
...
@@ -46,9 +46,9 @@
#include <limits.h>
#include <limits.h>
#include <time.h>
#include <time.h>
#include "sample3-inl.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include "sample1.h"
#include "sample1.h"
#include "sample3-inl.h"
namespace
{
namespace
{
// In this sample, we want to ensure that every test finishes within
// In this sample, we want to ensure that every test finishes within
// ~5 seconds. If a test takes longer to run, we consider it a
// ~5 seconds. If a test takes longer to run, we consider it a
...
...
googletest/samples/sample7_unittest.cc
View file @
0e6da4ce
...
@@ -40,7 +40,6 @@
...
@@ -40,7 +40,6 @@
#include "gtest/gtest.h"
#include "gtest/gtest.h"
namespace
{
namespace
{
#if GTEST_HAS_PARAM_TEST
using
::
testing
::
TestWithParam
;
using
::
testing
::
TestWithParam
;
using
::
testing
::
Values
;
using
::
testing
::
Values
;
...
@@ -116,15 +115,4 @@ INSTANTIATE_TEST_CASE_P(OnTheFlyAndPreCalculated, PrimeTableTestSmpl7,
...
@@ -116,15 +115,4 @@ INSTANTIATE_TEST_CASE_P(OnTheFlyAndPreCalculated, PrimeTableTestSmpl7,
Values
(
&
CreateOnTheFlyPrimeTable
,
Values
(
&
CreateOnTheFlyPrimeTable
,
&
CreatePreCalculatedPrimeTable
<
1000
>
));
&
CreatePreCalculatedPrimeTable
<
1000
>
));
#else
// Google Test may not support value-parameterized tests with some
// compilers. If we use conditional compilation to compile out all
// code referring to the gtest_main library, MSVC linker will not link
// that library at all and consequently complain about missing entry
// point defined in that library (fatal error LNK1561: entry point
// must be defined). This dummy test keeps gtest_main linked in.
TEST
(
DummyTest
,
ValueParameterizedTestsAreNotSupportedOnThisPlatform
)
{}
#endif // GTEST_HAS_PARAM_TEST
}
// namespace
}
// namespace
googletest/src/gtest-death-test.cc
View file @
0e6da4ce
...
@@ -66,15 +66,7 @@
...
@@ -66,15 +66,7 @@
#include "gtest/gtest-message.h"
#include "gtest/gtest-message.h"
#include "gtest/internal/gtest-string.h"
#include "gtest/internal/gtest-string.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 exists to
// prevent the accidental inclusion of gtest-internal-inl.h in the
// user's code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
namespace
testing
{
namespace
testing
{
...
@@ -259,7 +251,7 @@ enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW };
...
@@ -259,7 +251,7 @@ enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW };
// message is propagated back to the parent process. Otherwise, the
// message is propagated back to the parent process. Otherwise, the
// message is simply printed to stderr. In either case, the program
// message is simply printed to stderr. In either case, the program
// then exits with status 1.
// then exits with status 1.
void
DeathTestAbort
(
const
std
::
string
&
message
)
{
static
void
DeathTestAbort
(
const
std
::
string
&
message
)
{
// On a POSIX system, this function may be called from a threadsafe-style
// On a POSIX system, this function may be called from a threadsafe-style
// death test child process, which operates on a very small stack. Use
// death test child process, which operates on a very small stack. Use
// the heap for any additional non-minuscule memory requirements.
// the heap for any additional non-minuscule memory requirements.
...
@@ -985,6 +977,7 @@ static int ExecDeathTestChildMain(void* child_arg) {
...
@@ -985,6 +977,7 @@ static int ExecDeathTestChildMain(void* child_arg) {
}
}
# endif // !GTEST_OS_QNX
# endif // !GTEST_OS_QNX
# if GTEST_HAS_CLONE
// Two utility routines that together determine the direction the stack
// Two utility routines that together determine the direction the stack
// grows.
// grows.
// This could be accomplished more elegantly by a single recursive
// This could be accomplished more elegantly by a single recursive
...
@@ -994,20 +987,22 @@ static int ExecDeathTestChildMain(void* child_arg) {
...
@@ -994,20 +987,22 @@ static int ExecDeathTestChildMain(void* child_arg) {
// GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining
// GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining
// StackLowerThanAddress into StackGrowsDown, which then doesn't give
// StackLowerThanAddress into StackGrowsDown, which then doesn't give
// correct answer.
// correct answer.
void
StackLowerThanAddress
(
const
void
*
ptr
,
bool
*
result
)
GTEST_NO_INLINE_
;
static
void
StackLowerThanAddress
(
const
void
*
ptr
,
void
StackLowerThanAddress
(
const
void
*
ptr
,
bool
*
result
)
{
bool
*
result
)
GTEST_NO_INLINE_
;
static
void
StackLowerThanAddress
(
const
void
*
ptr
,
bool
*
result
)
{
int
dummy
;
int
dummy
;
*
result
=
(
&
dummy
<
ptr
);
*
result
=
(
&
dummy
<
ptr
);
}
}
// Make sure AddressSanitizer does not tamper with the stack here.
// Make sure AddressSanitizer does not tamper with the stack here.
GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
bool
StackGrowsDown
()
{
static
bool
StackGrowsDown
()
{
int
dummy
;
int
dummy
;
bool
result
;
bool
result
;
StackLowerThanAddress
(
&
dummy
,
&
result
);
StackLowerThanAddress
(
&
dummy
,
&
result
);
return
result
;
return
result
;
}
}
# endif // GTEST_HAS_CLONE
// Spawns a child process with the same executable as the current process in
// Spawns a child process with the same executable as the current process in
// a thread-safe manner and instructs it to run the death test. The
// a thread-safe manner and instructs it to run the death test. The
...
@@ -1223,12 +1218,12 @@ bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,
...
@@ -1223,12 +1218,12 @@ bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,
// Recreates the pipe and event handles from the provided parameters,
// Recreates the pipe and event handles from the provided parameters,
// signals the event, and returns a file descriptor wrapped around the pipe
// signals the event, and returns a file descriptor wrapped around the pipe
// handle. This function is called in the child process only.
// handle. This function is called in the child process only.
int
GetStatusFileDescriptor
(
unsigned
int
parent_process_id
,
static
int
GetStatusFileDescriptor
(
unsigned
int
parent_process_id
,
size_t
write_handle_as_size_t
,
size_t
write_handle_as_size_t
,
size_t
event_handle_as_size_t
)
{
size_t
event_handle_as_size_t
)
{
AutoHandle
parent_process_handle
(
::
OpenProcess
(
PROCESS_DUP_HANDLE
,
AutoHandle
parent_process_handle
(
::
OpenProcess
(
PROCESS_DUP_HANDLE
,
FALSE
,
// Non-inheritable.
FALSE
,
// Non-inheritable.
parent_process_id
));
parent_process_id
));
if
(
parent_process_handle
.
Get
()
==
INVALID_HANDLE_VALUE
)
{
if
(
parent_process_handle
.
Get
()
==
INVALID_HANDLE_VALUE
)
{
DeathTestAbort
(
"Unable to open parent process "
+
DeathTestAbort
(
"Unable to open parent process "
+
StreamableToString
(
parent_process_id
));
StreamableToString
(
parent_process_id
));
...
...
googletest/src/gtest-internal-inl.h
View file @
0e6da4ce
...
@@ -37,14 +37,6 @@
...
@@ -37,14 +37,6 @@
#ifndef GTEST_SRC_GTEST_INTERNAL_INL_H_
#ifndef GTEST_SRC_GTEST_INTERNAL_INL_H_
#define GTEST_SRC_GTEST_INTERNAL_INL_H_
#define GTEST_SRC_GTEST_INTERNAL_INL_H_
// GTEST_IMPLEMENTATION_ is defined to 1 iff the current translation unit is
// part of Google Test's implementation; otherwise it's undefined.
#if !GTEST_IMPLEMENTATION_
// If this file is included from the user's 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."
#endif // GTEST_IMPLEMENTATION_
#ifndef _WIN32_WCE
#ifndef _WIN32_WCE
# include <errno.h>
# include <errno.h>
#endif // !_WIN32_WCE
#endif // !_WIN32_WCE
...
@@ -664,13 +656,11 @@ class GTEST_API_ UnitTestImpl {
...
@@ -664,13 +656,11 @@ class GTEST_API_ UnitTestImpl {
tear_down_tc
)
->
AddTestInfo
(
test_info
);
tear_down_tc
)
->
AddTestInfo
(
test_info
);
}
}
#if GTEST_HAS_PARAM_TEST
// Returns ParameterizedTestCaseRegistry object used to keep track of
// Returns ParameterizedTestCaseRegistry object used to keep track of
// value-parameterized tests and instantiate and register them.
// value-parameterized tests and instantiate and register them.
internal
::
ParameterizedTestCaseRegistry
&
parameterized_test_registry
()
{
internal
::
ParameterizedTestCaseRegistry
&
parameterized_test_registry
()
{
return
parameterized_test_registry_
;
return
parameterized_test_registry_
;
}
}
#endif // GTEST_HAS_PARAM_TEST
// Sets the TestCase object for the test that's currently running.
// Sets the TestCase object for the test that's currently running.
void
set_current_test_case
(
TestCase
*
a_current_test_case
)
{
void
set_current_test_case
(
TestCase
*
a_current_test_case
)
{
...
@@ -845,14 +835,12 @@ class GTEST_API_ UnitTestImpl {
...
@@ -845,14 +835,12 @@ class GTEST_API_ UnitTestImpl {
// shuffled order.
// shuffled order.
std
::
vector
<
int
>
test_case_indices_
;
std
::
vector
<
int
>
test_case_indices_
;
#if GTEST_HAS_PARAM_TEST
// ParameterizedTestRegistry object used to register value-parameterized
// ParameterizedTestRegistry object used to register value-parameterized
// tests.
// tests.
internal
::
ParameterizedTestCaseRegistry
parameterized_test_registry_
;
internal
::
ParameterizedTestCaseRegistry
parameterized_test_registry_
;
// Indicates whether RegisterParameterizedTests() has been called already.
// Indicates whether RegisterParameterizedTests() has been called already.
bool
parameterized_tests_registered_
;
bool
parameterized_tests_registered_
;
#endif // GTEST_HAS_PARAM_TEST
// Index of the last death test case registered. Initially -1.
// Index of the last death test case registered. Initially -1.
int
last_death_test_case_
;
int
last_death_test_case_
;
...
...
googletest/src/gtest-port.cc
View file @
0e6da4ce
...
@@ -67,15 +67,7 @@
...
@@ -67,15 +67,7 @@
#include "gtest/gtest-message.h"
#include "gtest/gtest-message.h"
#include "gtest/internal/gtest-internal.h"
#include "gtest/internal/gtest-internal.h"
#include "gtest/internal/gtest-string.h"
#include "gtest/internal/gtest-string.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 exists to
// prevent the accidental inclusion of gtest-internal-inl.h in the
// user's code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
namespace
testing
{
namespace
testing
{
namespace
internal
{
namespace
internal
{
...
@@ -671,7 +663,7 @@ bool AtomMatchesChar(bool escaped, char pattern_char, char ch) {
...
@@ -671,7 +663,7 @@ bool AtomMatchesChar(bool escaped, char pattern_char, char ch) {
}
}
// Helper function used by ValidateRegex() to format error messages.
// Helper function used by ValidateRegex() to format error messages.
std
::
string
FormatRegexSyntaxError
(
const
char
*
regex
,
int
index
)
{
static
std
::
string
FormatRegexSyntaxError
(
const
char
*
regex
,
int
index
)
{
return
(
Message
()
<<
"Syntax error at index "
<<
index
return
(
Message
()
<<
"Syntax error at index "
<<
index
<<
" in simple regular expression
\"
"
<<
regex
<<
"
\"
: "
).
GetString
();
<<
" in simple regular expression
\"
"
<<
regex
<<
"
\"
: "
).
GetString
();
}
}
...
@@ -1015,7 +1007,9 @@ static CapturedStream* g_captured_stderr = NULL;
...
@@ -1015,7 +1007,9 @@ static CapturedStream* g_captured_stderr = NULL;
static
CapturedStream
*
g_captured_stdout
=
NULL
;
static
CapturedStream
*
g_captured_stdout
=
NULL
;
// Starts capturing an output stream (stdout/stderr).
// Starts capturing an output stream (stdout/stderr).
void
CaptureStream
(
int
fd
,
const
char
*
stream_name
,
CapturedStream
**
stream
)
{
static
void
CaptureStream
(
int
fd
,
const
char
*
stream_name
,
CapturedStream
**
stream
)
{
if
(
*
stream
!=
NULL
)
{
if
(
*
stream
!=
NULL
)
{
GTEST_LOG_
(
FATAL
)
<<
"Only one "
<<
stream_name
GTEST_LOG_
(
FATAL
)
<<
"Only one "
<<
stream_name
<<
" capturer can exist at a time."
;
<<
" capturer can exist at a time."
;
...
@@ -1024,7 +1018,7 @@ void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) {
...
@@ -1024,7 +1018,7 @@ void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) {
}
}
// Stops capturing the output stream and returns the captured string.
// Stops capturing the output stream and returns the captured string.
std
::
string
GetCapturedStream
(
CapturedStream
**
captured_stream
)
{
static
std
::
string
GetCapturedStream
(
CapturedStream
**
captured_stream
)
{
const
std
::
string
content
=
(
*
captured_stream
)
->
GetCapturedString
();
const
std
::
string
content
=
(
*
captured_stream
)
->
GetCapturedString
();
delete
*
captured_stream
;
delete
*
captured_stream
;
...
...
googletest/src/gtest-test-part.cc
View file @
0e6da4ce
...
@@ -32,15 +32,7 @@
...
@@ -32,15 +32,7 @@
// The Google C++ Testing Framework (Google Test)
// The Google C++ Testing Framework (Google Test)
#include "gtest/gtest-test-part.h"
#include "gtest/gtest-test-part.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 exists to
// prevent the accidental inclusion of gtest-internal-inl.h in the
// user's code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
namespace
testing
{
namespace
testing
{
...
...
googletest/src/gtest.cc
View file @
0e6da4ce
...
@@ -133,14 +133,7 @@
...
@@ -133,14 +133,7 @@
# include <sys/types.h> // NOLINT
# include <sys/types.h> // NOLINT
#endif
#endif
// 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
// their code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
#if GTEST_OS_WINDOWS
#if GTEST_OS_WINDOWS
# define vsnprintf _vsnprintf
# define vsnprintf _vsnprintf
...
@@ -629,12 +622,12 @@ extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId();
...
@@ -629,12 +622,12 @@ extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId();
// This predicate-formatter checks that 'results' contains a test part
// This predicate-formatter checks that 'results' contains a test part
// failure of the given type and that the failure message contains the
// failure of the given type and that the failure message contains the
// given substring.
// given substring.
AssertionResult
HasOneFailure
(
const
char
*
/* results_expr */
,
static
AssertionResult
HasOneFailure
(
const
char
*
/* results_expr */
,
const
char
*
/* type_expr */
,
const
char
*
/* type_expr */
,
const
char
*
/* substr_expr */
,
const
char
*
/* substr_expr */
,
const
TestPartResultArray
&
results
,
const
TestPartResultArray
&
results
,
TestPartResult
::
Type
type
,
TestPartResult
::
Type
type
,
const
std
::
string
&
substr
)
{
const
std
::
string
&
substr
)
{
const
std
::
string
expected
(
type
==
TestPartResult
::
kFatalFailure
?
const
std
::
string
expected
(
type
==
TestPartResult
::
kFatalFailure
?
"1 fatal failure"
:
"1 fatal failure"
:
"1 non-fatal failure"
);
"1 non-fatal failure"
);
...
@@ -2137,8 +2130,9 @@ static std::string FormatWordList(const std::vector<std::string>& words) {
...
@@ -2137,8 +2130,9 @@ static std::string FormatWordList(const std::vector<std::string>& words) {
return
word_list
.
GetString
();
return
word_list
.
GetString
();
}
}
bool
ValidateTestPropertyName
(
const
std
::
string
&
property_name
,
static
bool
ValidateTestPropertyName
(
const
std
::
vector
<
std
::
string
>&
reserved_names
)
{
const
std
::
string
&
property_name
,
const
std
::
vector
<
std
::
string
>&
reserved_names
)
{
if
(
std
::
find
(
reserved_names
.
begin
(),
reserved_names
.
end
(),
property_name
)
!=
if
(
std
::
find
(
reserved_names
.
begin
(),
reserved_names
.
end
(),
property_name
)
!=
reserved_names
.
end
())
{
reserved_names
.
end
())
{
ADD_FAILURE
()
<<
"Reserved key used in RecordProperty(): "
<<
property_name
ADD_FAILURE
()
<<
"Reserved key used in RecordProperty(): "
<<
property_name
...
@@ -2556,7 +2550,6 @@ TestInfo* MakeAndRegisterTestInfo(
...
@@ -2556,7 +2550,6 @@ TestInfo* MakeAndRegisterTestInfo(
return
test_info
;
return
test_info
;
}
}
#if GTEST_HAS_PARAM_TEST
void
ReportInvalidTestCaseType
(
const
char
*
test_case_name
,
void
ReportInvalidTestCaseType
(
const
char
*
test_case_name
,
CodeLocation
code_location
)
{
CodeLocation
code_location
)
{
Message
errors
;
Message
errors
;
...
@@ -2570,12 +2563,11 @@ void ReportInvalidTestCaseType(const char* test_case_name,
...
@@ -2570,12 +2563,11 @@ void ReportInvalidTestCaseType(const char* test_case_name,
<<
"probably rename one of the classes to put the tests into different
\n
"
<<
"probably rename one of the classes to put the tests into different
\n
"
<<
"test cases."
;
<<
"test cases."
;
GTEST_LOG_
(
ERROR
)
GTEST_LOG_
(
ERROR
)
<<
FormatFileLocation
(
code_location
.
file
.
c_str
(),
<<
FormatFileLocation
(
code_location
.
file
.
c_str
(),
code_location
.
line
)
code_location
.
line
)
<<
" "
<<
errors
.
GetString
();
<<
" "
<<
errors
.
GetString
();
}
}
#endif // GTEST_HAS_PARAM_TEST
}
// namespace internal
}
// namespace internal
...
@@ -2614,12 +2606,10 @@ namespace internal {
...
@@ -2614,12 +2606,10 @@ namespace internal {
// and INSTANTIATE_TEST_CASE_P into regular tests and registers those.
// and INSTANTIATE_TEST_CASE_P into regular tests and registers those.
// This will be done just once during the program runtime.
// This will be done just once during the program runtime.
void
UnitTestImpl
::
RegisterParameterizedTests
()
{
void
UnitTestImpl
::
RegisterParameterizedTests
()
{
#if GTEST_HAS_PARAM_TEST
if
(
!
parameterized_tests_registered_
)
{
if
(
!
parameterized_tests_registered_
)
{
parameterized_test_registry_
.
RegisterTests
();
parameterized_test_registry_
.
RegisterTests
();
parameterized_tests_registered_
=
true
;
parameterized_tests_registered_
=
true
;
}
}
#endif
}
}
}
// namespace internal
}
// namespace internal
...
@@ -2887,7 +2877,7 @@ enum GTestColor {
...
@@ -2887,7 +2877,7 @@ enum GTestColor {
!GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW
!GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW
// Returns the character attribute for the given color.
// Returns the character attribute for the given color.
WORD
GetColorAttribute
(
GTestColor
color
)
{
static
WORD
GetColorAttribute
(
GTestColor
color
)
{
switch
(
color
)
{
switch
(
color
)
{
case
COLOR_RED
:
return
FOREGROUND_RED
;
case
COLOR_RED
:
return
FOREGROUND_RED
;
case
COLOR_GREEN
:
return
FOREGROUND_GREEN
;
case
COLOR_GREEN
:
return
FOREGROUND_GREEN
;
...
@@ -2896,7 +2886,7 @@ WORD GetColorAttribute(GTestColor color) {
...
@@ -2896,7 +2886,7 @@ WORD GetColorAttribute(GTestColor color) {
}
}
}
}
int
GetBitOffset
(
WORD
color_mask
)
{
static
int
GetBitOffset
(
WORD
color_mask
)
{
if
(
color_mask
==
0
)
return
0
;
if
(
color_mask
==
0
)
return
0
;
int
bitOffset
=
0
;
int
bitOffset
=
0
;
...
@@ -2907,7 +2897,7 @@ int GetBitOffset(WORD color_mask) {
...
@@ -2907,7 +2897,7 @@ int GetBitOffset(WORD color_mask) {
return
bitOffset
;
return
bitOffset
;
}
}
WORD
GetNewColor
(
GTestColor
color
,
WORD
old_color_attrs
)
{
static
WORD
GetNewColor
(
GTestColor
color
,
WORD
old_color_attrs
)
{
// Let's reuse the BG
// Let's reuse the BG
static
const
WORD
background_mask
=
BACKGROUND_BLUE
|
BACKGROUND_GREEN
|
BACKGROUND_RED
|
BACKGROUND_INTENSITY
;
static
const
WORD
background_mask
=
BACKGROUND_BLUE
|
BACKGROUND_GREEN
|
BACKGROUND_RED
|
BACKGROUND_INTENSITY
;
static
const
WORD
foreground_mask
=
FOREGROUND_BLUE
|
FOREGROUND_GREEN
|
FOREGROUND_RED
|
FOREGROUND_INTENSITY
;
static
const
WORD
foreground_mask
=
FOREGROUND_BLUE
|
FOREGROUND_GREEN
|
FOREGROUND_RED
|
FOREGROUND_INTENSITY
;
...
@@ -2922,12 +2912,12 @@ WORD GetNewColor(GTestColor color, WORD old_color_attrs) {
...
@@ -2922,12 +2912,12 @@ WORD GetNewColor(GTestColor color, WORD old_color_attrs) {
}
}
return
new_color
;
return
new_color
;
}
}
#else
#else
// Returns the ANSI color code for the given color. COLOR_DEFAULT is
// Returns the ANSI color code for the given color. COLOR_DEFAULT is
// an invalid input.
// an invalid input.
const
char
*
GetAnsiColorCode
(
GTestColor
color
)
{
static
const
char
*
GetAnsiColorCode
(
GTestColor
color
)
{
switch
(
color
)
{
switch
(
color
)
{
case
COLOR_RED
:
return
"1"
;
case
COLOR_RED
:
return
"1"
;
case
COLOR_GREEN
:
return
"2"
;
case
COLOR_GREEN
:
return
"2"
;
...
@@ -2980,7 +2970,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
...
@@ -2980,7 +2970,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
// This routine must actually emit the characters rather than return a string
// This routine must actually emit the characters rather than return a string
// that would be colored when printed, as can be done on Linux.
// that would be colored when printed, as can be done on Linux.
GTEST_ATTRIBUTE_PRINTF_
(
2
,
3
)
GTEST_ATTRIBUTE_PRINTF_
(
2
,
3
)
void
ColoredPrintf
(
GTestColor
color
,
const
char
*
fmt
,
...)
{
static
void
ColoredPrintf
(
GTestColor
color
,
const
char
*
fmt
,
...)
{
va_list
args
;
va_list
args
;
va_start
(
args
,
fmt
);
va_start
(
args
,
fmt
);
...
@@ -3009,7 +2999,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
...
@@ -3009,7 +2999,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
GetConsoleScreenBufferInfo
(
stdout_handle
,
&
buffer_info
);
GetConsoleScreenBufferInfo
(
stdout_handle
,
&
buffer_info
);
const
WORD
old_color_attrs
=
buffer_info
.
wAttributes
;
const
WORD
old_color_attrs
=
buffer_info
.
wAttributes
;
const
WORD
new_color
=
GetNewColor
(
color
,
old_color_attrs
);
const
WORD
new_color
=
GetNewColor
(
color
,
old_color_attrs
);
// We need to flush the stream buffers into the console before each
// We need to flush the stream buffers into the console before each
// SetConsoleTextAttribute call lest it affect the text that is already
// SetConsoleTextAttribute call lest it affect the text that is already
// printed but has not yet reached the console.
// printed but has not yet reached the console.
...
@@ -3034,7 +3024,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
...
@@ -3034,7 +3024,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
static
const
char
kTypeParamLabel
[]
=
"TypeParam"
;
static
const
char
kTypeParamLabel
[]
=
"TypeParam"
;
static
const
char
kValueParamLabel
[]
=
"GetParam()"
;
static
const
char
kValueParamLabel
[]
=
"GetParam()"
;
void
PrintFullTestCommentIfPresent
(
const
TestInfo
&
test_info
)
{
static
void
PrintFullTestCommentIfPresent
(
const
TestInfo
&
test_info
)
{
const
char
*
const
type_param
=
test_info
.
type_param
();
const
char
*
const
type_param
=
test_info
.
type_param
();
const
char
*
const
value_param
=
test_info
.
value_param
();
const
char
*
const
value_param
=
test_info
.
value_param
();
...
@@ -3475,7 +3465,7 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
...
@@ -3475,7 +3465,7 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
// 3. To interpret the meaning of errno in a thread-safe way,
// 3. To interpret the meaning of errno in a thread-safe way,
// we need the strerror_r() function, which is not available on
// we need the strerror_r() function, which is not available on
// Windows.
// Windows.
GTEST_LOG_
(
FATAL
)
<<
"Unable to open file
\"
"
GTEST_LOG_
(
FATAL
)
<<
"Unable to open file
\"
"
<<
output_file_
<<
"
\"
"
;
<<
output_file_
<<
"
\"
"
;
}
}
std
::
stringstream
stream
;
std
::
stringstream
stream
;
...
@@ -4309,7 +4299,6 @@ const TestInfo* UnitTest::current_test_info() const
...
@@ -4309,7 +4299,6 @@ const TestInfo* UnitTest::current_test_info() const
// Returns the random seed used at the start of the current test run.
// Returns the random seed used at the start of the current test run.
int
UnitTest
::
random_seed
()
const
{
return
impl_
->
random_seed
();
}
int
UnitTest
::
random_seed
()
const
{
return
impl_
->
random_seed
();
}
#if GTEST_HAS_PARAM_TEST
// Returns ParameterizedTestCaseRegistry object used to keep track of
// Returns ParameterizedTestCaseRegistry object used to keep track of
// value-parameterized tests and instantiate and register them.
// value-parameterized tests and instantiate and register them.
internal
::
ParameterizedTestCaseRegistry
&
internal
::
ParameterizedTestCaseRegistry
&
...
@@ -4317,7 +4306,6 @@ internal::ParameterizedTestCaseRegistry&
...
@@ -4317,7 +4306,6 @@ internal::ParameterizedTestCaseRegistry&
GTEST_LOCK_EXCLUDED_
(
mutex_
)
{
GTEST_LOCK_EXCLUDED_
(
mutex_
)
{
return
impl_
->
parameterized_test_registry
();
return
impl_
->
parameterized_test_registry
();
}
}
#endif // GTEST_HAS_PARAM_TEST
// Creates an empty UnitTest.
// Creates an empty UnitTest.
UnitTest
::
UnitTest
()
{
UnitTest
::
UnitTest
()
{
...
@@ -4356,10 +4344,8 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent)
...
@@ -4356,10 +4344,8 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent)
&
default_global_test_part_result_reporter_
),
&
default_global_test_part_result_reporter_
),
per_thread_test_part_result_reporter_
(
per_thread_test_part_result_reporter_
(
&
default_per_thread_test_part_result_reporter_
),
&
default_per_thread_test_part_result_reporter_
),
#if GTEST_HAS_PARAM_TEST
parameterized_test_registry_
(),
parameterized_test_registry_
(),
parameterized_tests_registered_
(
false
),
parameterized_tests_registered_
(
false
),
#endif // GTEST_HAS_PARAM_TEST
last_death_test_case_
(
-
1
),
last_death_test_case_
(
-
1
),
current_test_case_
(
NULL
),
current_test_case_
(
NULL
),
current_test_info_
(
NULL
),
current_test_info_
(
NULL
),
...
@@ -4427,8 +4413,8 @@ void UnitTestImpl::ConfigureXmlOutput() {
...
@@ -4427,8 +4413,8 @@ void UnitTestImpl::ConfigureXmlOutput() {
listeners
()
->
SetDefaultXmlGenerator
(
new
XmlUnitTestResultPrinter
(
listeners
()
->
SetDefaultXmlGenerator
(
new
XmlUnitTestResultPrinter
(
UnitTestOptions
::
GetAbsolutePathToOutputFile
().
c_str
()));
UnitTestOptions
::
GetAbsolutePathToOutputFile
().
c_str
()));
}
else
if
(
output_format
!=
""
)
{
}
else
if
(
output_format
!=
""
)
{
GTEST_LOG_
(
WARNING
)
<<
"WARNING: unrecognized output format
\"
"
GTEST_LOG_
(
WARNING
)
<<
"WARNING: unrecognized output format
\"
"
<<
output_format
<<
output_format
<<
"
\"
ignored."
;
<<
"
\"
ignored."
;
}
}
}
}
...
@@ -4444,8 +4430,8 @@ void UnitTestImpl::ConfigureStreamingOutput() {
...
@@ -4444,8 +4430,8 @@ void UnitTestImpl::ConfigureStreamingOutput() {
listeners
()
->
Append
(
new
StreamingListener
(
target
.
substr
(
0
,
pos
),
listeners
()
->
Append
(
new
StreamingListener
(
target
.
substr
(
0
,
pos
),
target
.
substr
(
pos
+
1
)));
target
.
substr
(
pos
+
1
)));
}
else
{
}
else
{
GTEST_LOG_
(
WARNING
)
<<
"unrecognized streaming target
\"
"
GTEST_LOG_
(
WARNING
)
<<
"unrecognized streaming target
\"
"
<<
target
<<
target
<<
"
\"
ignored."
;
<<
"
\"
ignored."
;
}
}
}
}
...
@@ -4575,7 +4561,7 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); }
...
@@ -4575,7 +4561,7 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); }
bool
UnitTestImpl
::
RunAllTests
()
{
bool
UnitTestImpl
::
RunAllTests
()
{
// Makes sure InitGoogleTest() was called.
// Makes sure InitGoogleTest() was called.
if
(
!
GTestIsInitialized
())
{
if
(
!
GTestIsInitialized
())
{
GTEST_LOG_
(
ERROR
)
<<
GTEST_LOG_
(
ERROR
)
<<
"
\n
This test program did NOT call ::testing::InitGoogleTest "
"
\n
This test program did NOT call ::testing::InitGoogleTest "
"before calling RUN_ALL_TESTS(). Please fix it."
;
"before calling RUN_ALL_TESTS(). Please fix it."
;
return
false
;
return
false
;
...
@@ -5036,9 +5022,9 @@ bool SkipPrefix(const char* prefix, const char** pstr) {
...
@@ -5036,9 +5022,9 @@ bool SkipPrefix(const char* prefix, const char** pstr) {
// part can be omitted.
// part can be omitted.
//
//
// Returns the value of the flag, or NULL if the parsing failed.
// Returns the value of the flag, or NULL if the parsing failed.
const
char
*
ParseFlagValue
(
const
char
*
str
,
static
const
char
*
ParseFlagValue
(
const
char
*
str
,
const
char
*
flag
,
const
char
*
flag
,
bool
def_optional
)
{
bool
def_optional
)
{
// str and flag must not be NULL.
// str and flag must not be NULL.
if
(
str
==
NULL
||
flag
==
NULL
)
return
NULL
;
if
(
str
==
NULL
||
flag
==
NULL
)
return
NULL
;
...
@@ -5074,7 +5060,7 @@ const char* ParseFlagValue(const char* str,
...
@@ -5074,7 +5060,7 @@ const char* ParseFlagValue(const char* str,
//
//
// On success, stores the value of the flag in *value, and returns
// On success, stores the value of the flag in *value, and returns
// true. On failure, returns false without changing *value.
// true. On failure, returns false without changing *value.
bool
ParseBoolFlag
(
const
char
*
str
,
const
char
*
flag
,
bool
*
value
)
{
static
bool
ParseBoolFlag
(
const
char
*
str
,
const
char
*
flag
,
bool
*
value
)
{
// Gets the value of the flag as a string.
// Gets the value of the flag as a string.
const
char
*
const
value_str
=
ParseFlagValue
(
str
,
flag
,
true
);
const
char
*
const
value_str
=
ParseFlagValue
(
str
,
flag
,
true
);
...
@@ -5108,7 +5094,9 @@ bool ParseInt32Flag(const char* str, const char* flag, Int32* value) {
...
@@ -5108,7 +5094,9 @@ bool ParseInt32Flag(const char* str, const char* flag, Int32* value) {
//
//
// On success, stores the value of the flag in *value, and returns
// On success, stores the value of the flag in *value, and returns
// true. On failure, returns false without changing *value.
// true. On failure, returns false without changing *value.
bool
ParseStringFlag
(
const
char
*
str
,
const
char
*
flag
,
std
::
string
*
value
)
{
static
bool
ParseStringFlag
(
const
char
*
str
,
const
char
*
flag
,
std
::
string
*
value
)
{
// Gets the value of the flag as a string.
// Gets the value of the flag as a string.
const
char
*
const
value_str
=
ParseFlagValue
(
str
,
flag
,
false
);
const
char
*
const
value_str
=
ParseFlagValue
(
str
,
flag
,
false
);
...
@@ -5244,7 +5232,7 @@ static const char kColorEncodedHelpMessage[] =
...
@@ -5244,7 +5232,7 @@ static const char kColorEncodedHelpMessage[] =
"(not one in your own code or tests), please report it to
\n
"
"(not one in your own code or tests), please report it to
\n
"
"@G<"
GTEST_DEV_EMAIL_
">@D.
\n
"
;
"@G<"
GTEST_DEV_EMAIL_
">@D.
\n
"
;
bool
ParseGoogleTestFlag
(
const
char
*
const
arg
)
{
static
bool
ParseGoogleTestFlag
(
const
char
*
const
arg
)
{
return
ParseBoolFlag
(
arg
,
kAlsoRunDisabledTestsFlag
,
return
ParseBoolFlag
(
arg
,
kAlsoRunDisabledTestsFlag
,
&
GTEST_FLAG
(
also_run_disabled_tests
))
||
&
GTEST_FLAG
(
also_run_disabled_tests
))
||
ParseBoolFlag
(
arg
,
kBreakOnFailureFlag
,
ParseBoolFlag
(
arg
,
kBreakOnFailureFlag
,
...
@@ -5274,11 +5262,11 @@ bool ParseGoogleTestFlag(const char* const arg) {
...
@@ -5274,11 +5262,11 @@ bool ParseGoogleTestFlag(const char* const arg) {
}
}
#if GTEST_USE_OWN_FLAGFILE_FLAG_
#if GTEST_USE_OWN_FLAGFILE_FLAG_
void
LoadFlagsFromFile
(
const
std
::
string
&
path
)
{
static
void
LoadFlagsFromFile
(
const
std
::
string
&
path
)
{
FILE
*
flagfile
=
posix
::
FOpen
(
path
.
c_str
(),
"r"
);
FILE
*
flagfile
=
posix
::
FOpen
(
path
.
c_str
(),
"r"
);
if
(
!
flagfile
)
{
if
(
!
flagfile
)
{
GTEST_LOG_
(
FATAL
)
<<
"Unable to open file
\"
"
GTEST_LOG_
(
FATAL
)
<<
"Unable to open file
\"
"
<<
GTEST_FLAG
(
flagfile
)
<<
GTEST_FLAG
(
flagfile
)
<<
"
\"
"
;
<<
"
\"
"
;
}
}
std
::
string
contents
(
ReadEntireFile
(
flagfile
));
std
::
string
contents
(
ReadEntireFile
(
flagfile
));
...
...
googletest/test/BUILD.bazel
View file @
0e6da4ce
...
@@ -57,13 +57,15 @@ cc_test(
...
@@ -57,13 +57,15 @@ cc_test(
"gtest-param-test_test.cc"
,
"gtest-param-test_test.cc"
,
],
],
)
+
select
({
)
+
select
({
"//:win"
:
[],
"//:windows"
:
[],
"//:windows_msvc"
:
[],
"//conditions:default"
:
[
"//conditions:default"
:
[
"gtest-tuple_test.cc"
,
"gtest-tuple_test.cc"
,
],
],
}),
}),
copts
=
select
({
copts
=
select
({
"//:win"
:
[
"-DGTEST_USE_OWN_TR1_TUPLE=0"
],
"//:windows"
:
[
"-DGTEST_USE_OWN_TR1_TUPLE=0"
],
"//:windows_msvc"
:
[
"-DGTEST_USE_OWN_TR1_TUPLE=0"
],
"//conditions:default"
:
[
"-DGTEST_USE_OWN_TR1_TUPLE=1"
],
"//conditions:default"
:
[
"-DGTEST_USE_OWN_TR1_TUPLE=1"
],
}),
}),
includes
=
[
includes
=
[
...
@@ -73,7 +75,8 @@ cc_test(
...
@@ -73,7 +75,8 @@ cc_test(
"googletest/test"
,
"googletest/test"
,
],
],
linkopts
=
select
({
linkopts
=
select
({
"//:win"
:
[],
"//:windows"
:
[],
"//:windows_msvc"
:
[],
"//conditions:default"
:
[
"//conditions:default"
:
[
"-pthread"
,
"-pthread"
,
],
],
...
...
googletest/test/gtest-death-test_test.cc
View file @
0e6da4ce
...
@@ -56,15 +56,7 @@ using testing::internal::AlwaysTrue;
...
@@ -56,15 +56,7 @@ using testing::internal::AlwaysTrue;
# endif // GTEST_OS_LINUX
# endif // GTEST_OS_LINUX
# 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
// their code.
# define GTEST_IMPLEMENTATION_ 1
# include "src/gtest-internal-inl.h"
# include "src/gtest-internal-inl.h"
# undef GTEST_IMPLEMENTATION_
namespace
posix
=
::
testing
::
internal
::
posix
;
namespace
posix
=
::
testing
::
internal
::
posix
;
...
@@ -313,14 +305,14 @@ void DieWithEmbeddedNul() {
...
@@ -313,14 +305,14 @@ void DieWithEmbeddedNul() {
}
}
# if GTEST_USES_PCRE
# if GTEST_USES_PCRE
// Tests that EXPECT_DEATH and ASSERT_DEATH work when the error
// Tests that EXPECT_DEATH and ASSERT_DEATH work when the error
// message has a NUL character in it.
// message has a NUL character in it.
TEST_F
(
TestForDeathTest
,
EmbeddedNulInMessage
)
{
TEST_F
(
TestForDeathTest
,
EmbeddedNulInMessage
)
{
// TODO(wan@google.com): <regex.h> doesn't support matching strings
// with embedded NUL characters - find a way to workaround it.
EXPECT_DEATH
(
DieWithEmbeddedNul
(),
"my null world"
);
EXPECT_DEATH
(
DieWithEmbeddedNul
(),
"my null world"
);
ASSERT_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
// Tests that death test macros expand to code which interacts well with switch
...
...
googletest/test/gtest-filepath_test.cc
View file @
0e6da4ce
...
@@ -27,28 +27,18 @@
...
@@ -27,28 +27,18 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//
// Authors: keith.ray@gmail.com (Keith Ray)
//
//
// Google Test filepath utilities
// Google Test filepath utilities
//
//
// This file tests classes and functions used internally by
// This file tests classes and functions used internally by
// Google Test. They are subject to change without notice.
// Google Test. They are subject to change without notice.
//
//
// This file is #included from gtest_unittest.cc, to avoid changing
// This file is #included from gtest-internal.h.
// build or make-files for some existing Google Test clients. Do not
// Do not #include this file anywhere else!
// #include this file anywhere else!
#include "gtest/internal/gtest-filepath.h"
#include "gtest/internal/gtest-filepath.h"
#include "gtest/gtest.h"
#include "gtest/gtest.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
// their code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
#if GTEST_OS_WINDOWS_MOBILE
#if GTEST_OS_WINDOWS_MOBILE
# include <windows.h> // NOLINT
# include <windows.h> // NOLINT
...
...
googletest/test/gtest-options_test.cc
View file @
0e6da4ce
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//
// Authors: keith.ray@gmail.com (Keith Ray)
//
//
// Google Test UnitTestOptions tests
// Google Test UnitTestOptions tests
//
//
...
@@ -46,14 +45,7 @@
...
@@ -46,14 +45,7 @@
# include <direct.h>
# include <direct.h>
#endif // GTEST_OS_WINDOWS_MOBILE
#endif // GTEST_OS_WINDOWS_MOBILE
// 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
// their code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
namespace
testing
{
namespace
testing
{
namespace
internal
{
namespace
internal
{
...
...
googletest/test/gtest-param-test2_test.cc
View file @
0e6da4ce
...
@@ -36,8 +36,6 @@
...
@@ -36,8 +36,6 @@
#include "test/gtest-param-test_test.h"
#include "test/gtest-param-test_test.h"
#if GTEST_HAS_PARAM_TEST
using
::
testing
::
Values
;
using
::
testing
::
Values
;
using
::
testing
::
internal
::
ParamGenerator
;
using
::
testing
::
internal
::
ParamGenerator
;
...
@@ -62,4 +60,3 @@ INSTANTIATE_TEST_CASE_P(Sequence2,
...
@@ -62,4 +60,3 @@ INSTANTIATE_TEST_CASE_P(Sequence2,
InstantiationInMultipleTranslaionUnitsTest
,
InstantiationInMultipleTranslaionUnitsTest
,
Values
(
42
*
3
,
42
*
4
,
42
*
5
));
Values
(
42
*
3
,
42
*
4
,
42
*
5
));
#endif // GTEST_HAS_PARAM_TEST
googletest/test/gtest-param-test_test.cc
View file @
0e6da4ce
...
@@ -35,19 +35,13 @@
...
@@ -35,19 +35,13 @@
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#if GTEST_HAS_PARAM_TEST
# include <algorithm>
# include <algorithm>
# include <iostream>
# include <iostream>
# include <list>
# include <list>
# include <sstream>
# include <sstream>
# include <string>
# include <string>
# include <vector>
# include <vector>
// To include gtest-internal-inl.h.
# define GTEST_IMPLEMENTATION_ 1
# include "src/gtest-internal-inl.h" // for UnitTestOptions
# 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"
...
@@ -1025,31 +1019,19 @@ TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {
...
@@ -1025,31 +1019,19 @@ TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {
INSTANTIATE_TEST_CASE_P
(
RangeZeroToFive
,
ParameterizedDerivedTest
,
Range
(
0
,
5
));
INSTANTIATE_TEST_CASE_P
(
RangeZeroToFive
,
ParameterizedDerivedTest
,
Range
(
0
,
5
));
#endif // GTEST_HAS_PARAM_TEST
TEST
(
CompileTest
,
CombineIsDefinedOnlyWhenGtestHasParamTestIsDefined
)
{
#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
)
{
int
main
(
int
argc
,
char
**
argv
)
{
#if GTEST_HAS_PARAM_TEST
// Used in TestGenerationTest test case.
// Used in TestGenerationTest test case.
AddGlobalTestEnvironment
(
TestGenerationTest
::
Environment
::
Instance
());
AddGlobalTestEnvironment
(
TestGenerationTest
::
Environment
::
Instance
());
// Used in GeneratorEvaluationTest test case. Tests that the updated value
// Used in GeneratorEvaluationTest test case. Tests that the updated value
// will be picked up for instantiating tests in GeneratorEvaluationTest.
// will be picked up for instantiating tests in GeneratorEvaluationTest.
GeneratorEvaluationTest
::
set_param_value
(
1
);
GeneratorEvaluationTest
::
set_param_value
(
1
);
#endif // GTEST_HAS_PARAM_TEST
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
#if GTEST_HAS_PARAM_TEST
// Used in GeneratorEvaluationTest test case. Tests that value updated
// Used in GeneratorEvaluationTest test case. Tests that value updated
// here will NOT be used for instantiating tests in
// here will NOT be used for instantiating tests in
// GeneratorEvaluationTest.
// GeneratorEvaluationTest.
GeneratorEvaluationTest
::
set_param_value
(
2
);
GeneratorEvaluationTest
::
set_param_value
(
2
);
#endif // GTEST_HAS_PARAM_TEST
return
RUN_ALL_TESTS
();
return
RUN_ALL_TESTS
();
}
}
googletest/test/gtest-param-test_test.h
View file @
0e6da4ce
...
@@ -39,8 +39,6 @@
...
@@ -39,8 +39,6 @@
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#if GTEST_HAS_PARAM_TEST
// Test fixture for testing definition and instantiation of a test
// Test fixture for testing definition and instantiation of a test
// in separate translation units.
// in separate translation units.
class
ExternalInstantiationTest
:
public
::
testing
::
TestWithParam
<
int
>
{
class
ExternalInstantiationTest
:
public
::
testing
::
TestWithParam
<
int
>
{
...
@@ -52,6 +50,4 @@ class InstantiationInMultipleTranslaionUnitsTest
...
@@ -52,6 +50,4 @@ class InstantiationInMultipleTranslaionUnitsTest
:
public
::
testing
::
TestWithParam
<
int
>
{
:
public
::
testing
::
TestWithParam
<
int
>
{
};
};
#endif // GTEST_HAS_PARAM_TEST
#endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_
#endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_
googletest/test/gtest-port_test.cc
View file @
0e6da4ce
...
@@ -45,15 +45,7 @@
...
@@ -45,15 +45,7 @@
#include "gtest/gtest.h"
#include "gtest/gtest.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
// their code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
using
std
::
make_pair
;
using
std
::
make_pair
;
using
std
::
pair
;
using
std
::
pair
;
...
@@ -75,8 +67,8 @@ TEST(IsXDigitTest, WorksForNarrowAscii) {
...
@@ -75,8 +67,8 @@ TEST(IsXDigitTest, WorksForNarrowAscii) {
}
}
TEST
(
IsXDigitTest
,
ReturnsFalseForNarrowNonAscii
)
{
TEST
(
IsXDigitTest
,
ReturnsFalseForNarrowNonAscii
)
{
EXPECT_FALSE
(
IsXDigit
(
'\
x80
'
));
EXPECT_FALSE
(
IsXDigit
(
static_cast
<
char
>
(
0
x80
)
));
EXPECT_FALSE
(
IsXDigit
(
static_cast
<
char
>
(
'0'
|
'\
x80
'
)));
EXPECT_FALSE
(
IsXDigit
(
static_cast
<
char
>
(
'0'
|
0
x80
)));
}
}
TEST
(
IsXDigitTest
,
WorksForWideAscii
)
{
TEST
(
IsXDigitTest
,
WorksForWideAscii
)
{
...
...
googletest/test/gtest_break_on_failure_unittest_.cc
View file @
0e6da4ce
...
@@ -80,8 +80,7 @@ int main(int argc, char **argv) {
...
@@ -80,8 +80,7 @@ int main(int argc, char **argv) {
SetUnhandledExceptionFilter
(
ExitWithExceptionCode
);
SetUnhandledExceptionFilter
(
ExitWithExceptionCode
);
# endif
# endif
#endif
#endif // GTEST_OS_WINDOWS
testing
::
InitGoogleTest
(
&
argc
,
argv
);
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
return
RUN_ALL_TESTS
();
...
...
googletest/test/gtest_color_test_.cc
View file @
0e6da4ce
...
@@ -36,15 +36,7 @@
...
@@ -36,15 +36,7 @@
#include <stdio.h>
#include <stdio.h>
#include "gtest/gtest.h"
#include "gtest/gtest.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
// their code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
using
testing
::
internal
::
ShouldUseColor
;
using
testing
::
internal
::
ShouldUseColor
;
...
...
Prev
1
2
3
4
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