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
8dd1eb59
Unverified
Commit
8dd1eb59
authored
Feb 15, 2018
by
Gennadiy Civil
Committed by
GitHub
Feb 15, 2018
Browse files
Merge branch 'master' into fix-printers
parents
823f139b
42140509
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
66 additions
and
53 deletions
+66
-53
googletest/include/gtest/gtest-printers.h
googletest/include/gtest/gtest-printers.h
+1
-1
googletest/include/gtest/gtest_prod.h
googletest/include/gtest/gtest_prod.h
+7
-4
googletest/include/gtest/internal/gtest-filepath.h
googletest/include/gtest/internal/gtest-filepath.h
+1
-1
googletest/include/gtest/internal/gtest-internal.h
googletest/include/gtest/internal/gtest-internal.h
+0
-25
googletest/include/gtest/internal/gtest-port.h
googletest/include/gtest/internal/gtest-port.h
+33
-0
googletest/src/gtest-internal-inl.h
googletest/src/gtest-internal-inl.h
+2
-2
googletest/src/gtest-port.cc
googletest/src/gtest-port.cc
+6
-2
googletest/src/gtest-typed-test.cc
googletest/src/gtest-typed-test.cc
+1
-0
googletest/src/gtest.cc
googletest/src/gtest.cc
+12
-16
googletest/test/gtest_env_var_test_.cc
googletest/test/gtest_env_var_test_.cc
+1
-0
googletest/test/gtest_main_unittest.cc
googletest/test/gtest_main_unittest.cc
+2
-2
No files found.
googletest/include/gtest/gtest-printers.h
View file @
8dd1eb59
...
@@ -112,8 +112,8 @@
...
@@ -112,8 +112,8 @@
#endif
#endif
#if GTEST_HAS_ABSL
#if GTEST_HAS_ABSL
#include "absl/types/optional.h"
#include "absl/strings/string_view.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#endif // GTEST_HAS_ABSL
#endif // GTEST_HAS_ABSL
namespace
testing
{
namespace
testing
{
...
...
googletest/include/gtest/gtest_prod.h
View file @
8dd1eb59
...
@@ -40,17 +40,20 @@
...
@@ -40,17 +40,20 @@
//
//
// class MyClass {
// class MyClass {
// private:
// private:
// void
My
Method();
// void
Private
Method();
// FRIEND_TEST(MyClassTest,
My
Method);
// FRIEND_TEST(MyClassTest,
Private
Method
Works
);
// };
// };
//
//
// class MyClassTest : public testing::Test {
// class MyClassTest : public testing::Test {
// // ...
// // ...
// };
// };
//
//
// TEST_F(MyClassTest,
My
Method) {
// TEST_F(MyClassTest,
Private
Method
Works
) {
// // Can call MyClass::
My
Method() here.
// // Can call MyClass::
Private
Method() here.
// }
// }
//
// Note: The test class must be in the same namespace as the class being tested.
// For example, putting MyClassTest in an anonymous namespace will not work.
#define FRIEND_TEST(test_case_name, test_name)\
#define FRIEND_TEST(test_case_name, test_name)\
friend class test_case_name##_##test_name##_Test
friend class test_case_name##_##test_name##_Test
...
...
googletest/include/gtest/internal/gtest-filepath.h
View file @
8dd1eb59
...
@@ -191,7 +191,7 @@ class GTEST_API_ FilePath {
...
@@ -191,7 +191,7 @@ class GTEST_API_ FilePath {
void
Normalize
();
void
Normalize
();
// Returns a pointer to the last
i
occur
r
ence of a valid path separator in
// Returns a pointer to the last occurence of a valid path separator in
// the FilePath. On Windows, for example, both '/' and '\' are valid path
// the FilePath. On Windows, for example, both '/' and '\' are valid path
// separators. Returns NULL if no path separator was found.
// separators. Returns NULL if no path separator was found.
const
char
*
FindLastPathSeparator
()
const
;
const
char
*
FindLastPathSeparator
()
const
;
...
...
googletest/include/gtest/internal/gtest-internal.h
View file @
8dd1eb59
...
@@ -803,31 +803,6 @@ struct RemoveConst<T[N]> {
...
@@ -803,31 +803,6 @@ struct RemoveConst<T[N]> {
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))
GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))
// Adds reference to a type if it is not a reference type,
// otherwise leaves it unchanged. This is the same as
// tr1::add_reference, which is not widely available yet.
template
<
typename
T
>
struct
AddReference
{
typedef
T
&
type
;
};
// NOLINT
template
<
typename
T
>
struct
AddReference
<
T
&>
{
typedef
T
&
type
;
};
// NOLINT
// A handy wrapper around AddReference that works when the argument T
// depends on template parameters.
#define GTEST_ADD_REFERENCE_(T) \
typename ::testing::internal::AddReference<T>::type
// Adds a reference to const on top of T as necessary. For example,
// it transforms
//
// char ==> const char&
// const char ==> const char&
// char& ==> const char&
// const char& ==> const char&
//
// The argument T must depend on some template parameters.
#define GTEST_REFERENCE_TO_CONST_(T) \
GTEST_ADD_REFERENCE_(const GTEST_REMOVE_REFERENCE_(T))
// ImplicitlyConvertible<From, To>::value is a compile-time bool
// ImplicitlyConvertible<From, To>::value is a compile-time bool
// constant that's true iff type From can be implicitly converted to
// constant that's true iff type From can be implicitly converted to
// type To.
// type To.
...
...
googletest/include/gtest/internal/gtest-port.h
View file @
8dd1eb59
...
@@ -1366,6 +1366,39 @@ inline void FlushInfoLog() { fflush(NULL); }
...
@@ -1366,6 +1366,39 @@ inline void FlushInfoLog() { fflush(NULL); }
GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
<< gtest_error
<< gtest_error
// Adds reference to a type if it is not a reference type,
// otherwise leaves it unchanged. This is the same as
// tr1::add_reference, which is not widely available yet.
template
<
typename
T
>
struct
AddReference
{
typedef
T
&
type
;
};
// NOLINT
template
<
typename
T
>
struct
AddReference
<
T
&>
{
typedef
T
&
type
;
};
// NOLINT
// A handy wrapper around AddReference that works when the argument T
// depends on template parameters.
#define GTEST_ADD_REFERENCE_(T) \
typename ::testing::internal::AddReference<T>::type
// Transforms "T" into "const T&" according to standard reference collapsing
// rules (this is only needed as a backport for C++98 compilers that do not
// support reference collapsing). Specifically, it transforms:
//
// char ==> const char&
// const char ==> const char&
// char& ==> char&
// const char& ==> const char&
//
// Note that the non-const reference will not have "const" added. This is
// standard, and necessary so that "T" can always bind to "const T&".
template
<
typename
T
>
struct
ConstRef
{
typedef
const
T
&
type
;
};
template
<
typename
T
>
struct
ConstRef
<
T
&>
{
typedef
T
&
type
;
};
// The argument T must depend on some template parameters.
#define GTEST_REFERENCE_TO_CONST_(T) \
typename ::testing::internal::ConstRef<T>::type
#if GTEST_HAS_STD_MOVE_
#if GTEST_HAS_STD_MOVE_
using
std
::
forward
;
using
std
::
forward
;
using
std
::
move
;
using
std
::
move
;
...
...
googletest/src/gtest-internal-inl.h
View file @
8dd1eb59
...
@@ -59,7 +59,7 @@
...
@@ -59,7 +59,7 @@
# include <windows.h> // NOLINT
# include <windows.h> // NOLINT
#endif // GTEST_OS_WINDOWS
#endif // GTEST_OS_WINDOWS
#include "gtest/gtest.h"
// NOLINT
#include "gtest/gtest.h"
#include "gtest/gtest-spi.h"
#include "gtest/gtest-spi.h"
namespace
testing
{
namespace
testing
{
...
@@ -1024,7 +1024,7 @@ class TestResultAccessor {
...
@@ -1024,7 +1024,7 @@ class TestResultAccessor {
#if GTEST_CAN_STREAM_RESULTS_
#if GTEST_CAN_STREAM_RESULTS_
// Streams test results to the given port on the given host machine.
// Streams test results to the given port on the given host machine.
class
GTEST_API_
StreamingListener
:
public
EmptyTestEventListener
{
class
StreamingListener
:
public
EmptyTestEventListener
{
public:
public:
// Abstract base class for writing strings to a socket.
// Abstract base class for writing strings to a socket.
class
AbstractSocketWriter
{
class
AbstractSocketWriter
{
...
...
googletest/src/gtest-port.cc
View file @
8dd1eb59
...
@@ -915,6 +915,7 @@ GTestLog::~GTestLog() {
...
@@ -915,6 +915,7 @@ GTestLog::~GTestLog() {
posix
::
Abort
();
posix
::
Abort
();
}
}
}
}
// Disable Microsoft deprecation warnings for POSIX functions called from
// Disable Microsoft deprecation warnings for POSIX functions called from
// this class (creat, dup, dup2, and close)
// this class (creat, dup, dup2, and close)
GTEST_DISABLE_MSC_WARNINGS_PUSH_
(
4996
)
GTEST_DISABLE_MSC_WARNINGS_PUSH_
(
4996
)
...
@@ -1007,8 +1008,7 @@ static CapturedStream* g_captured_stderr = NULL;
...
@@ -1007,8 +1008,7 @@ 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).
static
void
CaptureStream
(
int
fd
,
static
void
CaptureStream
(
int
fd
,
const
char
*
stream_name
,
const
char
*
stream_name
,
CapturedStream
**
stream
)
{
CapturedStream
**
stream
)
{
if
(
*
stream
!=
NULL
)
{
if
(
*
stream
!=
NULL
)
{
GTEST_LOG_
(
FATAL
)
<<
"Only one "
<<
stream_name
GTEST_LOG_
(
FATAL
)
<<
"Only one "
<<
stream_name
...
@@ -1049,6 +1049,10 @@ std::string GetCapturedStderr() {
...
@@ -1049,6 +1049,10 @@ std::string GetCapturedStderr() {
#endif // GTEST_HAS_STREAM_REDIRECTION
#endif // GTEST_HAS_STREAM_REDIRECTION
size_t
GetFileSize
(
FILE
*
file
)
{
size_t
GetFileSize
(
FILE
*
file
)
{
fseek
(
file
,
0
,
SEEK_END
);
fseek
(
file
,
0
,
SEEK_END
);
return
static_cast
<
size_t
>
(
ftell
(
file
));
return
static_cast
<
size_t
>
(
ftell
(
file
));
...
...
googletest/src/gtest-typed-test.cc
View file @
8dd1eb59
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
// Author: wan@google.com (Zhanyong Wan)
// Author: wan@google.com (Zhanyong Wan)
#include "gtest/gtest-typed-test.h"
#include "gtest/gtest-typed-test.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
namespace
testing
{
namespace
testing
{
...
...
googletest/src/gtest.cc
View file @
8dd1eb59
...
@@ -2571,12 +2571,10 @@ void ReportInvalidTestCaseType(const char* test_case_name,
...
@@ -2571,12 +2571,10 @@ 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
();
}
}
}
// namespace internal
}
// namespace internal
namespace
{
namespace
{
...
@@ -2898,7 +2896,7 @@ static int GetBitOffset(WORD color_mask) {
...
@@ -2898,7 +2896,7 @@ static int GetBitOffset(WORD color_mask) {
if
(
color_mask
==
0
)
return
0
;
if
(
color_mask
==
0
)
return
0
;
int
bitOffset
=
0
;
int
bitOffset
=
0
;
while
((
color_mask
&
1
)
==
0
)
{
while
((
color_mask
&
1
)
==
0
)
{
color_mask
>>=
1
;
color_mask
>>=
1
;
++
bitOffset
;
++
bitOffset
;
}
}
...
@@ -3106,7 +3104,6 @@ void PrettyUnitTestResultPrinter::OnTestIterationStart(
...
@@ -3106,7 +3104,6 @@ void PrettyUnitTestResultPrinter::OnTestIterationStart(
"Note: Randomizing tests' orders with a seed of %d .
\n
"
,
"Note: Randomizing tests' orders with a seed of %d .
\n
"
,
unit_test
.
random_seed
());
unit_test
.
random_seed
());
}
}
ColoredPrintf
(
COLOR_GREEN
,
"[==========] "
);
ColoredPrintf
(
COLOR_GREEN
,
"[==========] "
);
printf
(
"Running %s from %s.
\n
"
,
printf
(
"Running %s from %s.
\n
"
,
FormatTestCount
(
unit_test
.
test_to_run_count
()).
c_str
(),
FormatTestCount
(
unit_test
.
test_to_run_count
()).
c_str
(),
...
@@ -3473,8 +3470,8 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
...
@@ -3473,8 +3470,8 @@ 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
\"
"
<<
output_file_
<<
"
\"
"
;
GTEST_LOG_
(
FATAL
)
<<
"Unable to open file
\"
"
<<
output_file_
<<
"
\"
"
;
}
}
std
::
stringstream
stream
;
std
::
stringstream
stream
;
PrintXmlUnitTest
(
&
stream
,
unit_test
);
PrintXmlUnitTest
(
&
stream
,
unit_test
);
...
@@ -3773,6 +3770,7 @@ std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(
...
@@ -3773,6 +3770,7 @@ std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(
// End XmlUnitTestResultPrinter
// End XmlUnitTestResultPrinter
#if GTEST_CAN_STREAM_RESULTS_
#if GTEST_CAN_STREAM_RESULTS_
// Checks if str contains '=', '&', '%' or '\n' characters. If yes,
// Checks if str contains '=', '&', '%' or '\n' characters. If yes,
...
@@ -4401,8 +4399,7 @@ void UnitTestImpl::ConfigureXmlOutput() {
...
@@ -4401,8 +4399,7 @@ void UnitTestImpl::ConfigureXmlOutput() {
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."
;
}
}
}
}
...
@@ -4417,8 +4414,7 @@ void UnitTestImpl::ConfigureStreamingOutput() {
...
@@ -4417,8 +4414,7 @@ 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."
;
}
}
}
}
...
@@ -5255,8 +5251,7 @@ static bool ParseGoogleTestFlag(const char* const arg) {
...
@@ -5255,8 +5251,7 @@ static bool ParseGoogleTestFlag(const char* const arg) {
static
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
));
...
@@ -5389,6 +5384,7 @@ std::string TempDir() {
...
@@ -5389,6 +5384,7 @@ std::string TempDir() {
#if defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_)
#if defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_)
return
GTEST_CUSTOM_TEMPDIR_FUNCTION_
();
return
GTEST_CUSTOM_TEMPDIR_FUNCTION_
();
#endif
#endif
#if GTEST_OS_WINDOWS_MOBILE
#if GTEST_OS_WINDOWS_MOBILE
return
"
\\
temp
\\
"
;
return
"
\\
temp
\\
"
;
#elif GTEST_OS_WINDOWS
#elif GTEST_OS_WINDOWS
...
...
googletest/test/gtest_env_var_test_.cc
View file @
8dd1eb59
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include <iostream>
#include <iostream>
#include "src/gtest-internal-inl.h"
#include "src/gtest-internal-inl.h"
using
::
std
::
cout
;
using
::
std
::
cout
;
...
...
googletest/test/gtest_main_unittest.cc
View file @
8dd1eb59
...
@@ -41,5 +41,5 @@ TEST(GTestMainTest, ShouldSucceed) {
...
@@ -41,5 +41,5 @@ TEST(GTestMainTest, ShouldSucceed) {
}
// namespace
}
// namespace
// We are using the main() function defined in
src/
gtest_main.cc, so
// We are using the main() function defined in gtest_main.cc, so
we
//
we
don't define it here.
// don't define it here.
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