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
ee014912
Unverified
Commit
ee014912
authored
Apr 16, 2020
by
Mark Jan van Kampen
Browse files
Merge branch 'master' of
https://github.com/google/googletest
into cmake-QNX-fix
# Conflicts: # CMakeLists.txt
parents
937b3ce9
e3f0319d
Changes
28
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
611 additions
and
497 deletions
+611
-497
CMakeLists.txt
CMakeLists.txt
+1
-1
googlemock/docs/cook_book.md
googlemock/docs/cook_book.md
+20
-18
googlemock/docs/for_dummies.md
googlemock/docs/for_dummies.md
+1
-1
googlemock/include/gmock/gmock-actions.h
googlemock/include/gmock/gmock-actions.h
+35
-4
googlemock/include/gmock/gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+10
-3
googlemock/include/gmock/gmock-spec-builders.h
googlemock/include/gmock/gmock-spec-builders.h
+92
-38
googlemock/test/BUILD.bazel
googlemock/test/BUILD.bazel
+0
-2
googlemock/test/gmock-actions_test.cc
googlemock/test/gmock-actions_test.cc
+13
-2
googlemock/test/gmock-function-mocker_test.cc
googlemock/test/gmock-function-mocker_test.cc
+51
-0
googlemock/test/gmock-matchers_test.cc
googlemock/test/gmock-matchers_test.cc
+8
-9
googletest/README.md
googletest/README.md
+3
-3
googletest/docs/advanced.md
googletest/docs/advanced.md
+21
-0
googletest/docs/pkgconfig.md
googletest/docs/pkgconfig.md
+0
-71
googletest/include/gtest/gtest-printers.h
googletest/include/gtest/gtest-printers.h
+159
-254
googletest/include/gtest/gtest.h
googletest/include/gtest/gtest.h
+10
-6
googletest/include/gtest/internal/gtest-internal.h
googletest/include/gtest/internal/gtest-internal.h
+5
-3
googletest/include/gtest/internal/gtest-port.h
googletest/include/gtest/internal/gtest-port.h
+18
-5
googletest/src/gtest-internal-inl.h
googletest/src/gtest-internal-inl.h
+4
-0
googletest/src/gtest-printers.cc
googletest/src/gtest-printers.cc
+1
-5
googletest/src/gtest.cc
googletest/src/gtest.cc
+159
-72
No files found.
CMakeLists.txt
View file @
ee014912
...
@@ -10,7 +10,7 @@ endif (POLICY CMP0048)
...
@@ -10,7 +10,7 @@ endif (POLICY CMP0048)
project
(
googletest-distribution
)
project
(
googletest-distribution
)
set
(
GOOGLETEST_VERSION 1.10.0
)
set
(
GOOGLETEST_VERSION 1.10.0
)
if
(
CMAKE_VERSION VERSION_GREATER
_EQUAL
"3.
1
"
)
if
(
CMAKE_VERSION VERSION_GREATER
"3.
0.2
"
)
if
(
NOT CYGWIN AND NOT MSYS AND NOT
${
CMAKE_SYSTEM_NAME
}
STREQUAL QNX
)
if
(
NOT CYGWIN AND NOT MSYS AND NOT
${
CMAKE_SYSTEM_NAME
}
STREQUAL QNX
)
set
(
CMAKE_CXX_EXTENSIONS OFF
)
set
(
CMAKE_CXX_EXTENSIONS OFF
)
endif
()
endif
()
...
...
googlemock/docs/cook_book.md
View file @
ee014912
...
@@ -421,7 +421,7 @@ sadly they are side effects of C++'s limitations):
...
@@ -421,7 +421,7 @@ sadly they are side effects of C++'s limitations):
`NiceMock<StrictMock<MockFoo> >`
) is
**not**
supported.
`NiceMock<StrictMock<MockFoo> >`
) is
**not**
supported.
2.
`NiceMock<MockFoo>`
and
`StrictMock<MockFoo>`
may not work correctly if the
2.
`NiceMock<MockFoo>`
and
`StrictMock<MockFoo>`
may not work correctly if the
destructor of
`MockFoo`
is not virtual. We would like to fix this, but it
destructor of
`MockFoo`
is not virtual. We would like to fix this, but it
requires cleaning up existing tests.
http://b/28934720 tracks the issue.
requires cleaning up existing tests.
3.
During the constructor or destructor of
`MockFoo`
, the mock object is
*not*
3.
During the constructor or destructor of
`MockFoo`
, the mock object is
*not*
nice or strict. This may cause surprises if the constructor or destructor
nice or strict. This may cause surprises if the constructor or destructor
calls a mock method on
`this`
object. (This behavior, however, is consistent
calls a mock method on
`this`
object. (This behavior, however, is consistent
...
@@ -2174,7 +2174,7 @@ own precedence order distinct from the `ON_CALL` precedence order.
...
@@ -2174,7 +2174,7 @@ own precedence order distinct from the `ON_CALL` precedence order.
### Using Functions/Methods/Functors/Lambdas as Actions {#FunctionsAsActions}
### Using Functions/Methods/Functors/Lambdas as Actions {#FunctionsAsActions}
If the built-in actions don't suit you, you can use an existing callable
If the built-in actions don't suit you, you can use an existing callable
(function,
`std::function`
, method, functor, lambda as an action.
(function,
`std::function`
, method, functor, lambda
)
as an action.
<!-- GOOGLETEST_CM0024 DO NOT DELETE -->
<!-- GOOGLETEST_CM0024 DO NOT DELETE -->
...
@@ -2203,6 +2203,7 @@ class Helper {
...
@@ -2203,6 +2203,7 @@ class Helper {
.
WillRepeatedly
(
Invoke
(
NewPermanentCallback
(
Sum3
,
1
)));
.
WillRepeatedly
(
Invoke
(
NewPermanentCallback
(
Sum3
,
1
)));
EXPECT_CALL
(
foo
,
ComplexJob
(
_
))
EXPECT_CALL
(
foo
,
ComplexJob
(
_
))
.
WillOnce
(
Invoke
(
&
helper
,
&
Helper
::
ComplexJob
))
.
WillOnce
(
Invoke
(
&
helper
,
&
Helper
::
ComplexJob
))
.
WillOnce
([]
{
return
true
;
})
.
WillRepeatedly
([](
int
x
)
{
return
x
>
0
;
});
.
WillRepeatedly
([](
int
x
)
{
return
x
>
0
;
});
foo
.
Sum
(
5
,
6
);
// Invokes CalculateSum(5, 6).
foo
.
Sum
(
5
,
6
);
// Invokes CalculateSum(5, 6).
...
@@ -2212,11 +2213,11 @@ class Helper {
...
@@ -2212,11 +2213,11 @@ class Helper {
```
```
The only requirement is that the type of the function, etc must be
*compatible*
The only requirement is that the type of the function, etc must be
*compatible*
with the signature of the mock function, meaning that the latter's arguments
can
with the signature of the mock function, meaning that the latter's arguments
(if
be implicitly converted to the corresponding arguments of the
former, and the
it takes any) can
be implicitly converted to the corresponding arguments of the
former's return type can be implicitly converted to that of the
latter. So, you
former, and the
former's return type can be implicitly converted to that of the
can invoke something whose type is
*not*
exactly the same as the
mock function,
latter. So, you
can invoke something whose type is
*not*
exactly the same as the
as long as it's safe to do so - nice, huh?
mock function,
as long as it's safe to do so - nice, huh?
**`Note:`{.escaped}**
**`Note:`{.escaped}**
...
@@ -2267,19 +2268,20 @@ TEST_F(FooTest, Test) {
...
@@ -2267,19 +2268,20 @@ TEST_F(FooTest, Test) {
### Invoking a Function/Method/Functor/Lambda/Callback Without Arguments
### Invoking a Function/Method/Functor/Lambda/Callback Without Arguments
`Invoke()`
is very useful for doing a
ctions
that are more complex. It passes the
`Invoke()`
passes the mock fun
ction
'
s
arguments to the function, etc being
mock function's arguments to the function, etc being invoked such that the
invoked such that the callee has the full context of the call to work with. If
callee has the full context of the call to work with. If the invoked function is
the invoked function is not interested in some or all of the arguments, it can
not interested in some or all of the arguments, it can
simply ignore them.
simply ignore them.
Yet, a common pattern is that a test author wants to invoke a function without
Yet, a common pattern is that a test author wants to invoke a function without
the arguments of the mock function.
`Invoke()`
allows her to do that using a
the arguments of the mock function. She could do that using a wrapper function
wrapper function that throws away the arguments before invoking an underlining
that throws away the arguments before invoking an underlining nullary function.
nullary function. Needless to say, this can be tedious and obscures the intent
Needless to say, this can be tedious and obscures the intent of the test.
of the test.
`InvokeWithoutArgs()`
solves this problem. It's like
`Invoke()`
except that it
There are two solutions to this problem. First, you can pass any callable of
doesn't pass the mock function's arguments to the callee. Here's an example:
zero args as an action. Alternatively, use
`InvokeWithoutArgs()`
, which is like
`Invoke()`
except that it doesn't pass the mock function's arguments to the
callee. Here's an example of each:
```
cpp
```
cpp
using
::
testing
::
_
;
using
::
testing
::
_
;
...
@@ -2296,7 +2298,7 @@ bool Job2(int n, char c) { ... }
...
@@ -2296,7 +2298,7 @@ bool Job2(int n, char c) { ... }
...
...
MockFoo
foo
;
MockFoo
foo
;
EXPECT_CALL
(
foo
,
ComplexJob
(
_
))
EXPECT_CALL
(
foo
,
ComplexJob
(
_
))
.
WillOnce
(
InvokeWithoutArgs
(
Job1
))
.
WillOnce
(
[]
{
Job1
();
});
.
WillOnce
(
InvokeWithoutArgs
(
NewPermanentCallback
(
Job2
,
5
,
'a'
)));
.
WillOnce
(
InvokeWithoutArgs
(
NewPermanentCallback
(
Job2
,
5
,
'a'
)));
foo
.
ComplexJob
(
10
);
// Invokes Job1().
foo
.
ComplexJob
(
10
);
// Invokes Job1().
...
...
googlemock/docs/for_dummies.md
View file @
ee014912
...
@@ -374,7 +374,7 @@ convenient way of saying "any value".
...
@@ -374,7 +374,7 @@ convenient way of saying "any value".
In the above examples,
`100`
and
`50`
are also matchers; implicitly, they are
In the above examples,
`100`
and
`50`
are also matchers; implicitly, they are
the same as
`Eq(100)`
and
`Eq(50)`
, which specify that the argument must be
the same as
`Eq(100)`
and
`Eq(50)`
, which specify that the argument must be
equal (using
`operator==`
) to the matcher argument. There are many
equal (using
`operator==`
) to the matcher argument. There are many
[
built-in matchers
](
#MatcherList
)
for common types (as well as
[
built-in matchers
](
cheat_sheet.md
#MatcherList
)
for common types (as well as
[
custom matchers
](
cook_book.md#NewMatchers
)
); for example:
[
custom matchers
](
cook_book.md#NewMatchers
)
); for example:
```
cpp
```
cpp
...
...
googlemock/include/gmock/gmock-actions.h
View file @
ee014912
...
@@ -263,6 +263,10 @@ GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(double, 0);
...
@@ -263,6 +263,10 @@ GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(double, 0);
#undef GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
#undef GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
// Simple two-arg form of std::disjunction.
template
<
typename
P
,
typename
Q
>
using
disjunction
=
typename
::
std
::
conditional
<
P
::
value
,
P
,
Q
>::
type
;
}
// namespace internal
}
// namespace internal
// When an unexpected function call is encountered, Google Mock will
// When an unexpected function call is encountered, Google Mock will
...
@@ -456,9 +460,15 @@ class Action {
...
@@ -456,9 +460,15 @@ class Action {
// This cannot take std::function directly, because then Action would not be
// This cannot take std::function directly, because then Action would not be
// directly constructible from lambda (it would require two conversions).
// directly constructible from lambda (it would require two conversions).
template
<
typename
G
,
template
<
typename
G
,
typename
=
typename
::
std
::
enable_if
<
typename
IsCompatibleFunctor
=
::
std
::
is_constructible
<::
std
::
function
<
F
>,
G
>::
value
>::
type
>
::
std
::
is_constructible
<::
std
::
function
<
F
>,
G
>
,
Action
(
G
&&
fun
)
:
fun_
(
::
std
::
forward
<
G
>
(
fun
))
{}
// NOLINT
typename
IsNoArgsFunctor
=
::
std
::
is_constructible
<::
std
::
function
<
Result
()
>
,
G
>
,
typename
=
typename
::
std
::
enable_if
<
internal
::
disjunction
<
IsCompatibleFunctor
,
IsNoArgsFunctor
>::
value
>::
type
>
Action
(
G
&&
fun
)
{
// NOLINT
Init
(
::
std
::
forward
<
G
>
(
fun
),
IsCompatibleFunctor
());
}
// Constructs an Action from its implementation.
// Constructs an Action from its implementation.
explicit
Action
(
ActionInterface
<
F
>*
impl
)
explicit
Action
(
ActionInterface
<
F
>*
impl
)
...
@@ -490,6 +500,26 @@ class Action {
...
@@ -490,6 +500,26 @@ class Action {
template
<
typename
G
>
template
<
typename
G
>
friend
class
Action
;
friend
class
Action
;
template
<
typename
G
>
void
Init
(
G
&&
g
,
::
std
::
true_type
)
{
fun_
=
::
std
::
forward
<
G
>
(
g
);
}
template
<
typename
G
>
void
Init
(
G
&&
g
,
::
std
::
false_type
)
{
fun_
=
IgnoreArgs
<
typename
::
std
::
decay
<
G
>::
type
>
{
::
std
::
forward
<
G
>
(
g
)};
}
template
<
typename
FunctionImpl
>
struct
IgnoreArgs
{
template
<
typename
...
Args
>
Result
operator
()(
const
Args
&
...)
const
{
return
function_impl
();
}
FunctionImpl
function_impl
;
};
// fun_ is an empty function if and only if this is the DoDefault() action.
// fun_ is an empty function if and only if this is the DoDefault() action.
::
std
::
function
<
F
>
fun_
;
::
std
::
function
<
F
>
fun_
;
};
};
...
@@ -940,7 +970,8 @@ struct InvokeMethodWithoutArgsAction {
...
@@ -940,7 +970,8 @@ struct InvokeMethodWithoutArgsAction {
Class
*
const
obj_ptr
;
Class
*
const
obj_ptr
;
const
MethodPtr
method_ptr
;
const
MethodPtr
method_ptr
;
using
ReturnType
=
typename
std
::
result_of
<
MethodPtr
(
Class
*
)
>::
type
;
using
ReturnType
=
decltype
((
std
::
declval
<
Class
*>
()
->*
std
::
declval
<
MethodPtr
>
())());
template
<
typename
...
Args
>
template
<
typename
...
Args
>
ReturnType
operator
()(
const
Args
&
...)
const
{
ReturnType
operator
()(
const
Args
&
...)
const
{
...
...
googlemock/include/gmock/gmock-matchers.h
View file @
ee014912
...
@@ -424,7 +424,14 @@ class MatcherCastImpl<T, Matcher<U> > {
...
@@ -424,7 +424,14 @@ class MatcherCastImpl<T, Matcher<U> > {
!
std
::
is_base_of
<
FromType
,
ToType
>::
value
,
!
std
::
is_base_of
<
FromType
,
ToType
>::
value
,
"Can't implicitly convert from <base> to <derived>"
);
"Can't implicitly convert from <base> to <derived>"
);
return
source_matcher_
.
MatchAndExplain
(
static_cast
<
U
>
(
x
),
listener
);
// Do the cast to `U` explicitly if necessary.
// Otherwise, let implicit conversions do the trick.
using
CastType
=
typename
std
::
conditional
<
std
::
is_convertible
<
T
&
,
const
U
&>::
value
,
T
&
,
U
>::
type
;
return
source_matcher_
.
MatchAndExplain
(
static_cast
<
CastType
>
(
x
),
listener
);
}
}
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
...
@@ -524,8 +531,8 @@ inline Matcher<T> SafeMatcherCast(const M& polymorphic_matcher_or_value) {
...
@@ -524,8 +531,8 @@ inline Matcher<T> SafeMatcherCast(const M& polymorphic_matcher_or_value) {
template
<
typename
T
,
typename
U
>
template
<
typename
T
,
typename
U
>
inline
Matcher
<
T
>
SafeMatcherCast
(
const
Matcher
<
U
>&
matcher
)
{
inline
Matcher
<
T
>
SafeMatcherCast
(
const
Matcher
<
U
>&
matcher
)
{
// Enforce that T can be implicitly converted to U.
// Enforce that T can be implicitly converted to U.
GTEST_COMPILE_ASSERT_
(
(
std
::
is_convertible
<
T
,
U
>::
value
)
,
static_assert
(
std
::
is_convertible
<
const
T
&
,
const
U
&
>::
value
,
"T must be implicitly convertible to U"
);
"T must be implicitly convertible to U"
);
// Enforce that we are not converting a non-reference type T to a reference
// Enforce that we are not converting a non-reference type T to a reference
// type U.
// type U.
GTEST_COMPILE_ASSERT_
(
GTEST_COMPILE_ASSERT_
(
...
...
googlemock/include/gmock/gmock-spec-builders.h
View file @
ee014912
...
@@ -1786,10 +1786,79 @@ void ReportUninterestingCall(CallReaction reaction, const std::string& msg);
...
@@ -1786,10 +1786,79 @@ void ReportUninterestingCall(CallReaction reaction, const std::string& msg);
}
// namespace internal
}
// namespace internal
// A MockFunction<F> class has one mock method whose type is F. It is
namespace
internal
{
// useful when you just want your test code to emit some messages and
// have Google Mock verify the right messages are sent (and perhaps at
template
<
typename
F
>
// the right times). For example, if you are exercising code:
class
MockFunction
;
template
<
typename
R
,
typename
...
Args
>
class
MockFunction
<
R
(
Args
...)
>
{
public:
MockFunction
(
const
MockFunction
&
)
=
delete
;
MockFunction
&
operator
=
(
const
MockFunction
&
)
=
delete
;
std
::
function
<
R
(
Args
...)
>
AsStdFunction
()
{
return
[
this
](
Args
...
args
)
->
R
{
return
this
->
Call
(
std
::
forward
<
Args
>
(
args
)...);
};
}
// Implementation detail: the expansion of the MOCK_METHOD macro.
R
Call
(
Args
...
args
)
{
mock_
.
SetOwnerAndName
(
this
,
"Call"
);
return
mock_
.
Invoke
(
std
::
forward
<
Args
>
(
args
)...);
}
MockSpec
<
R
(
Args
...)
>
gmock_Call
(
Matcher
<
Args
>
...
m
)
{
mock_
.
RegisterOwner
(
this
);
return
mock_
.
With
(
std
::
move
(
m
)...);
}
MockSpec
<
R
(
Args
...)
>
gmock_Call
(
const
WithoutMatchers
&
,
R
(
*
)(
Args
...))
{
return
this
->
gmock_Call
(
::
testing
::
A
<
Args
>
()...);
}
protected:
MockFunction
()
=
default
;
~
MockFunction
()
=
default
;
private:
FunctionMocker
<
R
(
Args
...)
>
mock_
;
};
/*
The SignatureOf<F> struct is a meta-function returning function signature
corresponding to the provided F argument.
It makes use of MockFunction easier by allowing it to accept more F arguments
than just function signatures.
Specializations provided here cover only a signature type itself and
std::function. However, if need be it can be easily extended to cover also other
types (like for example boost::function).
*/
template
<
typename
F
>
struct
SignatureOf
;
template
<
typename
R
,
typename
...
Args
>
struct
SignatureOf
<
R
(
Args
...)
>
{
using
type
=
R
(
Args
...);
};
template
<
typename
F
>
struct
SignatureOf
<
std
::
function
<
F
>>
:
SignatureOf
<
F
>
{};
template
<
typename
F
>
using
SignatureOfT
=
typename
SignatureOf
<
F
>::
type
;
}
// namespace internal
// A MockFunction<F> type has one mock method whose type is
// internal::SignatureOfT<F>. It is useful when you just want your
// test code to emit some messages and have Google Mock verify the
// right messages are sent (and perhaps at the right times). For
// example, if you are exercising code:
//
//
// Foo(1);
// Foo(1);
// Foo(2);
// Foo(2);
...
@@ -1823,49 +1892,34 @@ void ReportUninterestingCall(CallReaction reaction, const std::string& msg);
...
@@ -1823,49 +1892,34 @@ void ReportUninterestingCall(CallReaction reaction, const std::string& msg);
// Bar("a") is called by which call to Foo().
// Bar("a") is called by which call to Foo().
//
//
// MockFunction<F> can also be used to exercise code that accepts
// MockFunction<F> can also be used to exercise code that accepts
// std::function<
F
> callbacks. To do so, use
AsStdFunction() method
// std::function<
internal::SignatureOfT<F>
> callbacks. To do so, use
// to create std::function proxy forwarding to
original object's Call.
//
AsStdFunction() method
to create std::function proxy forwarding to
// Example:
//
original object's Call.
Example:
//
//
// TEST(FooTest, RunsCallbackWithBarArgument) {
// TEST(FooTest, RunsCallbackWithBarArgument) {
// MockFunction<int(string)> callback;
// MockFunction<int(string)> callback;
// EXPECT_CALL(callback, Call("bar")).WillOnce(Return(1));
// EXPECT_CALL(callback, Call("bar")).WillOnce(Return(1));
// Foo(callback.AsStdFunction());
// Foo(callback.AsStdFunction());
// }
// }
//
// The internal::SignatureOfT<F> indirection allows to use other types
// than just function signature type. This is typically useful when
// providing a mock for a predefined std::function type. Example:
//
// using FilterPredicate = std::function<bool(string)>;
// void MyFilterAlgorithm(FilterPredicate predicate);
//
// TEST(FooTest, FilterPredicateAlwaysAccepts) {
// MockFunction<FilterPredicate> predicateMock;
// EXPECT_CALL(predicateMock, Call(_)).WillRepeatedly(Return(true));
// MyFilterAlgorithm(predicateMock.AsStdFunction());
// }
template
<
typename
F
>
template
<
typename
F
>
class
MockFunction
;
class
MockFunction
:
public
internal
::
MockFunction
<
internal
::
SignatureOfT
<
F
>>
{
using
Base
=
internal
::
MockFunction
<
internal
::
SignatureOfT
<
F
>>
;
template
<
typename
R
,
typename
...
Args
>
class
MockFunction
<
R
(
Args
...)
>
{
public:
public:
MockFunction
()
{}
using
Base
::
Base
;
MockFunction
(
const
MockFunction
&
)
=
delete
;
MockFunction
&
operator
=
(
const
MockFunction
&
)
=
delete
;
std
::
function
<
R
(
Args
...)
>
AsStdFunction
()
{
return
[
this
](
Args
...
args
)
->
R
{
return
this
->
Call
(
std
::
forward
<
Args
>
(
args
)...);
};
}
// Implementation detail: the expansion of the MOCK_METHOD macro.
R
Call
(
Args
...
args
)
{
mock_
.
SetOwnerAndName
(
this
,
"Call"
);
return
mock_
.
Invoke
(
std
::
forward
<
Args
>
(
args
)...);
}
internal
::
MockSpec
<
R
(
Args
...)
>
gmock_Call
(
Matcher
<
Args
>
...
m
)
{
mock_
.
RegisterOwner
(
this
);
return
mock_
.
With
(
std
::
move
(
m
)...);
}
internal
::
MockSpec
<
R
(
Args
...)
>
gmock_Call
(
const
internal
::
WithoutMatchers
&
,
R
(
*
)(
Args
...))
{
return
this
->
gmock_Call
(
::
testing
::
A
<
Args
>
()...);
}
private:
internal
::
FunctionMocker
<
R
(
Args
...)
>
mock_
;
};
};
// The style guide prohibits "using" statements in a namespace scope
// The style guide prohibits "using" statements in a namespace scope
...
...
googlemock/test/BUILD.bazel
View file @
ee014912
...
@@ -28,8 +28,6 @@
...
@@ -28,8 +28,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.
#
#
# Author: misterg@google.com (Gennadiy Civil)
#
# Bazel Build for Google C++ Testing Framework(Google Test)-googlemock
# Bazel Build for Google C++ Testing Framework(Google Test)-googlemock
load
(
"@rules_cc//cc:defs.bzl"
,
"cc_binary"
,
"cc_test"
)
load
(
"@rules_cc//cc:defs.bzl"
,
"cc_binary"
,
"cc_test"
)
...
...
googlemock/test/gmock-actions_test.cc
View file @
ee014912
...
@@ -1470,8 +1470,19 @@ TEST(FunctorActionTest, TypeConversion) {
...
@@ -1470,8 +1470,19 @@ TEST(FunctorActionTest, TypeConversion) {
EXPECT_EQ
(
1
,
s2
.
Perform
(
std
::
make_tuple
(
"hello"
)));
EXPECT_EQ
(
1
,
s2
.
Perform
(
std
::
make_tuple
(
"hello"
)));
// Also between the lambda and the action itself.
// Also between the lambda and the action itself.
const
Action
<
bool
(
std
::
string
)
>
x
=
[](
Unused
)
{
return
42
;
};
const
Action
<
bool
(
std
::
string
)
>
x1
=
[](
Unused
)
{
return
42
;
};
EXPECT_TRUE
(
x
.
Perform
(
std
::
make_tuple
(
"hello"
)));
const
Action
<
bool
(
std
::
string
)
>
x2
=
[]
{
return
42
;
};
EXPECT_TRUE
(
x1
.
Perform
(
std
::
make_tuple
(
"hello"
)));
EXPECT_TRUE
(
x2
.
Perform
(
std
::
make_tuple
(
"hello"
)));
// Ensure decay occurs where required.
std
::
function
<
int
()
>
f
=
[]
{
return
7
;
};
Action
<
int
(
int
)
>
d
=
f
;
f
=
nullptr
;
EXPECT_EQ
(
7
,
d
.
Perform
(
std
::
make_tuple
(
1
)));
// Ensure creation of an empty action succeeds.
Action
<
void
(
int
)
>
(
nullptr
);
}
}
TEST
(
FunctorActionTest
,
UnusedArguments
)
{
TEST
(
FunctorActionTest
,
UnusedArguments
)
{
...
...
googlemock/test/gmock-function-mocker_test.cc
View file @
ee014912
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
# include <objbase.h>
# include <objbase.h>
#endif // GTEST_OS_WINDOWS
#endif // GTEST_OS_WINDOWS
#include <functional>
#include <map>
#include <map>
#include <string>
#include <string>
#include <type_traits>
#include <type_traits>
...
@@ -778,6 +779,56 @@ TEST(MockMethodMockFunctionTest, AsStdFunctionWithReferenceParameter) {
...
@@ -778,6 +779,56 @@ TEST(MockMethodMockFunctionTest, AsStdFunctionWithReferenceParameter) {
EXPECT_EQ
(
-
1
,
call
(
foo
.
AsStdFunction
(),
i
));
EXPECT_EQ
(
-
1
,
call
(
foo
.
AsStdFunction
(),
i
));
}
}
namespace
{
template
<
typename
Expected
,
typename
F
>
static
constexpr
bool
IsMockFunctionTemplateArgumentDeducedTo
(
const
MockFunction
<
F
>&
)
{
return
std
::
is_same
<
F
,
Expected
>::
value
;
}
}
// namespace
template
<
typename
F
>
class
MockMethodMockFunctionSignatureTest
:
public
Test
{};
using
MockMethodMockFunctionSignatureTypes
=
Types
<
void
(),
int
(),
void
(
int
),
int
(
int
),
int
(
bool
,
int
),
int
(
bool
,
char
,
int
,
int
,
int
,
int
,
int
,
char
,
int
,
bool
)
>
;
TYPED_TEST_SUITE
(
MockMethodMockFunctionSignatureTest
,
MockMethodMockFunctionSignatureTypes
);
TYPED_TEST
(
MockMethodMockFunctionSignatureTest
,
IsMockFunctionTemplateArgumentDeducedForRawSignature
)
{
using
Argument
=
TypeParam
;
MockFunction
<
Argument
>
foo
;
EXPECT_TRUE
(
IsMockFunctionTemplateArgumentDeducedTo
<
Argument
>
(
foo
));
}
TYPED_TEST
(
MockMethodMockFunctionSignatureTest
,
IsMockFunctionTemplateArgumentDeducedForStdFunction
)
{
using
Argument
=
std
::
function
<
TypeParam
>
;
MockFunction
<
Argument
>
foo
;
EXPECT_TRUE
(
IsMockFunctionTemplateArgumentDeducedTo
<
Argument
>
(
foo
));
}
TYPED_TEST
(
MockMethodMockFunctionSignatureTest
,
IsMockFunctionCallMethodSignatureTheSameForRawSignatureAndStdFunction
)
{
using
ForRawSignature
=
decltype
(
&
MockFunction
<
TypeParam
>::
Call
);
using
ForStdFunction
=
decltype
(
&
MockFunction
<
std
::
function
<
TypeParam
>>::
Call
);
EXPECT_TRUE
((
std
::
is_same
<
ForRawSignature
,
ForStdFunction
>::
value
));
}
TYPED_TEST
(
MockMethodMockFunctionSignatureTest
,
IsMockFunctionAsStdFunctionMethodSignatureTheSameForRawSignatureAndStdFunction
)
{
using
ForRawSignature
=
decltype
(
&
MockFunction
<
TypeParam
>::
AsStdFunction
);
using
ForStdFunction
=
decltype
(
&
MockFunction
<
std
::
function
<
TypeParam
>>::
AsStdFunction
);
EXPECT_TRUE
((
std
::
is_same
<
ForRawSignature
,
ForStdFunction
>::
value
));
}
struct
MockMethodSizes0
{
struct
MockMethodSizes0
{
MOCK_METHOD
(
void
,
func
,
());
MOCK_METHOD
(
void
,
func
,
());
...
...
googlemock/test/gmock-matchers_test.cc
View file @
ee014912
...
@@ -765,10 +765,11 @@ TEST(SafeMatcherCastTest, FromConstReferenceToReference) {
...
@@ -765,10 +765,11 @@ TEST(SafeMatcherCastTest, FromConstReferenceToReference) {
// Tests that MatcherCast<const T&>(m) works when m is a Matcher<T>.
// Tests that MatcherCast<const T&>(m) works when m is a Matcher<T>.
TEST
(
SafeMatcherCastTest
,
FromNonReferenceToConstReference
)
{
TEST
(
SafeMatcherCastTest
,
FromNonReferenceToConstReference
)
{
Matcher
<
int
>
m1
=
Eq
(
0
);
Matcher
<
std
::
unique_ptr
<
int
>>
m1
=
IsNull
();
Matcher
<
const
int
&>
m2
=
SafeMatcherCast
<
const
int
&>
(
m1
);
Matcher
<
const
std
::
unique_ptr
<
int
>&>
m2
=
EXPECT_TRUE
(
m2
.
Matches
(
0
));
SafeMatcherCast
<
const
std
::
unique_ptr
<
int
>&>
(
m1
);
EXPECT_FALSE
(
m2
.
Matches
(
1
));
EXPECT_TRUE
(
m2
.
Matches
(
std
::
unique_ptr
<
int
>
()));
EXPECT_FALSE
(
m2
.
Matches
(
std
::
unique_ptr
<
int
>
(
new
int
)));
}
}
// Tests that SafeMatcherCast<T&>(m) works when m is a Matcher<T>.
// Tests that SafeMatcherCast<T&>(m) works when m is a Matcher<T>.
...
@@ -4725,20 +4726,18 @@ TEST(SizeIsTest, ExplainsResult) {
...
@@ -4725,20 +4726,18 @@ TEST(SizeIsTest, ExplainsResult) {
Matcher
<
vector
<
int
>
>
m1
=
SizeIs
(
2
);
Matcher
<
vector
<
int
>
>
m1
=
SizeIs
(
2
);
Matcher
<
vector
<
int
>
>
m2
=
SizeIs
(
Lt
(
2u
));
Matcher
<
vector
<
int
>
>
m2
=
SizeIs
(
Lt
(
2u
));
Matcher
<
vector
<
int
>
>
m3
=
SizeIs
(
AnyOf
(
0
,
3
));
Matcher
<
vector
<
int
>
>
m3
=
SizeIs
(
AnyOf
(
0
,
3
));
Matcher
<
vector
<
int
>
>
m4
=
SizeIs
(
G
reaterThan
(
1
));
Matcher
<
vector
<
int
>
>
m4
=
SizeIs
(
G
t
(
1
u
));
vector
<
int
>
container
;
vector
<
int
>
container
;
EXPECT_EQ
(
"whose size 0 doesn't match"
,
Explain
(
m1
,
container
));
EXPECT_EQ
(
"whose size 0 doesn't match"
,
Explain
(
m1
,
container
));
EXPECT_EQ
(
"whose size 0 matches"
,
Explain
(
m2
,
container
));
EXPECT_EQ
(
"whose size 0 matches"
,
Explain
(
m2
,
container
));
EXPECT_EQ
(
"whose size 0 matches"
,
Explain
(
m3
,
container
));
EXPECT_EQ
(
"whose size 0 matches"
,
Explain
(
m3
,
container
));
EXPECT_EQ
(
"whose size 0 doesn't match, which is 1 less than 1"
,
EXPECT_EQ
(
"whose size 0 doesn't match"
,
Explain
(
m4
,
container
));
Explain
(
m4
,
container
));
container
.
push_back
(
0
);
container
.
push_back
(
0
);
container
.
push_back
(
0
);
container
.
push_back
(
0
);
EXPECT_EQ
(
"whose size 2 matches"
,
Explain
(
m1
,
container
));
EXPECT_EQ
(
"whose size 2 matches"
,
Explain
(
m1
,
container
));
EXPECT_EQ
(
"whose size 2 doesn't match"
,
Explain
(
m2
,
container
));
EXPECT_EQ
(
"whose size 2 doesn't match"
,
Explain
(
m2
,
container
));
EXPECT_EQ
(
"whose size 2 doesn't match"
,
Explain
(
m3
,
container
));
EXPECT_EQ
(
"whose size 2 doesn't match"
,
Explain
(
m3
,
container
));
EXPECT_EQ
(
"whose size 2 matches, which is 1 more than 1"
,
EXPECT_EQ
(
"whose size 2 matches"
,
Explain
(
m4
,
container
));
Explain
(
m4
,
container
));
}
}
#if GTEST_HAS_TYPED_TEST
#if GTEST_HAS_TYPED_TEST
...
...
googletest/README.md
View file @
ee014912
...
@@ -189,9 +189,9 @@ or
...
@@ -189,9 +189,9 @@ or
When Google Test uses pthread, you may need to add flags to your compiler and/or
When Google Test uses pthread, you may need to add flags to your compiler and/or
linker to select the pthread library, or you'll get link errors. If you use the
linker to select the pthread library, or you'll get link errors. If you use the
CMake script
or the deprecated Autotools script, this is taken care of for you.
CMake script
, this is taken care of for you. If you use your own build script,
If you use your own build script,
you'll need to read your compiler and linker's
you'll need to read your compiler and linker's
manual to figure out what flags
manual to figure out what flags
to add.
to add.
### As a Shared Library (DLL)
### As a Shared Library (DLL)
...
...
googletest/docs/advanced.md
View file @
ee014912
...
@@ -2116,6 +2116,15 @@ For example:
...
@@ -2116,6 +2116,15 @@ For example:
everything in test suite
`FooTest`
except
`FooTest.Bar`
and everything in
everything in test suite
`FooTest`
except
`FooTest.Bar`
and everything in
test suite
`BarTest`
except
`BarTest.Foo`
.
test suite
`BarTest`
except
`BarTest.Foo`
.
#### Stop test execution upon first failure
By default, a googletest program runs all tests the user has defined. In some
cases (e.g. iterative test development & execution) it may be desirable stop
test execution upon first failure (trading improved latency for completeness).
If
`GTEST_FAIL_FAST`
environment variable or
`--gtest_fail_fast`
flag is set,
the test runner will stop execution as soon as the first test failure is
found.
#### Temporarily Disabling Tests
#### Temporarily Disabling Tests
If you have a broken test that you cannot fix right away, you can add the
If you have a broken test that you cannot fix right away, you can add the
...
@@ -2553,6 +2562,18 @@ IMPORTANT: The exact format of the JSON document is subject to change.
...
@@ -2553,6 +2562,18 @@ IMPORTANT: The exact format of the JSON document is subject to change.
### Controlling How Failures Are Reported
### Controlling How Failures Are Reported
#### Detecting Test Premature Exit
Google Test implements the _premature-exit-file_ protocol for test runners
to catch any kind of unexpected exits of test programs. Upon start,
Google Test creates the file which will be automatically deleted after
all work has been finished. Then, the test runner can check if this file
exists. In case the file remains undeleted, the inspected test has exited
prematurely.
This feature is enabled only if the
`TEST_PREMATURE_EXIT_FILE`
environment
variable has been set.
#### Turning Assertion Failures into Break-Points
#### Turning Assertion Failures into Break-Points
When running test programs under a debugger, it's very convenient if the
When running test programs under a debugger, it's very convenient if the
...
...
googletest/docs/pkgconfig.md
View file @
ee014912
...
@@ -45,77 +45,6 @@ splitting the pkg-config `Cflags` variable into include dirs and macros for
...
@@ -45,77 +45,6 @@ splitting the pkg-config `Cflags` variable into include dirs and macros for
goes for using
`_LDFLAGS`
over the more commonplace
`_LIBRARIES`
, which happens
goes for using
`_LDFLAGS`
over the more commonplace
`_LIBRARIES`
, which happens
to discard
`-L`
flags and
`-pthread`
.
to discard
`-L`
flags and
`-pthread`
.
### Autotools
Finding GoogleTest in Autoconf and using it from Automake is also fairly easy:
In your
`configure.ac`
:
```
AC_PREREQ([2.69])
AC_INIT([my_gtest_pkgconfig], [0.0.1])
AC_CONFIG_SRCDIR([samples/sample3_unittest.cc])
AC_PROG_CXX
PKG_CHECK_MODULES([GTEST], [gtest_main])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
```
and in your
`Makefile.am`
:
```
check_PROGRAMS = testapp
TESTS = $(check_PROGRAMS)
testapp_SOURCES = samples/sample3_unittest.cc
testapp_CXXFLAGS = $(GTEST_CFLAGS)
testapp_LDADD = $(GTEST_LIBS)
```
### Meson
Meson natively uses pkgconfig to query dependencies:
```
project('my_gtest_pkgconfig', 'cpp', version : '0.0.1')
gtest_dep = dependency('gtest_main')
testapp = executable(
'testapp',
files(['samples/sample3_unittest.cc']),
dependencies : gtest_dep,
install : false)
test('first_and_only_test', testapp)
```
### Plain Makefiles
Since
`pkg-config`
is a small Unix command-line utility, it can be used in
handwritten
`Makefile`
s too:
```
makefile
GTEST_CFLAGS
=
`
pkg-config
--cflags
gtest_main
`
GTEST_LIBS
=
`
pkg-config
--libs
gtest_main
`
.PHONY
:
tests all
tests
:
all
./testapp
all
:
testapp
testapp
:
testapp.o
$(CXX)
$(CXXFLAGS)
$(LDFLAGS)
$<
-o
$@
$(GTEST_LIBS)
testapp.o
:
samples/sample3_unittest.cc
$(CXX)
$(CPPFLAGS)
$(CXXFLAGS)
$<
-c
-o
$@
$(GTEST_CFLAGS)
```
### Help! pkg-config can't find GoogleTest!
### Help! pkg-config can't find GoogleTest!
Let's say you have a
`CMakeLists.txt`
along the lines of the one in this
Let's say you have a
`CMakeLists.txt`
along the lines of the one in this
...
...
googletest/include/gtest/gtest-printers.h
View file @
ee014912
...
@@ -119,53 +119,126 @@
...
@@ -119,53 +119,126 @@
namespace
testing
{
namespace
testing
{
// Definitions in the
'
internal
' and 'internal2'
name
spaces are
// Definitions in the internal
*
namespaces are
subject to change without notice.
//
subject to change without notice.
DO NOT USE THEM IN USER CODE!
// DO NOT USE THEM IN USER CODE!
namespace
internal
2
{
namespace
internal
{
// Prints the given number of bytes in the given object to the given
template
<
typename
T
>
// ostream.
void
UniversalPrint
(
const
T
&
value
,
::
std
::
ostream
*
os
);
GTEST_API_
void
PrintBytesInObjectTo
(
const
unsigned
char
*
obj_bytes
,
size_t
count
,
::
std
::
ostream
*
os
);
// For selecting which printer to use when a given type has neither <<
// Used to print an STL-style container when the user doesn't define
// nor PrintTo().
// a PrintTo() for it.
enum
TypeKind
{
struct
ContainerPrinter
{
kProtobuf
,
// a protobuf type
template
<
typename
T
,
kConvertibleToInteger
,
// a type implicitly convertible to BiggestInt
typename
=
typename
std
::
enable_if
<
// (e.g. a named or unnamed enum type)
(
sizeof
(
IsContainerTest
<
T
>
(
0
))
==
sizeof
(
IsContainer
))
&&
#if GTEST_INTERNAL_HAS_STRING_VIEW
!
IsRecursiveContainer
<
T
>::
value
>::
type
>
kConvertibleToStringView
,
// a type implicitly convertible to
static
void
PrintValue
(
const
T
&
container
,
std
::
ostream
*
os
)
{
// absl::string_view or std::string_view
const
size_t
kMaxCount
=
32
;
// The maximum number of elements to print.
#endif
*
os
<<
'{'
;
kOtherType
// anything else
size_t
count
=
0
;
for
(
auto
&&
elem
:
container
)
{
if
(
count
>
0
)
{
*
os
<<
','
;
if
(
count
==
kMaxCount
)
{
// Enough has been printed.
*
os
<<
" ..."
;
break
;
}
}
*
os
<<
' '
;
// We cannot call PrintTo(elem, os) here as PrintTo() doesn't
// handle `elem` being a native array.
internal
::
UniversalPrint
(
elem
,
os
);
++
count
;
}
if
(
count
>
0
)
{
*
os
<<
' '
;
}
*
os
<<
'}'
;
}
};
};
// TypeWithoutFormatter<T, kTypeKind>::PrintValue(value, os) is called
// Used to print a pointer that is neither a char pointer nor a member
// by the universal printer to print a value of type T when neither
// pointer, when the user doesn't define PrintTo() for it. (A member
// operator<< nor PrintTo() is defined for T, where kTypeKind is the
// variable pointer or member function pointer doesn't really point to
// "kind" of T as defined by enum TypeKind.
// a location in the address space. Their representation is
template
<
typename
T
,
TypeKind
kTypeKind
>
// implementation-defined. Therefore they will be printed as raw
class
TypeWithoutFormatter
{
// bytes.)
public:
struct
FunctionPointerPrinter
{
// This default version is called when kTypeKind is kOtherType.
template
<
typename
T
,
typename
=
typename
std
::
enable_if
<
static
void
PrintValue
(
const
T
&
value
,
::
std
::
ostream
*
os
)
{
std
::
is_function
<
T
>::
value
>::
type
>
PrintBytesInObjectTo
(
static
void
PrintValue
(
T
*
p
,
::
std
::
ostream
*
os
)
{
static_cast
<
const
unsigned
char
*>
(
if
(
p
==
nullptr
)
{
reinterpret_cast
<
const
void
*>
(
std
::
addressof
(
value
))),
*
os
<<
"NULL"
;
sizeof
(
value
),
os
);
}
else
{
// T is a function type, so '*os << p' doesn't do what we want
// (it just prints p as bool). We want to print p as a const
// void*.
*
os
<<
reinterpret_cast
<
const
void
*>
(
p
);
}
}
}
};
};
// We print a protobuf using its ShortDebugString() when the string
struct
PointerPrinter
{
// doesn't exceed this many characters; otherwise we print it using
template
<
typename
T
>
// DebugString() for better readability.
static
void
PrintValue
(
T
*
p
,
::
std
::
ostream
*
os
)
{
const
size_t
kProtobufOneLinerMaxLength
=
50
;
if
(
p
==
nullptr
)
{
*
os
<<
"NULL"
;
}
else
{
// T is not a function type. We just call << to print p,
// relying on ADL to pick up user-defined << for their pointer
// types, if any.
*
os
<<
p
;
}
}
};
namespace
internal_stream
{
struct
Sentinel
;
template
<
typename
Char
,
typename
CharTraits
,
typename
T
>
Sentinel
*
operator
<<
(
::
std
::
basic_ostream
<
Char
,
CharTraits
>&
os
,
const
T
&
x
);
// Check if the user has a user-defined operator<< for their type.
//
// We put this in its own namespace to inject a custom operator<< that allows us
// to probe the type's operator.
//
// Note that this operator<< takes a generic std::basic_ostream<Char,
// CharTraits> type instead of the more restricted std::ostream. If
// we define it to take an std::ostream instead, we'll get an
// "ambiguous overloads" compiler error when trying to print a type
// Foo that supports streaming to std::basic_ostream<Char,
// CharTraits>, as the compiler cannot tell whether
// operator<<(std::ostream&, const T&) or
// operator<<(std::basic_stream<Char, CharTraits>, const Foo&) is more
// specific.
template
<
typename
T
>
template
<
typename
T
>
class
TypeWithoutFormatter
<
T
,
kProtobuf
>
{
constexpr
bool
UseStreamOperator
()
{
public:
return
!
std
::
is_same
<
decltype
(
std
::
declval
<
std
::
ostream
&>
()
<<
std
::
declval
<
const
T
&>
()),
Sentinel
*>::
value
;
}
}
// namespace internal_stream
struct
StreamPrinter
{
template
<
typename
T
,
typename
=
typename
std
::
enable_if
<
internal_stream
::
UseStreamOperator
<
T
>
()
>::
type
>
static
void
PrintValue
(
const
T
&
value
,
::
std
::
ostream
*
os
)
{
*
os
<<
value
;
}
};
struct
ProtobufPrinter
{
// We print a protobuf using its ShortDebugString() when the string
// doesn't exceed this many characters; otherwise we print it using
// DebugString() for better readability.
static
const
size_t
kProtobufOneLinerMaxLength
=
50
;
template
<
typename
T
,
typename
=
typename
std
::
enable_if
<
internal
::
IsAProtocolMessage
<
T
>::
value
>::
type
>
static
void
PrintValue
(
const
T
&
value
,
::
std
::
ostream
*
os
)
{
static
void
PrintValue
(
const
T
&
value
,
::
std
::
ostream
*
os
)
{
std
::
string
pretty_str
=
value
.
ShortDebugString
();
std
::
string
pretty_str
=
value
.
ShortDebugString
();
if
(
pretty_str
.
length
()
>
kProtobufOneLinerMaxLength
)
{
if
(
pretty_str
.
length
()
>
kProtobufOneLinerMaxLength
)
{
...
@@ -175,9 +248,7 @@ class TypeWithoutFormatter<T, kProtobuf> {
...
@@ -175,9 +248,7 @@ class TypeWithoutFormatter<T, kProtobuf> {
}
}
};
};
template
<
typename
T
>
struct
ConvertibleToIntegerPrinter
{
class
TypeWithoutFormatter
<
T
,
kConvertibleToInteger
>
{
public:
// Since T has no << operator or PrintTo() but can be implicitly
// Since T has no << operator or PrintTo() but can be implicitly
// converted to BiggestInt, we print it as a BiggestInt.
// converted to BiggestInt, we print it as a BiggestInt.
//
//
...
@@ -185,112 +256,64 @@ class TypeWithoutFormatter<T, kConvertibleToInteger> {
...
@@ -185,112 +256,64 @@ class TypeWithoutFormatter<T, kConvertibleToInteger> {
// case printing it as an integer is the desired behavior. In case
// case printing it as an integer is the desired behavior. In case
// T is not an enum, printing it as an integer is the best we can do
// T is not an enum, printing it as an integer is the best we can do
// given that it has no user-defined printer.
// given that it has no user-defined printer.
static
void
PrintValue
(
const
T
&
value
,
::
std
::
ostream
*
os
)
{
static
void
PrintValue
(
internal
::
BiggestInt
value
,
::
std
::
ostream
*
os
)
{
const
internal
::
BiggestInt
kBigInt
=
value
;
*
os
<<
value
;
*
os
<<
kBigInt
;
}
}
};
};
struct
ConvertibleToStringViewPrinter
{
#if GTEST_INTERNAL_HAS_STRING_VIEW
#if GTEST_INTERNAL_HAS_STRING_VIEW
template
<
typename
T
>
static
void
PrintValue
(
internal
::
StringView
value
,
::
std
::
ostream
*
os
)
{
class
TypeWithoutFormatter
<
T
,
kConvertibleToStringView
>
{
internal
::
UniversalPrint
(
value
,
os
);
public:
}
// Since T has neither operator<< nor PrintTo() but can be implicitly
// converted to absl::string_view, we print it as a absl::string_view
// (or std::string_view).
//
// Note: the implementation is further below, as it depends on
// internal::PrintTo symbol which is defined later in the file.
static
void
PrintValue
(
const
T
&
value
,
::
std
::
ostream
*
os
);
};
#endif
#endif
};
// Prints the given value to the given ostream. If the value is a
// protocol message, its debug string is printed; if it's an enum or
// of a type implicitly convertible to BiggestInt, it's printed as an
// integer; otherwise the bytes in the value are printed. This is
// what UniversalPrinter<T>::Print() does when it knows nothing about
// type T and T has neither << operator nor PrintTo().
//
// A user can override this behavior for a class type Foo by defining
// a << operator in the namespace where Foo is defined.
//
// We put this operator in namespace 'internal2' instead of 'internal'
// to simplify the implementation, as much code in 'internal' needs to
// use << in STL, which would conflict with our own << were it defined
// in 'internal'.
//
// Note that this operator<< takes a generic std::basic_ostream<Char,
// CharTraits> type instead of the more restricted std::ostream. If
// we define it to take an std::ostream instead, we'll get an
// "ambiguous overloads" compiler error when trying to print a type
// Foo that supports streaming to std::basic_ostream<Char,
// CharTraits>, as the compiler cannot tell whether
// operator<<(std::ostream&, const T&) or
// operator<<(std::basic_stream<Char, CharTraits>, const Foo&) is more
// specific.
template
<
typename
Char
,
typename
CharTraits
,
typename
T
>
::
std
::
basic_ostream
<
Char
,
CharTraits
>&
operator
<<
(
::
std
::
basic_ostream
<
Char
,
CharTraits
>&
os
,
const
T
&
x
)
{
TypeWithoutFormatter
<
T
,
(
internal
::
IsAProtocolMessage
<
T
>::
value
?
kProtobuf
:
std
::
is_convertible
<
const
T
&
,
internal
::
BiggestInt
>::
value
?
kConvertibleToInteger
:
#if GTEST_INTERNAL_HAS_STRING_VIEW
std
::
is_convertible
<
const
T
&
,
internal
::
StringView
>::
value
?
kConvertibleToStringView
:
#endif
kOtherType
)
>::
PrintValue
(
x
,
&
os
);
return
os
;
}
}
// namespace internal2
// Prints the given number of bytes in the given object to the given
}
// namespace testing
// ostream.
GTEST_API_
void
PrintBytesInObjectTo
(
const
unsigned
char
*
obj_bytes
,
size_t
count
,
::
std
::
ostream
*
os
);
struct
FallbackPrinter
{
template
<
typename
T
>
static
void
PrintValue
(
const
T
&
value
,
::
std
::
ostream
*
os
)
{
PrintBytesInObjectTo
(
static_cast
<
const
unsigned
char
*>
(
reinterpret_cast
<
const
void
*>
(
std
::
addressof
(
value
))),
sizeof
(
value
),
os
);
}
};
// Try every printer in order and return the first one that works.
template
<
typename
T
,
typename
E
,
typename
Printer
,
typename
...
Printers
>
struct
FindFirstPrinter
:
FindFirstPrinter
<
T
,
E
,
Printers
...
>
{};
// This namespace MUST NOT BE NESTED IN ::testing, or the name look-up
template
<
typename
T
,
typename
Printer
,
typename
...
Printers
>
// magic needed for implementing UniversalPrinter won't work.
struct
FindFirstPrinter
<
namespace
testing_internal
{
T
,
decltype
(
Printer
::
PrintValue
(
std
::
declval
<
const
T
&>
(),
nullptr
)),
Printer
,
Printers
...
>
{
using
type
=
Printer
;
};
// Used to print a value that is not an STL-style container when the
// Select the best printer in the following order:
// user doesn't define PrintTo() for it.
// - Print containers (they have begin/end/etc).
// - Print function pointers.
// - Print object pointers.
// - Use the stream operator, if available.
// - Print protocol buffers.
// - Print types convertible to BiggestInt.
// - Print types convertible to StringView, if available.
// - Fallback to printing the raw bytes of the object.
template
<
typename
T
>
template
<
typename
T
>
void
DefaultPrintNonContainerTo
(
const
T
&
value
,
::
std
::
ostream
*
os
)
{
void
PrintWithFallback
(
const
T
&
value
,
::
std
::
ostream
*
os
)
{
// With the following statement, during unqualified name lookup,
using
Printer
=
typename
FindFirstPrinter
<
// testing::internal2::operator<< appears as if it was declared in
T
,
void
,
ContainerPrinter
,
FunctionPointerPrinter
,
PointerPrinter
,
// the nearest enclosing namespace that contains both
StreamPrinter
,
ProtobufPrinter
,
ConvertibleToIntegerPrinter
,
// ::testing_internal and ::testing::internal2, i.e. the global
ConvertibleToStringViewPrinter
,
FallbackPrinter
>::
type
;
// namespace. For more details, refer to the C++ Standard section
Printer
::
PrintValue
(
value
,
os
);
// 7.3.4-1 [namespace.udir]. This allows us to fall back onto
// testing::internal2::operator<< in case T doesn't come with a <<
// operator.
using
::
testing
::
internal2
::
operator
<<
;
// Assuming T is defined in namespace foo, in the next statement,
// the compiler will consider all of:
//
// 1. foo::operator<< (thanks to Koenig look-up),
// 2. ::operator<< (as the current namespace is enclosed in ::),
// 3. testing::internal2::operator<< (thanks to the using statement above).
//
// The operator<< whose type matches T best will be picked.
//
// We deliberately allow #2 to be a candidate, as sometimes it's
// impossible to define #1 (e.g. when foo is ::std, defining
// anything in it is undefined behavior unless you are a compiler
// vendor.).
*
os
<<
value
;
}
}
}
// namespace testing_internal
namespace
testing
{
namespace
internal
{
// FormatForComparison<ToPrint, OtherOperand>::Format(value) formats a
// FormatForComparison<ToPrint, OtherOperand>::Format(value) formats a
// value of type ToPrint that is an operand of a comparison assertion
// value of type ToPrint that is an operand of a comparison assertion
// (e.g. ASSERT_EQ). OtherOperand is the type of the other operand in
// (e.g. ASSERT_EQ). OtherOperand is the type of the other operand in
...
@@ -388,85 +411,6 @@ std::string FormatForComparisonFailureMessage(
...
@@ -388,85 +411,6 @@ std::string FormatForComparisonFailureMessage(
template
<
typename
T
>
template
<
typename
T
>
class
UniversalPrinter
;
class
UniversalPrinter
;
template
<
typename
T
>
void
UniversalPrint
(
const
T
&
value
,
::
std
::
ostream
*
os
);
enum
DefaultPrinterType
{
kPrintContainer
,
kPrintPointer
,
kPrintFunctionPointer
,
kPrintOther
,
};
template
<
DefaultPrinterType
type
>
struct
WrapPrinterType
{};
// Used to print an STL-style container when the user doesn't define
// a PrintTo() for it.
template
<
typename
C
>
void
DefaultPrintTo
(
WrapPrinterType
<
kPrintContainer
>
/* dummy */
,
const
C
&
container
,
::
std
::
ostream
*
os
)
{
const
size_t
kMaxCount
=
32
;
// The maximum number of elements to print.
*
os
<<
'{'
;
size_t
count
=
0
;
for
(
typename
C
::
const_iterator
it
=
container
.
begin
();
it
!=
container
.
end
();
++
it
,
++
count
)
{
if
(
count
>
0
)
{
*
os
<<
','
;
if
(
count
==
kMaxCount
)
{
// Enough has been printed.
*
os
<<
" ..."
;
break
;
}
}
*
os
<<
' '
;
// We cannot call PrintTo(*it, os) here as PrintTo() doesn't
// handle *it being a native array.
internal
::
UniversalPrint
(
*
it
,
os
);
}
if
(
count
>
0
)
{
*
os
<<
' '
;
}
*
os
<<
'}'
;
}
// Used to print a pointer that is neither a char pointer nor a member
// pointer, when the user doesn't define PrintTo() for it. (A member
// variable pointer or member function pointer doesn't really point to
// a location in the address space. Their representation is
// implementation-defined. Therefore they will be printed as raw
// bytes.)
template
<
typename
T
>
void
DefaultPrintTo
(
WrapPrinterType
<
kPrintPointer
>
/* dummy */
,
T
*
p
,
::
std
::
ostream
*
os
)
{
if
(
p
==
nullptr
)
{
*
os
<<
"NULL"
;
}
else
{
// T is not a function type. We just call << to print p,
// relying on ADL to pick up user-defined << for their pointer
// types, if any.
*
os
<<
p
;
}
}
template
<
typename
T
>
void
DefaultPrintTo
(
WrapPrinterType
<
kPrintFunctionPointer
>
/* dummy */
,
T
*
p
,
::
std
::
ostream
*
os
)
{
if
(
p
==
nullptr
)
{
*
os
<<
"NULL"
;
}
else
{
// T is a function type, so '*os << p' doesn't do what we want
// (it just prints p as bool). We want to print p as a const
// void*.
*
os
<<
reinterpret_cast
<
const
void
*>
(
p
);
}
}
// Used to print a non-container, non-pointer value when the user
// doesn't define PrintTo() for it.
template
<
typename
T
>
void
DefaultPrintTo
(
WrapPrinterType
<
kPrintOther
>
/* dummy */
,
const
T
&
value
,
::
std
::
ostream
*
os
)
{
::
testing_internal
::
DefaultPrintNonContainerTo
(
value
,
os
);
}
// Prints the given value using the << operator if it has one;
// Prints the given value using the << operator if it has one;
// otherwise prints the bytes in it. This is what
// otherwise prints the bytes in it. This is what
// UniversalPrinter<T>::Print() does when PrintTo() is not specialized
// UniversalPrinter<T>::Print() does when PrintTo() is not specialized
...
@@ -480,36 +424,7 @@ void DefaultPrintTo(WrapPrinterType<kPrintOther> /* dummy */,
...
@@ -480,36 +424,7 @@ void DefaultPrintTo(WrapPrinterType<kPrintOther> /* dummy */,
// wants).
// wants).
template
<
typename
T
>
template
<
typename
T
>
void
PrintTo
(
const
T
&
value
,
::
std
::
ostream
*
os
)
{
void
PrintTo
(
const
T
&
value
,
::
std
::
ostream
*
os
)
{
// DefaultPrintTo() is overloaded. The type of its first argument
internal
::
PrintWithFallback
(
value
,
os
);
// determines which version will be picked.
//
// Note that we check for container types here, prior to we check
// for protocol message types in our operator<<. The rationale is:
//
// For protocol messages, we want to give people a chance to
// override Google Mock's format by defining a PrintTo() or
// operator<<. For STL containers, other formats can be
// incompatible with Google Mock's format for the container
// elements; therefore we check for container types here to ensure
// that our format is used.
//
// Note that MSVC and clang-cl do allow an implicit conversion from
// pointer-to-function to pointer-to-object, but clang-cl warns on it.
// So don't use ImplicitlyConvertible if it can be helped since it will
// cause this warning, and use a separate overload of DefaultPrintTo for
// function pointers so that the `*os << p` in the object pointer overload
// doesn't cause that warning either.
DefaultPrintTo
(
WrapPrinterType
<
(
sizeof
(
IsContainerTest
<
T
>
(
0
))
==
sizeof
(
IsContainer
))
&&
!
IsRecursiveContainer
<
T
>::
value
?
kPrintContainer
:
!
std
::
is_pointer
<
T
>::
value
?
kPrintOther
:
std
::
is_function
<
typename
std
::
remove_pointer
<
T
>::
type
>::
value
?
kPrintFunctionPointer
:
kPrintPointer
>
(),
value
,
os
);
}
}
// The following list of PrintTo() overloads tells
// The following list of PrintTo() overloads tells
...
@@ -900,16 +815,6 @@ Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
...
@@ -900,16 +815,6 @@ Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
}
// namespace internal
}
// namespace internal
#if GTEST_INTERNAL_HAS_STRING_VIEW
namespace
internal2
{
template
<
typename
T
>
void
TypeWithoutFormatter
<
T
,
kConvertibleToStringView
>::
PrintValue
(
const
T
&
value
,
::
std
::
ostream
*
os
)
{
internal
::
PrintTo
(
internal
::
StringView
(
value
),
os
);
}
}
// namespace internal2
#endif
template
<
typename
T
>
template
<
typename
T
>
::
std
::
string
PrintToString
(
const
T
&
value
)
{
::
std
::
string
PrintToString
(
const
T
&
value
)
{
::
std
::
stringstream
ss
;
::
std
::
stringstream
ss
;
...
...
googletest/include/gtest/gtest.h
View file @
ee014912
...
@@ -101,6 +101,10 @@ GTEST_DECLARE_bool_(catch_exceptions);
...
@@ -101,6 +101,10 @@ GTEST_DECLARE_bool_(catch_exceptions);
// to let Google Test decide.
// to let Google Test decide.
GTEST_DECLARE_string_
(
color
);
GTEST_DECLARE_string_
(
color
);
// This flag controls whether the test runner should continue execution past
// first failure.
GTEST_DECLARE_bool_
(
fail_fast
);
// This flag sets up the filter to select by name using a glob pattern
// This flag sets up the filter to select by name using a glob pattern
// the tests to run. If the filter is not given all tests are executed.
// the tests to run. If the filter is not given all tests are executed.
GTEST_DECLARE_string_
(
filter
);
GTEST_DECLARE_string_
(
filter
);
...
@@ -795,6 +799,9 @@ class GTEST_API_ TestInfo {
...
@@ -795,6 +799,9 @@ class GTEST_API_ TestInfo {
// deletes it.
// deletes it.
void
Run
();
void
Run
();
// Skip and records the test result for this object.
void
Skip
();
static
void
ClearTestResult
(
TestInfo
*
test_info
)
{
static
void
ClearTestResult
(
TestInfo
*
test_info
)
{
test_info
->
result_
.
Clear
();
test_info
->
result_
.
Clear
();
}
}
...
@@ -943,6 +950,9 @@ class GTEST_API_ TestSuite {
...
@@ -943,6 +950,9 @@ class GTEST_API_ TestSuite {
// Runs every test in this TestSuite.
// Runs every test in this TestSuite.
void
Run
();
void
Run
();
// Skips the execution of tests under this TestSuite
void
Skip
();
// Runs SetUpTestSuite() for this TestSuite. This wrapper is needed
// Runs SetUpTestSuite() for this TestSuite. This wrapper is needed
// for catching exceptions thrown from SetUpTestSuite().
// for catching exceptions thrown from SetUpTestSuite().
void
RunSetUpTestSuite
()
{
void
RunSetUpTestSuite
()
{
...
@@ -1807,12 +1817,6 @@ class GTEST_API_ AssertHelper {
...
@@ -1807,12 +1817,6 @@ class GTEST_API_ AssertHelper {
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
AssertHelper
);
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
AssertHelper
);
};
};
enum
GTestColor
{
COLOR_DEFAULT
,
COLOR_RED
,
COLOR_GREEN
,
COLOR_YELLOW
};
GTEST_API_
GTEST_ATTRIBUTE_PRINTF_
(
2
,
3
)
void
ColoredPrintf
(
GTestColor
color
,
const
char
*
fmt
,
...);
}
// namespace internal
}
// namespace internal
// The pure interface class that all value-parameterized tests inherit from.
// The pure interface class that all value-parameterized tests inherit from.
...
...
googletest/include/gtest/internal/gtest-internal.h
View file @
ee014912
...
@@ -90,7 +90,9 @@
...
@@ -90,7 +90,9 @@
#define GTEST_STRINGIFY_HELPER_(name, ...) #name
#define GTEST_STRINGIFY_HELPER_(name, ...) #name
#define GTEST_STRINGIFY_(...) GTEST_STRINGIFY_HELPER_(__VA_ARGS__, )
#define GTEST_STRINGIFY_(...) GTEST_STRINGIFY_HELPER_(__VA_ARGS__, )
namespace
proto2
{
class
Message
;
}
namespace
proto2
{
class
MessageLite
;
}
namespace
testing
{
namespace
testing
{
...
@@ -879,10 +881,10 @@ class GTEST_API_ Random {
...
@@ -879,10 +881,10 @@ class GTEST_API_ Random {
typename std::remove_const<typename std::remove_reference<T>::type>::type
typename std::remove_const<typename std::remove_reference<T>::type>::type
// IsAProtocolMessage<T>::value is a compile-time bool constant that's
// IsAProtocolMessage<T>::value is a compile-time bool constant that's
// true if and only if T is type proto2::Message or a subclass of it.
// true if and only if T is type proto2::Message
Lite
or a subclass of it.
template
<
typename
T
>
template
<
typename
T
>
struct
IsAProtocolMessage
struct
IsAProtocolMessage
:
public
std
::
is_convertible
<
const
T
*
,
const
::
proto2
::
Message
*>
{};
:
public
std
::
is_convertible
<
const
T
*
,
const
::
proto2
::
Message
Lite
*>
{};
// When the compiler sees expression IsContainerTest<C>(0), if C is an
// When the compiler sees expression IsContainerTest<C>(0), if C is an
// STL-style container class, the first overload of IsContainerTest
// STL-style container class, the first overload of IsContainerTest
...
...
googletest/include/gtest/internal/gtest-port.h
View file @
ee014912
...
@@ -252,6 +252,8 @@
...
@@ -252,6 +252,8 @@
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <cerrno>
#include <cstdint>
#include <cstdint>
#include <limits>
#include <limits>
#include <type_traits>
#include <type_traits>
...
@@ -1960,16 +1962,16 @@ namespace posix {
...
@@ -1960,16 +1962,16 @@ namespace posix {
typedef
struct
_stat
StatStruct
;
typedef
struct
_stat
StatStruct
;
# ifdef __BORLANDC__
# ifdef __BORLANDC__
inline
int
IsATTY
(
int
fd
)
{
return
isatty
(
fd
);
}
inline
int
Do
IsATTY
(
int
fd
)
{
return
isatty
(
fd
);
}
inline
int
StrCaseCmp
(
const
char
*
s1
,
const
char
*
s2
)
{
inline
int
StrCaseCmp
(
const
char
*
s1
,
const
char
*
s2
)
{
return
stricmp
(
s1
,
s2
);
return
stricmp
(
s1
,
s2
);
}
}
inline
char
*
StrDup
(
const
char
*
src
)
{
return
strdup
(
src
);
}
inline
char
*
StrDup
(
const
char
*
src
)
{
return
strdup
(
src
);
}
# else // !__BORLANDC__
# else // !__BORLANDC__
# if GTEST_OS_WINDOWS_MOBILE
# if GTEST_OS_WINDOWS_MOBILE
inline
int
IsATTY
(
int
/* fd */
)
{
return
0
;
}
inline
int
Do
IsATTY
(
int
/* fd */
)
{
return
0
;
}
# else
# else
inline
int
IsATTY
(
int
fd
)
{
return
_isatty
(
fd
);
}
inline
int
Do
IsATTY
(
int
fd
)
{
return
_isatty
(
fd
);
}
# endif // GTEST_OS_WINDOWS_MOBILE
# endif // GTEST_OS_WINDOWS_MOBILE
inline
int
StrCaseCmp
(
const
char
*
s1
,
const
char
*
s2
)
{
inline
int
StrCaseCmp
(
const
char
*
s1
,
const
char
*
s2
)
{
return
_stricmp
(
s1
,
s2
);
return
_stricmp
(
s1
,
s2
);
...
@@ -1994,7 +1996,7 @@ inline bool IsDir(const StatStruct& st) {
...
@@ -1994,7 +1996,7 @@ inline bool IsDir(const StatStruct& st) {
typedef
struct
stat
StatStruct
;
typedef
struct
stat
StatStruct
;
inline
int
FileNo
(
FILE
*
file
)
{
return
fileno
(
file
);
}
inline
int
FileNo
(
FILE
*
file
)
{
return
fileno
(
file
);
}
inline
int
IsATTY
(
int
fd
)
{
return
isatty
(
fd
);
}
inline
int
Do
IsATTY
(
int
fd
)
{
return
isatty
(
fd
);
}
inline
int
Stat
(
const
char
*
path
,
StatStruct
*
buf
)
{
inline
int
Stat
(
const
char
*
path
,
StatStruct
*
buf
)
{
// stat function not implemented on ESP8266
// stat function not implemented on ESP8266
return
0
;
return
0
;
...
@@ -2011,7 +2013,7 @@ inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
...
@@ -2011,7 +2013,7 @@ inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
typedef
struct
stat
StatStruct
;
typedef
struct
stat
StatStruct
;
inline
int
FileNo
(
FILE
*
file
)
{
return
fileno
(
file
);
}
inline
int
FileNo
(
FILE
*
file
)
{
return
fileno
(
file
);
}
inline
int
IsATTY
(
int
fd
)
{
return
isatty
(
fd
);
}
inline
int
Do
IsATTY
(
int
fd
)
{
return
isatty
(
fd
);
}
inline
int
Stat
(
const
char
*
path
,
StatStruct
*
buf
)
{
return
stat
(
path
,
buf
);
}
inline
int
Stat
(
const
char
*
path
,
StatStruct
*
buf
)
{
return
stat
(
path
,
buf
);
}
inline
int
StrCaseCmp
(
const
char
*
s1
,
const
char
*
s2
)
{
inline
int
StrCaseCmp
(
const
char
*
s1
,
const
char
*
s2
)
{
return
strcasecmp
(
s1
,
s2
);
return
strcasecmp
(
s1
,
s2
);
...
@@ -2022,6 +2024,17 @@ inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
...
@@ -2022,6 +2024,17 @@ inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
#endif // GTEST_OS_WINDOWS
#endif // GTEST_OS_WINDOWS
inline
int
IsATTY
(
int
fd
)
{
// DoIsATTY might change errno (for example ENOTTY in case you redirect stdout
// to a file on Linux), which is unexpected, so save the previous value, and
// restore it after the call.
int
savedErrno
=
errno
;
int
isAttyValue
=
DoIsATTY
(
fd
);
errno
=
savedErrno
;
return
isAttyValue
;
}
// Functions deprecated by MSVC 8.0.
// Functions deprecated by MSVC 8.0.
GTEST_DISABLE_MSC_DEPRECATED_PUSH_
()
GTEST_DISABLE_MSC_DEPRECATED_PUSH_
()
...
...
googletest/src/gtest-internal-inl.h
View file @
ee014912
...
@@ -84,6 +84,7 @@ const char kAlsoRunDisabledTestsFlag[] = "also_run_disabled_tests";
...
@@ -84,6 +84,7 @@ const char kAlsoRunDisabledTestsFlag[] = "also_run_disabled_tests";
const
char
kBreakOnFailureFlag
[]
=
"break_on_failure"
;
const
char
kBreakOnFailureFlag
[]
=
"break_on_failure"
;
const
char
kCatchExceptionsFlag
[]
=
"catch_exceptions"
;
const
char
kCatchExceptionsFlag
[]
=
"catch_exceptions"
;
const
char
kColorFlag
[]
=
"color"
;
const
char
kColorFlag
[]
=
"color"
;
const
char
kFailFast
[]
=
"fail_fast"
;
const
char
kFilterFlag
[]
=
"filter"
;
const
char
kFilterFlag
[]
=
"filter"
;
const
char
kListTestsFlag
[]
=
"list_tests"
;
const
char
kListTestsFlag
[]
=
"list_tests"
;
const
char
kOutputFlag
[]
=
"output"
;
const
char
kOutputFlag
[]
=
"output"
;
...
@@ -164,6 +165,7 @@ class GTestFlagSaver {
...
@@ -164,6 +165,7 @@ class GTestFlagSaver {
color_
=
GTEST_FLAG
(
color
);
color_
=
GTEST_FLAG
(
color
);
death_test_style_
=
GTEST_FLAG
(
death_test_style
);
death_test_style_
=
GTEST_FLAG
(
death_test_style
);
death_test_use_fork_
=
GTEST_FLAG
(
death_test_use_fork
);
death_test_use_fork_
=
GTEST_FLAG
(
death_test_use_fork
);
fail_fast_
=
GTEST_FLAG
(
fail_fast
);
filter_
=
GTEST_FLAG
(
filter
);
filter_
=
GTEST_FLAG
(
filter
);
internal_run_death_test_
=
GTEST_FLAG
(
internal_run_death_test
);
internal_run_death_test_
=
GTEST_FLAG
(
internal_run_death_test
);
list_tests_
=
GTEST_FLAG
(
list_tests
);
list_tests_
=
GTEST_FLAG
(
list_tests
);
...
@@ -187,6 +189,7 @@ class GTestFlagSaver {
...
@@ -187,6 +189,7 @@ class GTestFlagSaver {
GTEST_FLAG
(
death_test_style
)
=
death_test_style_
;
GTEST_FLAG
(
death_test_style
)
=
death_test_style_
;
GTEST_FLAG
(
death_test_use_fork
)
=
death_test_use_fork_
;
GTEST_FLAG
(
death_test_use_fork
)
=
death_test_use_fork_
;
GTEST_FLAG
(
filter
)
=
filter_
;
GTEST_FLAG
(
filter
)
=
filter_
;
GTEST_FLAG
(
fail_fast
)
=
fail_fast_
;
GTEST_FLAG
(
internal_run_death_test
)
=
internal_run_death_test_
;
GTEST_FLAG
(
internal_run_death_test
)
=
internal_run_death_test_
;
GTEST_FLAG
(
list_tests
)
=
list_tests_
;
GTEST_FLAG
(
list_tests
)
=
list_tests_
;
GTEST_FLAG
(
output
)
=
output_
;
GTEST_FLAG
(
output
)
=
output_
;
...
@@ -208,6 +211,7 @@ class GTestFlagSaver {
...
@@ -208,6 +211,7 @@ class GTestFlagSaver {
std
::
string
color_
;
std
::
string
color_
;
std
::
string
death_test_style_
;
std
::
string
death_test_style_
;
bool
death_test_use_fork_
;
bool
death_test_use_fork_
;
bool
fail_fast_
;
std
::
string
filter_
;
std
::
string
filter_
;
std
::
string
internal_run_death_test_
;
std
::
string
internal_run_death_test_
;
bool
list_tests_
;
bool
list_tests_
;
...
...
googletest/src/gtest-printers.cc
View file @
ee014912
...
@@ -104,7 +104,7 @@ void PrintBytesInObjectToImpl(const unsigned char* obj_bytes, size_t count,
...
@@ -104,7 +104,7 @@ void PrintBytesInObjectToImpl(const unsigned char* obj_bytes, size_t count,
}
// namespace
}
// namespace
namespace
internal
2
{
namespace
internal
{
// Delegates to PrintBytesInObjectToImpl() to print the bytes in the
// Delegates to PrintBytesInObjectToImpl() to print the bytes in the
// given object. The delegation simplifies the implementation, which
// given object. The delegation simplifies the implementation, which
...
@@ -116,10 +116,6 @@ void PrintBytesInObjectTo(const unsigned char* obj_bytes, size_t count,
...
@@ -116,10 +116,6 @@ void PrintBytesInObjectTo(const unsigned char* obj_bytes, size_t count,
PrintBytesInObjectToImpl
(
obj_bytes
,
count
,
os
);
PrintBytesInObjectToImpl
(
obj_bytes
,
count
,
os
);
}
}
}
// namespace internal2
namespace
internal
{
// Depending on the value of a char (or wchar_t), we print it in one
// Depending on the value of a char (or wchar_t), we print it in one
// of three formats:
// of three formats:
// - as is if it's a printable ASCII (e.g. 'a', '2', ' '),
// - as is if it's a printable ASCII (e.g. 'a', '2', ' '),
...
...
googletest/src/gtest.cc
View file @
ee014912
This diff is collapsed.
Click to expand it.
Prev
1
2
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