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
4327d95b
Commit
4327d95b
authored
Oct 07, 2018
by
Jerry Turcios
Browse files
Merge branch 'master' of
https://github.com/google/googletest
parents
7caf5ffd
40f82ce5
Changes
59
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
251 additions
and
349 deletions
+251
-349
googlemock/include/gmock/gmock-actions.h
googlemock/include/gmock/gmock-actions.h
+14
-15
googlemock/include/gmock/gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+23
-25
googlemock/include/gmock/gmock-spec-builders.h
googlemock/include/gmock/gmock-spec-builders.h
+10
-10
googlemock/src/gmock-spec-builders.cc
googlemock/src/gmock-spec-builders.cc
+19
-22
googlemock/src/gmock.cc
googlemock/src/gmock.cc
+6
-6
googlemock/test/gmock-actions_test.cc
googlemock/test/gmock-actions_test.cc
+14
-14
googlemock/test/gmock-generated-function-mockers_test.cc
googlemock/test/gmock-generated-function-mockers_test.cc
+1
-1
googlemock/test/gmock-generated-matchers_test.cc
googlemock/test/gmock-generated-matchers_test.cc
+2
-2
googlemock/test/gmock-internal-utils_test.cc
googlemock/test/gmock-internal-utils_test.cc
+3
-3
googlemock/test/gmock-matchers_test.cc
googlemock/test/gmock-matchers_test.cc
+62
-62
googlemock/test/gmock-more-actions_test.cc
googlemock/test/gmock-more-actions_test.cc
+2
-1
googlemock/test/gmock-spec-builders_test.cc
googlemock/test/gmock-spec-builders_test.cc
+3
-3
googlemock/test/gmock_link_test.h
googlemock/test/gmock_link_test.h
+19
-19
googlemock/test/gmock_stress_test.cc
googlemock/test/gmock_stress_test.cc
+4
-4
googlemock/test/gmock_test.cc
googlemock/test/gmock_test.cc
+34
-114
googletest/docs/primer.md
googletest/docs/primer.md
+2
-5
googletest/include/gtest/gtest-message.h
googletest/include/gtest/gtest-message.h
+1
-1
googletest/include/gtest/gtest-printers.h
googletest/include/gtest/gtest-printers.h
+4
-12
googletest/include/gtest/gtest-test-part.h
googletest/include/gtest/gtest-test-part.h
+4
-7
googletest/include/gtest/gtest.h
googletest/include/gtest/gtest.h
+24
-23
No files found.
googlemock/include/gmock/gmock-actions.h
View file @
4327d95b
...
@@ -137,7 +137,7 @@ template <typename T>
...
@@ -137,7 +137,7 @@ template <typename T>
class
BuiltInDefaultValue
<
T
*>
{
class
BuiltInDefaultValue
<
T
*>
{
public:
public:
static
bool
Exists
()
{
return
true
;
}
static
bool
Exists
()
{
return
true
;
}
static
T
*
Get
()
{
return
NULL
;
}
static
T
*
Get
()
{
return
nullptr
;
}
};
};
// The following specializations define the default values for
// The following specializations define the default values for
...
@@ -220,11 +220,11 @@ class DefaultValue {
...
@@ -220,11 +220,11 @@ class DefaultValue {
// Unsets the default value for type T.
// Unsets the default value for type T.
static
void
Clear
()
{
static
void
Clear
()
{
delete
producer_
;
delete
producer_
;
producer_
=
NULL
;
producer_
=
nullptr
;
}
}
// Returns true iff the user has set the default value for type T.
// Returns true iff the user has set the default value for type T.
static
bool
IsSet
()
{
return
producer_
!=
NULL
;
}
static
bool
IsSet
()
{
return
producer_
!=
nullptr
;
}
// Returns true if T has a default return value set by the user or there
// Returns true if T has a default return value set by the user or there
// exists a built-in default value.
// exists a built-in default value.
...
@@ -236,8 +236,8 @@ class DefaultValue {
...
@@ -236,8 +236,8 @@ class DefaultValue {
// otherwise returns the built-in default value. Requires that Exists()
// otherwise returns the built-in default value. Requires that Exists()
// is true, which ensures that the return value is well-defined.
// is true, which ensures that the return value is well-defined.
static
T
Get
()
{
static
T
Get
()
{
return
producer_
==
NULL
?
return
producer_
==
nullptr
?
internal
::
BuiltInDefaultValue
<
T
>::
Get
()
internal
::
BuiltInDefaultValue
<
T
>::
Get
()
:
producer_
->
Produce
();
:
producer_
->
Produce
();
}
}
private:
private:
...
@@ -282,12 +282,10 @@ class DefaultValue<T&> {
...
@@ -282,12 +282,10 @@ class DefaultValue<T&> {
}
}
// Unsets the default value for type T&.
// Unsets the default value for type T&.
static
void
Clear
()
{
static
void
Clear
()
{
address_
=
nullptr
;
}
address_
=
NULL
;
}
// Returns true iff the user has set the default value for type T&.
// Returns true iff the user has set the default value for type T&.
static
bool
IsSet
()
{
return
address_
!=
NULL
;
}
static
bool
IsSet
()
{
return
address_
!=
nullptr
;
}
// Returns true if T has a default return value set by the user or there
// Returns true if T has a default return value set by the user or there
// exists a built-in default value.
// exists a built-in default value.
...
@@ -299,8 +297,8 @@ class DefaultValue<T&> {
...
@@ -299,8 +297,8 @@ class DefaultValue<T&> {
// otherwise returns the built-in default value if there is one;
// otherwise returns the built-in default value if there is one;
// otherwise aborts the process.
// otherwise aborts the process.
static
T
&
Get
()
{
static
T
&
Get
()
{
return
address_
==
NULL
?
return
address_
==
nullptr
?
internal
::
BuiltInDefaultValue
<
T
&>::
Get
()
internal
::
BuiltInDefaultValue
<
T
&>::
Get
()
:
*
address_
;
:
*
address_
;
}
}
private:
private:
...
@@ -318,11 +316,11 @@ class DefaultValue<void> {
...
@@ -318,11 +316,11 @@ class DefaultValue<void> {
// Points to the user-set default value for type T.
// Points to the user-set default value for type T.
template
<
typename
T
>
template
<
typename
T
>
typename
DefaultValue
<
T
>::
ValueProducer
*
DefaultValue
<
T
>::
producer_
=
NULL
;
typename
DefaultValue
<
T
>::
ValueProducer
*
DefaultValue
<
T
>::
producer_
=
nullptr
;
// Points to the user-set default value for type T&.
// Points to the user-set default value for type T&.
template
<
typename
T
>
template
<
typename
T
>
T
*
DefaultValue
<
T
&>::
address_
=
NULL
;
T
*
DefaultValue
<
T
&>::
address_
=
nullptr
;
// Implement this interface to define an action for function type F.
// Implement this interface to define an action for function type F.
template
<
typename
F
>
template
<
typename
F
>
...
@@ -1108,8 +1106,9 @@ Action<To>::Action(const Action<From>& from)
...
@@ -1108,8 +1106,9 @@ Action<To>::Action(const Action<From>& from)
#if GTEST_LANG_CXX11
#if GTEST_LANG_CXX11
fun_
(
from
.
fun_
),
fun_
(
from
.
fun_
),
#endif
#endif
impl_
(
from
.
impl_
==
NULL
?
NULL
impl_
(
from
.
impl_
==
nullptr
:
new
internal
::
ActionAdaptor
<
To
,
From
>
(
from
))
{
?
nullptr
:
new
internal
::
ActionAdaptor
<
To
,
From
>
(
from
))
{
}
}
// Creates an action that returns 'value'. 'value' is passed by value
// Creates an action that returns 'value'. 'value' is passed by value
...
...
googlemock/include/gmock/gmock-matchers.h
View file @
4327d95b
...
@@ -94,8 +94,7 @@ class MatchResultListener {
...
@@ -94,8 +94,7 @@ class MatchResultListener {
// is NULL.
// is NULL.
template
<
typename
T
>
template
<
typename
T
>
MatchResultListener
&
operator
<<
(
const
T
&
x
)
{
MatchResultListener
&
operator
<<
(
const
T
&
x
)
{
if
(
stream_
!=
NULL
)
if
(
stream_
!=
nullptr
)
*
stream_
<<
x
;
*
stream_
<<
x
;
return
*
this
;
return
*
this
;
}
}
...
@@ -106,7 +105,7 @@ class MatchResultListener {
...
@@ -106,7 +105,7 @@ class MatchResultListener {
// the match result. A matcher's MatchAndExplain() method can use
// the match result. A matcher's MatchAndExplain() method can use
// this information to avoid generating the explanation when no one
// this information to avoid generating the explanation when no one
// intends to hear it.
// intends to hear it.
bool
IsInterested
()
const
{
return
stream_
!=
NULL
;
}
bool
IsInterested
()
const
{
return
stream_
!=
nullptr
;
}
private:
private:
::
std
::
ostream
*
const
stream_
;
::
std
::
ostream
*
const
stream_
;
...
@@ -261,7 +260,7 @@ struct AnyGe {
...
@@ -261,7 +260,7 @@ struct AnyGe {
// A match result listener that ignores the explanation.
// A match result listener that ignores the explanation.
class
DummyMatchResultListener
:
public
MatchResultListener
{
class
DummyMatchResultListener
:
public
MatchResultListener
{
public:
public:
DummyMatchResultListener
()
:
MatchResultListener
(
NULL
)
{}
DummyMatchResultListener
()
:
MatchResultListener
(
nullptr
)
{}
private:
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
DummyMatchResultListener
);
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
DummyMatchResultListener
);
...
@@ -333,7 +332,7 @@ class MatcherBase {
...
@@ -333,7 +332,7 @@ class MatcherBase {
const
MatcherInterface
<
U
>*
impl
,
const
MatcherInterface
<
U
>*
impl
,
typename
internal
::
EnableIf
<
typename
internal
::
EnableIf
<
!
internal
::
IsSame
<
U
,
GTEST_REFERENCE_TO_CONST_
(
U
)
>::
value
>::
type
*
=
!
internal
::
IsSame
<
U
,
GTEST_REFERENCE_TO_CONST_
(
U
)
>::
value
>::
type
*
=
NULL
)
nullptr
)
:
impl_
(
new
internal
::
MatcherInterfaceAdapter
<
U
>
(
impl
))
{}
:
impl_
(
new
internal
::
MatcherInterfaceAdapter
<
U
>
(
impl
))
{}
virtual
~
MatcherBase
()
{}
virtual
~
MatcherBase
()
{}
...
@@ -375,9 +374,11 @@ class Matcher : public internal::MatcherBase<T> {
...
@@ -375,9 +374,11 @@ class Matcher : public internal::MatcherBase<T> {
:
internal
::
MatcherBase
<
T
>
(
impl
)
{}
:
internal
::
MatcherBase
<
T
>
(
impl
)
{}
template
<
typename
U
>
template
<
typename
U
>
explicit
Matcher
(
const
MatcherInterface
<
U
>*
impl
,
explicit
Matcher
(
typename
internal
::
EnableIf
<!
internal
::
IsSame
<
const
MatcherInterface
<
U
>*
impl
,
U
,
GTEST_REFERENCE_TO_CONST_
(
U
)
>::
value
>::
type
*
=
NULL
)
typename
internal
::
EnableIf
<
!
internal
::
IsSame
<
U
,
GTEST_REFERENCE_TO_CONST_
(
U
)
>::
value
>::
type
*
=
nullptr
)
:
internal
::
MatcherBase
<
T
>
(
impl
)
{}
:
internal
::
MatcherBase
<
T
>
(
impl
)
{}
// Implicit constructor here allows people to write
// Implicit constructor here allows people to write
...
@@ -850,7 +851,7 @@ namespace internal {
...
@@ -850,7 +851,7 @@ namespace internal {
// If the explanation is not empty, prints it to the ostream.
// If the explanation is not empty, prints it to the ostream.
inline
void
PrintIfNotEmpty
(
const
std
::
string
&
explanation
,
inline
void
PrintIfNotEmpty
(
const
std
::
string
&
explanation
,
::
std
::
ostream
*
os
)
{
::
std
::
ostream
*
os
)
{
if
(
explanation
!=
""
&&
os
!=
NULL
)
{
if
(
explanation
!=
""
&&
os
!=
nullptr
)
{
*
os
<<
", "
<<
explanation
;
*
os
<<
", "
<<
explanation
;
}
}
}
}
...
@@ -1321,7 +1322,7 @@ class StrEqualityMatcher {
...
@@ -1321,7 +1322,7 @@ class StrEqualityMatcher {
// wchar_t*
// wchar_t*
template
<
typename
CharType
>
template
<
typename
CharType
>
bool
MatchAndExplain
(
CharType
*
s
,
MatchResultListener
*
listener
)
const
{
bool
MatchAndExplain
(
CharType
*
s
,
MatchResultListener
*
listener
)
const
{
if
(
s
==
NULL
)
{
if
(
s
==
nullptr
)
{
return
!
expect_eq_
;
return
!
expect_eq_
;
}
}
return
MatchAndExplain
(
StringType
(
s
),
listener
);
return
MatchAndExplain
(
StringType
(
s
),
listener
);
...
@@ -1391,7 +1392,7 @@ class HasSubstrMatcher {
...
@@ -1391,7 +1392,7 @@ class HasSubstrMatcher {
// wchar_t*
// wchar_t*
template
<
typename
CharType
>
template
<
typename
CharType
>
bool
MatchAndExplain
(
CharType
*
s
,
MatchResultListener
*
listener
)
const
{
bool
MatchAndExplain
(
CharType
*
s
,
MatchResultListener
*
listener
)
const
{
return
s
!=
NULL
&&
MatchAndExplain
(
StringType
(
s
),
listener
);
return
s
!=
nullptr
&&
MatchAndExplain
(
StringType
(
s
),
listener
);
}
}
// Matches anything that can convert to StringType.
// Matches anything that can convert to StringType.
...
@@ -1448,7 +1449,7 @@ class StartsWithMatcher {
...
@@ -1448,7 +1449,7 @@ class StartsWithMatcher {
// wchar_t*
// wchar_t*
template
<
typename
CharType
>
template
<
typename
CharType
>
bool
MatchAndExplain
(
CharType
*
s
,
MatchResultListener
*
listener
)
const
{
bool
MatchAndExplain
(
CharType
*
s
,
MatchResultListener
*
listener
)
const
{
return
s
!=
NULL
&&
MatchAndExplain
(
StringType
(
s
),
listener
);
return
s
!=
nullptr
&&
MatchAndExplain
(
StringType
(
s
),
listener
);
}
}
// Matches anything that can convert to StringType.
// Matches anything that can convert to StringType.
...
@@ -1504,7 +1505,7 @@ class EndsWithMatcher {
...
@@ -1504,7 +1505,7 @@ class EndsWithMatcher {
// wchar_t*
// wchar_t*
template
<
typename
CharType
>
template
<
typename
CharType
>
bool
MatchAndExplain
(
CharType
*
s
,
MatchResultListener
*
listener
)
const
{
bool
MatchAndExplain
(
CharType
*
s
,
MatchResultListener
*
listener
)
const
{
return
s
!=
NULL
&&
MatchAndExplain
(
StringType
(
s
),
listener
);
return
s
!=
nullptr
&&
MatchAndExplain
(
StringType
(
s
),
listener
);
}
}
// Matches anything that can convert to StringType.
// Matches anything that can convert to StringType.
...
@@ -1557,7 +1558,7 @@ class MatchesRegexMatcher {
...
@@ -1557,7 +1558,7 @@ class MatchesRegexMatcher {
// wchar_t*
// wchar_t*
template
<
typename
CharType
>
template
<
typename
CharType
>
bool
MatchAndExplain
(
CharType
*
s
,
MatchResultListener
*
listener
)
const
{
bool
MatchAndExplain
(
CharType
*
s
,
MatchResultListener
*
listener
)
const
{
return
s
!=
NULL
&&
MatchAndExplain
(
std
::
string
(
s
),
listener
);
return
s
!=
nullptr
&&
MatchAndExplain
(
std
::
string
(
s
),
listener
);
}
}
// Matches anything that can convert to std::string.
// Matches anything that can convert to std::string.
...
@@ -2347,8 +2348,7 @@ class PointeeMatcher {
...
@@ -2347,8 +2348,7 @@ class PointeeMatcher {
virtual
bool
MatchAndExplain
(
Pointer
pointer
,
virtual
bool
MatchAndExplain
(
Pointer
pointer
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
{
if
(
GetRawPointer
(
pointer
)
==
NULL
)
if
(
GetRawPointer
(
pointer
)
==
nullptr
)
return
false
;
return
false
;
*
listener
<<
"which points to "
;
*
listener
<<
"which points to "
;
return
MatchPrintAndExplain
(
*
pointer
,
matcher_
,
listener
);
return
MatchPrintAndExplain
(
*
pointer
,
matcher_
,
listener
);
...
@@ -2431,7 +2431,7 @@ class WhenDynamicCastToMatcher<To&> : public WhenDynamicCastToMatcherBase<To&> {
...
@@ -2431,7 +2431,7 @@ class WhenDynamicCastToMatcher<To&> : public WhenDynamicCastToMatcherBase<To&> {
bool
MatchAndExplain
(
From
&
from
,
MatchResultListener
*
listener
)
const
{
bool
MatchAndExplain
(
From
&
from
,
MatchResultListener
*
listener
)
const
{
// We don't want an std::bad_cast here, so do the cast with pointers.
// We don't want an std::bad_cast here, so do the cast with pointers.
To
*
to
=
dynamic_cast
<
To
*>
(
&
from
);
To
*
to
=
dynamic_cast
<
To
*>
(
&
from
);
if
(
to
==
NULL
)
{
if
(
to
==
nullptr
)
{
*
listener
<<
"which cannot be dynamic_cast to "
<<
this
->
GetToName
();
*
listener
<<
"which cannot be dynamic_cast to "
<<
this
->
GetToName
();
return
false
;
return
false
;
}
}
...
@@ -2485,8 +2485,7 @@ class FieldMatcher {
...
@@ -2485,8 +2485,7 @@ class FieldMatcher {
bool
MatchAndExplainImpl
(
true_type
/* is_pointer */
,
const
Class
*
p
,
bool
MatchAndExplainImpl
(
true_type
/* is_pointer */
,
const
Class
*
p
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
{
if
(
p
==
NULL
)
if
(
p
==
nullptr
)
return
false
;
return
false
;
*
listener
<<
"which points to an object "
;
*
listener
<<
"which points to an object "
;
// Since *p has a field, it must be a class/struct/union type and
// Since *p has a field, it must be a class/struct/union type and
...
@@ -2570,8 +2569,7 @@ class PropertyMatcher {
...
@@ -2570,8 +2569,7 @@ class PropertyMatcher {
bool
MatchAndExplainImpl
(
true_type
/* is_pointer */
,
const
Class
*
p
,
bool
MatchAndExplainImpl
(
true_type
/* is_pointer */
,
const
Class
*
p
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
{
if
(
p
==
NULL
)
if
(
p
==
nullptr
)
return
false
;
return
false
;
*
listener
<<
"which points to an object "
;
*
listener
<<
"which points to an object "
;
// Since *p has a property method, it must be a class/struct/union
// Since *p has a property method, it must be a class/struct/union
...
@@ -2615,7 +2613,7 @@ struct CallableTraits<ResType(*)(ArgType)> {
...
@@ -2615,7 +2613,7 @@ struct CallableTraits<ResType(*)(ArgType)> {
typedef
ResType
(
*
StorageType
)(
ArgType
);
typedef
ResType
(
*
StorageType
)(
ArgType
);
static
void
CheckIsValid
(
ResType
(
*
f
)(
ArgType
))
{
static
void
CheckIsValid
(
ResType
(
*
f
)(
ArgType
))
{
GTEST_CHECK_
(
f
!=
NULL
)
GTEST_CHECK_
(
f
!=
nullptr
)
<<
"NULL function pointer is passed into ResultOf()."
;
<<
"NULL function pointer is passed into ResultOf()."
;
}
}
template
<
typename
T
>
template
<
typename
T
>
...
@@ -2857,7 +2855,7 @@ class ContainerEqMatcher {
...
@@ -2857,7 +2855,7 @@ class ContainerEqMatcher {
return
true
;
return
true
;
::
std
::
ostream
*
const
os
=
listener
->
stream
();
::
std
::
ostream
*
const
os
=
listener
->
stream
();
if
(
os
!=
NULL
)
{
if
(
os
!=
nullptr
)
{
// Something is different. Check for extra values first.
// Something is different. Check for extra values first.
bool
printed_header
=
false
;
bool
printed_header
=
false
;
for
(
typename
LhsStlContainer
::
const_iterator
it
=
for
(
typename
LhsStlContainer
::
const_iterator
it
=
...
@@ -4136,11 +4134,11 @@ class AnyCastMatcher {
...
@@ -4136,11 +4134,11 @@ class AnyCastMatcher {
::
testing
::
MatchResultListener
*
listener
)
const
{
::
testing
::
MatchResultListener
*
listener
)
const
{
if
(
!
listener
->
IsInterested
())
{
if
(
!
listener
->
IsInterested
())
{
const
T
*
ptr
=
any_cast
<
T
>
(
&
value
);
const
T
*
ptr
=
any_cast
<
T
>
(
&
value
);
return
ptr
!=
NULL
&&
matcher_
.
Matches
(
*
ptr
);
return
ptr
!=
nullptr
&&
matcher_
.
Matches
(
*
ptr
);
}
}
const
T
*
elem
=
any_cast
<
T
>
(
&
value
);
const
T
*
elem
=
any_cast
<
T
>
(
&
value
);
if
(
elem
==
NULL
)
{
if
(
elem
==
nullptr
)
{
*
listener
<<
"whose value is not of type '"
<<
GetTypeName
()
<<
"'"
;
*
listener
<<
"whose value is not of type '"
<<
GetTypeName
()
<<
"'"
;
return
false
;
return
false
;
}
}
...
...
googlemock/include/gmock/gmock-spec-builders.h
View file @
4327d95b
...
@@ -1213,7 +1213,7 @@ class TypedExpectation : public ExpectationBase {
...
@@ -1213,7 +1213,7 @@ class TypedExpectation : public ExpectationBase {
// FIXME: allow the user to control whether
// FIXME: allow the user to control whether
// unexpected calls should fail immediately or continue using a
// unexpected calls should fail immediately or continue using a
// flag --gmock_unexpected_calls_are_fatal.
// flag --gmock_unexpected_calls_are_fatal.
return
NULL
;
return
nullptr
;
}
}
IncrementCallCount
();
IncrementCallCount
();
...
@@ -1498,7 +1498,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1498,7 +1498,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
return
spec
;
return
spec
;
}
}
return
NULL
;
return
nullptr
;
}
}
// Performs the default action of this mock function on the given
// Performs the default action of this mock function on the given
...
@@ -1513,7 +1513,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1513,7 +1513,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
const
std
::
string
&
call_description
)
const
{
const
std
::
string
&
call_description
)
const
{
const
OnCallSpec
<
F
>*
const
spec
=
const
OnCallSpec
<
F
>*
const
spec
=
this
->
FindOnCallSpec
(
args
);
this
->
FindOnCallSpec
(
args
);
if
(
spec
!=
NULL
)
{
if
(
spec
!=
nullptr
)
{
return
spec
->
GetAction
().
Perform
(
internal
::
move
(
args
));
return
spec
->
GetAction
().
Perform
(
internal
::
move
(
args
));
}
}
const
std
::
string
message
=
const
std
::
string
message
=
...
@@ -1630,7 +1630,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1630,7 +1630,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// Adds this expectation into the implicit sequence if there is one.
// Adds this expectation into the implicit sequence if there is one.
Sequence
*
const
implicit_sequence
=
g_gmock_implicit_sequence
.
get
();
Sequence
*
const
implicit_sequence
=
g_gmock_implicit_sequence
.
get
();
if
(
implicit_sequence
!=
NULL
)
{
if
(
implicit_sequence
!=
nullptr
)
{
implicit_sequence
->
AddExpectation
(
Expectation
(
untyped_expectation
));
implicit_sequence
->
AddExpectation
(
Expectation
(
untyped_expectation
));
}
}
...
@@ -1649,7 +1649,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1649,7 +1649,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
::
std
::
ostream
*
os
)
const
{
::
std
::
ostream
*
os
)
const
{
const
OnCallSpec
<
F
>*
const
spec
=
FindOnCallSpec
(
args
);
const
OnCallSpec
<
F
>*
const
spec
=
FindOnCallSpec
(
args
);
if
(
spec
==
NULL
)
{
if
(
spec
==
nullptr
)
{
*
os
<<
(
internal
::
type_equals
<
Result
,
void
>::
value
?
*
os
<<
(
internal
::
type_equals
<
Result
,
void
>::
value
?
"returning directly.
\n
"
:
"returning directly.
\n
"
:
"returning default value.
\n
"
);
"returning default value.
\n
"
);
...
@@ -1699,9 +1699,9 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1699,9 +1699,9 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
*
static_cast
<
const
ArgumentTuple
*>
(
untyped_args
);
*
static_cast
<
const
ArgumentTuple
*>
(
untyped_args
);
MutexLock
l
(
&
g_gmock_mutex
);
MutexLock
l
(
&
g_gmock_mutex
);
TypedExpectation
<
F
>*
exp
=
this
->
FindMatchingExpectationLocked
(
args
);
TypedExpectation
<
F
>*
exp
=
this
->
FindMatchingExpectationLocked
(
args
);
if
(
exp
==
NULL
)
{
// A match wasn't found.
if
(
exp
==
nullptr
)
{
// A match wasn't found.
this
->
FormatUnexpectedCallMessageLocked
(
args
,
what
,
why
);
this
->
FormatUnexpectedCallMessageLocked
(
args
,
what
,
why
);
return
NULL
;
return
nullptr
;
}
}
// This line must be done before calling GetActionForArguments(),
// This line must be done before calling GetActionForArguments(),
...
@@ -1709,8 +1709,8 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1709,8 +1709,8 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// its saturation status.
// its saturation status.
*
is_excessive
=
exp
->
IsSaturated
();
*
is_excessive
=
exp
->
IsSaturated
();
const
Action
<
F
>*
action
=
exp
->
GetActionForArguments
(
this
,
args
,
what
,
why
);
const
Action
<
F
>*
action
=
exp
->
GetActionForArguments
(
this
,
args
,
what
,
why
);
if
(
action
!=
NULL
&&
action
->
IsDoDefault
())
if
(
action
!=
nullptr
&&
action
->
IsDoDefault
())
action
=
NULL
;
// Normalize "do default" to NULL.
action
=
nullptr
;
// Normalize "do default" to NULL.
*
untyped_action
=
action
;
*
untyped_action
=
action
;
return
exp
;
return
exp
;
}
}
...
@@ -1740,7 +1740,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1740,7 +1740,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
return
exp
;
return
exp
;
}
}
}
}
return
NULL
;
return
nullptr
;
}
}
// Returns a message that the arguments don't match any expectation.
// Returns a message that the arguments don't match any expectation.
...
...
googlemock/src/gmock-spec-builders.cc
View file @
4327d95b
...
@@ -296,12 +296,12 @@ void ReportUninterestingCall(CallReaction reaction, const std::string& msg) {
...
@@ -296,12 +296,12 @@ void ReportUninterestingCall(CallReaction reaction, const std::string& msg) {
stack_frames_to_skip
);
stack_frames_to_skip
);
break
;
break
;
default:
// FAIL
default:
// FAIL
Expect
(
false
,
NULL
,
-
1
,
msg
);
Expect
(
false
,
nullptr
,
-
1
,
msg
);
}
}
}
}
UntypedFunctionMockerBase
::
UntypedFunctionMockerBase
()
UntypedFunctionMockerBase
::
UntypedFunctionMockerBase
()
:
mock_obj_
(
NULL
),
name_
(
""
)
{}
:
mock_obj_
(
nullptr
),
name_
(
""
)
{}
UntypedFunctionMockerBase
::~
UntypedFunctionMockerBase
()
{}
UntypedFunctionMockerBase
::~
UntypedFunctionMockerBase
()
{}
...
@@ -340,7 +340,7 @@ const void* UntypedFunctionMockerBase::MockObject() const
...
@@ -340,7 +340,7 @@ const void* UntypedFunctionMockerBase::MockObject() const
// We protect mock_obj_ under g_gmock_mutex in case this mock
// We protect mock_obj_ under g_gmock_mutex in case this mock
// function is called from two threads concurrently.
// function is called from two threads concurrently.
MutexLock
l
(
&
g_gmock_mutex
);
MutexLock
l
(
&
g_gmock_mutex
);
Assert
(
mock_obj_
!=
NULL
,
__FILE__
,
__LINE__
,
Assert
(
mock_obj_
!=
nullptr
,
__FILE__
,
__LINE__
,
"MockObject() must not be called before RegisterOwner() or "
"MockObject() must not be called before RegisterOwner() or "
"SetOwnerAndName() has been called."
);
"SetOwnerAndName() has been called."
);
mock_obj
=
mock_obj_
;
mock_obj
=
mock_obj_
;
...
@@ -357,7 +357,7 @@ const char* UntypedFunctionMockerBase::Name() const
...
@@ -357,7 +357,7 @@ const char* UntypedFunctionMockerBase::Name() const
// We protect name_ under g_gmock_mutex in case this mock
// We protect name_ under g_gmock_mutex in case this mock
// function is called from two threads concurrently.
// function is called from two threads concurrently.
MutexLock
l
(
&
g_gmock_mutex
);
MutexLock
l
(
&
g_gmock_mutex
);
Assert
(
name_
!=
NULL
,
__FILE__
,
__LINE__
,
Assert
(
name_
!=
nullptr
,
__FILE__
,
__LINE__
,
"Name() must not be called before SetOwnerAndName() has "
"Name() must not be called before SetOwnerAndName() has "
"been called."
);
"been called."
);
name
=
name_
;
name
=
name_
;
...
@@ -414,8 +414,7 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
...
@@ -414,8 +414,7 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
this
->
UntypedPerformDefaultAction
(
untyped_args
,
ss
.
str
());
this
->
UntypedPerformDefaultAction
(
untyped_args
,
ss
.
str
());
// Prints the function result.
// Prints the function result.
if
(
result
!=
NULL
)
if
(
result
!=
nullptr
)
result
->
PrintAsActionResult
(
&
ss
);
result
->
PrintAsActionResult
(
&
ss
);
ReportUninterestingCall
(
reaction
,
ss
.
str
());
ReportUninterestingCall
(
reaction
,
ss
.
str
());
return
result
;
return
result
;
...
@@ -425,7 +424,7 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
...
@@ -425,7 +424,7 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
::
std
::
stringstream
ss
;
::
std
::
stringstream
ss
;
::
std
::
stringstream
why
;
::
std
::
stringstream
why
;
::
std
::
stringstream
loc
;
::
std
::
stringstream
loc
;
const
void
*
untyped_action
=
NULL
;
const
void
*
untyped_action
=
nullptr
;
// The UntypedFindMatchingExpectation() function acquires and
// The UntypedFindMatchingExpectation() function acquires and
// releases g_gmock_mutex.
// releases g_gmock_mutex.
...
@@ -433,7 +432,7 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
...
@@ -433,7 +432,7 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
this
->
UntypedFindMatchingExpectation
(
this
->
UntypedFindMatchingExpectation
(
untyped_args
,
&
untyped_action
,
&
is_excessive
,
untyped_args
,
&
untyped_action
,
&
is_excessive
,
&
ss
,
&
why
);
&
ss
,
&
why
);
const
bool
found
=
untyped_expectation
!=
NULL
;
const
bool
found
=
untyped_expectation
!=
nullptr
;
// True iff we need to print the call's arguments and return value.
// True iff we need to print the call's arguments and return value.
// This definition must be kept in sync with the uses of Expect()
// This definition must be kept in sync with the uses of Expect()
...
@@ -442,10 +441,9 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
...
@@ -442,10 +441,9 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
!
found
||
is_excessive
||
LogIsVisible
(
kInfo
);
!
found
||
is_excessive
||
LogIsVisible
(
kInfo
);
if
(
!
need_to_report_call
)
{
if
(
!
need_to_report_call
)
{
// Perform the action without printing the call information.
// Perform the action without printing the call information.
return
return
untyped_action
==
nullptr
untyped_action
==
NULL
?
?
this
->
UntypedPerformDefaultAction
(
untyped_args
,
""
)
this
->
UntypedPerformDefaultAction
(
untyped_args
,
""
)
:
:
this
->
UntypedPerformAction
(
untyped_action
,
untyped_args
);
this
->
UntypedPerformAction
(
untyped_action
,
untyped_args
);
}
}
ss
<<
" Function call: "
<<
Name
();
ss
<<
" Function call: "
<<
Name
();
...
@@ -458,16 +456,15 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
...
@@ -458,16 +456,15 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
}
}
UntypedActionResultHolderBase
*
const
result
=
UntypedActionResultHolderBase
*
const
result
=
untyped_action
==
NULL
?
untyped_action
==
nullptr
this
->
UntypedPerformDefaultAction
(
untyped_args
,
ss
.
str
())
:
?
this
->
UntypedPerformDefaultAction
(
untyped_args
,
ss
.
str
())
this
->
UntypedPerformAction
(
untyped_action
,
untyped_args
);
:
this
->
UntypedPerformAction
(
untyped_action
,
untyped_args
);
if
(
result
!=
NULL
)
if
(
result
!=
nullptr
)
result
->
PrintAsActionResult
(
&
ss
);
result
->
PrintAsActionResult
(
&
ss
);
ss
<<
"
\n
"
<<
why
.
str
();
ss
<<
"
\n
"
<<
why
.
str
();
if
(
!
found
)
{
if
(
!
found
)
{
// No expectation matches this call - reports a failure.
// No expectation matches this call - reports a failure.
Expect
(
false
,
NULL
,
-
1
,
ss
.
str
());
Expect
(
false
,
nullptr
,
-
1
,
ss
.
str
());
}
else
if
(
is_excessive
)
{
}
else
if
(
is_excessive
)
{
// We had an upper-bound violation and the failure message is in ss.
// We had an upper-bound violation and the failure message is in ss.
Expect
(
false
,
untyped_expectation
->
file
(),
Expect
(
false
,
untyped_expectation
->
file
(),
...
@@ -568,7 +565,7 @@ typedef std::set<internal::UntypedFunctionMockerBase*> FunctionMockers;
...
@@ -568,7 +565,7 @@ typedef std::set<internal::UntypedFunctionMockerBase*> FunctionMockers;
// expectations.
// expectations.
struct
MockObjectState
{
struct
MockObjectState
{
MockObjectState
()
MockObjectState
()
:
first_used_file
(
NULL
),
first_used_line
(
-
1
),
leakable
(
false
)
{}
:
first_used_file
(
nullptr
),
first_used_line
(
-
1
),
leakable
(
false
)
{}
// Where in the source file an ON_CALL or EXPECT_CALL is first
// Where in the source file an ON_CALL or EXPECT_CALL is first
// invoked on this mock object.
// invoked on this mock object.
...
@@ -776,12 +773,12 @@ void Mock::RegisterUseByOnCallOrExpectCall(const void* mock_obj,
...
@@ -776,12 +773,12 @@ void Mock::RegisterUseByOnCallOrExpectCall(const void* mock_obj,
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
)
{
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
)
{
internal
::
MutexLock
l
(
&
internal
::
g_gmock_mutex
);
internal
::
MutexLock
l
(
&
internal
::
g_gmock_mutex
);
MockObjectState
&
state
=
g_mock_object_registry
.
states
()[
mock_obj
];
MockObjectState
&
state
=
g_mock_object_registry
.
states
()[
mock_obj
];
if
(
state
.
first_used_file
==
NULL
)
{
if
(
state
.
first_used_file
==
nullptr
)
{
state
.
first_used_file
=
file
;
state
.
first_used_file
=
file
;
state
.
first_used_line
=
line
;
state
.
first_used_line
=
line
;
const
TestInfo
*
const
test_info
=
const
TestInfo
*
const
test_info
=
UnitTest
::
GetInstance
()
->
current_test_info
();
UnitTest
::
GetInstance
()
->
current_test_info
();
if
(
test_info
!=
NULL
)
{
if
(
test_info
!=
nullptr
)
{
// FIXME: record the test case name when the
// FIXME: record the test case name when the
// ON_CALL or EXPECT_CALL is invoked from SetUpTestCase() or
// ON_CALL or EXPECT_CALL is invoked from SetUpTestCase() or
// TearDownTestCase().
// TearDownTestCase().
...
@@ -846,7 +843,7 @@ Expectation::~Expectation() {}
...
@@ -846,7 +843,7 @@ Expectation::~Expectation() {}
// Adds an expectation to a sequence.
// Adds an expectation to a sequence.
void
Sequence
::
AddExpectation
(
const
Expectation
&
expectation
)
const
{
void
Sequence
::
AddExpectation
(
const
Expectation
&
expectation
)
const
{
if
(
*
last_expectation_
!=
expectation
)
{
if
(
*
last_expectation_
!=
expectation
)
{
if
(
last_expectation_
->
expectation_base
()
!=
NULL
)
{
if
(
last_expectation_
->
expectation_base
()
!=
nullptr
)
{
expectation
.
expectation_base
()
->
immediate_prerequisites_
expectation
.
expectation_base
()
->
immediate_prerequisites_
+=
*
last_expectation_
;
+=
*
last_expectation_
;
}
}
...
...
googlemock/src/gmock.cc
View file @
4327d95b
...
@@ -65,12 +65,12 @@ static const char* ParseGoogleMockFlagValue(const char* str,
...
@@ -65,12 +65,12 @@ static const char* ParseGoogleMockFlagValue(const char* str,
const
char
*
flag
,
const
char
*
flag
,
bool
def_optional
)
{
bool
def_optional
)
{
// str and flag must not be NULL.
// str and flag must not be NULL.
if
(
str
==
NULL
||
flag
==
NULL
)
return
NULL
;
if
(
str
==
nullptr
||
flag
==
nullptr
)
return
nullptr
;
// The flag must start with "--gmock_".
// The flag must start with "--gmock_".
const
std
::
string
flag_str
=
std
::
string
(
"--gmock_"
)
+
flag
;
const
std
::
string
flag_str
=
std
::
string
(
"--gmock_"
)
+
flag
;
const
size_t
flag_len
=
flag_str
.
length
();
const
size_t
flag_len
=
flag_str
.
length
();
if
(
strncmp
(
str
,
flag_str
.
c_str
(),
flag_len
)
!=
0
)
return
NULL
;
if
(
strncmp
(
str
,
flag_str
.
c_str
(),
flag_len
)
!=
0
)
return
nullptr
;
// Skips the flag name.
// Skips the flag name.
const
char
*
flag_end
=
str
+
flag_len
;
const
char
*
flag_end
=
str
+
flag_len
;
...
@@ -83,7 +83,7 @@ static const char* ParseGoogleMockFlagValue(const char* str,
...
@@ -83,7 +83,7 @@ static const char* ParseGoogleMockFlagValue(const char* str,
// If def_optional is true and there are more characters after the
// If def_optional is true and there are more characters after the
// flag name, or if def_optional is false, there must be a '=' after
// flag name, or if def_optional is false, there must be a '=' after
// the flag name.
// the flag name.
if
(
flag_end
[
0
]
!=
'='
)
return
NULL
;
if
(
flag_end
[
0
]
!=
'='
)
return
nullptr
;
// Returns the string after "=".
// Returns the string after "=".
return
flag_end
+
1
;
return
flag_end
+
1
;
...
@@ -100,7 +100,7 @@ static bool ParseGoogleMockBoolFlag(const char* str, const char* flag,
...
@@ -100,7 +100,7 @@ static bool ParseGoogleMockBoolFlag(const char* str, const char* flag,
const
char
*
const
value_str
=
ParseGoogleMockFlagValue
(
str
,
flag
,
true
);
const
char
*
const
value_str
=
ParseGoogleMockFlagValue
(
str
,
flag
,
true
);
// Aborts if the parsing failed.
// Aborts if the parsing failed.
if
(
value_str
==
NULL
)
return
false
;
if
(
value_str
==
nullptr
)
return
false
;
// Converts the string value to a bool.
// Converts the string value to a bool.
*
value
=
!
(
*
value_str
==
'0'
||
*
value_str
==
'f'
||
*
value_str
==
'F'
);
*
value
=
!
(
*
value_str
==
'0'
||
*
value_str
==
'f'
||
*
value_str
==
'F'
);
...
@@ -119,7 +119,7 @@ static bool ParseGoogleMockStringFlag(const char* str, const char* flag,
...
@@ -119,7 +119,7 @@ static bool ParseGoogleMockStringFlag(const char* str, const char* flag,
const
char
*
const
value_str
=
ParseGoogleMockFlagValue
(
str
,
flag
,
false
);
const
char
*
const
value_str
=
ParseGoogleMockFlagValue
(
str
,
flag
,
false
);
// Aborts if the parsing failed.
// Aborts if the parsing failed.
if
(
value_str
==
NULL
)
return
false
;
if
(
value_str
==
nullptr
)
return
false
;
// Sets *value to the value of the flag.
// Sets *value to the value of the flag.
*
value
=
value_str
;
*
value
=
value_str
;
...
@@ -132,7 +132,7 @@ static bool ParseGoogleMockIntFlag(const char* str, const char* flag,
...
@@ -132,7 +132,7 @@ static bool ParseGoogleMockIntFlag(const char* str, const char* flag,
const
char
*
const
value_str
=
ParseGoogleMockFlagValue
(
str
,
flag
,
true
);
const
char
*
const
value_str
=
ParseGoogleMockFlagValue
(
str
,
flag
,
true
);
// Aborts if the parsing failed.
// Aborts if the parsing failed.
if
(
value_str
==
NULL
)
return
false
;
if
(
value_str
==
nullptr
)
return
false
;
// Sets *value to the value of the flag.
// Sets *value to the value of the flag.
return
ParseInt32
(
Message
()
<<
"The value of flag --"
<<
flag
,
return
ParseInt32
(
Message
()
<<
"The value of flag --"
<<
flag
,
...
...
googlemock/test/gmock-actions_test.cc
View file @
4327d95b
...
@@ -89,9 +89,9 @@ using testing::SetErrnoAndReturn;
...
@@ -89,9 +89,9 @@ using testing::SetErrnoAndReturn;
// Tests that BuiltInDefaultValue<T*>::Get() returns NULL.
// Tests that BuiltInDefaultValue<T*>::Get() returns NULL.
TEST
(
BuiltInDefaultValueTest
,
IsNullForPointerTypes
)
{
TEST
(
BuiltInDefaultValueTest
,
IsNullForPointerTypes
)
{
EXPECT_TRUE
(
BuiltInDefaultValue
<
int
*>::
Get
()
==
NULL
);
EXPECT_TRUE
(
BuiltInDefaultValue
<
int
*>::
Get
()
==
nullptr
);
EXPECT_TRUE
(
BuiltInDefaultValue
<
const
char
*>::
Get
()
==
NULL
);
EXPECT_TRUE
(
BuiltInDefaultValue
<
const
char
*>::
Get
()
==
nullptr
);
EXPECT_TRUE
(
BuiltInDefaultValue
<
void
*>::
Get
()
==
NULL
);
EXPECT_TRUE
(
BuiltInDefaultValue
<
void
*>::
Get
()
==
nullptr
);
}
}
// Tests that BuiltInDefaultValue<T*>::Exists() return true.
// Tests that BuiltInDefaultValue<T*>::Exists() return true.
...
@@ -196,7 +196,7 @@ TEST(BuiltInDefaultValueTest, ExistsForString) {
...
@@ -196,7 +196,7 @@ TEST(BuiltInDefaultValueTest, ExistsForString) {
TEST
(
BuiltInDefaultValueTest
,
WorksForConstTypes
)
{
TEST
(
BuiltInDefaultValueTest
,
WorksForConstTypes
)
{
EXPECT_EQ
(
""
,
BuiltInDefaultValue
<
const
std
::
string
>::
Get
());
EXPECT_EQ
(
""
,
BuiltInDefaultValue
<
const
std
::
string
>::
Get
());
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
const
int
>::
Get
());
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
const
int
>::
Get
());
EXPECT_TRUE
(
BuiltInDefaultValue
<
char
*
const
>::
Get
()
==
NULL
);
EXPECT_TRUE
(
BuiltInDefaultValue
<
char
*
const
>::
Get
()
==
nullptr
);
EXPECT_FALSE
(
BuiltInDefaultValue
<
const
bool
>::
Get
());
EXPECT_FALSE
(
BuiltInDefaultValue
<
const
bool
>::
Get
());
}
}
...
@@ -306,7 +306,7 @@ TEST(DefaultValueDeathTest, GetReturnsBuiltInDefaultValueWhenUnset) {
...
@@ -306,7 +306,7 @@ TEST(DefaultValueDeathTest, GetReturnsBuiltInDefaultValueWhenUnset) {
#if GTEST_HAS_STD_UNIQUE_PTR_
#if GTEST_HAS_STD_UNIQUE_PTR_
TEST
(
DefaultValueTest
,
GetWorksForMoveOnlyIfSet
)
{
TEST
(
DefaultValueTest
,
GetWorksForMoveOnlyIfSet
)
{
EXPECT_TRUE
(
DefaultValue
<
std
::
unique_ptr
<
int
>>::
Exists
());
EXPECT_TRUE
(
DefaultValue
<
std
::
unique_ptr
<
int
>>::
Exists
());
EXPECT_TRUE
(
DefaultValue
<
std
::
unique_ptr
<
int
>>::
Get
()
==
NULL
);
EXPECT_TRUE
(
DefaultValue
<
std
::
unique_ptr
<
int
>>::
Get
()
==
nullptr
);
DefaultValue
<
std
::
unique_ptr
<
int
>>::
SetFactory
([]
{
DefaultValue
<
std
::
unique_ptr
<
int
>>::
SetFactory
([]
{
return
std
::
unique_ptr
<
int
>
(
new
int
(
42
));
return
std
::
unique_ptr
<
int
>
(
new
int
(
42
));
});
});
...
@@ -519,7 +519,7 @@ TEST(MakePolymorphicActionTest, WorksWhenPerformHasOneTemplateParameter) {
...
@@ -519,7 +519,7 @@ TEST(MakePolymorphicActionTest, WorksWhenPerformHasOneTemplateParameter) {
EXPECT_EQ
(
0
,
a1
.
Perform
(
make_tuple
()));
EXPECT_EQ
(
0
,
a1
.
Perform
(
make_tuple
()));
Action
<
void
*
()
>
a2
=
ReturnZeroFromNullaryFunction
();
Action
<
void
*
()
>
a2
=
ReturnZeroFromNullaryFunction
();
EXPECT_TRUE
(
a2
.
Perform
(
make_tuple
())
==
NULL
);
EXPECT_TRUE
(
a2
.
Perform
(
make_tuple
())
==
nullptr
);
}
}
// Tests that Return() works as an action for void-returning
// Tests that Return() works as an action for void-returning
...
@@ -636,10 +636,10 @@ TEST(ReturnTest, CanConvertArgumentUsingNonConstTypeCastOperator) {
...
@@ -636,10 +636,10 @@ TEST(ReturnTest, CanConvertArgumentUsingNonConstTypeCastOperator) {
// Tests that ReturnNull() returns NULL in a pointer-returning function.
// Tests that ReturnNull() returns NULL in a pointer-returning function.
TEST
(
ReturnNullTest
,
WorksInPointerReturningFunction
)
{
TEST
(
ReturnNullTest
,
WorksInPointerReturningFunction
)
{
const
Action
<
int
*
()
>
a1
=
ReturnNull
();
const
Action
<
int
*
()
>
a1
=
ReturnNull
();
EXPECT_TRUE
(
a1
.
Perform
(
make_tuple
())
==
NULL
);
EXPECT_TRUE
(
a1
.
Perform
(
make_tuple
())
==
nullptr
);
const
Action
<
const
char
*
(
bool
)
>
a2
=
ReturnNull
();
// NOLINT
const
Action
<
const
char
*
(
bool
)
>
a2
=
ReturnNull
();
// NOLINT
EXPECT_TRUE
(
a2
.
Perform
(
make_tuple
(
true
))
==
NULL
);
EXPECT_TRUE
(
a2
.
Perform
(
make_tuple
(
true
))
==
nullptr
);
}
}
#if GTEST_HAS_STD_UNIQUE_PTR_
#if GTEST_HAS_STD_UNIQUE_PTR_
...
@@ -819,10 +819,10 @@ TEST(SetArgPointeeTest, AcceptsStringLiteral) {
...
@@ -819,10 +819,10 @@ TEST(SetArgPointeeTest, AcceptsStringLiteral) {
typedef
void
MyFunction
(
std
::
string
*
,
const
char
**
);
typedef
void
MyFunction
(
std
::
string
*
,
const
char
**
);
Action
<
MyFunction
>
a
=
SetArgPointee
<
0
>
(
"hi"
);
Action
<
MyFunction
>
a
=
SetArgPointee
<
0
>
(
"hi"
);
std
::
string
str
;
std
::
string
str
;
const
char
*
ptr
=
NULL
;
const
char
*
ptr
=
nullptr
;
a
.
Perform
(
make_tuple
(
&
str
,
&
ptr
));
a
.
Perform
(
make_tuple
(
&
str
,
&
ptr
));
EXPECT_EQ
(
"hi"
,
str
);
EXPECT_EQ
(
"hi"
,
str
);
EXPECT_TRUE
(
ptr
==
NULL
);
EXPECT_TRUE
(
ptr
==
nullptr
);
a
=
SetArgPointee
<
1
>
(
"world"
);
a
=
SetArgPointee
<
1
>
(
"world"
);
str
=
""
;
str
=
""
;
...
@@ -834,7 +834,7 @@ TEST(SetArgPointeeTest, AcceptsStringLiteral) {
...
@@ -834,7 +834,7 @@ TEST(SetArgPointeeTest, AcceptsStringLiteral) {
TEST
(
SetArgPointeeTest
,
AcceptsWideStringLiteral
)
{
TEST
(
SetArgPointeeTest
,
AcceptsWideStringLiteral
)
{
typedef
void
MyFunction
(
const
wchar_t
**
);
typedef
void
MyFunction
(
const
wchar_t
**
);
Action
<
MyFunction
>
a
=
SetArgPointee
<
0
>
(
L"world"
);
Action
<
MyFunction
>
a
=
SetArgPointee
<
0
>
(
L"world"
);
const
wchar_t
*
ptr
=
NULL
;
const
wchar_t
*
ptr
=
nullptr
;
a
.
Perform
(
make_tuple
(
&
ptr
));
a
.
Perform
(
make_tuple
(
&
ptr
));
EXPECT_STREQ
(
L"world"
,
ptr
);
EXPECT_STREQ
(
L"world"
,
ptr
);
...
@@ -856,10 +856,10 @@ TEST(SetArgPointeeTest, AcceptsCharPointer) {
...
@@ -856,10 +856,10 @@ TEST(SetArgPointeeTest, AcceptsCharPointer) {
const
char
*
const
hi
=
"hi"
;
const
char
*
const
hi
=
"hi"
;
Action
<
MyFunction
>
a
=
SetArgPointee
<
1
>
(
hi
);
Action
<
MyFunction
>
a
=
SetArgPointee
<
1
>
(
hi
);
std
::
string
str
;
std
::
string
str
;
const
char
*
ptr
=
NULL
;
const
char
*
ptr
=
nullptr
;
a
.
Perform
(
make_tuple
(
true
,
&
str
,
&
ptr
));
a
.
Perform
(
make_tuple
(
true
,
&
str
,
&
ptr
));
EXPECT_EQ
(
"hi"
,
str
);
EXPECT_EQ
(
"hi"
,
str
);
EXPECT_TRUE
(
ptr
==
NULL
);
EXPECT_TRUE
(
ptr
==
nullptr
);
char
world_array
[]
=
"world"
;
char
world_array
[]
=
"world"
;
char
*
const
world
=
world_array
;
char
*
const
world
=
world_array
;
...
@@ -874,7 +874,7 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) {
...
@@ -874,7 +874,7 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) {
typedef
void
MyFunction
(
bool
,
const
wchar_t
**
);
typedef
void
MyFunction
(
bool
,
const
wchar_t
**
);
const
wchar_t
*
const
hi
=
L"hi"
;
const
wchar_t
*
const
hi
=
L"hi"
;
Action
<
MyFunction
>
a
=
SetArgPointee
<
1
>
(
hi
);
Action
<
MyFunction
>
a
=
SetArgPointee
<
1
>
(
hi
);
const
wchar_t
*
ptr
=
NULL
;
const
wchar_t
*
ptr
=
nullptr
;
a
.
Perform
(
make_tuple
(
true
,
&
ptr
));
a
.
Perform
(
make_tuple
(
true
,
&
ptr
));
EXPECT_EQ
(
hi
,
ptr
);
EXPECT_EQ
(
hi
,
ptr
);
...
...
googlemock/test/gmock-generated-function-mockers_test.cc
View file @
4327d95b
...
@@ -228,7 +228,7 @@ TEST_F(FunctionMockerTest, MocksDecimalFunction) {
...
@@ -228,7 +228,7 @@ TEST_F(FunctionMockerTest, MocksDecimalFunction) {
Lt
(
100
),
5U
,
NULL
,
"hi"
))
Lt
(
100
),
5U
,
NULL
,
"hi"
))
.
WillOnce
(
Return
(
5
));
.
WillOnce
(
Return
(
5
));
EXPECT_EQ
(
5
,
foo_
->
Decimal
(
true
,
'a'
,
0
,
0
,
1
,
0
,
0
,
5
,
NULL
,
"hi"
));
EXPECT_EQ
(
5
,
foo_
->
Decimal
(
true
,
'a'
,
0
,
0
,
1
,
0
,
0
,
5
,
nullptr
,
"hi"
));
}
}
// Tests mocking a function that takes a non-const reference.
// Tests mocking a function that takes a non-const reference.
...
...
googlemock/test/gmock-generated-matchers_test.cc
View file @
4327d95b
...
@@ -697,7 +697,7 @@ TEST(ElementsAreArrayTest, CanBeCreatedWithIteratorRange) {
...
@@ -697,7 +697,7 @@ TEST(ElementsAreArrayTest, CanBeCreatedWithIteratorRange) {
// Pointers are iterators, too.
// Pointers are iterators, too.
EXPECT_THAT
(
test_vector
,
ElementsAreArray
(
a
,
a
+
GTEST_ARRAY_SIZE_
(
a
)));
EXPECT_THAT
(
test_vector
,
ElementsAreArray
(
a
,
a
+
GTEST_ARRAY_SIZE_
(
a
)));
// The empty range of NULL pointers should also be okay.
// The empty range of NULL pointers should also be okay.
int
*
const
null_int
=
NULL
;
int
*
const
null_int
=
nullptr
;
EXPECT_THAT
(
test_vector
,
Not
(
ElementsAreArray
(
null_int
,
null_int
)));
EXPECT_THAT
(
test_vector
,
Not
(
ElementsAreArray
(
null_int
,
null_int
)));
EXPECT_THAT
((
vector
<
int
>
()),
ElementsAreArray
(
null_int
,
null_int
));
EXPECT_THAT
((
vector
<
int
>
()),
ElementsAreArray
(
null_int
,
null_int
));
}
}
...
@@ -770,7 +770,7 @@ MATCHER_P2(EqSumOf, x, y, std::string(negation ? "doesn't equal" : "equals") +
...
@@ -770,7 +770,7 @@ MATCHER_P2(EqSumOf, x, y, std::string(negation ? "doesn't equal" : "equals") +
}
else
{
}
else
{
// Verifies that we can stream to the underlying stream of
// Verifies that we can stream to the underlying stream of
// result_listener.
// result_listener.
if
(
result_listener
->
stream
()
!=
NULL
)
{
if
(
result_listener
->
stream
()
!=
nullptr
)
{
*
result_listener
->
stream
()
<<
"diff == "
<<
(
x
+
y
-
arg
);
*
result_listener
->
stream
()
<<
"diff == "
<<
(
x
+
y
-
arg
);
}
}
return
false
;
return
false
;
...
...
googlemock/test/gmock-internal-utils_test.cc
View file @
4327d95b
...
@@ -158,9 +158,9 @@ TEST(GetRawPointerTest, WorksForSmartPointers) {
...
@@ -158,9 +158,9 @@ TEST(GetRawPointerTest, WorksForSmartPointers) {
}
}
TEST
(
GetRawPointerTest
,
WorksForRawPointers
)
{
TEST
(
GetRawPointerTest
,
WorksForRawPointers
)
{
int
*
p
=
NULL
;
int
*
p
=
nullptr
;
// Don't use EXPECT_EQ as no NULL-testing magic on Symbian.
// Don't use EXPECT_EQ as no NULL-testing magic on Symbian.
EXPECT_TRUE
(
NULL
==
GetRawPointer
(
p
));
EXPECT_TRUE
(
nullptr
==
GetRawPointer
(
p
));
int
n
=
1
;
int
n
=
1
;
EXPECT_EQ
(
&
n
,
GetRawPointer
(
&
n
));
EXPECT_EQ
(
&
n
,
GetRawPointer
(
&
n
));
}
}
...
@@ -492,7 +492,7 @@ TEST(LogTest, NoSkippingStackFrameInOptMode) {
...
@@ -492,7 +492,7 @@ TEST(LogTest, NoSkippingStackFrameInOptMode) {
AllOf
(
Ge
(
expected_skip_count
),
Le
(
expected_skip_count
+
10
)));
AllOf
(
Ge
(
expected_skip_count
),
Le
(
expected_skip_count
+
10
)));
// Restores the default OS stack trace getter.
// Restores the default OS stack trace getter.
GetUnitTestImpl
()
->
set_os_stack_trace_getter
(
NULL
);
GetUnitTestImpl
()
->
set_os_stack_trace_getter
(
nullptr
);
}
}
// Tests that all logs are printed when the value of the
// Tests that all logs are printed when the value of the
...
...
googlemock/test/gmock-matchers_test.cc
View file @
4327d95b
...
@@ -238,8 +238,8 @@ TEST(MatchResultListenerTest, StreamingWorks) {
...
@@ -238,8 +238,8 @@ TEST(MatchResultListenerTest, StreamingWorks) {
}
}
TEST
(
MatchResultListenerTest
,
CanAccessUnderlyingStream
)
{
TEST
(
MatchResultListenerTest
,
CanAccessUnderlyingStream
)
{
EXPECT_TRUE
(
DummyMatchResultListener
().
stream
()
==
NULL
);
EXPECT_TRUE
(
DummyMatchResultListener
().
stream
()
==
nullptr
);
EXPECT_TRUE
(
StreamMatchResultListener
(
NULL
).
stream
()
==
NULL
);
EXPECT_TRUE
(
StreamMatchResultListener
(
nullptr
).
stream
()
==
nullptr
);
EXPECT_EQ
(
&
std
::
cout
,
StreamMatchResultListener
(
&
std
::
cout
).
stream
());
EXPECT_EQ
(
&
std
::
cout
,
StreamMatchResultListener
(
&
std
::
cout
).
stream
());
}
}
...
@@ -249,7 +249,7 @@ TEST(MatchResultListenerTest, IsInterestedWorks) {
...
@@ -249,7 +249,7 @@ TEST(MatchResultListenerTest, IsInterestedWorks) {
EXPECT_TRUE
(
StreamMatchResultListener
(
&
std
::
cout
).
IsInterested
());
EXPECT_TRUE
(
StreamMatchResultListener
(
&
std
::
cout
).
IsInterested
());
EXPECT_FALSE
(
DummyMatchResultListener
().
IsInterested
());
EXPECT_FALSE
(
DummyMatchResultListener
().
IsInterested
());
EXPECT_FALSE
(
StreamMatchResultListener
(
NULL
).
IsInterested
());
EXPECT_FALSE
(
StreamMatchResultListener
(
nullptr
).
IsInterested
());
}
}
// Makes sure that the MatcherInterface<T> interface doesn't
// Makes sure that the MatcherInterface<T> interface doesn't
...
@@ -283,7 +283,7 @@ class NewEvenMatcherImpl : public MatcherInterface<int> {
...
@@ -283,7 +283,7 @@ class NewEvenMatcherImpl : public MatcherInterface<int> {
const
bool
match
=
x
%
2
==
0
;
const
bool
match
=
x
%
2
==
0
;
// Verifies that we can stream to a listener directly.
// Verifies that we can stream to a listener directly.
*
listener
<<
"value % "
<<
2
;
*
listener
<<
"value % "
<<
2
;
if
(
listener
->
stream
()
!=
NULL
)
{
if
(
listener
->
stream
()
!=
nullptr
)
{
// Verifies that we can stream to a listener's underlying stream
// Verifies that we can stream to a listener's underlying stream
// too.
// too.
*
listener
->
stream
()
<<
" == "
<<
(
x
%
2
);
*
listener
->
stream
()
<<
" == "
<<
(
x
%
2
);
...
@@ -327,7 +327,7 @@ TEST(MatcherTest, CanBeImplicitlyConstructedFromValue) {
...
@@ -327,7 +327,7 @@ TEST(MatcherTest, CanBeImplicitlyConstructedFromValue) {
// Tests that NULL can be used in place of Eq(NULL).
// Tests that NULL can be used in place of Eq(NULL).
TEST
(
MatcherTest
,
CanBeImplicitlyConstructedFromNULL
)
{
TEST
(
MatcherTest
,
CanBeImplicitlyConstructedFromNULL
)
{
Matcher
<
int
*>
m1
=
NULL
;
Matcher
<
int
*>
m1
=
NULL
;
EXPECT_TRUE
(
m1
.
Matches
(
NULL
));
EXPECT_TRUE
(
m1
.
Matches
(
nullptr
));
int
n
=
0
;
int
n
=
0
;
EXPECT_FALSE
(
m1
.
Matches
(
&
n
));
EXPECT_FALSE
(
m1
.
Matches
(
&
n
));
}
}
...
@@ -512,7 +512,7 @@ TEST(StringViewMatcherTest, CanBeImplicitlyConstructedFromStringView) {
...
@@ -512,7 +512,7 @@ TEST(StringViewMatcherTest, CanBeImplicitlyConstructedFromStringView) {
// MatcherInterface* without requiring the user to explicitly
// MatcherInterface* without requiring the user to explicitly
// write the type.
// write the type.
TEST
(
MakeMatcherTest
,
ConstructsMatcherFromMatcherInterface
)
{
TEST
(
MakeMatcherTest
,
ConstructsMatcherFromMatcherInterface
)
{
const
MatcherInterface
<
int
>*
dummy_impl
=
NULL
;
const
MatcherInterface
<
int
>*
dummy_impl
=
nullptr
;
Matcher
<
int
>
m
=
MakeMatcher
(
dummy_impl
);
Matcher
<
int
>
m
=
MakeMatcher
(
dummy_impl
);
}
}
...
@@ -571,7 +571,7 @@ class PolymorphicIsEvenImpl {
...
@@ -571,7 +571,7 @@ class PolymorphicIsEvenImpl {
bool
MatchAndExplain
(
const
T
&
x
,
MatchResultListener
*
listener
)
const
{
bool
MatchAndExplain
(
const
T
&
x
,
MatchResultListener
*
listener
)
const
{
// Verifies that we can stream to the listener directly.
// Verifies that we can stream to the listener directly.
*
listener
<<
"% "
<<
2
;
*
listener
<<
"% "
<<
2
;
if
(
listener
->
stream
()
!=
NULL
)
{
if
(
listener
->
stream
()
!=
nullptr
)
{
// Verifies that we can stream to the listener's underlying stream
// Verifies that we can stream to the listener's underlying stream
// too.
// too.
*
listener
->
stream
()
<<
" == "
<<
(
x
%
2
);
*
listener
->
stream
()
<<
" == "
<<
(
x
%
2
);
...
@@ -1154,13 +1154,13 @@ TEST(NeTest, CanDescribeSelf) {
...
@@ -1154,13 +1154,13 @@ TEST(NeTest, CanDescribeSelf) {
// Tests that IsNull() matches any NULL pointer of any type.
// Tests that IsNull() matches any NULL pointer of any type.
TEST
(
IsNullTest
,
MatchesNullPointer
)
{
TEST
(
IsNullTest
,
MatchesNullPointer
)
{
Matcher
<
int
*>
m1
=
IsNull
();
Matcher
<
int
*>
m1
=
IsNull
();
int
*
p1
=
NULL
;
int
*
p1
=
nullptr
;
int
n
=
0
;
int
n
=
0
;
EXPECT_TRUE
(
m1
.
Matches
(
p1
));
EXPECT_TRUE
(
m1
.
Matches
(
p1
));
EXPECT_FALSE
(
m1
.
Matches
(
&
n
));
EXPECT_FALSE
(
m1
.
Matches
(
&
n
));
Matcher
<
const
char
*>
m2
=
IsNull
();
Matcher
<
const
char
*>
m2
=
IsNull
();
const
char
*
p2
=
NULL
;
const
char
*
p2
=
nullptr
;
EXPECT_TRUE
(
m2
.
Matches
(
p2
));
EXPECT_TRUE
(
m2
.
Matches
(
p2
));
EXPECT_FALSE
(
m2
.
Matches
(
"hi"
));
EXPECT_FALSE
(
m2
.
Matches
(
"hi"
));
...
@@ -1174,7 +1174,7 @@ TEST(IsNullTest, MatchesNullPointer) {
...
@@ -1174,7 +1174,7 @@ TEST(IsNullTest, MatchesNullPointer) {
// gmock_matchers_test::IsNullTest_MatchesNullPointer_Test::TestBody()')
// gmock_matchers_test::IsNullTest_MatchesNullPointer_Test::TestBody()')
// gmock-matchers.h: (instantiating: 'testing::PolymorphicMatc
// gmock-matchers.h: (instantiating: 'testing::PolymorphicMatc
Matcher
<
void
*>
m3
=
IsNull
();
Matcher
<
void
*>
m3
=
IsNull
();
void
*
p3
=
NULL
;
void
*
p3
=
nullptr
;
EXPECT_TRUE
(
m3
.
Matches
(
p3
));
EXPECT_TRUE
(
m3
.
Matches
(
p3
));
EXPECT_FALSE
(
m3
.
Matches
(
reinterpret_cast
<
void
*>
(
0xbeef
)));
EXPECT_FALSE
(
m3
.
Matches
(
reinterpret_cast
<
void
*>
(
0xbeef
)));
#endif
#endif
...
@@ -1217,13 +1217,13 @@ TEST(IsNullTest, CanDescribeSelf) {
...
@@ -1217,13 +1217,13 @@ TEST(IsNullTest, CanDescribeSelf) {
// Tests that NotNull() matches any non-NULL pointer of any type.
// Tests that NotNull() matches any non-NULL pointer of any type.
TEST
(
NotNullTest
,
MatchesNonNullPointer
)
{
TEST
(
NotNullTest
,
MatchesNonNullPointer
)
{
Matcher
<
int
*>
m1
=
NotNull
();
Matcher
<
int
*>
m1
=
NotNull
();
int
*
p1
=
NULL
;
int
*
p1
=
nullptr
;
int
n
=
0
;
int
n
=
0
;
EXPECT_FALSE
(
m1
.
Matches
(
p1
));
EXPECT_FALSE
(
m1
.
Matches
(
p1
));
EXPECT_TRUE
(
m1
.
Matches
(
&
n
));
EXPECT_TRUE
(
m1
.
Matches
(
&
n
));
Matcher
<
const
char
*>
m2
=
NotNull
();
Matcher
<
const
char
*>
m2
=
NotNull
();
const
char
*
p2
=
NULL
;
const
char
*
p2
=
nullptr
;
EXPECT_FALSE
(
m2
.
Matches
(
p2
));
EXPECT_FALSE
(
m2
.
Matches
(
p2
));
EXPECT_TRUE
(
m2
.
Matches
(
"hi"
));
EXPECT_TRUE
(
m2
.
Matches
(
"hi"
));
}
}
...
@@ -1324,7 +1324,7 @@ TEST(StrEqTest, MatchesEqualString) {
...
@@ -1324,7 +1324,7 @@ TEST(StrEqTest, MatchesEqualString) {
Matcher
<
const
char
*>
m
=
StrEq
(
std
::
string
(
"Hello"
));
Matcher
<
const
char
*>
m
=
StrEq
(
std
::
string
(
"Hello"
));
EXPECT_TRUE
(
m
.
Matches
(
"Hello"
));
EXPECT_TRUE
(
m
.
Matches
(
"Hello"
));
EXPECT_FALSE
(
m
.
Matches
(
"hello"
));
EXPECT_FALSE
(
m
.
Matches
(
"hello"
));
EXPECT_FALSE
(
m
.
Matches
(
NULL
));
EXPECT_FALSE
(
m
.
Matches
(
nullptr
));
Matcher
<
const
std
::
string
&>
m2
=
StrEq
(
"Hello"
);
Matcher
<
const
std
::
string
&>
m2
=
StrEq
(
"Hello"
);
EXPECT_TRUE
(
m2
.
Matches
(
"Hello"
));
EXPECT_TRUE
(
m2
.
Matches
(
"Hello"
));
...
@@ -1360,7 +1360,7 @@ TEST(StrEqTest, CanDescribeSelf) {
...
@@ -1360,7 +1360,7 @@ TEST(StrEqTest, CanDescribeSelf) {
TEST
(
StrNeTest
,
MatchesUnequalString
)
{
TEST
(
StrNeTest
,
MatchesUnequalString
)
{
Matcher
<
const
char
*>
m
=
StrNe
(
"Hello"
);
Matcher
<
const
char
*>
m
=
StrNe
(
"Hello"
);
EXPECT_TRUE
(
m
.
Matches
(
""
));
EXPECT_TRUE
(
m
.
Matches
(
""
));
EXPECT_TRUE
(
m
.
Matches
(
NULL
));
EXPECT_TRUE
(
m
.
Matches
(
nullptr
));
EXPECT_FALSE
(
m
.
Matches
(
"Hello"
));
EXPECT_FALSE
(
m
.
Matches
(
"Hello"
));
Matcher
<
std
::
string
>
m2
=
StrNe
(
std
::
string
(
"Hello"
));
Matcher
<
std
::
string
>
m2
=
StrNe
(
std
::
string
(
"Hello"
));
...
@@ -1385,7 +1385,7 @@ TEST(StrCaseEqTest, MatchesEqualStringIgnoringCase) {
...
@@ -1385,7 +1385,7 @@ TEST(StrCaseEqTest, MatchesEqualStringIgnoringCase) {
EXPECT_TRUE
(
m
.
Matches
(
"Hello"
));
EXPECT_TRUE
(
m
.
Matches
(
"Hello"
));
EXPECT_TRUE
(
m
.
Matches
(
"hello"
));
EXPECT_TRUE
(
m
.
Matches
(
"hello"
));
EXPECT_FALSE
(
m
.
Matches
(
"Hi"
));
EXPECT_FALSE
(
m
.
Matches
(
"Hi"
));
EXPECT_FALSE
(
m
.
Matches
(
NULL
));
EXPECT_FALSE
(
m
.
Matches
(
nullptr
));
Matcher
<
const
std
::
string
&>
m2
=
StrCaseEq
(
"Hello"
);
Matcher
<
const
std
::
string
&>
m2
=
StrCaseEq
(
"Hello"
);
EXPECT_TRUE
(
m2
.
Matches
(
"hello"
));
EXPECT_TRUE
(
m2
.
Matches
(
"hello"
));
...
@@ -1433,7 +1433,7 @@ TEST(StrCaseEqTest, CanDescribeSelf) {
...
@@ -1433,7 +1433,7 @@ TEST(StrCaseEqTest, CanDescribeSelf) {
TEST
(
StrCaseNeTest
,
MatchesUnequalStringIgnoringCase
)
{
TEST
(
StrCaseNeTest
,
MatchesUnequalStringIgnoringCase
)
{
Matcher
<
const
char
*>
m
=
StrCaseNe
(
"Hello"
);
Matcher
<
const
char
*>
m
=
StrCaseNe
(
"Hello"
);
EXPECT_TRUE
(
m
.
Matches
(
"Hi"
));
EXPECT_TRUE
(
m
.
Matches
(
"Hi"
));
EXPECT_TRUE
(
m
.
Matches
(
NULL
));
EXPECT_TRUE
(
m
.
Matches
(
nullptr
));
EXPECT_FALSE
(
m
.
Matches
(
"Hello"
));
EXPECT_FALSE
(
m
.
Matches
(
"Hello"
));
EXPECT_FALSE
(
m
.
Matches
(
"hello"
));
EXPECT_FALSE
(
m
.
Matches
(
"hello"
));
...
@@ -1475,17 +1475,17 @@ TEST(HasSubstrTest, WorksForCStrings) {
...
@@ -1475,17 +1475,17 @@ TEST(HasSubstrTest, WorksForCStrings) {
const
Matcher
<
char
*>
m1
=
HasSubstr
(
"foo"
);
const
Matcher
<
char
*>
m1
=
HasSubstr
(
"foo"
);
EXPECT_TRUE
(
m1
.
Matches
(
const_cast
<
char
*>
(
"I love food."
)));
EXPECT_TRUE
(
m1
.
Matches
(
const_cast
<
char
*>
(
"I love food."
)));
EXPECT_FALSE
(
m1
.
Matches
(
const_cast
<
char
*>
(
"tofo"
)));
EXPECT_FALSE
(
m1
.
Matches
(
const_cast
<
char
*>
(
"tofo"
)));
EXPECT_FALSE
(
m1
.
Matches
(
NULL
));
EXPECT_FALSE
(
m1
.
Matches
(
nullptr
));
const
Matcher
<
const
char
*>
m2
=
HasSubstr
(
"foo"
);
const
Matcher
<
const
char
*>
m2
=
HasSubstr
(
"foo"
);
EXPECT_TRUE
(
m2
.
Matches
(
"I love food."
));
EXPECT_TRUE
(
m2
.
Matches
(
"I love food."
));
EXPECT_FALSE
(
m2
.
Matches
(
"tofo"
));
EXPECT_FALSE
(
m2
.
Matches
(
"tofo"
));
EXPECT_FALSE
(
m2
.
Matches
(
NULL
));
EXPECT_FALSE
(
m2
.
Matches
(
nullptr
));
const
Matcher
<
const
char
*>
m_empty
=
HasSubstr
(
""
);
const
Matcher
<
const
char
*>
m_empty
=
HasSubstr
(
""
);
EXPECT_TRUE
(
m_empty
.
Matches
(
"not empty"
));
EXPECT_TRUE
(
m_empty
.
Matches
(
"not empty"
));
EXPECT_TRUE
(
m_empty
.
Matches
(
""
));
EXPECT_TRUE
(
m_empty
.
Matches
(
""
));
EXPECT_FALSE
(
m_empty
.
Matches
(
NULL
));
EXPECT_FALSE
(
m_empty
.
Matches
(
nullptr
));
}
}
#if GTEST_HAS_ABSL
#if GTEST_HAS_ABSL
...
@@ -1720,7 +1720,7 @@ TEST(StartsWithTest, MatchesStringWithGivenPrefix) {
...
@@ -1720,7 +1720,7 @@ TEST(StartsWithTest, MatchesStringWithGivenPrefix) {
const
Matcher
<
const
char
*>
m1
=
StartsWith
(
std
::
string
(
""
));
const
Matcher
<
const
char
*>
m1
=
StartsWith
(
std
::
string
(
""
));
EXPECT_TRUE
(
m1
.
Matches
(
"Hi"
));
EXPECT_TRUE
(
m1
.
Matches
(
"Hi"
));
EXPECT_TRUE
(
m1
.
Matches
(
""
));
EXPECT_TRUE
(
m1
.
Matches
(
""
));
EXPECT_FALSE
(
m1
.
Matches
(
NULL
));
EXPECT_FALSE
(
m1
.
Matches
(
nullptr
));
const
Matcher
<
const
std
::
string
&>
m2
=
StartsWith
(
"Hi"
);
const
Matcher
<
const
std
::
string
&>
m2
=
StartsWith
(
"Hi"
);
EXPECT_TRUE
(
m2
.
Matches
(
"Hi"
));
EXPECT_TRUE
(
m2
.
Matches
(
"Hi"
));
...
@@ -1748,7 +1748,7 @@ TEST(EndsWithTest, MatchesStringWithGivenSuffix) {
...
@@ -1748,7 +1748,7 @@ TEST(EndsWithTest, MatchesStringWithGivenSuffix) {
const
Matcher
<
const
char
*>
m1
=
EndsWith
(
""
);
const
Matcher
<
const
char
*>
m1
=
EndsWith
(
""
);
EXPECT_TRUE
(
m1
.
Matches
(
"Hi"
));
EXPECT_TRUE
(
m1
.
Matches
(
"Hi"
));
EXPECT_TRUE
(
m1
.
Matches
(
""
));
EXPECT_TRUE
(
m1
.
Matches
(
""
));
EXPECT_FALSE
(
m1
.
Matches
(
NULL
));
EXPECT_FALSE
(
m1
.
Matches
(
nullptr
));
const
Matcher
<
const
std
::
string
&>
m2
=
EndsWith
(
std
::
string
(
"Hi"
));
const
Matcher
<
const
std
::
string
&>
m2
=
EndsWith
(
std
::
string
(
"Hi"
));
EXPECT_TRUE
(
m2
.
Matches
(
"Hi"
));
EXPECT_TRUE
(
m2
.
Matches
(
"Hi"
));
...
@@ -1786,7 +1786,7 @@ TEST(MatchesRegexTest, MatchesStringMatchingGivenRegex) {
...
@@ -1786,7 +1786,7 @@ TEST(MatchesRegexTest, MatchesStringMatchingGivenRegex) {
const
Matcher
<
const
char
*>
m1
=
MatchesRegex
(
"a.*z"
);
const
Matcher
<
const
char
*>
m1
=
MatchesRegex
(
"a.*z"
);
EXPECT_TRUE
(
m1
.
Matches
(
"az"
));
EXPECT_TRUE
(
m1
.
Matches
(
"az"
));
EXPECT_TRUE
(
m1
.
Matches
(
"abcz"
));
EXPECT_TRUE
(
m1
.
Matches
(
"abcz"
));
EXPECT_FALSE
(
m1
.
Matches
(
NULL
));
EXPECT_FALSE
(
m1
.
Matches
(
nullptr
));
const
Matcher
<
const
std
::
string
&>
m2
=
MatchesRegex
(
new
RE
(
"a.*z"
));
const
Matcher
<
const
std
::
string
&>
m2
=
MatchesRegex
(
new
RE
(
"a.*z"
));
EXPECT_TRUE
(
m2
.
Matches
(
"azbz"
));
EXPECT_TRUE
(
m2
.
Matches
(
"azbz"
));
...
@@ -1824,7 +1824,7 @@ TEST(ContainsRegexTest, MatchesStringContainingGivenRegex) {
...
@@ -1824,7 +1824,7 @@ TEST(ContainsRegexTest, MatchesStringContainingGivenRegex) {
const
Matcher
<
const
char
*>
m1
=
ContainsRegex
(
std
::
string
(
"a.*z"
));
const
Matcher
<
const
char
*>
m1
=
ContainsRegex
(
std
::
string
(
"a.*z"
));
EXPECT_TRUE
(
m1
.
Matches
(
"az"
));
EXPECT_TRUE
(
m1
.
Matches
(
"az"
));
EXPECT_TRUE
(
m1
.
Matches
(
"0abcz1"
));
EXPECT_TRUE
(
m1
.
Matches
(
"0abcz1"
));
EXPECT_FALSE
(
m1
.
Matches
(
NULL
));
EXPECT_FALSE
(
m1
.
Matches
(
nullptr
));
const
Matcher
<
const
std
::
string
&>
m2
=
ContainsRegex
(
new
RE
(
"a.*z"
));
const
Matcher
<
const
std
::
string
&>
m2
=
ContainsRegex
(
new
RE
(
"a.*z"
));
EXPECT_TRUE
(
m2
.
Matches
(
"azbz"
));
EXPECT_TRUE
(
m2
.
Matches
(
"azbz"
));
...
@@ -1862,7 +1862,7 @@ TEST(StdWideStrEqTest, MatchesEqual) {
...
@@ -1862,7 +1862,7 @@ TEST(StdWideStrEqTest, MatchesEqual) {
Matcher
<
const
wchar_t
*>
m
=
StrEq
(
::
std
::
wstring
(
L"Hello"
));
Matcher
<
const
wchar_t
*>
m
=
StrEq
(
::
std
::
wstring
(
L"Hello"
));
EXPECT_TRUE
(
m
.
Matches
(
L"Hello"
));
EXPECT_TRUE
(
m
.
Matches
(
L"Hello"
));
EXPECT_FALSE
(
m
.
Matches
(
L"hello"
));
EXPECT_FALSE
(
m
.
Matches
(
L"hello"
));
EXPECT_FALSE
(
m
.
Matches
(
NULL
));
EXPECT_FALSE
(
m
.
Matches
(
nullptr
));
Matcher
<
const
::
std
::
wstring
&>
m2
=
StrEq
(
L"Hello"
);
Matcher
<
const
::
std
::
wstring
&>
m2
=
StrEq
(
L"Hello"
);
EXPECT_TRUE
(
m2
.
Matches
(
L"Hello"
));
EXPECT_TRUE
(
m2
.
Matches
(
L"Hello"
));
...
@@ -1902,7 +1902,7 @@ TEST(StdWideStrEqTest, CanDescribeSelf) {
...
@@ -1902,7 +1902,7 @@ TEST(StdWideStrEqTest, CanDescribeSelf) {
TEST
(
StdWideStrNeTest
,
MatchesUnequalString
)
{
TEST
(
StdWideStrNeTest
,
MatchesUnequalString
)
{
Matcher
<
const
wchar_t
*>
m
=
StrNe
(
L"Hello"
);
Matcher
<
const
wchar_t
*>
m
=
StrNe
(
L"Hello"
);
EXPECT_TRUE
(
m
.
Matches
(
L""
));
EXPECT_TRUE
(
m
.
Matches
(
L""
));
EXPECT_TRUE
(
m
.
Matches
(
NULL
));
EXPECT_TRUE
(
m
.
Matches
(
nullptr
));
EXPECT_FALSE
(
m
.
Matches
(
L"Hello"
));
EXPECT_FALSE
(
m
.
Matches
(
L"Hello"
));
Matcher
<
::
std
::
wstring
>
m2
=
StrNe
(
::
std
::
wstring
(
L"Hello"
));
Matcher
<
::
std
::
wstring
>
m2
=
StrNe
(
::
std
::
wstring
(
L"Hello"
));
...
@@ -1920,7 +1920,7 @@ TEST(StdWideStrCaseEqTest, MatchesEqualStringIgnoringCase) {
...
@@ -1920,7 +1920,7 @@ TEST(StdWideStrCaseEqTest, MatchesEqualStringIgnoringCase) {
EXPECT_TRUE
(
m
.
Matches
(
L"Hello"
));
EXPECT_TRUE
(
m
.
Matches
(
L"Hello"
));
EXPECT_TRUE
(
m
.
Matches
(
L"hello"
));
EXPECT_TRUE
(
m
.
Matches
(
L"hello"
));
EXPECT_FALSE
(
m
.
Matches
(
L"Hi"
));
EXPECT_FALSE
(
m
.
Matches
(
L"Hi"
));
EXPECT_FALSE
(
m
.
Matches
(
NULL
));
EXPECT_FALSE
(
m
.
Matches
(
nullptr
));
Matcher
<
const
::
std
::
wstring
&>
m2
=
StrCaseEq
(
L"Hello"
);
Matcher
<
const
::
std
::
wstring
&>
m2
=
StrCaseEq
(
L"Hello"
);
EXPECT_TRUE
(
m2
.
Matches
(
L"hello"
));
EXPECT_TRUE
(
m2
.
Matches
(
L"hello"
));
...
@@ -1960,7 +1960,7 @@ TEST(StdWideStrCaseEqTest, CanDescribeSelf) {
...
@@ -1960,7 +1960,7 @@ TEST(StdWideStrCaseEqTest, CanDescribeSelf) {
TEST
(
StdWideStrCaseNeTest
,
MatchesUnequalStringIgnoringCase
)
{
TEST
(
StdWideStrCaseNeTest
,
MatchesUnequalStringIgnoringCase
)
{
Matcher
<
const
wchar_t
*>
m
=
StrCaseNe
(
L"Hello"
);
Matcher
<
const
wchar_t
*>
m
=
StrCaseNe
(
L"Hello"
);
EXPECT_TRUE
(
m
.
Matches
(
L"Hi"
));
EXPECT_TRUE
(
m
.
Matches
(
L"Hi"
));
EXPECT_TRUE
(
m
.
Matches
(
NULL
));
EXPECT_TRUE
(
m
.
Matches
(
nullptr
));
EXPECT_FALSE
(
m
.
Matches
(
L"Hello"
));
EXPECT_FALSE
(
m
.
Matches
(
L"Hello"
));
EXPECT_FALSE
(
m
.
Matches
(
L"hello"
));
EXPECT_FALSE
(
m
.
Matches
(
L"hello"
));
...
@@ -1990,12 +1990,12 @@ TEST(StdWideHasSubstrTest, WorksForCStrings) {
...
@@ -1990,12 +1990,12 @@ TEST(StdWideHasSubstrTest, WorksForCStrings) {
const
Matcher
<
wchar_t
*>
m1
=
HasSubstr
(
L"foo"
);
const
Matcher
<
wchar_t
*>
m1
=
HasSubstr
(
L"foo"
);
EXPECT_TRUE
(
m1
.
Matches
(
const_cast
<
wchar_t
*>
(
L"I love food."
)));
EXPECT_TRUE
(
m1
.
Matches
(
const_cast
<
wchar_t
*>
(
L"I love food."
)));
EXPECT_FALSE
(
m1
.
Matches
(
const_cast
<
wchar_t
*>
(
L"tofo"
)));
EXPECT_FALSE
(
m1
.
Matches
(
const_cast
<
wchar_t
*>
(
L"tofo"
)));
EXPECT_FALSE
(
m1
.
Matches
(
NULL
));
EXPECT_FALSE
(
m1
.
Matches
(
nullptr
));
const
Matcher
<
const
wchar_t
*>
m2
=
HasSubstr
(
L"foo"
);
const
Matcher
<
const
wchar_t
*>
m2
=
HasSubstr
(
L"foo"
);
EXPECT_TRUE
(
m2
.
Matches
(
L"I love food."
));
EXPECT_TRUE
(
m2
.
Matches
(
L"I love food."
));
EXPECT_FALSE
(
m2
.
Matches
(
L"tofo"
));
EXPECT_FALSE
(
m2
.
Matches
(
L"tofo"
));
EXPECT_FALSE
(
m2
.
Matches
(
NULL
));
EXPECT_FALSE
(
m2
.
Matches
(
nullptr
));
}
}
// Tests that HasSubstr(s) describes itself properly.
// Tests that HasSubstr(s) describes itself properly.
...
@@ -2010,7 +2010,7 @@ TEST(StdWideStartsWithTest, MatchesStringWithGivenPrefix) {
...
@@ -2010,7 +2010,7 @@ TEST(StdWideStartsWithTest, MatchesStringWithGivenPrefix) {
const
Matcher
<
const
wchar_t
*>
m1
=
StartsWith
(
::
std
::
wstring
(
L""
));
const
Matcher
<
const
wchar_t
*>
m1
=
StartsWith
(
::
std
::
wstring
(
L""
));
EXPECT_TRUE
(
m1
.
Matches
(
L"Hi"
));
EXPECT_TRUE
(
m1
.
Matches
(
L"Hi"
));
EXPECT_TRUE
(
m1
.
Matches
(
L""
));
EXPECT_TRUE
(
m1
.
Matches
(
L""
));
EXPECT_FALSE
(
m1
.
Matches
(
NULL
));
EXPECT_FALSE
(
m1
.
Matches
(
nullptr
));
const
Matcher
<
const
::
std
::
wstring
&>
m2
=
StartsWith
(
L"Hi"
);
const
Matcher
<
const
::
std
::
wstring
&>
m2
=
StartsWith
(
L"Hi"
);
EXPECT_TRUE
(
m2
.
Matches
(
L"Hi"
));
EXPECT_TRUE
(
m2
.
Matches
(
L"Hi"
));
...
@@ -2031,7 +2031,7 @@ TEST(StdWideEndsWithTest, MatchesStringWithGivenSuffix) {
...
@@ -2031,7 +2031,7 @@ TEST(StdWideEndsWithTest, MatchesStringWithGivenSuffix) {
const
Matcher
<
const
wchar_t
*>
m1
=
EndsWith
(
L""
);
const
Matcher
<
const
wchar_t
*>
m1
=
EndsWith
(
L""
);
EXPECT_TRUE
(
m1
.
Matches
(
L"Hi"
));
EXPECT_TRUE
(
m1
.
Matches
(
L"Hi"
));
EXPECT_TRUE
(
m1
.
Matches
(
L""
));
EXPECT_TRUE
(
m1
.
Matches
(
L""
));
EXPECT_FALSE
(
m1
.
Matches
(
NULL
));
EXPECT_FALSE
(
m1
.
Matches
(
nullptr
));
const
Matcher
<
const
::
std
::
wstring
&>
m2
=
EndsWith
(
::
std
::
wstring
(
L"Hi"
));
const
Matcher
<
const
::
std
::
wstring
&>
m2
=
EndsWith
(
::
std
::
wstring
(
L"Hi"
));
EXPECT_TRUE
(
m2
.
Matches
(
L"Hi"
));
EXPECT_TRUE
(
m2
.
Matches
(
L"Hi"
));
...
@@ -2053,7 +2053,7 @@ TEST(GlobalWideStrEqTest, MatchesEqual) {
...
@@ -2053,7 +2053,7 @@ TEST(GlobalWideStrEqTest, MatchesEqual) {
Matcher
<
const
wchar_t
*>
m
=
StrEq
(
::
wstring
(
L"Hello"
));
Matcher
<
const
wchar_t
*>
m
=
StrEq
(
::
wstring
(
L"Hello"
));
EXPECT_TRUE
(
m
.
Matches
(
L"Hello"
));
EXPECT_TRUE
(
m
.
Matches
(
L"Hello"
));
EXPECT_FALSE
(
m
.
Matches
(
L"hello"
));
EXPECT_FALSE
(
m
.
Matches
(
L"hello"
));
EXPECT_FALSE
(
m
.
Matches
(
NULL
));
EXPECT_FALSE
(
m
.
Matches
(
nullptr
));
Matcher
<
const
::
wstring
&>
m2
=
StrEq
(
L"Hello"
);
Matcher
<
const
::
wstring
&>
m2
=
StrEq
(
L"Hello"
);
EXPECT_TRUE
(
m2
.
Matches
(
L"Hello"
));
EXPECT_TRUE
(
m2
.
Matches
(
L"Hello"
));
...
@@ -2093,7 +2093,7 @@ TEST(GlobalWideStrEqTest, CanDescribeSelf) {
...
@@ -2093,7 +2093,7 @@ TEST(GlobalWideStrEqTest, CanDescribeSelf) {
TEST
(
GlobalWideStrNeTest
,
MatchesUnequalString
)
{
TEST
(
GlobalWideStrNeTest
,
MatchesUnequalString
)
{
Matcher
<
const
wchar_t
*>
m
=
StrNe
(
L"Hello"
);
Matcher
<
const
wchar_t
*>
m
=
StrNe
(
L"Hello"
);
EXPECT_TRUE
(
m
.
Matches
(
L""
));
EXPECT_TRUE
(
m
.
Matches
(
L""
));
EXPECT_TRUE
(
m
.
Matches
(
NULL
));
EXPECT_TRUE
(
m
.
Matches
(
nullptr
));
EXPECT_FALSE
(
m
.
Matches
(
L"Hello"
));
EXPECT_FALSE
(
m
.
Matches
(
L"Hello"
));
Matcher
<
::
wstring
>
m2
=
StrNe
(
::
wstring
(
L"Hello"
));
Matcher
<
::
wstring
>
m2
=
StrNe
(
::
wstring
(
L"Hello"
));
...
@@ -2111,7 +2111,7 @@ TEST(GlobalWideStrCaseEqTest, MatchesEqualStringIgnoringCase) {
...
@@ -2111,7 +2111,7 @@ TEST(GlobalWideStrCaseEqTest, MatchesEqualStringIgnoringCase) {
EXPECT_TRUE
(
m
.
Matches
(
L"Hello"
));
EXPECT_TRUE
(
m
.
Matches
(
L"Hello"
));
EXPECT_TRUE
(
m
.
Matches
(
L"hello"
));
EXPECT_TRUE
(
m
.
Matches
(
L"hello"
));
EXPECT_FALSE
(
m
.
Matches
(
L"Hi"
));
EXPECT_FALSE
(
m
.
Matches
(
L"Hi"
));
EXPECT_FALSE
(
m
.
Matches
(
NULL
));
EXPECT_FALSE
(
m
.
Matches
(
nullptr
));
Matcher
<
const
::
wstring
&>
m2
=
StrCaseEq
(
L"Hello"
);
Matcher
<
const
::
wstring
&>
m2
=
StrCaseEq
(
L"Hello"
);
EXPECT_TRUE
(
m2
.
Matches
(
L"hello"
));
EXPECT_TRUE
(
m2
.
Matches
(
L"hello"
));
...
@@ -2151,7 +2151,7 @@ TEST(GlobalWideStrCaseEqTest, CanDescribeSelf) {
...
@@ -2151,7 +2151,7 @@ TEST(GlobalWideStrCaseEqTest, CanDescribeSelf) {
TEST
(
GlobalWideStrCaseNeTest
,
MatchesUnequalStringIgnoringCase
)
{
TEST
(
GlobalWideStrCaseNeTest
,
MatchesUnequalStringIgnoringCase
)
{
Matcher
<
const
wchar_t
*>
m
=
StrCaseNe
(
L"Hello"
);
Matcher
<
const
wchar_t
*>
m
=
StrCaseNe
(
L"Hello"
);
EXPECT_TRUE
(
m
.
Matches
(
L"Hi"
));
EXPECT_TRUE
(
m
.
Matches
(
L"Hi"
));
EXPECT_TRUE
(
m
.
Matches
(
NULL
));
EXPECT_TRUE
(
m
.
Matches
(
nullptr
));
EXPECT_FALSE
(
m
.
Matches
(
L"Hello"
));
EXPECT_FALSE
(
m
.
Matches
(
L"Hello"
));
EXPECT_FALSE
(
m
.
Matches
(
L"hello"
));
EXPECT_FALSE
(
m
.
Matches
(
L"hello"
));
...
@@ -2181,12 +2181,12 @@ TEST(GlobalWideHasSubstrTest, WorksForCStrings) {
...
@@ -2181,12 +2181,12 @@ TEST(GlobalWideHasSubstrTest, WorksForCStrings) {
const
Matcher
<
wchar_t
*>
m1
=
HasSubstr
(
L"foo"
);
const
Matcher
<
wchar_t
*>
m1
=
HasSubstr
(
L"foo"
);
EXPECT_TRUE
(
m1
.
Matches
(
const_cast
<
wchar_t
*>
(
L"I love food."
)));
EXPECT_TRUE
(
m1
.
Matches
(
const_cast
<
wchar_t
*>
(
L"I love food."
)));
EXPECT_FALSE
(
m1
.
Matches
(
const_cast
<
wchar_t
*>
(
L"tofo"
)));
EXPECT_FALSE
(
m1
.
Matches
(
const_cast
<
wchar_t
*>
(
L"tofo"
)));
EXPECT_FALSE
(
m1
.
Matches
(
NULL
));
EXPECT_FALSE
(
m1
.
Matches
(
nullptr
));
const
Matcher
<
const
wchar_t
*>
m2
=
HasSubstr
(
L"foo"
);
const
Matcher
<
const
wchar_t
*>
m2
=
HasSubstr
(
L"foo"
);
EXPECT_TRUE
(
m2
.
Matches
(
L"I love food."
));
EXPECT_TRUE
(
m2
.
Matches
(
L"I love food."
));
EXPECT_FALSE
(
m2
.
Matches
(
L"tofo"
));
EXPECT_FALSE
(
m2
.
Matches
(
L"tofo"
));
EXPECT_FALSE
(
m2
.
Matches
(
NULL
));
EXPECT_FALSE
(
m2
.
Matches
(
nullptr
));
}
}
// Tests that HasSubstr(s) describes itself properly.
// Tests that HasSubstr(s) describes itself properly.
...
@@ -2201,7 +2201,7 @@ TEST(GlobalWideStartsWithTest, MatchesStringWithGivenPrefix) {
...
@@ -2201,7 +2201,7 @@ TEST(GlobalWideStartsWithTest, MatchesStringWithGivenPrefix) {
const
Matcher
<
const
wchar_t
*>
m1
=
StartsWith
(
::
wstring
(
L""
));
const
Matcher
<
const
wchar_t
*>
m1
=
StartsWith
(
::
wstring
(
L""
));
EXPECT_TRUE
(
m1
.
Matches
(
L"Hi"
));
EXPECT_TRUE
(
m1
.
Matches
(
L"Hi"
));
EXPECT_TRUE
(
m1
.
Matches
(
L""
));
EXPECT_TRUE
(
m1
.
Matches
(
L""
));
EXPECT_FALSE
(
m1
.
Matches
(
NULL
));
EXPECT_FALSE
(
m1
.
Matches
(
nullptr
));
const
Matcher
<
const
::
wstring
&>
m2
=
StartsWith
(
L"Hi"
);
const
Matcher
<
const
::
wstring
&>
m2
=
StartsWith
(
L"Hi"
);
EXPECT_TRUE
(
m2
.
Matches
(
L"Hi"
));
EXPECT_TRUE
(
m2
.
Matches
(
L"Hi"
));
...
@@ -2222,7 +2222,7 @@ TEST(GlobalWideEndsWithTest, MatchesStringWithGivenSuffix) {
...
@@ -2222,7 +2222,7 @@ TEST(GlobalWideEndsWithTest, MatchesStringWithGivenSuffix) {
const
Matcher
<
const
wchar_t
*>
m1
=
EndsWith
(
L""
);
const
Matcher
<
const
wchar_t
*>
m1
=
EndsWith
(
L""
);
EXPECT_TRUE
(
m1
.
Matches
(
L"Hi"
));
EXPECT_TRUE
(
m1
.
Matches
(
L"Hi"
));
EXPECT_TRUE
(
m1
.
Matches
(
L""
));
EXPECT_TRUE
(
m1
.
Matches
(
L""
));
EXPECT_FALSE
(
m1
.
Matches
(
NULL
));
EXPECT_FALSE
(
m1
.
Matches
(
nullptr
));
const
Matcher
<
const
::
wstring
&>
m2
=
EndsWith
(
::
wstring
(
L"Hi"
));
const
Matcher
<
const
::
wstring
&>
m2
=
EndsWith
(
::
wstring
(
L"Hi"
));
EXPECT_TRUE
(
m2
.
Matches
(
L"Hi"
));
EXPECT_TRUE
(
m2
.
Matches
(
L"Hi"
));
...
@@ -3701,7 +3701,7 @@ TEST(PointeeTest, RawPointer) {
...
@@ -3701,7 +3701,7 @@ TEST(PointeeTest, RawPointer) {
EXPECT_TRUE
(
m
.
Matches
(
&
n
));
EXPECT_TRUE
(
m
.
Matches
(
&
n
));
n
=
-
1
;
n
=
-
1
;
EXPECT_FALSE
(
m
.
Matches
(
&
n
));
EXPECT_FALSE
(
m
.
Matches
(
&
n
));
EXPECT_FALSE
(
m
.
Matches
(
NULL
));
EXPECT_FALSE
(
m
.
Matches
(
nullptr
));
}
}
TEST
(
PointeeTest
,
RawPointerToConst
)
{
TEST
(
PointeeTest
,
RawPointerToConst
)
{
...
@@ -3711,7 +3711,7 @@ TEST(PointeeTest, RawPointerToConst) {
...
@@ -3711,7 +3711,7 @@ TEST(PointeeTest, RawPointerToConst) {
EXPECT_TRUE
(
m
.
Matches
(
&
x
));
EXPECT_TRUE
(
m
.
Matches
(
&
x
));
x
=
-
1
;
x
=
-
1
;
EXPECT_FALSE
(
m
.
Matches
(
&
x
));
EXPECT_FALSE
(
m
.
Matches
(
&
x
));
EXPECT_FALSE
(
m
.
Matches
(
NULL
));
EXPECT_FALSE
(
m
.
Matches
(
nullptr
));
}
}
TEST
(
PointeeTest
,
ReferenceToConstRawPointer
)
{
TEST
(
PointeeTest
,
ReferenceToConstRawPointer
)
{
...
@@ -3721,7 +3721,7 @@ TEST(PointeeTest, ReferenceToConstRawPointer) {
...
@@ -3721,7 +3721,7 @@ TEST(PointeeTest, ReferenceToConstRawPointer) {
EXPECT_TRUE
(
m
.
Matches
(
&
n
));
EXPECT_TRUE
(
m
.
Matches
(
&
n
));
n
=
-
1
;
n
=
-
1
;
EXPECT_FALSE
(
m
.
Matches
(
&
n
));
EXPECT_FALSE
(
m
.
Matches
(
&
n
));
EXPECT_FALSE
(
m
.
Matches
(
NULL
));
EXPECT_FALSE
(
m
.
Matches
(
nullptr
));
}
}
TEST
(
PointeeTest
,
ReferenceToNonConstRawPointer
)
{
TEST
(
PointeeTest
,
ReferenceToNonConstRawPointer
)
{
...
@@ -3732,7 +3732,7 @@ TEST(PointeeTest, ReferenceToNonConstRawPointer) {
...
@@ -3732,7 +3732,7 @@ TEST(PointeeTest, ReferenceToNonConstRawPointer) {
EXPECT_TRUE
(
m
.
Matches
(
p
));
EXPECT_TRUE
(
m
.
Matches
(
p
));
x
=
-
1
;
x
=
-
1
;
EXPECT_FALSE
(
m
.
Matches
(
p
));
EXPECT_FALSE
(
m
.
Matches
(
p
));
p
=
NULL
;
p
=
nullptr
;
EXPECT_FALSE
(
m
.
Matches
(
p
));
EXPECT_FALSE
(
m
.
Matches
(
p
));
}
}
...
@@ -3771,7 +3771,7 @@ TEST(WhenDynamicCastToTest, WrongTypes) {
...
@@ -3771,7 +3771,7 @@ TEST(WhenDynamicCastToTest, WrongTypes) {
TEST
(
WhenDynamicCastToTest
,
AlreadyNull
)
{
TEST
(
WhenDynamicCastToTest
,
AlreadyNull
)
{
// Already NULL.
// Already NULL.
Base
*
as_base_ptr
=
NULL
;
Base
*
as_base_ptr
=
nullptr
;
EXPECT_THAT
(
as_base_ptr
,
WhenDynamicCastTo
<
Derived
*>
(
IsNull
()));
EXPECT_THAT
(
as_base_ptr
,
WhenDynamicCastTo
<
Derived
*>
(
IsNull
()));
}
}
...
@@ -3807,7 +3807,7 @@ TEST(WhenDynamicCastToTest, Describe) {
...
@@ -3807,7 +3807,7 @@ TEST(WhenDynamicCastToTest, Describe) {
TEST
(
WhenDynamicCastToTest
,
Explain
)
{
TEST
(
WhenDynamicCastToTest
,
Explain
)
{
Matcher
<
Base
*>
matcher
=
WhenDynamicCastTo
<
Derived
*>
(
Pointee
(
_
));
Matcher
<
Base
*>
matcher
=
WhenDynamicCastTo
<
Derived
*>
(
Pointee
(
_
));
Base
*
null
=
NULL
;
Base
*
null
=
nullptr
;
EXPECT_THAT
(
Explain
(
matcher
,
null
),
HasSubstr
(
"NULL"
));
EXPECT_THAT
(
Explain
(
matcher
,
null
),
HasSubstr
(
"NULL"
));
Derived
derived
;
Derived
derived
;
EXPECT_TRUE
(
matcher
.
Matches
(
&
derived
));
EXPECT_TRUE
(
matcher
.
Matches
(
&
derived
));
...
@@ -3868,7 +3868,7 @@ TEST(PointeeTest, WorksWithConstPropagatingPointers) {
...
@@ -3868,7 +3868,7 @@ TEST(PointeeTest, WorksWithConstPropagatingPointers) {
TEST
(
PointeeTest
,
NeverMatchesNull
)
{
TEST
(
PointeeTest
,
NeverMatchesNull
)
{
const
Matcher
<
const
char
*>
m
=
Pointee
(
_
);
const
Matcher
<
const
char
*>
m
=
Pointee
(
_
);
EXPECT_FALSE
(
m
.
Matches
(
NULL
));
EXPECT_FALSE
(
m
.
Matches
(
nullptr
));
}
}
// Tests that we can write Pointee(value) instead of Pointee(Eq(value)).
// Tests that we can write Pointee(value) instead of Pointee(Eq(value)).
...
@@ -3879,7 +3879,7 @@ TEST(PointeeTest, MatchesAgainstAValue) {
...
@@ -3879,7 +3879,7 @@ TEST(PointeeTest, MatchesAgainstAValue) {
EXPECT_TRUE
(
m
.
Matches
(
&
n
));
EXPECT_TRUE
(
m
.
Matches
(
&
n
));
n
=
-
1
;
n
=
-
1
;
EXPECT_FALSE
(
m
.
Matches
(
&
n
));
EXPECT_FALSE
(
m
.
Matches
(
&
n
));
EXPECT_FALSE
(
m
.
Matches
(
NULL
));
EXPECT_FALSE
(
m
.
Matches
(
nullptr
));
}
}
TEST
(
PointeeTest
,
CanDescribeSelf
)
{
TEST
(
PointeeTest
,
CanDescribeSelf
)
{
...
@@ -3892,7 +3892,7 @@ TEST(PointeeTest, CanDescribeSelf) {
...
@@ -3892,7 +3892,7 @@ TEST(PointeeTest, CanDescribeSelf) {
TEST
(
PointeeTest
,
CanExplainMatchResult
)
{
TEST
(
PointeeTest
,
CanExplainMatchResult
)
{
const
Matcher
<
const
std
::
string
*>
m
=
Pointee
(
StartsWith
(
"Hi"
));
const
Matcher
<
const
std
::
string
*>
m
=
Pointee
(
StartsWith
(
"Hi"
));
EXPECT_EQ
(
""
,
Explain
(
m
,
static_cast
<
const
std
::
string
*>
(
NULL
)));
EXPECT_EQ
(
""
,
Explain
(
m
,
static_cast
<
const
std
::
string
*>
(
nullptr
)));
const
Matcher
<
long
*>
m2
=
Pointee
(
GreaterThan
(
1
));
// NOLINT
const
Matcher
<
long
*>
m2
=
Pointee
(
GreaterThan
(
1
));
// NOLINT
long
n
=
3
;
// NOLINT
long
n
=
3
;
// NOLINT
...
@@ -3929,7 +3929,7 @@ MATCHER_P(UncopyableIs, inner_matcher, "") {
...
@@ -3929,7 +3929,7 @@ MATCHER_P(UncopyableIs, inner_matcher, "") {
// A user-defined struct for testing Field().
// A user-defined struct for testing Field().
struct
AStruct
{
struct
AStruct
{
AStruct
()
:
x
(
0
),
y
(
1.0
),
z
(
5
),
p
(
NULL
)
{}
AStruct
()
:
x
(
0
),
y
(
1.0
),
z
(
5
),
p
(
nullptr
)
{}
AStruct
(
const
AStruct
&
rhs
)
AStruct
(
const
AStruct
&
rhs
)
:
x
(
rhs
.
x
),
y
(
rhs
.
y
),
z
(
rhs
.
z
.
value
()),
p
(
rhs
.
p
)
{}
:
x
(
rhs
.
x
),
y
(
rhs
.
y
),
z
(
rhs
.
z
.
value
()),
p
(
rhs
.
p
)
{}
...
@@ -3990,7 +3990,7 @@ TEST(FieldTest, WorksForUncopyableField) {
...
@@ -3990,7 +3990,7 @@ TEST(FieldTest, WorksForUncopyableField) {
// Tests that Field(&Foo::field, ...) works when field is a pointer.
// Tests that Field(&Foo::field, ...) works when field is a pointer.
TEST
(
FieldTest
,
WorksForPointerField
)
{
TEST
(
FieldTest
,
WorksForPointerField
)
{
// Matching against NULL.
// Matching against NULL.
Matcher
<
AStruct
>
m
=
Field
(
&
AStruct
::
p
,
static_cast
<
const
char
*>
(
NULL
));
Matcher
<
AStruct
>
m
=
Field
(
&
AStruct
::
p
,
static_cast
<
const
char
*>
(
nullptr
));
AStruct
a
;
AStruct
a
;
EXPECT_TRUE
(
m
.
Matches
(
a
));
EXPECT_TRUE
(
m
.
Matches
(
a
));
a
.
p
=
"hi"
;
a
.
p
=
"hi"
;
...
@@ -4116,7 +4116,7 @@ TEST(FieldForPointerTest, WorksForReferenceToConstPointer) {
...
@@ -4116,7 +4116,7 @@ TEST(FieldForPointerTest, WorksForReferenceToConstPointer) {
// Tests that Field() does not match the NULL pointer.
// Tests that Field() does not match the NULL pointer.
TEST
(
FieldForPointerTest
,
DoesNotMatchNull
)
{
TEST
(
FieldForPointerTest
,
DoesNotMatchNull
)
{
Matcher
<
const
AStruct
*>
m
=
Field
(
&
AStruct
::
x
,
_
);
Matcher
<
const
AStruct
*>
m
=
Field
(
&
AStruct
::
x
,
_
);
EXPECT_FALSE
(
m
.
Matches
(
NULL
));
EXPECT_FALSE
(
m
.
Matches
(
nullptr
));
}
}
// Tests that Field(&Foo::field, ...) works when the argument's type
// Tests that Field(&Foo::field, ...) works when the argument's type
...
@@ -4154,7 +4154,7 @@ TEST(FieldForPointerTest, CanExplainMatchResult) {
...
@@ -4154,7 +4154,7 @@ TEST(FieldForPointerTest, CanExplainMatchResult) {
AStruct
a
;
AStruct
a
;
a
.
x
=
1
;
a
.
x
=
1
;
EXPECT_EQ
(
""
,
Explain
(
m
,
static_cast
<
const
AStruct
*>
(
NULL
)));
EXPECT_EQ
(
""
,
Explain
(
m
,
static_cast
<
const
AStruct
*>
(
nullptr
)));
EXPECT_EQ
(
"which points to an object whose given field is 1"
+
OfType
(
"int"
),
EXPECT_EQ
(
"which points to an object whose given field is 1"
+
OfType
(
"int"
),
Explain
(
m
,
&
a
));
Explain
(
m
,
&
a
));
...
@@ -4168,7 +4168,7 @@ TEST(FieldForPointerTest, CanExplainMatchResultWithFieldName) {
...
@@ -4168,7 +4168,7 @@ TEST(FieldForPointerTest, CanExplainMatchResultWithFieldName) {
AStruct
a
;
AStruct
a
;
a
.
x
=
1
;
a
.
x
=
1
;
EXPECT_EQ
(
""
,
Explain
(
m
,
static_cast
<
const
AStruct
*>
(
NULL
)));
EXPECT_EQ
(
""
,
Explain
(
m
,
static_cast
<
const
AStruct
*>
(
nullptr
)));
EXPECT_EQ
(
EXPECT_EQ
(
"which points to an object whose field `field_name` is 1"
+
OfType
(
"int"
),
"which points to an object whose field `field_name` is 1"
+
OfType
(
"int"
),
Explain
(
m
,
&
a
));
Explain
(
m
,
&
a
));
...
@@ -4413,7 +4413,7 @@ TEST(PropertyForPointerTest, WorksForReferenceToConstPointer) {
...
@@ -4413,7 +4413,7 @@ TEST(PropertyForPointerTest, WorksForReferenceToConstPointer) {
// Tests that Property() does not match the NULL pointer.
// Tests that Property() does not match the NULL pointer.
TEST
(
PropertyForPointerTest
,
WorksForReferenceToNonConstProperty
)
{
TEST
(
PropertyForPointerTest
,
WorksForReferenceToNonConstProperty
)
{
Matcher
<
const
AClass
*>
m
=
Property
(
&
AClass
::
x
,
_
);
Matcher
<
const
AClass
*>
m
=
Property
(
&
AClass
::
x
,
_
);
EXPECT_FALSE
(
m
.
Matches
(
NULL
));
EXPECT_FALSE
(
m
.
Matches
(
nullptr
));
}
}
// Tests that Property(&Foo::property, ...) works when the argument's
// Tests that Property(&Foo::property, ...) works when the argument's
...
@@ -4454,7 +4454,7 @@ TEST(PropertyForPointerTest, CanExplainMatchResult) {
...
@@ -4454,7 +4454,7 @@ TEST(PropertyForPointerTest, CanExplainMatchResult) {
AClass
a
;
AClass
a
;
a
.
set_n
(
1
);
a
.
set_n
(
1
);
EXPECT_EQ
(
""
,
Explain
(
m
,
static_cast
<
const
AClass
*>
(
NULL
)));
EXPECT_EQ
(
""
,
Explain
(
m
,
static_cast
<
const
AClass
*>
(
nullptr
)));
EXPECT_EQ
(
EXPECT_EQ
(
"which points to an object whose given property is 1"
+
OfType
(
"int"
),
"which points to an object whose given property is 1"
+
OfType
(
"int"
),
Explain
(
m
,
&
a
));
Explain
(
m
,
&
a
));
...
@@ -4470,7 +4470,7 @@ TEST(PropertyForPointerTest, CanExplainMatchResultWithPropertyName) {
...
@@ -4470,7 +4470,7 @@ TEST(PropertyForPointerTest, CanExplainMatchResultWithPropertyName) {
AClass
a
;
AClass
a
;
a
.
set_n
(
1
);
a
.
set_n
(
1
);
EXPECT_EQ
(
""
,
Explain
(
m
,
static_cast
<
const
AClass
*>
(
NULL
)));
EXPECT_EQ
(
""
,
Explain
(
m
,
static_cast
<
const
AClass
*>
(
nullptr
)));
EXPECT_EQ
(
"which points to an object whose property `fancy_name` is 1"
+
EXPECT_EQ
(
"which points to an object whose property `fancy_name` is 1"
+
OfType
(
"int"
),
OfType
(
"int"
),
Explain
(
m
,
&
a
));
Explain
(
m
,
&
a
));
...
@@ -4581,7 +4581,7 @@ TEST(ResultOfTest, WorksForCompatibleMatcherTypes) {
...
@@ -4581,7 +4581,7 @@ TEST(ResultOfTest, WorksForCompatibleMatcherTypes) {
// a NULL function pointer.
// a NULL function pointer.
TEST
(
ResultOfDeathTest
,
DiesOnNullFunctionPointers
)
{
TEST
(
ResultOfDeathTest
,
DiesOnNullFunctionPointers
)
{
EXPECT_DEATH_IF_SUPPORTED
(
EXPECT_DEATH_IF_SUPPORTED
(
ResultOf
(
static_cast
<
std
::
string
(
*
)(
int
dummy
)
>
(
NULL
),
ResultOf
(
static_cast
<
std
::
string
(
*
)(
int
dummy
)
>
(
nullptr
),
Eq
(
std
::
string
(
"foo"
))),
Eq
(
std
::
string
(
"foo"
))),
"NULL function pointer is passed into ResultOf
\\
(
\\
)
\\
."
);
"NULL function pointer is passed into ResultOf
\\
(
\\
)
\\
."
);
}
}
...
@@ -6181,7 +6181,7 @@ TEST_P(BipartiteRandomTest, LargerNets) {
...
@@ -6181,7 +6181,7 @@ TEST_P(BipartiteRandomTest, LargerNets) {
testing
::
internal
::
Int32
seed
=
GTEST_FLAG
(
random_seed
);
testing
::
internal
::
Int32
seed
=
GTEST_FLAG
(
random_seed
);
if
(
seed
==
0
)
{
if
(
seed
==
0
)
{
seed
=
static_cast
<
testing
::
internal
::
Int32
>
(
time
(
NULL
));
seed
=
static_cast
<
testing
::
internal
::
Int32
>
(
time
(
nullptr
));
}
}
for
(;
iters
>
0
;
--
iters
,
++
seed
)
{
for
(;
iters
>
0
;
--
iters
,
++
seed
)
{
...
@@ -6684,7 +6684,7 @@ class SampleVariantIntString {
...
@@ -6684,7 +6684,7 @@ class SampleVariantIntString {
template
<
typename
T
>
template
<
typename
T
>
friend
const
T
&
get
(
const
SampleVariantIntString
&
value
)
{
friend
const
T
&
get
(
const
SampleVariantIntString
&
value
)
{
return
value
.
get_impl
(
static_cast
<
T
*>
(
NULL
));
return
value
.
get_impl
(
static_cast
<
T
*>
(
nullptr
));
}
}
private:
private:
...
@@ -6743,7 +6743,7 @@ class SampleAnyType {
...
@@ -6743,7 +6743,7 @@ class SampleAnyType {
template
<
typename
T
>
template
<
typename
T
>
friend
const
T
*
any_cast
(
const
SampleAnyType
*
any
)
{
friend
const
T
*
any_cast
(
const
SampleAnyType
*
any
)
{
return
any
->
get_impl
(
static_cast
<
T
*>
(
NULL
));
return
any
->
get_impl
(
static_cast
<
T
*>
(
nullptr
));
}
}
private:
private:
...
@@ -6751,9 +6751,9 @@ class SampleAnyType {
...
@@ -6751,9 +6751,9 @@ class SampleAnyType {
int
i_
;
int
i_
;
std
::
string
s_
;
std
::
string
s_
;
const
int
*
get_impl
(
int
*
)
const
{
return
index_
==
0
?
&
i_
:
NULL
;
}
const
int
*
get_impl
(
int
*
)
const
{
return
index_
==
0
?
&
i_
:
nullptr
;
}
const
std
::
string
*
get_impl
(
std
::
string
*
)
const
{
const
std
::
string
*
get_impl
(
std
::
string
*
)
const
{
return
index_
==
1
?
&
s_
:
NULL
;
return
index_
==
1
?
&
s_
:
nullptr
;
}
}
};
};
...
...
googlemock/test/gmock-more-actions_test.cc
View file @
4327d95b
...
@@ -333,7 +333,8 @@ TEST(InvokeTest, FunctionWithUnusedParameters) {
...
@@ -333,7 +333,8 @@ TEST(InvokeTest, FunctionWithUnusedParameters) {
Action
<
int
(
int
,
int
,
bool
,
int
*
)
>
a2
=
Action
<
int
(
int
,
int
,
bool
,
int
*
)
>
a2
=
Invoke
(
SumOfFirst2
);
Invoke
(
SumOfFirst2
);
EXPECT_EQ
(
23
,
a2
.
Perform
(
make_tuple
(
20
,
3
,
true
,
static_cast
<
int
*>
(
NULL
))));
EXPECT_EQ
(
23
,
a2
.
Perform
(
make_tuple
(
20
,
3
,
true
,
static_cast
<
int
*>
(
nullptr
))));
}
}
// Tests using Invoke() with methods with parameters declared as Unused.
// Tests using Invoke() with methods with parameters declared as Unused.
...
...
googlemock/test/gmock-spec-builders_test.cc
View file @
4327d95b
...
@@ -2041,7 +2041,7 @@ TEST(FunctionCallMessageTest,
...
@@ -2041,7 +2041,7 @@ TEST(FunctionCallMessageTest,
GMOCK_FLAG
(
verbose
)
=
kWarningVerbosity
;
GMOCK_FLAG
(
verbose
)
=
kWarningVerbosity
;
NaggyMock
<
MockC
>
c
;
NaggyMock
<
MockC
>
c
;
CaptureStdout
();
CaptureStdout
();
c
.
VoidMethod
(
false
,
5
,
"Hi"
,
NULL
,
Printable
(),
Unprintable
());
c
.
VoidMethod
(
false
,
5
,
"Hi"
,
nullptr
,
Printable
(),
Unprintable
());
const
std
::
string
output
=
GetCapturedStdout
();
const
std
::
string
output
=
GetCapturedStdout
();
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"GMOCK WARNING"
,
output
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"GMOCK WARNING"
,
output
);
EXPECT_PRED_FORMAT2
(
IsNotSubstring
,
"Stack trace:"
,
output
);
EXPECT_PRED_FORMAT2
(
IsNotSubstring
,
"Stack trace:"
,
output
);
...
@@ -2055,7 +2055,7 @@ TEST(FunctionCallMessageTest,
...
@@ -2055,7 +2055,7 @@ TEST(FunctionCallMessageTest,
GMOCK_FLAG
(
verbose
)
=
kInfoVerbosity
;
GMOCK_FLAG
(
verbose
)
=
kInfoVerbosity
;
NaggyMock
<
MockC
>
c
;
NaggyMock
<
MockC
>
c
;
CaptureStdout
();
CaptureStdout
();
c
.
VoidMethod
(
false
,
5
,
"Hi"
,
NULL
,
Printable
(),
Unprintable
());
c
.
VoidMethod
(
false
,
5
,
"Hi"
,
nullptr
,
Printable
(),
Unprintable
());
const
std
::
string
output
=
GetCapturedStdout
();
const
std
::
string
output
=
GetCapturedStdout
();
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"GMOCK WARNING"
,
output
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"GMOCK WARNING"
,
output
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"Stack trace:"
,
output
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"Stack trace:"
,
output
);
...
@@ -2098,7 +2098,7 @@ TEST(FunctionCallMessageTest,
...
@@ -2098,7 +2098,7 @@ TEST(FunctionCallMessageTest,
// A void mock function.
// A void mock function.
NaggyMock
<
MockC
>
c
;
NaggyMock
<
MockC
>
c
;
CaptureStdout
();
CaptureStdout
();
c
.
VoidMethod
(
false
,
5
,
"Hi"
,
NULL
,
Printable
(),
Unprintable
());
c
.
VoidMethod
(
false
,
5
,
"Hi"
,
nullptr
,
Printable
(),
Unprintable
());
const
std
::
string
output2
=
GetCapturedStdout
();
const
std
::
string
output2
=
GetCapturedStdout
();
EXPECT_THAT
(
output2
.
c_str
(),
EXPECT_THAT
(
output2
.
c_str
(),
ContainsRegex
(
ContainsRegex
(
...
...
googlemock/test/gmock_link_test.h
View file @
4327d95b
...
@@ -248,7 +248,7 @@ TEST(LinkTest, TestReturnVoid) {
...
@@ -248,7 +248,7 @@ TEST(LinkTest, TestReturnVoid) {
Mock
mock
;
Mock
mock
;
EXPECT_CALL
(
mock
,
VoidFromString
(
_
)).
WillOnce
(
Return
());
EXPECT_CALL
(
mock
,
VoidFromString
(
_
)).
WillOnce
(
Return
());
mock
.
VoidFromString
(
NULL
);
mock
.
VoidFromString
(
nullptr
);
}
}
// Tests the linkage of the Return action.
// Tests the linkage of the Return action.
...
@@ -257,7 +257,7 @@ TEST(LinkTest, TestReturn) {
...
@@ -257,7 +257,7 @@ TEST(LinkTest, TestReturn) {
char
ch
=
'x'
;
char
ch
=
'x'
;
EXPECT_CALL
(
mock
,
StringFromString
(
_
)).
WillOnce
(
Return
(
&
ch
));
EXPECT_CALL
(
mock
,
StringFromString
(
_
)).
WillOnce
(
Return
(
&
ch
));
mock
.
StringFromString
(
NULL
);
mock
.
StringFromString
(
nullptr
);
}
}
// Tests the linkage of the ReturnNull action.
// Tests the linkage of the ReturnNull action.
...
@@ -265,7 +265,7 @@ TEST(LinkTest, TestReturnNull) {
...
@@ -265,7 +265,7 @@ TEST(LinkTest, TestReturnNull) {
Mock
mock
;
Mock
mock
;
EXPECT_CALL
(
mock
,
VoidFromString
(
_
)).
WillOnce
(
Return
());
EXPECT_CALL
(
mock
,
VoidFromString
(
_
)).
WillOnce
(
Return
());
mock
.
VoidFromString
(
NULL
);
mock
.
VoidFromString
(
nullptr
);
}
}
// Tests the linkage of the ReturnRef action.
// Tests the linkage of the ReturnRef action.
...
@@ -274,7 +274,7 @@ TEST(LinkTest, TestReturnRef) {
...
@@ -274,7 +274,7 @@ TEST(LinkTest, TestReturnRef) {
int
n
=
42
;
int
n
=
42
;
EXPECT_CALL
(
mock
,
IntRefFromString
(
_
)).
WillOnce
(
ReturnRef
(
n
));
EXPECT_CALL
(
mock
,
IntRefFromString
(
_
)).
WillOnce
(
ReturnRef
(
n
));
mock
.
IntRefFromString
(
NULL
);
mock
.
IntRefFromString
(
nullptr
);
}
}
// Tests the linkage of the Assign action.
// Tests the linkage of the Assign action.
...
@@ -283,7 +283,7 @@ TEST(LinkTest, TestAssign) {
...
@@ -283,7 +283,7 @@ TEST(LinkTest, TestAssign) {
char
ch
=
'x'
;
char
ch
=
'x'
;
EXPECT_CALL
(
mock
,
VoidFromString
(
_
)).
WillOnce
(
Assign
(
&
ch
,
'y'
));
EXPECT_CALL
(
mock
,
VoidFromString
(
_
)).
WillOnce
(
Assign
(
&
ch
,
'y'
));
mock
.
VoidFromString
(
NULL
);
mock
.
VoidFromString
(
nullptr
);
}
}
// Tests the linkage of the SetArgPointee action.
// Tests the linkage of the SetArgPointee action.
...
@@ -314,7 +314,7 @@ TEST(LinkTest, TestSetErrnoAndReturn) {
...
@@ -314,7 +314,7 @@ TEST(LinkTest, TestSetErrnoAndReturn) {
int
saved_errno
=
errno
;
int
saved_errno
=
errno
;
EXPECT_CALL
(
mock
,
IntFromString
(
_
)).
WillOnce
(
SetErrnoAndReturn
(
1
,
-
1
));
EXPECT_CALL
(
mock
,
IntFromString
(
_
)).
WillOnce
(
SetErrnoAndReturn
(
1
,
-
1
));
mock
.
IntFromString
(
NULL
);
mock
.
IntFromString
(
nullptr
);
errno
=
saved_errno
;
errno
=
saved_errno
;
}
}
...
@@ -328,8 +328,8 @@ TEST(LinkTest, TestInvoke) {
...
@@ -328,8 +328,8 @@ TEST(LinkTest, TestInvoke) {
EXPECT_CALL
(
mock
,
VoidFromString
(
_
))
EXPECT_CALL
(
mock
,
VoidFromString
(
_
))
.
WillOnce
(
Invoke
(
&
InvokeHelper
::
StaticVoidFromString
))
.
WillOnce
(
Invoke
(
&
InvokeHelper
::
StaticVoidFromString
))
.
WillOnce
(
Invoke
(
&
test_invoke_helper
,
&
InvokeHelper
::
VoidFromString
));
.
WillOnce
(
Invoke
(
&
test_invoke_helper
,
&
InvokeHelper
::
VoidFromString
));
mock
.
VoidFromString
(
NULL
);
mock
.
VoidFromString
(
nullptr
);
mock
.
VoidFromString
(
NULL
);
mock
.
VoidFromString
(
nullptr
);
}
}
// Tests the linkage of the InvokeWithoutArgs action.
// Tests the linkage of the InvokeWithoutArgs action.
...
@@ -341,8 +341,8 @@ TEST(LinkTest, TestInvokeWithoutArgs) {
...
@@ -341,8 +341,8 @@ TEST(LinkTest, TestInvokeWithoutArgs) {
.
WillOnce
(
InvokeWithoutArgs
(
&
InvokeHelper
::
StaticVoidFromVoid
))
.
WillOnce
(
InvokeWithoutArgs
(
&
InvokeHelper
::
StaticVoidFromVoid
))
.
WillOnce
(
InvokeWithoutArgs
(
&
test_invoke_helper
,
.
WillOnce
(
InvokeWithoutArgs
(
&
test_invoke_helper
,
&
InvokeHelper
::
VoidFromVoid
));
&
InvokeHelper
::
VoidFromVoid
));
mock
.
VoidFromString
(
NULL
);
mock
.
VoidFromString
(
nullptr
);
mock
.
VoidFromString
(
NULL
);
mock
.
VoidFromString
(
nullptr
);
}
}
// Tests the linkage of the InvokeArgument action.
// Tests the linkage of the InvokeArgument action.
...
@@ -360,7 +360,7 @@ TEST(LinkTest, TestWithArg) {
...
@@ -360,7 +360,7 @@ TEST(LinkTest, TestWithArg) {
EXPECT_CALL
(
mock
,
VoidFromString
(
_
))
EXPECT_CALL
(
mock
,
VoidFromString
(
_
))
.
WillOnce
(
WithArg
<
0
>
(
Invoke
(
&
InvokeHelper
::
StaticVoidFromString
)));
.
WillOnce
(
WithArg
<
0
>
(
Invoke
(
&
InvokeHelper
::
StaticVoidFromString
)));
mock
.
VoidFromString
(
NULL
);
mock
.
VoidFromString
(
nullptr
);
}
}
// Tests the linkage of the WithArgs action.
// Tests the linkage of the WithArgs action.
...
@@ -369,7 +369,7 @@ TEST(LinkTest, TestWithArgs) {
...
@@ -369,7 +369,7 @@ TEST(LinkTest, TestWithArgs) {
EXPECT_CALL
(
mock
,
VoidFromString
(
_
))
EXPECT_CALL
(
mock
,
VoidFromString
(
_
))
.
WillOnce
(
WithArgs
<
0
>
(
Invoke
(
&
InvokeHelper
::
StaticVoidFromString
)));
.
WillOnce
(
WithArgs
<
0
>
(
Invoke
(
&
InvokeHelper
::
StaticVoidFromString
)));
mock
.
VoidFromString
(
NULL
);
mock
.
VoidFromString
(
nullptr
);
}
}
// Tests the linkage of the WithoutArgs action.
// Tests the linkage of the WithoutArgs action.
...
@@ -377,7 +377,7 @@ TEST(LinkTest, TestWithoutArgs) {
...
@@ -377,7 +377,7 @@ TEST(LinkTest, TestWithoutArgs) {
Mock
mock
;
Mock
mock
;
EXPECT_CALL
(
mock
,
VoidFromString
(
_
)).
WillOnce
(
WithoutArgs
(
Return
()));
EXPECT_CALL
(
mock
,
VoidFromString
(
_
)).
WillOnce
(
WithoutArgs
(
Return
()));
mock
.
VoidFromString
(
NULL
);
mock
.
VoidFromString
(
nullptr
);
}
}
// Tests the linkage of the DoAll action.
// Tests the linkage of the DoAll action.
...
@@ -405,7 +405,7 @@ TEST(LinkTest, TestIgnoreResult) {
...
@@ -405,7 +405,7 @@ TEST(LinkTest, TestIgnoreResult) {
Mock
mock
;
Mock
mock
;
EXPECT_CALL
(
mock
,
VoidFromString
(
_
)).
WillOnce
(
IgnoreResult
(
Return
(
42
)));
EXPECT_CALL
(
mock
,
VoidFromString
(
_
)).
WillOnce
(
IgnoreResult
(
Return
(
42
)));
mock
.
VoidFromString
(
NULL
);
mock
.
VoidFromString
(
nullptr
);
}
}
#if GTEST_HAS_EXCEPTIONS
#if GTEST_HAS_EXCEPTIONS
...
@@ -437,7 +437,7 @@ TEST(LinkTest, TestActionMacro) {
...
@@ -437,7 +437,7 @@ TEST(LinkTest, TestActionMacro) {
Mock
mock
;
Mock
mock
;
EXPECT_CALL
(
mock
,
IntFromString
(
_
)).
WillOnce
(
Return1
());
EXPECT_CALL
(
mock
,
IntFromString
(
_
)).
WillOnce
(
Return1
());
mock
.
IntFromString
(
NULL
);
mock
.
IntFromString
(
nullptr
);
}
}
// Tests the linkage of actions created using ACTION_P macro.
// Tests the linkage of actions created using ACTION_P macro.
...
@@ -449,7 +449,7 @@ TEST(LinkTest, TestActionPMacro) {
...
@@ -449,7 +449,7 @@ TEST(LinkTest, TestActionPMacro) {
Mock
mock
;
Mock
mock
;
EXPECT_CALL
(
mock
,
IntFromString
(
_
)).
WillOnce
(
ReturnArgument
(
42
));
EXPECT_CALL
(
mock
,
IntFromString
(
_
)).
WillOnce
(
ReturnArgument
(
42
));
mock
.
IntFromString
(
NULL
);
mock
.
IntFromString
(
nullptr
);
}
}
// Tests the linkage of actions created using ACTION_P2 macro.
// Tests the linkage of actions created using ACTION_P2 macro.
...
@@ -646,7 +646,7 @@ TEST(LinkTest, TestMatcherProperty) {
...
@@ -646,7 +646,7 @@ TEST(LinkTest, TestMatcherProperty) {
// Tests the linkage of the ResultOf matcher.
// Tests the linkage of the ResultOf matcher.
TEST
(
LinkTest
,
TestMatcherResultOf
)
{
TEST
(
LinkTest
,
TestMatcherResultOf
)
{
Matcher
<
char
*>
m
=
ResultOf
(
&
InvokeHelper
::
StaticIntFromString
,
Eq
(
1
));
Matcher
<
char
*>
m
=
ResultOf
(
&
InvokeHelper
::
StaticIntFromString
,
Eq
(
1
));
EXPECT_TRUE
(
m
.
Matches
(
NULL
));
EXPECT_TRUE
(
m
.
Matches
(
nullptr
));
}
}
// Tests the linkage of the ResultOf matcher.
// Tests the linkage of the ResultOf matcher.
...
@@ -660,7 +660,7 @@ TEST(LinkTest, TestMatcherPointee) {
...
@@ -660,7 +660,7 @@ TEST(LinkTest, TestMatcherPointee) {
// Tests the linkage of the Truly matcher.
// Tests the linkage of the Truly matcher.
TEST
(
LinkTest
,
TestMatcherTruly
)
{
TEST
(
LinkTest
,
TestMatcherTruly
)
{
Matcher
<
const
char
*>
m
=
Truly
(
&
InvokeHelper
::
StaticBoolFromString
);
Matcher
<
const
char
*>
m
=
Truly
(
&
InvokeHelper
::
StaticBoolFromString
);
EXPECT_TRUE
(
m
.
Matches
(
NULL
));
EXPECT_TRUE
(
m
.
Matches
(
nullptr
));
}
}
// Tests the linkage of the AllOf matcher.
// Tests the linkage of the AllOf matcher.
...
@@ -684,7 +684,7 @@ TEST(LinkTest, TestMatcherNot) {
...
@@ -684,7 +684,7 @@ TEST(LinkTest, TestMatcherNot) {
// Tests the linkage of the MatcherCast<T>() function.
// Tests the linkage of the MatcherCast<T>() function.
TEST
(
LinkTest
,
TestMatcherCast
)
{
TEST
(
LinkTest
,
TestMatcherCast
)
{
Matcher
<
const
char
*>
m
=
MatcherCast
<
const
char
*>
(
_
);
Matcher
<
const
char
*>
m
=
MatcherCast
<
const
char
*>
(
_
);
EXPECT_TRUE
(
m
.
Matches
(
NULL
));
EXPECT_TRUE
(
m
.
Matches
(
nullptr
));
}
}
#endif // GMOCK_TEST_GMOCK_LINK_TEST_H_
#endif // GMOCK_TEST_GMOCK_LINK_TEST_H_
googlemock/test/gmock_stress_test.cc
View file @
4327d95b
...
@@ -210,7 +210,7 @@ void TestConcurrentCallsOnSameObject(Dummy /* dummy */) {
...
@@ -210,7 +210,7 @@ void TestConcurrentCallsOnSameObject(Dummy /* dummy */) {
int
count1
=
0
;
int
count1
=
0
;
const
Helper1Param
param
=
{
&
foo
,
&
count1
};
const
Helper1Param
param
=
{
&
foo
,
&
count1
};
ThreadWithParam
<
Helper1Param
>*
const
t
=
ThreadWithParam
<
Helper1Param
>*
const
t
=
new
ThreadWithParam
<
Helper1Param
>
(
Helper1
,
param
,
NULL
);
new
ThreadWithParam
<
Helper1Param
>
(
Helper1
,
param
,
nullptr
);
int
count2
=
0
;
int
count2
=
0
;
const
Helper1Param
param2
=
{
&
foo
,
&
count2
};
const
Helper1Param
param2
=
{
&
foo
,
&
count2
};
...
@@ -264,7 +264,7 @@ void TestPartiallyOrderedExpectationsWithThreads(Dummy /* dummy */) {
...
@@ -264,7 +264,7 @@ void TestPartiallyOrderedExpectationsWithThreads(Dummy /* dummy */) {
foo
.
Bar
(
1
);
foo
.
Bar
(
1
);
ThreadWithParam
<
MockFoo
*>*
const
t
=
ThreadWithParam
<
MockFoo
*>*
const
t
=
new
ThreadWithParam
<
MockFoo
*>
(
Helper2
,
&
foo
,
NULL
);
new
ThreadWithParam
<
MockFoo
*>
(
Helper2
,
&
foo
,
nullptr
);
Helper2
(
&
foo
);
Helper2
(
&
foo
);
JoinAndDelete
(
t
);
JoinAndDelete
(
t
);
...
@@ -288,8 +288,8 @@ TEST(StressTest, CanUseGMockWithThreads) {
...
@@ -288,8 +288,8 @@ TEST(StressTest, CanUseGMockWithThreads) {
ThreadWithParam
<
Dummy
>*
threads
[
kTestThreads
]
=
{};
ThreadWithParam
<
Dummy
>*
threads
[
kTestThreads
]
=
{};
for
(
int
i
=
0
;
i
<
kTestThreads
;
i
++
)
{
for
(
int
i
=
0
;
i
<
kTestThreads
;
i
++
)
{
// Creates a thread to run the test function.
// Creates a thread to run the test function.
threads
[
i
]
=
threads
[
i
]
=
new
ThreadWithParam
<
Dummy
>
(
test_routines
[
i
%
kRoutines
],
new
ThreadWithParam
<
Dummy
>
(
test_routines
[
i
%
kRoutines
],
Dummy
(),
NULL
);
Dummy
(),
nullptr
);
GTEST_LOG_
(
INFO
)
<<
"Thread #"
<<
i
<<
" running . . ."
;
GTEST_LOG_
(
INFO
)
<<
"Thread #"
<<
i
<<
" running . . ."
;
}
}
...
...
googlemock/test/gmock_test.cc
View file @
4327d95b
...
@@ -64,59 +64,35 @@ void TestInitGoogleMock(const Char* (&argv)[M], const Char* (&new_argv)[N],
...
@@ -64,59 +64,35 @@ void TestInitGoogleMock(const Char* (&argv)[M], const Char* (&new_argv)[N],
}
}
TEST
(
InitGoogleMockTest
,
ParsesInvalidCommandLine
)
{
TEST
(
InitGoogleMockTest
,
ParsesInvalidCommandLine
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
nullptr
};
NULL
};
const
char
*
new_argv
[]
=
{
const
char
*
new_argv
[]
=
{
nullptr
};
NULL
};
TestInitGoogleMock
(
argv
,
new_argv
,
GMOCK_FLAG
(
verbose
));
TestInitGoogleMock
(
argv
,
new_argv
,
GMOCK_FLAG
(
verbose
));
}
}
TEST
(
InitGoogleMockTest
,
ParsesEmptyCommandLine
)
{
TEST
(
InitGoogleMockTest
,
ParsesEmptyCommandLine
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
nullptr
};
"foo.exe"
,
NULL
};
const
char
*
new_argv
[]
=
{
const
char
*
new_argv
[]
=
{
"foo.exe"
,
nullptr
};
"foo.exe"
,
NULL
};
TestInitGoogleMock
(
argv
,
new_argv
,
GMOCK_FLAG
(
verbose
));
TestInitGoogleMock
(
argv
,
new_argv
,
GMOCK_FLAG
(
verbose
));
}
}
TEST
(
InitGoogleMockTest
,
ParsesSingleFlag
)
{
TEST
(
InitGoogleMockTest
,
ParsesSingleFlag
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"--gmock_verbose=info"
,
nullptr
};
"foo.exe"
,
"--gmock_verbose=info"
,
NULL
};
const
char
*
new_argv
[]
=
{
const
char
*
new_argv
[]
=
{
"foo.exe"
,
nullptr
};
"foo.exe"
,
NULL
};
TestInitGoogleMock
(
argv
,
new_argv
,
"info"
);
TestInitGoogleMock
(
argv
,
new_argv
,
"info"
);
}
}
TEST
(
InitGoogleMockTest
,
ParsesMultipleFlags
)
{
TEST
(
InitGoogleMockTest
,
ParsesMultipleFlags
)
{
int
old_default_behavior
=
GMOCK_FLAG
(
default_mock_behavior
);
int
old_default_behavior
=
GMOCK_FLAG
(
default_mock_behavior
);
const
wchar_t
*
argv
[]
=
{
const
wchar_t
*
argv
[]
=
{
L"foo.exe"
,
L"--gmock_verbose=info"
,
L"foo.exe"
,
L"--gmock_default_mock_behavior=2"
,
nullptr
};
L"--gmock_verbose=info"
,
L"--gmock_default_mock_behavior=2"
,
const
wchar_t
*
new_argv
[]
=
{
L"foo.exe"
,
nullptr
};
NULL
};
const
wchar_t
*
new_argv
[]
=
{
L"foo.exe"
,
NULL
};
TestInitGoogleMock
(
argv
,
new_argv
,
"info"
);
TestInitGoogleMock
(
argv
,
new_argv
,
"info"
);
EXPECT_EQ
(
2
,
GMOCK_FLAG
(
default_mock_behavior
));
EXPECT_EQ
(
2
,
GMOCK_FLAG
(
default_mock_behavior
));
...
@@ -125,92 +101,52 @@ TEST(InitGoogleMockTest, ParsesMultipleFlags) {
...
@@ -125,92 +101,52 @@ TEST(InitGoogleMockTest, ParsesMultipleFlags) {
}
}
TEST
(
InitGoogleMockTest
,
ParsesUnrecognizedFlag
)
{
TEST
(
InitGoogleMockTest
,
ParsesUnrecognizedFlag
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"--non_gmock_flag=blah"
,
nullptr
};
"foo.exe"
,
"--non_gmock_flag=blah"
,
const
char
*
new_argv
[]
=
{
"foo.exe"
,
"--non_gmock_flag=blah"
,
nullptr
};
NULL
};
const
char
*
new_argv
[]
=
{
"foo.exe"
,
"--non_gmock_flag=blah"
,
NULL
};
TestInitGoogleMock
(
argv
,
new_argv
,
GMOCK_FLAG
(
verbose
));
TestInitGoogleMock
(
argv
,
new_argv
,
GMOCK_FLAG
(
verbose
));
}
}
TEST
(
InitGoogleMockTest
,
ParsesGoogleMockFlagAndUnrecognizedFlag
)
{
TEST
(
InitGoogleMockTest
,
ParsesGoogleMockFlagAndUnrecognizedFlag
)
{
const
char
*
argv
[]
=
{
const
char
*
argv
[]
=
{
"foo.exe"
,
"--non_gmock_flag=blah"
,
"foo.exe"
,
"--gmock_verbose=error"
,
nullptr
};
"--non_gmock_flag=blah"
,
"--gmock_verbose=error"
,
const
char
*
new_argv
[]
=
{
"foo.exe"
,
"--non_gmock_flag=blah"
,
nullptr
};
NULL
};
const
char
*
new_argv
[]
=
{
"foo.exe"
,
"--non_gmock_flag=blah"
,
NULL
};
TestInitGoogleMock
(
argv
,
new_argv
,
"error"
);
TestInitGoogleMock
(
argv
,
new_argv
,
"error"
);
}
}
TEST
(
WideInitGoogleMockTest
,
ParsesInvalidCommandLine
)
{
TEST
(
WideInitGoogleMockTest
,
ParsesInvalidCommandLine
)
{
const
wchar_t
*
argv
[]
=
{
const
wchar_t
*
argv
[]
=
{
nullptr
};
NULL
};
const
wchar_t
*
new_argv
[]
=
{
const
wchar_t
*
new_argv
[]
=
{
nullptr
};
NULL
};
TestInitGoogleMock
(
argv
,
new_argv
,
GMOCK_FLAG
(
verbose
));
TestInitGoogleMock
(
argv
,
new_argv
,
GMOCK_FLAG
(
verbose
));
}
}
TEST
(
WideInitGoogleMockTest
,
ParsesEmptyCommandLine
)
{
TEST
(
WideInitGoogleMockTest
,
ParsesEmptyCommandLine
)
{
const
wchar_t
*
argv
[]
=
{
const
wchar_t
*
argv
[]
=
{
L"foo.exe"
,
nullptr
};
L"foo.exe"
,
NULL
};
const
wchar_t
*
new_argv
[]
=
{
const
wchar_t
*
new_argv
[]
=
{
L"foo.exe"
,
nullptr
};
L"foo.exe"
,
NULL
};
TestInitGoogleMock
(
argv
,
new_argv
,
GMOCK_FLAG
(
verbose
));
TestInitGoogleMock
(
argv
,
new_argv
,
GMOCK_FLAG
(
verbose
));
}
}
TEST
(
WideInitGoogleMockTest
,
ParsesSingleFlag
)
{
TEST
(
WideInitGoogleMockTest
,
ParsesSingleFlag
)
{
const
wchar_t
*
argv
[]
=
{
const
wchar_t
*
argv
[]
=
{
L"foo.exe"
,
L"--gmock_verbose=info"
,
nullptr
};
L"foo.exe"
,
L"--gmock_verbose=info"
,
NULL
};
const
wchar_t
*
new_argv
[]
=
{
const
wchar_t
*
new_argv
[]
=
{
L"foo.exe"
,
nullptr
};
L"foo.exe"
,
NULL
};
TestInitGoogleMock
(
argv
,
new_argv
,
"info"
);
TestInitGoogleMock
(
argv
,
new_argv
,
"info"
);
}
}
TEST
(
WideInitGoogleMockTest
,
ParsesMultipleFlags
)
{
TEST
(
WideInitGoogleMockTest
,
ParsesMultipleFlags
)
{
int
old_default_behavior
=
GMOCK_FLAG
(
default_mock_behavior
);
int
old_default_behavior
=
GMOCK_FLAG
(
default_mock_behavior
);
const
wchar_t
*
argv
[]
=
{
const
wchar_t
*
argv
[]
=
{
L"foo.exe"
,
L"--gmock_verbose=info"
,
L"foo.exe"
,
L"--gmock_default_mock_behavior=2"
,
nullptr
};
L"--gmock_verbose=info"
,
L"--gmock_default_mock_behavior=2"
,
const
wchar_t
*
new_argv
[]
=
{
L"foo.exe"
,
nullptr
};
NULL
};
const
wchar_t
*
new_argv
[]
=
{
L"foo.exe"
,
NULL
};
TestInitGoogleMock
(
argv
,
new_argv
,
"info"
);
TestInitGoogleMock
(
argv
,
new_argv
,
"info"
);
EXPECT_EQ
(
2
,
GMOCK_FLAG
(
default_mock_behavior
));
EXPECT_EQ
(
2
,
GMOCK_FLAG
(
default_mock_behavior
));
...
@@ -219,34 +155,18 @@ TEST(WideInitGoogleMockTest, ParsesMultipleFlags) {
...
@@ -219,34 +155,18 @@ TEST(WideInitGoogleMockTest, ParsesMultipleFlags) {
}
}
TEST
(
WideInitGoogleMockTest
,
ParsesUnrecognizedFlag
)
{
TEST
(
WideInitGoogleMockTest
,
ParsesUnrecognizedFlag
)
{
const
wchar_t
*
argv
[]
=
{
const
wchar_t
*
argv
[]
=
{
L"foo.exe"
,
L"--non_gmock_flag=blah"
,
nullptr
};
L"foo.exe"
,
L"--non_gmock_flag=blah"
,
const
wchar_t
*
new_argv
[]
=
{
L"foo.exe"
,
L"--non_gmock_flag=blah"
,
nullptr
};
NULL
};
const
wchar_t
*
new_argv
[]
=
{
L"foo.exe"
,
L"--non_gmock_flag=blah"
,
NULL
};
TestInitGoogleMock
(
argv
,
new_argv
,
GMOCK_FLAG
(
verbose
));
TestInitGoogleMock
(
argv
,
new_argv
,
GMOCK_FLAG
(
verbose
));
}
}
TEST
(
WideInitGoogleMockTest
,
ParsesGoogleMockFlagAndUnrecognizedFlag
)
{
TEST
(
WideInitGoogleMockTest
,
ParsesGoogleMockFlagAndUnrecognizedFlag
)
{
const
wchar_t
*
argv
[]
=
{
const
wchar_t
*
argv
[]
=
{
L"foo.exe"
,
L"--non_gmock_flag=blah"
,
L"foo.exe"
,
L"--gmock_verbose=error"
,
nullptr
};
L"--non_gmock_flag=blah"
,
L"--gmock_verbose=error"
,
const
wchar_t
*
new_argv
[]
=
{
L"foo.exe"
,
L"--non_gmock_flag=blah"
,
nullptr
};
NULL
};
const
wchar_t
*
new_argv
[]
=
{
L"foo.exe"
,
L"--non_gmock_flag=blah"
,
NULL
};
TestInitGoogleMock
(
argv
,
new_argv
,
"error"
);
TestInitGoogleMock
(
argv
,
new_argv
,
"error"
);
}
}
...
...
googletest/docs/primer.md
View file @
4327d95b
...
@@ -477,11 +477,8 @@ If a fatal failure happens the subsequent steps will be skipped.
...
@@ -477,11 +477,8 @@ If a fatal failure happens the subsequent steps will be skipped.
## Writing the main() Function
## Writing the main() Function
In
`google3`
, the simplest approach is to use the default main() function
Write your own main() function, which should
provided by linking in
`"//testing/base/public:gtest_main"`
. If that doesn't
return the value of
`RUN_ALL_TESTS()`
cover what you need, you should write your own main() function, which should
return the value of
`RUN_ALL_TESTS()`
. Link to
`"//testing/base/public:gunit"`
.
You can start from this boilerplate:
```
c++
```
c++
#include "this/package/foo.h"
#include "this/package/foo.h"
...
...
googletest/include/gtest/gtest-message.h
View file @
4327d95b
...
@@ -151,7 +151,7 @@ class GTEST_API_ Message {
...
@@ -151,7 +151,7 @@ class GTEST_API_ Message {
// as "(null)".
// as "(null)".
template
<
typename
T
>
template
<
typename
T
>
inline
Message
&
operator
<<
(
T
*
const
&
pointer
)
{
// NOLINT
inline
Message
&
operator
<<
(
T
*
const
&
pointer
)
{
// NOLINT
if
(
pointer
==
NULL
)
{
if
(
pointer
==
nullptr
)
{
*
ss_
<<
"(null)"
;
*
ss_
<<
"(null)"
;
}
else
{
}
else
{
*
ss_
<<
pointer
;
*
ss_
<<
pointer
;
...
...
googletest/include/gtest/gtest-printers.h
View file @
4327d95b
...
@@ -449,7 +449,7 @@ void DefaultPrintTo(WrapPrinterType<kPrintContainer> /* dummy */,
...
@@ -449,7 +449,7 @@ void DefaultPrintTo(WrapPrinterType<kPrintContainer> /* dummy */,
template
<
typename
T
>
template
<
typename
T
>
void
DefaultPrintTo
(
WrapPrinterType
<
kPrintPointer
>
/* dummy */
,
void
DefaultPrintTo
(
WrapPrinterType
<
kPrintPointer
>
/* dummy */
,
T
*
p
,
::
std
::
ostream
*
os
)
{
T
*
p
,
::
std
::
ostream
*
os
)
{
if
(
p
==
NULL
)
{
if
(
p
==
nullptr
)
{
*
os
<<
"NULL"
;
*
os
<<
"NULL"
;
}
else
{
}
else
{
// T is not a function type. We just call << to print p,
// T is not a function type. We just call << to print p,
...
@@ -461,7 +461,7 @@ void DefaultPrintTo(WrapPrinterType<kPrintPointer> /* dummy */,
...
@@ -461,7 +461,7 @@ void DefaultPrintTo(WrapPrinterType<kPrintPointer> /* dummy */,
template
<
typename
T
>
template
<
typename
T
>
void
DefaultPrintTo
(
WrapPrinterType
<
kPrintFunctionPointer
>
/* dummy */
,
void
DefaultPrintTo
(
WrapPrinterType
<
kPrintFunctionPointer
>
/* dummy */
,
T
*
p
,
::
std
::
ostream
*
os
)
{
T
*
p
,
::
std
::
ostream
*
os
)
{
if
(
p
==
NULL
)
{
if
(
p
==
nullptr
)
{
*
os
<<
"NULL"
;
*
os
<<
"NULL"
;
}
else
{
}
else
{
// T is a function type, so '*os << p' doesn't do what we want
// T is a function type, so '*os << p' doesn't do what we want
...
@@ -518,11 +518,7 @@ void PrintTo(const T& value, ::std::ostream* os) {
...
@@ -518,11 +518,7 @@ void PrintTo(const T& value, ::std::ostream* os) {
?
kPrintContainer
?
kPrintContainer
:
!
is_pointer
<
T
>::
value
:
!
is_pointer
<
T
>::
value
?
kPrintOther
?
kPrintOther
#if GTEST_LANG_CXX11
:
std
::
is_function
<
typename
std
::
remove_pointer
<
T
>::
type
>::
value
:
std
::
is_function
<
typename
std
::
remove_pointer
<
T
>::
type
>::
value
#else
:
!
internal
::
ImplicitlyConvertible
<
T
,
const
void
*>::
value
#endif
?
kPrintFunctionPointer
?
kPrintFunctionPointer
:
kPrintPointer
>
(),
:
kPrintPointer
>
(),
value
,
os
);
value
,
os
);
...
@@ -639,8 +635,6 @@ inline void PrintTo(absl::string_view sp, ::std::ostream* os) {
...
@@ -639,8 +635,6 @@ inline void PrintTo(absl::string_view sp, ::std::ostream* os) {
}
}
#endif // GTEST_HAS_ABSL
#endif // GTEST_HAS_ABSL
#if GTEST_LANG_CXX11
inline
void
PrintTo
(
std
::
nullptr_t
,
::
std
::
ostream
*
os
)
{
*
os
<<
"(nullptr)"
;
}
inline
void
PrintTo
(
std
::
nullptr_t
,
::
std
::
ostream
*
os
)
{
*
os
<<
"(nullptr)"
;
}
template
<
typename
T
>
template
<
typename
T
>
...
@@ -649,8 +643,6 @@ void PrintTo(std::reference_wrapper<T> ref, ::std::ostream* os) {
...
@@ -649,8 +643,6 @@ void PrintTo(std::reference_wrapper<T> ref, ::std::ostream* os) {
PrintTo
(
ref
.
get
(),
os
);
PrintTo
(
ref
.
get
(),
os
);
}
}
#endif // GTEST_LANG_CXX11
#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
// Helper function for printing a tuple. T must be instantiated with
// Helper function for printing a tuple. T must be instantiated with
// a tuple type.
// a tuple type.
...
@@ -914,7 +906,7 @@ template <>
...
@@ -914,7 +906,7 @@ template <>
class
UniversalTersePrinter
<
const
char
*>
{
class
UniversalTersePrinter
<
const
char
*>
{
public:
public:
static
void
Print
(
const
char
*
str
,
::
std
::
ostream
*
os
)
{
static
void
Print
(
const
char
*
str
,
::
std
::
ostream
*
os
)
{
if
(
str
==
NULL
)
{
if
(
str
==
nullptr
)
{
*
os
<<
"NULL"
;
*
os
<<
"NULL"
;
}
else
{
}
else
{
UniversalPrint
(
std
::
string
(
str
),
os
);
UniversalPrint
(
std
::
string
(
str
),
os
);
...
@@ -934,7 +926,7 @@ template <>
...
@@ -934,7 +926,7 @@ template <>
class
UniversalTersePrinter
<
const
wchar_t
*>
{
class
UniversalTersePrinter
<
const
wchar_t
*>
{
public:
public:
static
void
Print
(
const
wchar_t
*
str
,
::
std
::
ostream
*
os
)
{
static
void
Print
(
const
wchar_t
*
str
,
::
std
::
ostream
*
os
)
{
if
(
str
==
NULL
)
{
if
(
str
==
nullptr
)
{
*
os
<<
"NULL"
;
*
os
<<
"NULL"
;
}
else
{
}
else
{
UniversalPrint
(
::
std
::
wstring
(
str
),
os
);
UniversalPrint
(
::
std
::
wstring
(
str
),
os
);
...
...
googletest/include/gtest/gtest-test-part.h
View file @
4327d95b
...
@@ -60,16 +60,13 @@ class GTEST_API_ TestPartResult {
...
@@ -60,16 +60,13 @@ class GTEST_API_ TestPartResult {
// C'tor. TestPartResult does NOT have a default constructor.
// C'tor. TestPartResult does NOT have a default constructor.
// Always use this constructor (with parameters) to create a
// Always use this constructor (with parameters) to create a
// TestPartResult object.
// TestPartResult object.
TestPartResult
(
Type
a_type
,
TestPartResult
(
Type
a_type
,
const
char
*
a_file_name
,
int
a_line_number
,
const
char
*
a_file_name
,
int
a_line_number
,
const
char
*
a_message
)
const
char
*
a_message
)
:
type_
(
a_type
),
:
type_
(
a_type
),
file_name_
(
a_file_name
==
NULL
?
""
:
a_file_name
),
file_name_
(
a_file_name
==
nullptr
?
""
:
a_file_name
),
line_number_
(
a_line_number
),
line_number_
(
a_line_number
),
summary_
(
ExtractSummary
(
a_message
)),
summary_
(
ExtractSummary
(
a_message
)),
message_
(
a_message
)
{
message_
(
a_message
)
{}
}
// Gets the outcome of the test part.
// Gets the outcome of the test part.
Type
type
()
const
{
return
type_
;
}
Type
type
()
const
{
return
type_
;
}
...
@@ -77,7 +74,7 @@ class GTEST_API_ TestPartResult {
...
@@ -77,7 +74,7 @@ class GTEST_API_ TestPartResult {
// Gets the name of the source file where the test part took place, or
// Gets the name of the source file where the test part took place, or
// NULL if it's unknown.
// NULL if it's unknown.
const
char
*
file_name
()
const
{
const
char
*
file_name
()
const
{
return
file_name_
.
empty
()
?
NULL
:
file_name_
.
c_str
();
return
file_name_
.
empty
()
?
nullptr
:
file_name_
.
c_str
();
}
}
// Gets the line in the source file where the test part took place,
// Gets the line in the source file where the test part took place,
...
...
googletest/include/gtest/gtest.h
View file @
4327d95b
...
@@ -300,7 +300,8 @@ class GTEST_API_ AssertionResult {
...
@@ -300,7 +300,8 @@ class GTEST_API_ AssertionResult {
const
T
&
success
,
const
T
&
success
,
typename
internal
::
EnableIf
<
typename
internal
::
EnableIf
<
!
internal
::
ImplicitlyConvertible
<
T
,
AssertionResult
>::
value
>::
type
*
!
internal
::
ImplicitlyConvertible
<
T
,
AssertionResult
>::
value
>::
type
*
/*enabler*/
=
NULL
)
/*enabler*/
=
nullptr
)
:
success_
(
success
)
{}
:
success_
(
success
)
{}
#if defined(_MSC_VER) && _MSC_VER < 1910
#if defined(_MSC_VER) && _MSC_VER < 1910
...
@@ -324,7 +325,7 @@ class GTEST_API_ AssertionResult {
...
@@ -324,7 +325,7 @@ class GTEST_API_ AssertionResult {
// assertion's expectation). When nothing has been streamed into the
// assertion's expectation). When nothing has been streamed into the
// object, returns an empty string.
// object, returns an empty string.
const
char
*
message
()
const
{
const
char
*
message
()
const
{
return
message_
.
get
()
!=
NULL
?
message_
->
c_str
()
:
""
;
return
message_
.
get
()
!=
nullptr
?
message_
->
c_str
()
:
""
;
}
}
// FIXME: Remove this after making sure no clients use it.
// FIXME: Remove this after making sure no clients use it.
// Deprecated; please use message() instead.
// Deprecated; please use message() instead.
...
@@ -347,8 +348,7 @@ class GTEST_API_ AssertionResult {
...
@@ -347,8 +348,7 @@ class GTEST_API_ AssertionResult {
private:
private:
// Appends the contents of message to message_.
// Appends the contents of message to message_.
void
AppendMessage
(
const
Message
&
a_message
)
{
void
AppendMessage
(
const
Message
&
a_message
)
{
if
(
message_
.
get
()
==
NULL
)
if
(
message_
.
get
()
==
nullptr
)
message_
.
reset
(
new
::
std
::
string
);
message_
.
reset
(
new
::
std
::
string
);
message_
->
append
(
a_message
.
GetString
().
c_str
());
message_
->
append
(
a_message
.
GetString
().
c_str
());
}
}
...
@@ -512,7 +512,7 @@ class GTEST_API_ Test {
...
@@ -512,7 +512,7 @@ class GTEST_API_ Test {
// If you see an error about overriding the following function or
// If you see an error about overriding the following function or
// about it being private, you have mis-spelled SetUp() as Setup().
// about it being private, you have mis-spelled SetUp() as Setup().
struct
Setup_should_be_spelled_SetUp
{};
struct
Setup_should_be_spelled_SetUp
{};
virtual
Setup_should_be_spelled_SetUp
*
Setup
()
{
return
NULL
;
}
virtual
Setup_should_be_spelled_SetUp
*
Setup
()
{
return
nullptr
;
}
// We disallow copying Tests.
// We disallow copying Tests.
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
Test
);
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
Test
);
...
@@ -700,17 +700,15 @@ class GTEST_API_ TestInfo {
...
@@ -700,17 +700,15 @@ class GTEST_API_ TestInfo {
// Returns the name of the parameter type, or NULL if this is not a typed
// Returns the name of the parameter type, or NULL if this is not a typed
// or a type-parameterized test.
// or a type-parameterized test.
const
char
*
type_param
()
const
{
const
char
*
type_param
()
const
{
if
(
type_param_
.
get
()
!=
NULL
)
if
(
type_param_
.
get
()
!=
nullptr
)
return
type_param_
->
c_str
();
return
type_param_
->
c_str
();
return
nullptr
;
return
NULL
;
}
}
// Returns the text representation of the value parameter, or NULL if this
// Returns the text representation of the value parameter, or NULL if this
// is not a value-parameterized test.
// is not a value-parameterized test.
const
char
*
value_param
()
const
{
const
char
*
value_param
()
const
{
if
(
value_param_
.
get
()
!=
NULL
)
if
(
value_param_
.
get
()
!=
nullptr
)
return
value_param_
->
c_str
();
return
value_param_
->
c_str
();
return
nullptr
;
return
NULL
;
}
}
// Returns the file name where this test is defined.
// Returns the file name where this test is defined.
...
@@ -849,9 +847,8 @@ class GTEST_API_ TestCase {
...
@@ -849,9 +847,8 @@ class GTEST_API_ TestCase {
// Returns the name of the parameter type, or NULL if this is not a
// Returns the name of the parameter type, or NULL if this is not a
// type-parameterized test case.
// type-parameterized test case.
const
char
*
type_param
()
const
{
const
char
*
type_param
()
const
{
if
(
type_param_
.
get
()
!=
NULL
)
if
(
type_param_
.
get
()
!=
nullptr
)
return
type_param_
->
c_str
();
return
type_param_
->
c_str
();
return
nullptr
;
return
NULL
;
}
}
// Returns true if any test in this test case should run.
// Returns true if any test in this test case should run.
...
@@ -1038,7 +1035,7 @@ class Environment {
...
@@ -1038,7 +1035,7 @@ class Environment {
// If you see an error about overriding the following function or
// If you see an error about overriding the following function or
// about it being private, you have mis-spelled SetUp() as Setup().
// about it being private, you have mis-spelled SetUp() as Setup().
struct
Setup_should_be_spelled_SetUp
{};
struct
Setup_should_be_spelled_SetUp
{};
virtual
Setup_should_be_spelled_SetUp
*
Setup
()
{
return
NULL
;
}
virtual
Setup_should_be_spelled_SetUp
*
Setup
()
{
return
nullptr
;
}
};
};
#if GTEST_HAS_EXCEPTIONS
#if GTEST_HAS_EXCEPTIONS
...
@@ -1514,16 +1511,14 @@ class EqHelper<true> {
...
@@ -1514,16 +1511,14 @@ class EqHelper<true> {
// EXPECT_EQ(false, a_bool).
// EXPECT_EQ(false, a_bool).
template
<
typename
T1
,
typename
T2
>
template
<
typename
T1
,
typename
T2
>
static
AssertionResult
Compare
(
static
AssertionResult
Compare
(
const
char
*
lhs_expression
,
const
char
*
lhs_expression
,
const
char
*
rhs_expression
,
const
T1
&
lhs
,
const
char
*
rhs_expression
,
const
T1
&
lhs
,
const
T2
&
rhs
,
const
T2
&
rhs
,
// The following line prevents this overload from being considered if T2
// The following line prevents this overload from being considered if T2
// is not a pointer type. We need this because ASSERT_EQ(NULL, my_ptr)
// is not a pointer type. We need this because ASSERT_EQ(NULL, my_ptr)
// expands to Compare("", "", NULL, my_ptr), which requires a conversion
// expands to Compare("", "", NULL, my_ptr), which requires a conversion
// to match the Secret* in the other overload, which would otherwise make
// to match the Secret* in the other overload, which would otherwise make
// this template match better.
// this template match better.
typename
EnableIf
<!
is_pointer
<
T2
>::
value
>::
type
*
=
0
)
{
typename
EnableIf
<!
is_pointer
<
T2
>::
value
>::
type
*
=
nullptr
)
{
return
CmpHelperEQ
(
lhs_expression
,
rhs_expression
,
lhs
,
rhs
);
return
CmpHelperEQ
(
lhs_expression
,
rhs_expression
,
lhs
,
rhs
);
}
}
...
@@ -1542,8 +1537,8 @@ class EqHelper<true> {
...
@@ -1542,8 +1537,8 @@ class EqHelper<true> {
Secret
*
/* lhs (NULL) */
,
Secret
*
/* lhs (NULL) */
,
T
*
rhs
)
{
T
*
rhs
)
{
// We already know that 'lhs' is a null pointer.
// We already know that 'lhs' is a null pointer.
return
CmpHelperEQ
(
lhs_expression
,
rhs_expression
,
return
CmpHelperEQ
(
lhs_expression
,
rhs_expression
,
static_cast
<
T
*>
(
nullptr
),
static_cast
<
T
*>
(
NULL
),
rhs
);
rhs
);
}
}
};
};
...
@@ -1772,6 +1767,12 @@ class GTEST_API_ AssertHelper {
...
@@ -1772,6 +1767,12 @@ 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.
...
@@ -1817,7 +1818,7 @@ class WithParamInterface {
...
@@ -1817,7 +1818,7 @@ class WithParamInterface {
// The current parameter value. Is also available in the test fixture's
// The current parameter value. Is also available in the test fixture's
// constructor.
// constructor.
static
const
ParamType
&
GetParam
()
{
static
const
ParamType
&
GetParam
()
{
GTEST_CHECK_
(
parameter_
!=
NULL
)
GTEST_CHECK_
(
parameter_
!=
nullptr
)
<<
"GetParam() can only be called inside a value-parameterized test "
<<
"GetParam() can only be called inside a value-parameterized test "
<<
"-- did you intend to write TEST_P instead of TEST_F?"
;
<<
"-- did you intend to write TEST_P instead of TEST_F?"
;
return
*
parameter_
;
return
*
parameter_
;
...
@@ -1838,7 +1839,7 @@ class WithParamInterface {
...
@@ -1838,7 +1839,7 @@ class WithParamInterface {
};
};
template
<
typename
T
>
template
<
typename
T
>
const
T
*
WithParamInterface
<
T
>::
parameter_
=
NULL
;
const
T
*
WithParamInterface
<
T
>::
parameter_
=
nullptr
;
// Most value-parameterized classes can ignore the existence of
// Most value-parameterized classes can ignore the existence of
// WithParamInterface, and can just inherit from ::testing::TestWithParam.
// WithParamInterface, and can just inherit from ::testing::TestWithParam.
...
...
Prev
1
2
3
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