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
27bb844e
Unverified
Commit
27bb844e
authored
Jan 12, 2018
by
Conor Burgess
Committed by
GitHub
Jan 12, 2018
Browse files
Merge branch 'master' into fix-argc
parents
8f90d46c
ed8d02cf
Changes
84
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
62 additions
and
196 deletions
+62
-196
googletest/src/gtest.cc
googletest/src/gtest.cc
+37
-50
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
-4
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-printers_test.cc
googletest/test/gtest-printers_test.cc
+11
-14
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
googletest/test/gtest_env_var_test_.cc
googletest/test/gtest_env_var_test_.cc
+0
-3
googletest/test/gtest_environment_test.cc
googletest/test/gtest_environment_test.cc
+0
-3
googletest/test/gtest_filter_unittest_.cc
googletest/test/gtest_filter_unittest_.cc
+0
-2
googletest/test/gtest_output_test_.cc
googletest/test/gtest_output_test_.cc
+0
-12
googletest/test/gtest_repeat_test.cc
googletest/test/gtest_repeat_test.cc
+1
-18
googletest/test/gtest_stress_test.cc
googletest/test/gtest_stress_test.cc
+0
-6
googletest/test/gtest_unittest.cc
googletest/test/gtest_unittest.cc
+0
-8
googletest/test/gtest_xml_outfile1_test_.cc
googletest/test/gtest_xml_outfile1_test_.cc
+0
-1
No files found.
googletest/src/gtest.cc
View file @
27bb844e
...
...
@@ -133,14 +133,7 @@
# include <sys/types.h> // NOLINT
#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"
#undef GTEST_IMPLEMENTATION_
#if GTEST_OS_WINDOWS
# define vsnprintf _vsnprintf
...
...
@@ -635,12 +628,12 @@ extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId();
// This predicate-formatter checks that 'results' contains a test part
// failure of the given type and that the failure message contains the
// given substring.
AssertionResult
HasOneFailure
(
const
char
*
/* results_expr */
,
const
char
*
/* type_expr */
,
const
char
*
/* substr_expr */
,
const
TestPartResultArray
&
results
,
TestPartResult
::
Type
type
,
const
std
::
string
&
substr
)
{
static
AssertionResult
HasOneFailure
(
const
char
*
/* results_expr */
,
const
char
*
/* type_expr */
,
const
char
*
/* substr_expr */
,
const
TestPartResultArray
&
results
,
TestPartResult
::
Type
type
,
const
std
::
string
&
substr
)
{
const
std
::
string
expected
(
type
==
TestPartResult
::
kFatalFailure
?
"1 fatal failure"
:
"1 non-fatal failure"
);
...
...
@@ -2143,8 +2136,9 @@ static std::string FormatWordList(const std::vector<std::string>& words) {
return
word_list
.
GetString
();
}
bool
ValidateTestPropertyName
(
const
std
::
string
&
property_name
,
const
std
::
vector
<
std
::
string
>&
reserved_names
)
{
static
bool
ValidateTestPropertyName
(
const
std
::
string
&
property_name
,
const
std
::
vector
<
std
::
string
>&
reserved_names
)
{
if
(
std
::
find
(
reserved_names
.
begin
(),
reserved_names
.
end
(),
property_name
)
!=
reserved_names
.
end
())
{
ADD_FAILURE
()
<<
"Reserved key used in RecordProperty(): "
<<
property_name
...
...
@@ -2562,7 +2556,6 @@ TestInfo* MakeAndRegisterTestInfo(
return
test_info
;
}
#if GTEST_HAS_PARAM_TEST
void
ReportInvalidTestCaseType
(
const
char
*
test_case_name
,
CodeLocation
code_location
)
{
Message
errors
;
...
...
@@ -2576,12 +2569,11 @@ void ReportInvalidTestCaseType(const char* test_case_name,
<<
"probably rename one of the classes to put the tests into different
\n
"
<<
"test cases."
;
GTEST_LOG_
(
ERROR
)
GTEST_LOG_
(
ERROR
)
<<
FormatFileLocation
(
code_location
.
file
.
c_str
(),
code_location
.
line
)
<<
" "
<<
errors
.
GetString
();
}
#endif // GTEST_HAS_PARAM_TEST
}
// namespace internal
...
...
@@ -2620,12 +2612,10 @@ 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 GTEST_HAS_PARAM_TEST
if
(
!
parameterized_tests_registered_
)
{
parameterized_test_registry_
.
RegisterTests
();
parameterized_tests_registered_
=
true
;
}
#endif
}
}
// namespace internal
...
...
@@ -2893,7 +2883,7 @@ enum GTestColor {
!GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW
// Returns the character attribute for the given color.
WORD
GetColorAttribute
(
GTestColor
color
)
{
static
WORD
GetColorAttribute
(
GTestColor
color
)
{
switch
(
color
)
{
case
COLOR_RED
:
return
FOREGROUND_RED
;
case
COLOR_GREEN
:
return
FOREGROUND_GREEN
;
...
...
@@ -2902,7 +2892,7 @@ WORD GetColorAttribute(GTestColor color) {
}
}
int
GetBitOffset
(
WORD
color_mask
)
{
static
int
GetBitOffset
(
WORD
color_mask
)
{
if
(
color_mask
==
0
)
return
0
;
int
bitOffset
=
0
;
...
...
@@ -2913,7 +2903,7 @@ int GetBitOffset(WORD color_mask) {
return
bitOffset
;
}
WORD
GetNewColor
(
GTestColor
color
,
WORD
old_color_attrs
)
{
static
WORD
GetNewColor
(
GTestColor
color
,
WORD
old_color_attrs
)
{
// Let's reuse the BG
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
;
...
...
@@ -2928,12 +2918,12 @@ WORD GetNewColor(GTestColor color, WORD old_color_attrs) {
}
return
new_color
;
}
#else
// Returns the ANSI color code for the given color. COLOR_DEFAULT is
// an invalid input.
const
char
*
GetAnsiColorCode
(
GTestColor
color
)
{
static
const
char
*
GetAnsiColorCode
(
GTestColor
color
)
{
switch
(
color
)
{
case
COLOR_RED
:
return
"1"
;
case
COLOR_GREEN
:
return
"2"
;
...
...
@@ -2986,7 +2976,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
// This routine must actually emit the characters rather than return a string
// that would be colored when printed, as can be done on Linux.
GTEST_ATTRIBUTE_PRINTF_
(
2
,
3
)
void
ColoredPrintf
(
GTestColor
color
,
const
char
*
fmt
,
...)
{
static
void
ColoredPrintf
(
GTestColor
color
,
const
char
*
fmt
,
...)
{
va_list
args
;
va_start
(
args
,
fmt
);
...
...
@@ -3015,7 +3005,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
GetConsoleScreenBufferInfo
(
stdout_handle
,
&
buffer_info
);
const
WORD
old_color_attrs
=
buffer_info
.
wAttributes
;
const
WORD
new_color
=
GetNewColor
(
color
,
old_color_attrs
);
// We need to flush the stream buffers into the console before each
// SetConsoleTextAttribute call lest it affect the text that is already
// printed but has not yet reached the console.
...
...
@@ -3040,7 +3030,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
static
const
char
kTypeParamLabel
[]
=
"TypeParam"
;
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
value_param
=
test_info
.
value_param
();
...
...
@@ -3481,7 +3471,7 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
// 3. To interpret the meaning of errno in a thread-safe way,
// we need the strerror_r() function, which is not available on
// Windows.
GTEST_LOG_
(
FATAL
)
<<
"Unable to open file
\"
"
GTEST_LOG_
(
FATAL
)
<<
"Unable to open file
\"
"
<<
output_file_
<<
"
\"
"
;
}
std
::
stringstream
stream
;
...
...
@@ -3855,12 +3845,11 @@ void StreamingListener::SocketWriter::MakeConnection() {
// Pushes the given source file location and message onto a per-thread
// trace stack maintained by Google Test.
ScopedTrace
::
ScopedTrace
(
const
char
*
file
,
int
line
,
const
Message
&
message
)
GTEST_LOCK_EXCLUDED_
(
&
UnitTest
::
mutex_
)
{
void
ScopedTrace
::
PushTrace
(
const
char
*
file
,
int
line
,
std
::
string
message
)
{
TraceInfo
trace
;
trace
.
file
=
file
;
trace
.
line
=
line
;
trace
.
message
=
message
.
GetString
(
);
trace
.
message
.
swap
(
message
);
UnitTest
::
GetInstance
()
->
PushGTestTrace
(
trace
);
}
...
...
@@ -4315,7 +4304,6 @@ const TestInfo* UnitTest::current_test_info() const
// Returns the random seed used at the start of the current test run.
int
UnitTest
::
random_seed
()
const
{
return
impl_
->
random_seed
();
}
#if GTEST_HAS_PARAM_TEST
// Returns ParameterizedTestCaseRegistry object used to keep track of
// value-parameterized tests and instantiate and register them.
internal
::
ParameterizedTestCaseRegistry
&
...
...
@@ -4323,7 +4311,6 @@ internal::ParameterizedTestCaseRegistry&
GTEST_LOCK_EXCLUDED_
(
mutex_
)
{
return
impl_
->
parameterized_test_registry
();
}
#endif // GTEST_HAS_PARAM_TEST
// Creates an empty UnitTest.
UnitTest
::
UnitTest
()
{
...
...
@@ -4362,10 +4349,8 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent)
&
default_global_test_part_result_reporter_
),
per_thread_test_part_result_reporter_
(
&
default_per_thread_test_part_result_reporter_
),
#if GTEST_HAS_PARAM_TEST
parameterized_test_registry_
(),
parameterized_tests_registered_
(
false
),
#endif // GTEST_HAS_PARAM_TEST
last_death_test_case_
(
-
1
),
current_test_case_
(
NULL
),
current_test_info_
(
NULL
),
...
...
@@ -4433,8 +4418,8 @@ void UnitTestImpl::ConfigureXmlOutput() {
listeners
()
->
SetDefaultXmlGenerator
(
new
XmlUnitTestResultPrinter
(
UnitTestOptions
::
GetAbsolutePathToOutputFile
().
c_str
()));
}
else
if
(
output_format
!=
""
)
{
GTEST_LOG_
(
WARNING
)
<<
"WARNING: unrecognized output format
\"
"
<<
output_format
GTEST_LOG_
(
WARNING
)
<<
"WARNING: unrecognized output format
\"
"
<<
output_format
<<
"
\"
ignored."
;
}
}
...
...
@@ -4450,8 +4435,8 @@ void UnitTestImpl::ConfigureStreamingOutput() {
listeners
()
->
Append
(
new
StreamingListener
(
target
.
substr
(
0
,
pos
),
target
.
substr
(
pos
+
1
)));
}
else
{
GTEST_LOG_
(
WARNING
)
<<
"unrecognized streaming target
\"
"
<<
target
GTEST_LOG_
(
WARNING
)
<<
"unrecognized streaming target
\"
"
<<
target
<<
"
\"
ignored."
;
}
}
...
...
@@ -4581,7 +4566,7 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); }
bool
UnitTestImpl
::
RunAllTests
()
{
// Makes sure InitGoogleTest() was called.
if
(
!
GTestIsInitialized
())
{
GTEST_LOG_
(
ERROR
)
<<
GTEST_LOG_
(
ERROR
)
<<
"
\n
This test program did NOT call ::testing::InitGoogleTest "
"before calling RUN_ALL_TESTS(). Please fix it."
;
return
false
;
...
...
@@ -5042,9 +5027,9 @@ bool SkipPrefix(const char* prefix, const char** pstr) {
// part can be omitted.
//
// Returns the value of the flag, or NULL if the parsing failed.
const
char
*
ParseFlagValue
(
const
char
*
str
,
const
char
*
flag
,
bool
def_optional
)
{
static
const
char
*
ParseFlagValue
(
const
char
*
str
,
const
char
*
flag
,
bool
def_optional
)
{
// str and flag must not be NULL.
if
(
str
==
NULL
||
flag
==
NULL
)
return
NULL
;
...
...
@@ -5080,7 +5065,7 @@ const char* ParseFlagValue(const char* str,
//
// On success, stores the value of the flag in *value, and returns
// 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.
const
char
*
const
value_str
=
ParseFlagValue
(
str
,
flag
,
true
);
...
...
@@ -5114,7 +5099,9 @@ bool ParseInt32Flag(const char* str, const char* flag, Int32* value) {
//
// On success, stores the value of the flag in *value, and returns
// 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.
const
char
*
const
value_str
=
ParseFlagValue
(
str
,
flag
,
false
);
...
...
@@ -5250,7 +5237,7 @@ static const char kColorEncodedHelpMessage[] =
"(not one in your own code or tests), please report it to
\n
"
"@G<"
GTEST_DEV_EMAIL_
">@D.
\n
"
;
bool
ParseGoogleTestFlag
(
const
char
*
const
arg
)
{
static
bool
ParseGoogleTestFlag
(
const
char
*
const
arg
)
{
return
ParseBoolFlag
(
arg
,
kAlsoRunDisabledTestsFlag
,
&
GTEST_FLAG
(
also_run_disabled_tests
))
||
ParseBoolFlag
(
arg
,
kBreakOnFailureFlag
,
...
...
@@ -5280,11 +5267,11 @@ bool ParseGoogleTestFlag(const char* const arg) {
}
#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"
);
if
(
!
flagfile
)
{
GTEST_LOG_
(
FATAL
)
<<
"Unable to open file
\"
"
<<
GTEST_FLAG
(
flagfile
)
GTEST_LOG_
(
FATAL
)
<<
"Unable to open file
\"
"
<<
GTEST_FLAG
(
flagfile
)
<<
"
\"
"
;
}
std
::
string
contents
(
ReadEntireFile
(
flagfile
));
...
...
googletest/test/BUILD.bazel
View file @
27bb844e
...
...
@@ -57,13 +57,15 @@ cc_test(
"gtest-param-test_test.cc"
,
],
)
+
select
({
"//:win"
:
[],
"//:windows"
:
[],
"//:windows_msvc"
:
[],
"//conditions:default"
:
[
"gtest-tuple_test.cc"
,
],
}),
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"
],
}),
includes
=
[
...
...
@@ -73,7 +75,8 @@ cc_test(
"googletest/test"
,
],
linkopts
=
select
({
"//:win"
:
[],
"//:windows"
:
[],
"//:windows_msvc"
:
[],
"//conditions:default"
:
[
"-pthread"
,
],
...
...
googletest/test/gtest-death-test_test.cc
View file @
27bb844e
...
...
@@ -56,15 +56,7 @@ using testing::internal::AlwaysTrue;
# endif // GTEST_OS_LINUX
# 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"
# undef GTEST_IMPLEMENTATION_
namespace
posix
=
::
testing
::
internal
::
posix
;
...
...
@@ -313,14 +305,14 @@ void DieWithEmbeddedNul() {
}
# if GTEST_USES_PCRE
// Tests that EXPECT_DEATH and ASSERT_DEATH work when the error
// message has a NUL character in it.
TEST_F
(
TestForDeathTest
,
EmbeddedNulInMessage
)
{
// 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"
);
ASSERT_DEATH
(
DieWithEmbeddedNul
(),
"my null world"
);
}
# endif // GTEST_USES_PCRE
// Tests that death test macros expand to code which interacts well with switch
...
...
googletest/test/gtest-filepath_test.cc
View file @
27bb844e
...
...
@@ -27,28 +27,18 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Authors: keith.ray@gmail.com (Keith Ray)
//
// Google Test filepath utilities
//
// This file tests classes and functions used internally by
// Google Test. They are subject to change without notice.
//
// This file is #included from gtest_unittest.cc, to avoid changing
// build or make-files for some existing Google Test clients. Do not
// #include this file anywhere else!
// This file is #included from gtest-internal.h.
// Do not #include this file anywhere else!
#include "gtest/internal/gtest-filepath.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"
#undef GTEST_IMPLEMENTATION_
#if GTEST_OS_WINDOWS_MOBILE
# include <windows.h> // NOLINT
...
...
googletest/test/gtest-options_test.cc
View file @
27bb844e
...
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Authors: keith.ray@gmail.com (Keith Ray)
//
// Google Test UnitTestOptions tests
//
...
...
@@ -46,14 +45,7 @@
# include <direct.h>
#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"
#undef GTEST_IMPLEMENTATION_
namespace
testing
{
namespace
internal
{
...
...
googletest/test/gtest-param-test2_test.cc
View file @
27bb844e
...
...
@@ -33,11 +33,8 @@
// Google Test work.
#include "gtest/gtest.h"
#include "test/gtest-param-test_test.h"
#if GTEST_HAS_PARAM_TEST
using
::
testing
::
Values
;
using
::
testing
::
internal
::
ParamGenerator
;
...
...
@@ -62,4 +59,3 @@ INSTANTIATE_TEST_CASE_P(Sequence2,
InstantiationInMultipleTranslaionUnitsTest
,
Values
(
42
*
3
,
42
*
4
,
42
*
5
));
#endif // GTEST_HAS_PARAM_TEST
googletest/test/gtest-param-test_test.cc
View file @
27bb844e
...
...
@@ -35,19 +35,13 @@
#include "gtest/gtest.h"
#if GTEST_HAS_PARAM_TEST
# include <algorithm>
# include <iostream>
# include <list>
# include <sstream>
# include <string>
# include <vector>
// To include gtest-internal-inl.h.
# define GTEST_IMPLEMENTATION_ 1
# include "src/gtest-internal-inl.h" // for UnitTestOptions
# undef GTEST_IMPLEMENTATION_
# include "test/gtest-param-test_test.h"
...
...
@@ -1025,31 +1019,19 @@ TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {
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
)
{
#if GTEST_HAS_PARAM_TEST
// Used in TestGenerationTest test case.
AddGlobalTestEnvironment
(
TestGenerationTest
::
Environment
::
Instance
());
// Used in GeneratorEvaluationTest test case. Tests that the updated value
// will be picked up for instantiating tests in GeneratorEvaluationTest.
GeneratorEvaluationTest
::
set_param_value
(
1
);
#endif // GTEST_HAS_PARAM_TEST
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
#if GTEST_HAS_PARAM_TEST
// Used in GeneratorEvaluationTest test case. Tests that value updated
// here will NOT be used for instantiating tests in
// GeneratorEvaluationTest.
GeneratorEvaluationTest
::
set_param_value
(
2
);
#endif // GTEST_HAS_PARAM_TEST
return
RUN_ALL_TESTS
();
}
googletest/test/gtest-param-test_test.h
View file @
27bb844e
...
...
@@ -39,8 +39,6 @@
#include "gtest/gtest.h"
#if GTEST_HAS_PARAM_TEST
// Test fixture for testing definition and instantiation of a test
// in separate translation units.
class
ExternalInstantiationTest
:
public
::
testing
::
TestWithParam
<
int
>
{
...
...
@@ -52,6 +50,4 @@ class InstantiationInMultipleTranslaionUnitsTest
:
public
::
testing
::
TestWithParam
<
int
>
{
};
#endif // GTEST_HAS_PARAM_TEST
#endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_
googletest/test/gtest-port_test.cc
View file @
27bb844e
...
...
@@ -45,15 +45,7 @@
#include "gtest/gtest.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"
#undef GTEST_IMPLEMENTATION_
using
std
::
make_pair
;
using
std
::
pair
;
...
...
@@ -75,8 +67,8 @@ TEST(IsXDigitTest, WorksForNarrowAscii) {
}
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
)
{
...
...
googletest/test/gtest-printers_test.cc
View file @
27bb844e
...
...
@@ -52,13 +52,13 @@
// hash_map and hash_set are available under Visual C++, or on Linux.
#if GTEST_HAS_UNORDERED_MAP_
# include <unordered_map>
// NOLINT
# include <unordered_map> // NOLINT
#elif GTEST_HAS_HASH_MAP_
# include <hash_map> // NOLINT
#endif // GTEST_HAS_HASH_MAP_
#if GTEST_HAS_UNORDERED_SET_
# include <unordered_set>
// NOLINT
# include <unordered_set> // NOLINT
#elif GTEST_HAS_HASH_SET_
# include <hash_set> // NOLINT
#endif // GTEST_HAS_HASH_SET_
...
...
@@ -192,13 +192,12 @@ inline ::std::ostream& operator<<(::std::ostream& os,
return
os
<<
"StreamableTemplateInFoo: "
<<
x
.
value
();
}
// A user-defined streamable but recursivly-defined container type in
// A user-defined streamable but recursivly-defined container type in
// a user namespace, it mimics therefore std::filesystem::path or
// boost::filesystem::path.
class
PathLike
{
public:
struct
iterator
{
struct
iterator
{
typedef
PathLike
value_type
;
};
typedef
iterator
const_iterator
;
...
...
@@ -208,9 +207,7 @@ class PathLike {
iterator
begin
()
const
{
return
iterator
();
}
iterator
end
()
const
{
return
iterator
();
}
friend
::
std
::
ostream
&
operator
<<
(
::
std
::
ostream
&
os
,
const
PathLike
&
)
{
friend
::
std
::
ostream
&
operator
<<
(
::
std
::
ostream
&
os
,
const
PathLike
&
)
{
return
os
<<
"Streamable-PathLike"
;
}
};
...
...
@@ -250,9 +247,9 @@ using ::testing::internal::string;
#if GTEST_HAS_UNORDERED_MAP_
#define GTEST_HAS_HASH_MAP_ 1
template
<
class
Key
,
class
T
>
template
<
class
Key
,
class
T
>
using
hash_map
=
::
std
::
unordered_map
<
Key
,
T
>
;
template
<
class
Key
,
class
T
>
template
<
class
Key
,
class
T
>
using
hash_multimap
=
::
std
::
unordered_multimap
<
Key
,
T
>
;
#elif GTEST_HAS_HASH_MAP_
...
...
@@ -270,9 +267,9 @@ using ::stdext::hash_multimap;
#if GTEST_HAS_UNORDERED_SET_
#define GTEST_HAS_HASH_SET_ 1
template
<
class
Key
>
template
<
class
Key
>
using
hash_set
=
::
std
::
unordered_set
<
Key
>
;
template
<
class
Key
>
template
<
class
Key
>
using
hash_multiset
=
::
std
::
unordered_multiset
<
Key
>
;
#elif GTEST_HAS_HASH_SET_
...
...
@@ -1092,7 +1089,7 @@ TEST(PrintTr1TupleTest, VariousSizes) {
::
std
::
tr1
::
tuple
<
bool
,
char
,
short
,
testing
::
internal
::
Int32
,
// NOLINT
testing
::
internal
::
Int64
,
float
,
double
,
const
char
*
,
void
*
,
std
::
string
>
t10
(
false
,
'a'
,
static_cast
<
short
>
(
3
),
4
,
5
,
1.5
F
,
-
2.5
,
str
,
t10
(
false
,
'a'
,
static_cast
<
short
>
(
3
),
4
,
5
,
1.5
F
,
-
2.5
,
str
,
// NOLINT
ImplicitCast_
<
void
*>
(
NULL
),
"10"
);
EXPECT_EQ
(
"(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, "
+
PrintPointer
(
str
)
+
" pointing to
\"
8
\"
, NULL,
\"
10
\"
)"
,
...
...
@@ -1152,7 +1149,7 @@ TEST(PrintStdTupleTest, VariousSizes) {
::
std
::
tuple
<
bool
,
char
,
short
,
testing
::
internal
::
Int32
,
// NOLINT
testing
::
internal
::
Int64
,
float
,
double
,
const
char
*
,
void
*
,
std
::
string
>
t10
(
false
,
'a'
,
static_cast
<
short
>
(
3
),
4
,
5
,
1.5
F
,
-
2.5
,
str
,
t10
(
false
,
'a'
,
static_cast
<
short
>
(
3
),
4
,
5
,
1.5
F
,
-
2.5
,
str
,
// NOLINT
ImplicitCast_
<
void
*>
(
NULL
),
"10"
);
EXPECT_EQ
(
"(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, "
+
PrintPointer
(
str
)
+
" pointing to
\"
8
\"
, NULL,
\"
10
\"
)"
,
...
...
googletest/test/gtest_break_on_failure_unittest_.cc
View file @
27bb844e
...
...
@@ -80,8 +80,7 @@ int main(int argc, char **argv) {
SetUnhandledExceptionFilter
(
ExitWithExceptionCode
);
# endif
#endif
#endif // GTEST_OS_WINDOWS
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
...
...
googletest/test/gtest_color_test_.cc
View file @
27bb844e
...
...
@@ -36,15 +36,7 @@
#include <stdio.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"
#undef GTEST_IMPLEMENTATION_
using
testing
::
internal
::
ShouldUseColor
;
...
...
googletest/test/gtest_env_var_test_.cc
View file @
27bb844e
...
...
@@ -35,10 +35,7 @@
#include "gtest/gtest.h"
#include <iostream>
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
using
::
std
::
cout
;
...
...
googletest/test/gtest_environment_test.cc
View file @
27bb844e
...
...
@@ -34,10 +34,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "gtest/gtest.h"
#define GTEST_IMPLEMENTATION_ 1 // Required for the next #include.
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
namespace
testing
{
GTEST_DECLARE_string_
(
filter
);
...
...
googletest/test/gtest_filter_unittest_.cc
View file @
27bb844e
...
...
@@ -117,7 +117,6 @@ TEST(DISABLED_FoobarbazTest, TestA) {
FAIL
()
<<
"Expected failure."
;
}
#if GTEST_HAS_PARAM_TEST
class
ParamTest
:
public
testing
::
TestWithParam
<
int
>
{
};
...
...
@@ -129,7 +128,6 @@ TEST_P(ParamTest, TestY) {
INSTANTIATE_TEST_CASE_P
(
SeqP
,
ParamTest
,
testing
::
Values
(
1
,
2
));
INSTANTIATE_TEST_CASE_P
(
SeqQ
,
ParamTest
,
testing
::
Values
(
5
,
6
));
#endif // GTEST_HAS_PARAM_TEST
}
// namespace
...
...
googletest/test/gtest_output_test_.cc
View file @
27bb844e
...
...
@@ -37,15 +37,7 @@
#include "gtest/gtest-spi.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"
#undef GTEST_IMPLEMENTATION_
#include <stdlib.h>
...
...
@@ -757,8 +749,6 @@ TEST(ExpectFatalFailureTest, FailsWhenStatementThrows) {
// This #ifdef block tests the output of value-parameterized tests.
#if GTEST_HAS_PARAM_TEST
std
::
string
ParamNameFunc
(
const
testing
::
TestParamInfo
<
std
::
string
>&
info
)
{
return
info
.
param
;
}
...
...
@@ -779,8 +769,6 @@ INSTANTIATE_TEST_CASE_P(PrintingStrings,
testing
::
Values
(
std
::
string
(
"a"
)),
ParamNameFunc
);
#endif // GTEST_HAS_PARAM_TEST
// This #ifdef block tests the output of typed tests.
#if GTEST_HAS_TYPED_TEST
...
...
googletest/test/gtest_repeat_test.cc
View file @
27bb844e
...
...
@@ -34,15 +34,7 @@
#include <stdlib.h>
#include <iostream>
#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"
#undef GTEST_IMPLEMENTATION_
namespace
testing
{
...
...
@@ -119,7 +111,6 @@ TEST(BarDeathTest, ThreadSafeAndFast) {
EXPECT_DEATH_IF_SUPPORTED
(
::
testing
::
internal
::
posix
::
Abort
(),
""
);
}
#if GTEST_HAS_PARAM_TEST
int
g_param_test_count
=
0
;
const
int
kNumberOfParamTests
=
10
;
...
...
@@ -135,7 +126,6 @@ TEST_P(MyParamTest, ShouldPass) {
INSTANTIATE_TEST_CASE_P
(
MyParamSequence
,
MyParamTest
,
testing
::
Range
(
0
,
kNumberOfParamTests
));
#endif // GTEST_HAS_PARAM_TEST
// Resets the count for each test.
void
ResetCounts
()
{
...
...
@@ -144,9 +134,7 @@ void ResetCounts() {
g_should_fail_count
=
0
;
g_should_pass_count
=
0
;
g_death_test_count
=
0
;
#if GTEST_HAS_PARAM_TEST
g_param_test_count
=
0
;
#endif // GTEST_HAS_PARAM_TEST
}
// Checks that the count for each test is expected.
...
...
@@ -156,9 +144,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 GTEST_HAS_PARAM_TEST
GTEST_CHECK_INT_EQ_
(
expected
*
kNumberOfParamTests
,
g_param_test_count
);
#endif // GTEST_HAS_PARAM_TEST
}
// Tests the behavior of Google Test when --gtest_repeat is not specified.
...
...
@@ -201,9 +187,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 GTEST_HAS_PARAM_TEST
GTEST_CHECK_INT_EQ_
(
repeat
*
kNumberOfParamTests
,
g_param_test_count
);
#endif // GTEST_HAS_PARAM_TEST
}
// Tests using --gtest_repeat when --gtest_filter specifies a set of
...
...
@@ -219,15 +203,14 @@ 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 GTEST_HAS_PARAM_TEST
GTEST_CHECK_INT_EQ_
(
0
,
g_param_test_count
);
#endif // GTEST_HAS_PARAM_TEST
}
}
// namespace
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
testing
::
AddGlobalTestEnvironment
(
new
MyEnvironment
);
TestRepeatUnspecified
();
...
...
googletest/test/gtest_stress_test.cc
View file @
27bb844e
...
...
@@ -34,15 +34,9 @@
#include "gtest/gtest.h"
#include <iostream>
#include <vector>
// We must define this macro in order to #include
// gtest-internal-inl.h. This is how Google Test prevents a user from
// accidentally depending on its internal implementation.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
#if GTEST_IS_THREADSAFE
...
...
googletest/test/gtest_unittest.cc
View file @
27bb844e
...
...
@@ -66,15 +66,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
#include <ostream>
#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"
#undef GTEST_IMPLEMENTATION_
namespace
testing
{
namespace
internal
{
...
...
googletest/test/gtest_xml_outfile1_test_.cc
View file @
27bb844e
...
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: keith.ray@gmail.com (Keith Ray)
//
// gtest_xml_outfile1_test_ writes some xml via TestProperty used by
// gtest_xml_outfiles_test.py
...
...
Prev
1
2
3
4
5
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