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
6c093a23
Commit
6c093a23
authored
Nov 24, 2017
by
Scott Slack-Smith
Browse files
Merge branch 'master' of
https://github.com/google/googletest
parents
c958e26f
d175c8bf
Changes
167
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
361 additions
and
140 deletions
+361
-140
googletest/samples/sample6_unittest.cc
googletest/samples/sample6_unittest.cc
+2
-1
googletest/samples/sample7_unittest.cc
googletest/samples/sample7_unittest.cc
+10
-10
googletest/samples/sample8_unittest.cc
googletest/samples/sample8_unittest.cc
+2
-1
googletest/samples/sample9_unittest.cc
googletest/samples/sample9_unittest.cc
+0
-3
googletest/scripts/fuse_gtest_files.py
googletest/scripts/fuse_gtest_files.py
+1
-1
googletest/scripts/upload.py
googletest/scripts/upload.py
+1
-1
googletest/src/gtest-death-test.cc
googletest/src/gtest-death-test.cc
+1
-1
googletest/src/gtest-port.cc
googletest/src/gtest-port.cc
+1
-1
googletest/src/gtest.cc
googletest/src/gtest.cc
+62
-39
googletest/test/BUILD.bazel
googletest/test/BUILD.bazel
+118
-0
googletest/test/gtest-death-test_test.cc
googletest/test/gtest-death-test_test.cc
+1
-1
googletest/test/gtest-filepath_test.cc
googletest/test/gtest-filepath_test.cc
+1
-1
googletest/test/gtest-options_test.cc
googletest/test/gtest-options_test.cc
+1
-1
googletest/test/gtest-param-test_test.cc
googletest/test/gtest-param-test_test.cc
+6
-6
googletest/test/gtest-port_test.cc
googletest/test/gtest-port_test.cc
+2
-2
googletest/test/gtest-printers_test.cc
googletest/test/gtest-printers_test.cc
+73
-10
googletest/test/gtest_catch_exceptions_test_.cc
googletest/test/gtest_catch_exceptions_test_.cc
+1
-1
googletest/test/gtest_color_test_.cc
googletest/test/gtest_color_test_.cc
+1
-1
googletest/test/gtest_output_test_.cc
googletest/test/gtest_output_test_.cc
+1
-1
googletest/test/gtest_output_test_golden_lin.txt
googletest/test/gtest_output_test_golden_lin.txt
+76
-58
No files found.
googletest/samples/sample6_unittest.cc
View file @
6c093a23
...
...
@@ -36,7 +36,7 @@
#include "prime_tables.h"
#include "gtest/gtest.h"
namespace
{
// First, we define some factory functions for creating instances of
// the implementations. You may be able to skip this step if all your
// implementations can be constructed the same way.
...
...
@@ -222,3 +222,4 @@ INSTANTIATE_TYPED_TEST_CASE_P(OnTheFlyAndPreCalculated, // Instance name
PrimeTableImplementations
);
// Type list
#endif // GTEST_HAS_TYPED_TEST_P
}
// namespace
googletest/samples/sample7_unittest.cc
View file @
6c093a23
...
...
@@ -39,7 +39,7 @@
#include "prime_tables.h"
#include "gtest/gtest.h"
namespace
{
#if GTEST_HAS_PARAM_TEST
using
::
testing
::
TestWithParam
;
...
...
@@ -65,9 +65,9 @@ PrimeTable* CreatePreCalculatedPrimeTable() {
// can refer to the test parameter by GetParam(). In this case, the test
// parameter is a factory function which we call in fixture's SetUp() to
// create and store an instance of PrimeTable.
class
PrimeTableTest
:
public
TestWithParam
<
CreatePrimeTableFunc
*>
{
class
PrimeTableTest
Smpl7
:
public
TestWithParam
<
CreatePrimeTableFunc
*>
{
public:
virtual
~
PrimeTableTest
()
{
delete
table_
;
}
virtual
~
PrimeTableTest
Smpl7
()
{
delete
table_
;
}
virtual
void
SetUp
()
{
table_
=
(
*
GetParam
())();
}
virtual
void
TearDown
()
{
delete
table_
;
...
...
@@ -78,7 +78,7 @@ class PrimeTableTest : public TestWithParam<CreatePrimeTableFunc*> {
PrimeTable
*
table_
;
};
TEST_P
(
PrimeTableTest
,
ReturnsFalseForNonPrimes
)
{
TEST_P
(
PrimeTableTest
Smpl7
,
ReturnsFalseForNonPrimes
)
{
EXPECT_FALSE
(
table_
->
IsPrime
(
-
5
));
EXPECT_FALSE
(
table_
->
IsPrime
(
0
));
EXPECT_FALSE
(
table_
->
IsPrime
(
1
));
...
...
@@ -87,7 +87,7 @@ TEST_P(PrimeTableTest, ReturnsFalseForNonPrimes) {
EXPECT_FALSE
(
table_
->
IsPrime
(
100
));
}
TEST_P
(
PrimeTableTest
,
ReturnsTrueForPrimes
)
{
TEST_P
(
PrimeTableTest
Smpl7
,
ReturnsTrueForPrimes
)
{
EXPECT_TRUE
(
table_
->
IsPrime
(
2
));
EXPECT_TRUE
(
table_
->
IsPrime
(
3
));
EXPECT_TRUE
(
table_
->
IsPrime
(
5
));
...
...
@@ -96,7 +96,7 @@ TEST_P(PrimeTableTest, ReturnsTrueForPrimes) {
EXPECT_TRUE
(
table_
->
IsPrime
(
131
));
}
TEST_P
(
PrimeTableTest
,
CanGetNextPrime
)
{
TEST_P
(
PrimeTableTest
Smpl7
,
CanGetNextPrime
)
{
EXPECT_EQ
(
2
,
table_
->
GetNextPrime
(
0
));
EXPECT_EQ
(
3
,
table_
->
GetNextPrime
(
2
));
EXPECT_EQ
(
5
,
table_
->
GetNextPrime
(
3
));
...
...
@@ -112,10 +112,9 @@ TEST_P(PrimeTableTest, CanGetNextPrime) {
//
// Here, we instantiate our tests with a list of two PrimeTable object
// factory functions:
INSTANTIATE_TEST_CASE_P
(
OnTheFlyAndPreCalculated
,
PrimeTableTest
,
Values
(
&
CreateOnTheFlyPrimeTable
,
&
CreatePreCalculatedPrimeTable
<
1000
>
));
INSTANTIATE_TEST_CASE_P
(
OnTheFlyAndPreCalculated
,
PrimeTableTestSmpl7
,
Values
(
&
CreateOnTheFlyPrimeTable
,
&
CreatePreCalculatedPrimeTable
<
1000
>
));
#else
...
...
@@ -128,3 +127,4 @@ INSTANTIATE_TEST_CASE_P(
TEST
(
DummyTest
,
ValueParameterizedTestsAreNotSupportedOnThisPlatform
)
{}
#endif // GTEST_HAS_PARAM_TEST
}
// namespace
googletest/samples/sample8_unittest.cc
View file @
6c093a23
...
...
@@ -37,7 +37,7 @@
#include "prime_tables.h"
#include "gtest/gtest.h"
namespace
{
#if GTEST_HAS_COMBINE
// Suppose we want to introduce a new, improved implementation of PrimeTable
...
...
@@ -171,3 +171,4 @@ INSTANTIATE_TEST_CASE_P(MeaningfulTestParameters,
TEST
(
DummyTest
,
CombineIsNotSupportedOnThisPlatform
)
{}
#endif // GTEST_HAS_COMBINE
}
// namespace
googletest/samples/sample9_unittest.cc
View file @
6c093a23
...
...
@@ -44,9 +44,7 @@ using ::testing::TestEventListeners;
using
::
testing
::
TestInfo
;
using
::
testing
::
TestPartResult
;
using
::
testing
::
UnitTest
;
namespace
{
// Provides alternative output mode which produces minimal amount of
// information about tests.
class
TersePrinter
:
public
EmptyTestEventListener
{
...
...
@@ -102,7 +100,6 @@ TEST(CustomOutputTest, Fails) {
EXPECT_EQ
(
1
,
2
)
<<
"This test fails in order to demonstrate alternative failure messages"
;
}
}
// namespace
int
main
(
int
argc
,
char
**
argv
)
{
...
...
googletest/scripts/fuse_gtest_files.py
View file @
6c093a23
...
...
@@ -52,7 +52,7 @@ EXAMPLES
This tool is experimental. In particular, it assumes that there is no
conditional inclusion of Google Test headers. Please report any
problems to googletestframework@googlegroups.com. You can read
http://
code.google.com/p/googletest/wiki/G
oogle
T
estAdvancedGuide for
http
s
://
github.com/google/googletest/blob/master/g
oogle
t
est
/docs/
AdvancedGuide
.md
for
more information.
"""
...
...
googletest/scripts/upload.py
View file @
6c093a23
...
...
@@ -732,7 +732,7 @@ class SubversionVCS(VersionControlSystem):
else
:
self
.
rev_start
=
self
.
rev_end
=
None
# Cache output from "svn list -r REVNO dirname".
# Keys: dirname, Values: 2-tuple (ouput for start rev and end rev).
# Keys: dirname, Values: 2-tuple (ou
t
put for start rev and end rev).
self
.
svnls_cache
=
{}
# SVN base URL is required to fetch files deleted in an older revision.
# Result is cached to not guess it over and over again in GetBaseFile().
...
...
googletest/src/gtest-death-test.cc
View file @
6c093a23
...
...
@@ -1242,7 +1242,7 @@ int GetStatusFileDescriptor(unsigned int parent_process_id,
reinterpret_cast
<
HANDLE
>
(
write_handle_as_size_t
);
HANDLE
dup_write_handle
;
// The newly initialized handle is accessible only in
in
the parent
// The newly initialized handle is accessible only in the parent
// process. To obtain one accessible within the child, we need to use
// DuplicateHandle.
if
(
!::
DuplicateHandle
(
parent_process_handle
.
Get
(),
write_handle
,
...
...
googletest/src/gtest-port.cc
View file @
6c093a23
...
...
@@ -537,7 +537,7 @@ class ThreadLocalRegistryImpl {
FALSE
,
thread_id
);
GTEST_CHECK_
(
thread
!=
NULL
);
// We need to
to
pass a valid thread ID pointer into CreateThread for it
// We need to pass a valid thread ID pointer into CreateThread for it
// to work correctly under Win98.
DWORD
watcher_thread_id
;
HANDLE
watcher_thread
=
::
CreateThread
(
...
...
googletest/src/gtest.cc
View file @
6c093a23
...
...
@@ -137,7 +137,7 @@
// 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.
//
their
code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
...
...
@@ -310,7 +310,8 @@ namespace internal {
// than kMaxRange.
UInt32
Random
::
Generate
(
UInt32
range
)
{
// These constants are the same as are used in glibc's rand(3).
state_
=
(
1103515245U
*
state_
+
12345U
)
%
kMaxRange
;
// Use wider types than necessary to prevent unsigned overflow diagnostics.
state_
=
static_cast
<
UInt32
>
(
1103515245ULL
*
state_
+
12345U
)
%
kMaxRange
;
GTEST_CHECK_
(
range
>
0
)
<<
"Cannot generate a number in the range [0, 0)."
;
...
...
@@ -1168,7 +1169,7 @@ class Hunk {
// Print a unified diff header for one hunk.
// The format is
// "@@ -<left_start>,<left_length> +<right_start>,<right_length> @@"
// where the left/right parts are om
m
itted if unnecessary.
// where the left/right parts are omitted if unnecessary.
void
PrintHeader
(
std
::
ostream
*
ss
)
const
{
*
ss
<<
"@@ "
;
if
(
removes_
)
{
...
...
@@ -1312,13 +1313,14 @@ AssertionResult EqFailure(const char* lhs_expression,
const
std
::
string
&
rhs_value
,
bool
ignoring_case
)
{
Message
msg
;
msg
<<
" Expected: "
<<
lhs_expression
;
msg
<<
"Expected equality of these values:"
;
msg
<<
"
\n
"
<<
lhs_expression
;
if
(
lhs_value
!=
lhs_expression
)
{
msg
<<
"
\n
Which is: "
<<
lhs_value
;
msg
<<
"
\n
Which is: "
<<
lhs_value
;
}
msg
<<
"
\n
To be equal to:
"
<<
rhs_expression
;
msg
<<
"
\n
"
<<
rhs_expression
;
if
(
rhs_value
!=
rhs_expression
)
{
msg
<<
"
\n
Which is: "
<<
rhs_value
;
msg
<<
"
\n
Which is: "
<<
rhs_value
;
}
if
(
ignoring_case
)
{
...
...
@@ -1781,7 +1783,7 @@ std::string CodePointToUtf8(UInt32 code_point) {
return
str
;
}
// The following two functions only make sense if the
the
system
// The following two functions only make sense if the system
// uses UTF-16 for wide string encoding. All supported systems
// with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16.
...
...
@@ -2568,10 +2570,10 @@ void ReportInvalidTestCaseType(const char* test_case_name,
<<
"probably rename one of the classes to put the tests into different
\n
"
<<
"test cases."
;
fprintf
(
stderr
,
"%s %s"
,
FormatFileLocation
(
code_location
.
file
.
c_str
(),
code_location
.
line
)
.
c_str
(),
errors
.
GetString
()
.
c_str
())
;
GTEST_LOG_
(
ERROR
)
<<
FormatFileLocation
(
code_location
.
file
.
c_str
(),
code_location
.
line
)
<<
" "
<<
errors
.
GetString
();
}
#endif // GTEST_HAS_PARAM_TEST
...
...
@@ -2894,6 +2896,33 @@ WORD GetColorAttribute(GTestColor color) {
}
}
int
GetBitOffset
(
WORD
color_mask
)
{
if
(
color_mask
==
0
)
return
0
;
int
bitOffset
=
0
;
while
((
color_mask
&
1
)
==
0
)
{
color_mask
>>=
1
;
++
bitOffset
;
}
return
bitOffset
;
}
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
;
const
WORD
existing_bg
=
old_color_attrs
&
background_mask
;
WORD
new_color
=
GetColorAttribute
(
color
)
|
existing_bg
|
FOREGROUND_INTENSITY
;
static
const
int
bg_bitOffset
=
GetBitOffset
(
background_mask
);
static
const
int
fg_bitOffset
=
GetBitOffset
(
foreground_mask
);
if
(((
new_color
&
background_mask
)
>>
bg_bitOffset
)
==
((
new_color
&
foreground_mask
)
>>
fg_bitOffset
))
{
new_color
^=
FOREGROUND_INTENSITY
;
//invert intensity
}
return
new_color
;
}
#else
// Returns the ANSI color code for the given color. COLOR_DEFAULT is
...
...
@@ -2979,13 +3008,14 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
CONSOLE_SCREEN_BUFFER_INFO
buffer_info
;
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.
fflush
(
stdout
);
SetConsoleTextAttribute
(
stdout_handle
,
GetColorAttribute
(
color
)
|
FOREGROUND_INTENSITY
);
SetConsoleTextAttribute
(
stdout_handle
,
new_color
);
vprintf
(
fmt
,
args
);
fflush
(
stdout
);
...
...
@@ -3420,9 +3450,7 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
XmlUnitTestResultPrinter
::
XmlUnitTestResultPrinter
(
const
char
*
output_file
)
:
output_file_
(
output_file
)
{
if
(
output_file_
.
c_str
()
==
NULL
||
output_file_
.
empty
())
{
fprintf
(
stderr
,
"XML output file may not be null
\n
"
);
fflush
(
stderr
);
exit
(
EXIT_FAILURE
);
GTEST_LOG_
(
FATAL
)
<<
"XML output file may not be null"
;
}
}
...
...
@@ -3447,11 +3475,8 @@ 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.
fprintf
(
stderr
,
"Unable to open file
\"
%s
\"\n
"
,
output_file_
.
c_str
());
fflush
(
stderr
);
exit
(
EXIT_FAILURE
);
GTEST_LOG_
(
FATAL
)
<<
"Unable to open file
\"
"
<<
output_file_
<<
"
\"
"
;
}
std
::
stringstream
stream
;
PrintXmlUnitTest
(
&
stream
,
unit_test
);
...
...
@@ -4402,9 +4427,9 @@ void UnitTestImpl::ConfigureXmlOutput() {
listeners
()
->
SetDefaultXmlGenerator
(
new
XmlUnitTestResultPrinter
(
UnitTestOptions
::
GetAbsolutePathToOutputFile
().
c_str
()));
}
else
if
(
output_format
!=
""
)
{
printf
(
"WARNING: unrecognized output format
\"
%s
\"
ignored.
\n
"
,
output_format
.
c_str
());
fflush
(
stdout
)
;
GTEST_LOG_
(
WARNING
)
<<
"WARNING: unrecognized output format
\"
"
<<
output_format
<<
"
\"
ignored."
;
}
}
...
...
@@ -4419,9 +4444,9 @@ void UnitTestImpl::ConfigureStreamingOutput() {
listeners
()
->
Append
(
new
StreamingListener
(
target
.
substr
(
0
,
pos
),
target
.
substr
(
pos
+
1
)));
}
else
{
printf
(
"
WARNING
:
unrecognized streaming target
\"
%s
\"
ignored.
\n
"
,
target
.
c_str
());
fflush
(
stdout
)
;
GTEST_LOG_
(
WARNING
)
<<
"
unrecognized streaming target
\"
"
<<
target
<<
"
\"
ignored."
;
}
}
}
...
...
@@ -4550,9 +4575,9 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); }
bool
UnitTestImpl
::
RunAllTests
()
{
// Makes sure InitGoogleTest() was called.
if
(
!
GTestIsInitialized
())
{
printf
(
"%s"
,
"
\n
This test program did NOT call ::testing::InitGoogleTest "
"before calling RUN_ALL_TESTS(). Please fix it.
\n
"
)
;
GTEST_LOG_
(
ERROR
)
<<
"
\n
This test program did NOT call ::testing::InitGoogleTest "
"before calling RUN_ALL_TESTS(). Please fix it.
"
;
return
false
;
}
...
...
@@ -4783,7 +4808,7 @@ bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) {
// each TestCase and TestInfo object.
// If shard_tests == true, further filters tests based on sharding
// variables in the environment - see
// http://
code.google.com/p/googletest/wiki/G
oogle
T
estAdvancedGuide.
// http
s
://
github.com/google/googletest/blob/master/g
oogle
t
est
/docs/
AdvancedGuide.
md .
// Returns the number of tests that should run.
int
UnitTestImpl
::
FilterTests
(
ReactionToSharding
shard_tests
)
{
const
Int32
total_shards
=
shard_tests
==
HONOR_SHARDING_PROTOCOL
?
...
...
@@ -5188,7 +5213,7 @@ static const char kColorEncodedHelpMessage[] =
" @G--"
GTEST_FLAG_PREFIX_
"output=xml@Y[@G:@YDIRECTORY_PATH@G"
GTEST_PATH_SEP_
"@Y|@G:@YFILE_PATH]@D
\n
"
" Generate an XML report in the given directory or with the given file
\n
"
" name. @YFILE_PATH@D defaults to @Gtest_detail
s
.xml@D.
\n
"
" name. @YFILE_PATH@D defaults to @Gtest_detail.xml@D.
\n
"
#if GTEST_CAN_STREAM_RESULTS_
" @G--"
GTEST_FLAG_PREFIX_
"stream_result_to=@YHOST@G:@YPORT@D
\n
"
" Stream test results to the given server.
\n
"
...
...
@@ -5252,11 +5277,9 @@ bool ParseGoogleTestFlag(const char* const arg) {
void
LoadFlagsFromFile
(
const
std
::
string
&
path
)
{
FILE
*
flagfile
=
posix
::
FOpen
(
path
.
c_str
(),
"r"
);
if
(
!
flagfile
)
{
fprintf
(
stderr
,
"Unable to open file
\"
%s
\"\n
"
,
GTEST_FLAG
(
flagfile
).
c_str
());
fflush
(
stderr
);
exit
(
EXIT_FAILURE
);
GTEST_LOG_
(
FATAL
)
<<
"Unable to open file
\"
"
<<
GTEST_FLAG
(
flagfile
)
<<
"
\"
"
;
}
std
::
string
contents
(
ReadEntireFile
(
flagfile
));
posix
::
FClose
(
flagfile
);
...
...
googletest/test/BUILD.bazel
0 → 100644
View file @
6c093a23
# Copyright 2017 Google Inc.
# All Rights Reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (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: misterg@google.com (Gennadiy Civil)
#
# Bazel BUILD for The Google C++ Testing Framework (Google Test)
licenses
([
"notice"
])
""" gtest own tests """
#on windows exclude gtest-tuple.h and gtest-tuple_test.cc
cc_test
(
name
=
"gtest_all_test"
,
size
=
"small"
,
srcs
=
glob
(
include
=
[
"gtest-*.cc"
,
"*.h"
,
"googletest/include/gtest/**/*.h"
,
],
exclude
=
[
"gtest-unittest-api_test.cc"
,
"gtest-tuple_test.cc"
,
"googletest/src/gtest-all.cc"
,
"gtest_all_test.cc"
,
"gtest-death-test_ex_test.cc"
,
"gtest-listener_test.cc"
,
"gtest-unittest-api_test.cc"
,
"gtest-param-test_test.cc"
,
],
)
+
select
({
"//:win"
:
[],
"//conditions:default"
:
[
"gtest-tuple_test.cc"
,
],
}),
copts
=
select
({
"//:win"
:
[
"-DGTEST_USE_OWN_TR1_TUPLE=0"
],
"//conditions:default"
:
[
"-DGTEST_USE_OWN_TR1_TUPLE=1"
],
}),
includes
=
[
"googletest"
,
"googletest/include"
,
"googletest/include/internal"
,
"googletest/test"
,
],
linkopts
=
select
({
"//:win"
:
[],
"//conditions:default"
:
[
"-pthread"
,
],
}),
deps
=
[
"//:gtest_main"
],
)
#These googletest tests have their own main()
cc_test
(
name
=
"gtest-listener_test"
,
size
=
"small"
,
srcs
=
[
"gtest-listener_test.cc"
,
],
deps
=
[
"//:gtest"
,
],
)
cc_test
(
name
=
"gtest-unittest-api_test"
,
size
=
"small"
,
srcs
=
[
"gtest-unittest-api_test.cc"
,
],
deps
=
[
"//:gtest"
,
],
)
cc_test
(
name
=
"gtest-param-test_test"
,
size
=
"small"
,
srcs
=
[
"gtest-param-test2_test.cc"
,
"gtest-param-test_test.cc"
,
"gtest-param-test_test.h"
,
],
deps
=
[
"//:gtest"
,
],
)
googletest/test/gtest-death-test_test.cc
View file @
6c093a23
...
...
@@ -61,7 +61,7 @@ using testing::internal::AlwaysTrue;
// 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.
//
their
code.
# define GTEST_IMPLEMENTATION_ 1
# include "src/gtest-internal-inl.h"
# undef GTEST_IMPLEMENTATION_
...
...
googletest/test/gtest-filepath_test.cc
View file @
6c093a23
...
...
@@ -45,7 +45,7 @@
// 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.
//
their
code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
...
...
googletest/test/gtest-options_test.cc
View file @
6c093a23
...
...
@@ -50,7 +50,7 @@
// 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.
//
their
code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
...
...
googletest/test/gtest-param-test_test.cc
View file @
6c093a23
...
...
@@ -141,7 +141,7 @@ void VerifyGenerator(const ParamGenerator<T>& generator,
<<
", expected_values[i] is "
<<
PrintValue
(
expected_values
[
i
])
<<
", *it is "
<<
PrintValue
(
*
it
)
<<
", and 'it' is an iterator created with the copy constructor.
\n
"
;
it
++
;
++
it
;
}
EXPECT_TRUE
(
it
==
generator
.
end
())
<<
"At the presumed end of sequence when accessing via an iterator "
...
...
@@ -161,7 +161,7 @@ void VerifyGenerator(const ParamGenerator<T>& generator,
<<
", expected_values[i] is "
<<
PrintValue
(
expected_values
[
i
])
<<
", *it is "
<<
PrintValue
(
*
it
)
<<
", and 'it' is an iterator created with the copy constructor.
\n
"
;
it
++
;
++
it
;
}
EXPECT_TRUE
(
it
==
generator
.
end
())
<<
"At the presumed end of sequence when accessing via an iterator "
...
...
@@ -196,7 +196,7 @@ TEST(IteratorTest, ParamIteratorConformsToForwardIteratorConcept) {
<<
"element same as its source points to"
;
// Verifies that iterator assignment works as expected.
it
++
;
++
it
;
EXPECT_FALSE
(
*
it
==
*
it2
);
it2
=
it
;
EXPECT_TRUE
(
*
it
==
*
it2
)
<<
"Assigned iterators must point to the "
...
...
@@ -215,7 +215,7 @@ TEST(IteratorTest, ParamIteratorConformsToForwardIteratorConcept) {
// Verifies that prefix and postfix operator++() advance an iterator
// all the same.
it2
=
it
;
it
++
;
++
it
;
++
it2
;
EXPECT_TRUE
(
*
it
==
*
it2
);
}
...
...
@@ -857,8 +857,8 @@ TEST_P(CustomLambdaNamingTest, CustomTestNames) {}
INSTANTIATE_TEST_CASE_P
(
CustomParamNameLambda
,
CustomLambdaNamingTest
,
Values
(
std
::
string
(
"LambdaName"
)),
[](
const
::
testing
::
TestParamInfo
<
std
::
string
>&
info
)
{
return
info
.
param
;
[](
const
::
testing
::
TestParamInfo
<
std
::
string
>&
tp
info
)
{
return
tp
info
.
param
;
});
#endif // GTEST_LANG_CXX11
...
...
googletest/test/gtest-port_test.cc
View file @
6c093a23
...
...
@@ -50,7 +50,7 @@
// 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.
//
their
code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
...
...
@@ -1209,7 +1209,7 @@ class DestructorTracker {
:
index_
(
GetNewIndex
())
{}
~
DestructorTracker
()
{
// We never access DestructorCall::List() concurrently, so we don't need
// to protect this acc
c
ess with a mutex.
// to protect this access with a mutex.
DestructorCall
::
List
()[
index_
]
->
ReportDestroyed
();
}
...
...
googletest/test/gtest-printers_test.cc
View file @
6c093a23
...
...
@@ -51,10 +51,15 @@
#include "gtest/gtest.h"
// hash_map and hash_set are available under Visual C++, or on Linux.
#if GTEST_HAS_HASH_MAP_
#if GTEST_HAS_UNORDERED_MAP_
# include <unordered_map> // NOLINT
#elif GTEST_HAS_HASH_MAP_
# include <hash_map> // NOLINT
#endif // GTEST_HAS_HASH_MAP_
#if GTEST_HAS_HASH_SET_
#if GTEST_HAS_UNORDERED_SET_
# include <unordered_set> // NOLINT
#elif GTEST_HAS_HASH_SET_
# include <hash_set> // NOLINT
#endif // GTEST_HAS_HASH_SET_
...
...
@@ -187,6 +192,29 @@ inline ::std::ostream& operator<<(::std::ostream& os,
return
os
<<
"StreamableTemplateInFoo: "
<<
x
.
value
();
}
// 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
{
typedef
PathLike
value_type
;
};
typedef
iterator
const_iterator
;
PathLike
()
{}
iterator
begin
()
const
{
return
iterator
();
}
iterator
end
()
const
{
return
iterator
();
}
friend
::
std
::
ostream
&
operator
<<
(
::
std
::
ostream
&
os
,
const
PathLike
&
)
{
return
os
<<
"Streamable-PathLike"
;
}
};
}
// namespace foo
namespace
testing
{
...
...
@@ -216,21 +244,47 @@ using ::testing::internal::UniversalTersePrintTupleFieldsToStrings;
#endif
using
::
testing
::
internal
::
string
;
#if GTEST_HAS_HASH_MAP_
// The hash_* classes are not part of the C++ standard. STLport
// defines them in namespace std. MSVC defines them in ::stdext. GCC
// defines them in ::.
#if GTEST_HAS_UNORDERED_MAP_
#define GTEST_HAS_HASH_MAP_ 1
template
<
class
Key
,
class
T
>
using
hash_map
=
::
std
::
unordered_map
<
Key
,
T
>
;
template
<
class
Key
,
class
T
>
using
hash_multimap
=
::
std
::
unordered_multimap
<
Key
,
T
>
;
#elif GTEST_HAS_HASH_MAP_
#ifdef _STLP_HASH_MAP // We got <hash_map> from STLport.
using
::
std
::
hash_map
;
using
::
std
::
hash_set
;
using
::
std
::
hash_multimap
;
using
::
std
::
hash_multiset
;
#elif _MSC_VER
using
::
stdext
::
hash_map
;
using
::
stdext
::
hash_set
;
using
::
stdext
::
hash_multimap
;
#endif
#endif
#if GTEST_HAS_UNORDERED_SET_
#define GTEST_HAS_HASH_SET_ 1
template
<
class
Key
>
using
hash_set
=
::
std
::
unordered_set
<
Key
>
;
template
<
class
Key
>
using
hash_multiset
=
::
std
::
unordered_multiset
<
Key
>
;
#elif GTEST_HAS_HASH_SET_
#ifdef _STLP_HASH_MAP // We got <hash_map> from STLport.
using
::
std
::
hash_set
;
using
::
std
::
hash_multiset
;
#elif _MSC_VER
using
::
stdext
::
hash_set
;
using
::
stdext
::
hash_multiset
;
#endif
#endif
// Prints a value to a string using the universal value printer. This
...
...
@@ -1038,8 +1092,8 @@ 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'
,
3
,
4
,
5
,
1.5
F
,
-
2.5
,
str
,
ImplicitCast_
<
void
*>
(
NULL
),
"10"
);
t10
(
false
,
'a'
,
static_cast
<
short
>
(
3
)
,
4
,
5
,
1.5
F
,
-
2.5
,
str
,
ImplicitCast_
<
void
*>
(
NULL
),
"10"
);
EXPECT_EQ
(
"(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, "
+
PrintPointer
(
str
)
+
" pointing to
\"
8
\"
, NULL,
\"
10
\"
)"
,
Print
(
t10
));
...
...
@@ -1098,8 +1152,8 @@ 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'
,
3
,
4
,
5
,
1.5
F
,
-
2.5
,
str
,
ImplicitCast_
<
void
*>
(
NULL
),
"10"
);
t10
(
false
,
'a'
,
static_cast
<
short
>
(
3
)
,
4
,
5
,
1.5
F
,
-
2.5
,
str
,
ImplicitCast_
<
void
*>
(
NULL
),
"10"
);
EXPECT_EQ
(
"(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, "
+
PrintPointer
(
str
)
+
" pointing to
\"
8
\"
, NULL,
\"
10
\"
)"
,
Print
(
t10
));
...
...
@@ -1161,6 +1215,15 @@ TEST(PrintStreamableTypeTest, TemplateTypeInUserNamespace) {
Print
(
::
foo
::
StreamableTemplateInFoo
<
int
>
()));
}
// Tests printing a user-defined recursive container type that has a <<
// operator.
TEST
(
PrintStreamableTypeTest
,
PathLikeInUserNamespace
)
{
::
foo
::
PathLike
x
;
EXPECT_EQ
(
"Streamable-PathLike"
,
Print
(
x
));
const
::
foo
::
PathLike
cx
;
EXPECT_EQ
(
"Streamable-PathLike"
,
Print
(
cx
));
}
// Tests printing user-defined types that have a PrintTo() function.
TEST
(
PrintPrintableTypeTest
,
InUserNamespace
)
{
EXPECT_EQ
(
"PrintableViaPrintTo: 0"
,
...
...
googletest/test/gtest_catch_exceptions_test_.cc
View file @
6c093a23
...
...
@@ -138,7 +138,7 @@ TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) {
}
// Exceptions in destructors are not supported in C++11.
#if !
defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L && _MSC_VER < 1900
#if !
GTEST_LANG_CXX11
class
CxxExceptionInDestructorTest
:
public
Test
{
public:
static
void
TearDownTestCase
()
{
...
...
googletest/test/gtest_color_test_.cc
View file @
6c093a23
...
...
@@ -41,7 +41,7 @@
// 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.
//
their
code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
...
...
googletest/test/gtest_output_test_.cc
View file @
6c093a23
...
...
@@ -42,7 +42,7 @@
// 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.
//
their
code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
...
...
googletest/test/gtest_output_test_golden_lin.txt
View file @
6c093a23
...
...
@@ -5,8 +5,9 @@ Value of: false
Actual: false
Expected: true
gtest_output_test_.cc:#: Failure
Expected: 2
To be equal to: 3
Expected equality of these values:
2
3
[0;32m[==========] [mRunning 66 tests from 29 test cases.
[0;32m[----------] [mGlobal test environment set-up.
FooEnvironment::SetUp() called.
...
...
@@ -34,21 +35,24 @@ BarEnvironment::SetUp() called.
[0;32m[----------] [m2 tests from NonfatalFailureTest
[0;32m[ RUN ] [mNonfatalFailureTest.EscapesStringOperands
gtest_output_test_.cc:#: Failure
Expected: kGoldenString
Which is: "\"Line"
To be equal to: actual
Which is: "actual \"string\""
gtest_output_test_.cc:#: Failure
Expected: golden
Which is: "\"Line"
To be equal to: actual
Which is: "actual \"string\""
Expected equality of these values:
kGoldenString
Which is: "\"Line"
actual
Which is: "actual \"string\""
gtest_output_test_.cc:#: Failure
Expected equality of these values:
golden
Which is: "\"Line"
actual
Which is: "actual \"string\""
[0;31m[ FAILED ] [mNonfatalFailureTest.EscapesStringOperands
[0;32m[ RUN ] [mNonfatalFailureTest.DiffForLongStrings
gtest_output_test_.cc:#: Failure
Expected: golden_str
Which is: "\"Line\0 1\"\nLine 2"
To be equal to: "Line 2"
Expected equality of these values:
golden_str
Which is: "\"Line\0 1\"\nLine 2"
"Line 2"
With diff:
@@ -1,2 @@
-\"Line\0 1\"
...
...
@@ -59,16 +63,18 @@ With diff:
[0;32m[ RUN ] [mFatalFailureTest.FatalFailureInSubroutine
(expecting a failure that x should be 1)
gtest_output_test_.cc:#: Failure
Expected: 1
To be equal to: x
Which is: 2
Expected equality of these values:
1
x
Which is: 2
[0;31m[ FAILED ] [mFatalFailureTest.FatalFailureInSubroutine
[0;32m[ RUN ] [mFatalFailureTest.FatalFailureInNestedSubroutine
(expecting a failure that x should be 1)
gtest_output_test_.cc:#: Failure
Expected: 1
To be equal to: x
Which is: 2
Expected equality of these values:
1
x
Which is: 2
[0;31m[ FAILED ] [mFatalFailureTest.FatalFailureInNestedSubroutine
[0;32m[ RUN ] [mFatalFailureTest.NonfatalFailureInSubroutine
(expecting a failure on false)
...
...
@@ -107,39 +113,44 @@ This failure is expected, and shouldn't have a trace.
[0;32m[ RUN ] [mSCOPED_TRACETest.WorksInLoop
(expected to fail)
gtest_output_test_.cc:#: Failure
Expected: 2
To be equal to: n
Which is: 1
Expected equality of these values:
2
n
Which is: 1
Google Test trace:
gtest_output_test_.cc:#: i = 1
gtest_output_test_.cc:#: Failure
Expected: 1
To be equal to: n
Which is: 2
Expected equality of these values:
1
n
Which is: 2
Google Test trace:
gtest_output_test_.cc:#: i = 2
[0;31m[ FAILED ] [mSCOPED_TRACETest.WorksInLoop
[0;32m[ RUN ] [mSCOPED_TRACETest.WorksInSubroutine
(expected to fail)
gtest_output_test_.cc:#: Failure
Expected: 2
To be equal to: n
Which is: 1
Expected equality of these values:
2
n
Which is: 1
Google Test trace:
gtest_output_test_.cc:#: n = 1
gtest_output_test_.cc:#: Failure
Expected: 1
To be equal to: n
Which is: 2
Expected equality of these values:
1
n
Which is: 2
Google Test trace:
gtest_output_test_.cc:#: n = 2
[0;31m[ FAILED ] [mSCOPED_TRACETest.WorksInSubroutine
[0;32m[ RUN ] [mSCOPED_TRACETest.CanBeNested
(expected to fail)
gtest_output_test_.cc:#: Failure
Expected: 1
To be equal to: n
Which is: 2
Expected equality of these values:
1
n
Which is: 2
Google Test trace:
gtest_output_test_.cc:#: n = 2
gtest_output_test_.cc:#:
...
...
@@ -437,9 +448,10 @@ Expected: 1 fatal failure
[0;32m[ OK ] [mTypedTest/0.Success
[0;32m[ RUN ] [mTypedTest/0.Failure
gtest_output_test_.cc:#: Failure
Expected: 1
To be equal to: TypeParam()
Which is: 0
Expected equality of these values:
1
TypeParam()
Which is: 0
Expected failure
[0;31m[ FAILED ] [mTypedTest/0.Failure, where TypeParam = int
[0;32m[----------] [m2 tests from Unsigned/TypedTestP/0, where TypeParam = unsigned char
...
...
@@ -447,10 +459,11 @@ Expected failure
[0;32m[ OK ] [mUnsigned/TypedTestP/0.Success
[0;32m[ RUN ] [mUnsigned/TypedTestP/0.Failure
gtest_output_test_.cc:#: Failure
Expected: 1U
Which is: 1
To be equal to: TypeParam()
Which is: '\0'
Expected equality of these values:
1U
Which is: 1
TypeParam()
Which is: '\0'
Expected failure
[0;31m[ FAILED ] [mUnsigned/TypedTestP/0.Failure, where TypeParam = unsigned char
[0;32m[----------] [m2 tests from Unsigned/TypedTestP/1, where TypeParam = unsigned int
...
...
@@ -458,10 +471,11 @@ Expected failure
[0;32m[ OK ] [mUnsigned/TypedTestP/1.Success
[0;32m[ RUN ] [mUnsigned/TypedTestP/1.Failure
gtest_output_test_.cc:#: Failure
Expected: 1U
Which is: 1
To be equal to: TypeParam()
Which is: 0
Expected equality of these values:
1U
Which is: 1
TypeParam()
Which is: 0
Expected failure
[0;31m[ FAILED ] [mUnsigned/TypedTestP/1.Failure, where TypeParam = unsigned int
[0;32m[----------] [m4 tests from ExpectFailureTest
...
...
@@ -597,18 +611,20 @@ Expected non-fatal failure.
[0;32m[----------] [m1 test from PrintingFailingParams/FailingParamTest
[0;32m[ RUN ] [mPrintingFailingParams/FailingParamTest.Fails/0
gtest_output_test_.cc:#: Failure
Expected: 1
To be equal to: GetParam()
Which is: 2
Expected equality of these values:
1
GetParam()
Which is: 2
[0;31m[ FAILED ] [mPrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2
[0;32m[----------] [m2 tests from PrintingStrings/ParamTest
[0;32m[ RUN ] [mPrintingStrings/ParamTest.Success/a
[0;32m[ OK ] [mPrintingStrings/ParamTest.Success/a
[0;32m[ RUN ] [mPrintingStrings/ParamTest.Failure/a
gtest_output_test_.cc:#: Failure
Expected: "b"
To be equal to: GetParam()
Which is: "a"
Expected equality of these values:
"b"
GetParam()
Which is: "a"
Expected failure
[0;31m[ FAILED ] [mPrintingStrings/ParamTest.Failure/a, where GetParam() = "a"
[0;32m[----------] [mGlobal test environment tear-down
...
...
@@ -678,16 +694,18 @@ Expected fatal failure.
[ RUN ] FatalFailureTest.FatalFailureInSubroutine
(expecting a failure that x should be 1)
gtest_output_test_.cc:#: Failure
Expected: 1
To be equal to: x
Which is: 2
Expected equality of these values:
1
x
Which is: 2
[ FAILED ] FatalFailureTest.FatalFailureInSubroutine (? ms)
[ RUN ] FatalFailureTest.FatalFailureInNestedSubroutine
(expecting a failure that x should be 1)
gtest_output_test_.cc:#: Failure
Expected: 1
To be equal to: x
Which is: 2
Expected equality of these values:
1
x
Which is: 2
[ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine (? ms)
[ RUN ] FatalFailureTest.NonfatalFailureInSubroutine
(expecting a failure on false)
...
...
Prev
1
…
4
5
6
7
8
9
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