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
3896e3b5
"googlemock/git@developer.sourcefind.cn:yangql/googletest.git" did not exist on "849ed6b172c70bce63763221559e1c74837619e3"
Commit
3896e3b5
authored
Oct 29, 2018
by
Jerry Turcios
Browse files
Merge branch 'master' of
https://github.com/google/googletest
parents
b8a03c80
b9347b31
Changes
36
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
72 additions
and
220 deletions
+72
-220
googlemock/include/gmock/gmock-actions.h
googlemock/include/gmock/gmock-actions.h
+10
-11
googlemock/include/gmock/gmock-cardinalities.h
googlemock/include/gmock/gmock-cardinalities.h
+4
-4
googlemock/include/gmock/gmock-generated-actions.h
googlemock/include/gmock/gmock-generated-actions.h
+2
-1
googlemock/include/gmock/gmock-generated-actions.h.pump
googlemock/include/gmock/gmock-generated-actions.h.pump
+2
-1
googlemock/include/gmock/gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+6
-19
googlemock/include/gmock/gmock-spec-builders.h
googlemock/include/gmock/gmock-spec-builders.h
+14
-22
googlemock/include/gmock/internal/gmock-internal-utils.h
googlemock/include/gmock/internal/gmock-internal-utils.h
+0
-9
googlemock/include/gmock/internal/gmock-port.h
googlemock/include/gmock/internal/gmock-port.h
+0
-1
googlemock/src/gmock-spec-builders.cc
googlemock/src/gmock-spec-builders.cc
+4
-3
googlemock/test/gmock-generated-actions_test.cc
googlemock/test/gmock-generated-actions_test.cc
+8
-8
googlemock/test/gmock-generated-function-mockers_test.cc
googlemock/test/gmock-generated-function-mockers_test.cc
+5
-5
googlemock/test/gmock-internal-utils_test.cc
googlemock/test/gmock-internal-utils_test.cc
+1
-7
googlemock/test/gmock-matchers_test.cc
googlemock/test/gmock-matchers_test.cc
+9
-29
googlemock/test/gmock-more-actions_test.cc
googlemock/test/gmock-more-actions_test.cc
+1
-10
googlemock/test/gmock-spec-builders_test.cc
googlemock/test/gmock-spec-builders_test.cc
+4
-4
googlemock/test/gmock_link_test.h
googlemock/test/gmock_link_test.h
+1
-1
googlemock/test/gmock_stress_test.cc
googlemock/test/gmock_stress_test.cc
+0
-81
googletest/CMakeLists.txt
googletest/CMakeLists.txt
+0
-1
googletest/Makefile.am
googletest/Makefile.am
+0
-2
googletest/include/gtest/gtest-message.h
googletest/include/gtest/gtest-message.h
+1
-1
No files found.
googlemock/include/gmock/gmock-actions.h
View file @
3896e3b5
...
@@ -42,6 +42,7 @@
...
@@ -42,6 +42,7 @@
#endif
#endif
#include <algorithm>
#include <algorithm>
#include <memory>
#include <string>
#include <string>
#include <utility>
#include <utility>
...
@@ -346,9 +347,7 @@ class ActionInterface {
...
@@ -346,9 +347,7 @@ class ActionInterface {
// An Action<F> is a copyable and IMMUTABLE (except by assignment)
// An Action<F> is a copyable and IMMUTABLE (except by assignment)
// object that represents an action to be taken when a mock function
// object that represents an action to be taken when a mock function
// of type F is called. The implementation of Action<T> is just a
// of type F is called. The implementation of Action<T> is just a
// linked_ptr to const ActionInterface<T>, so copying is fairly cheap.
// std::shared_ptr to const ActionInterface<T>. Don't inherit from Action!
// Don't inherit from Action!
//
// You can view an object implementing ActionInterface<F> as a
// You can view an object implementing ActionInterface<F> as a
// concrete action (including its current state), and an Action<F>
// concrete action (including its current state), and an Action<F>
// object as a handle to it.
// object as a handle to it.
...
@@ -425,7 +424,7 @@ class Action {
...
@@ -425,7 +424,7 @@ class Action {
#if GTEST_LANG_CXX11
#if GTEST_LANG_CXX11
::
std
::
function
<
F
>
fun_
;
::
std
::
function
<
F
>
fun_
;
#endif
#endif
internal
::
link
ed_ptr
<
ActionInterface
<
F
>
>
impl_
;
std
::
shar
ed_ptr
<
ActionInterface
<
F
>>
impl_
;
};
};
// The PolymorphicAction class template makes it easy to implement a
// The PolymorphicAction class template makes it easy to implement a
...
@@ -519,7 +518,7 @@ class ActionAdaptor : public ActionInterface<F1> {
...
@@ -519,7 +518,7 @@ class ActionAdaptor : public ActionInterface<F1> {
}
}
private:
private:
const
internal
::
link
ed_ptr
<
ActionInterface
<
F2
>
>
impl_
;
const
std
::
shar
ed_ptr
<
ActionInterface
<
F2
>>
impl_
;
GTEST_DISALLOW_ASSIGN_
(
ActionAdaptor
);
GTEST_DISALLOW_ASSIGN_
(
ActionAdaptor
);
};
};
...
@@ -601,7 +600,7 @@ class ReturnAction {
...
@@ -601,7 +600,7 @@ class ReturnAction {
// Result to call. ImplicitCast_ forces the compiler to convert R to
// Result to call. ImplicitCast_ forces the compiler to convert R to
// Result without considering explicit constructors, thus resolving the
// Result without considering explicit constructors, thus resolving the
// ambiguity. value_ is then initialized using its copy constructor.
// ambiguity. value_ is then initialized using its copy constructor.
explicit
Impl
(
const
link
ed_ptr
<
R
>&
value
)
explicit
Impl
(
const
std
::
shar
ed_ptr
<
R
>&
value
)
:
value_before_cast_
(
*
value
),
:
value_before_cast_
(
*
value
),
value_
(
ImplicitCast_
<
Result
>
(
value_before_cast_
))
{}
value_
(
ImplicitCast_
<
Result
>
(
value_before_cast_
))
{}
...
@@ -626,7 +625,7 @@ class ReturnAction {
...
@@ -626,7 +625,7 @@ class ReturnAction {
typedef
typename
Function
<
F
>::
Result
Result
;
typedef
typename
Function
<
F
>::
Result
Result
;
typedef
typename
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
typedef
typename
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
explicit
Impl
(
const
link
ed_ptr
<
R
>&
wrapper
)
explicit
Impl
(
const
std
::
shar
ed_ptr
<
R
>&
wrapper
)
:
performed_
(
false
),
wrapper_
(
wrapper
)
{}
:
performed_
(
false
),
wrapper_
(
wrapper
)
{}
virtual
Result
Perform
(
const
ArgumentTuple
&
)
{
virtual
Result
Perform
(
const
ArgumentTuple
&
)
{
...
@@ -638,12 +637,12 @@ class ReturnAction {
...
@@ -638,12 +637,12 @@ class ReturnAction {
private:
private:
bool
performed_
;
bool
performed_
;
const
link
ed_ptr
<
R
>
wrapper_
;
const
std
::
shar
ed_ptr
<
R
>
wrapper_
;
GTEST_DISALLOW_ASSIGN_
(
Impl
);
GTEST_DISALLOW_ASSIGN_
(
Impl
);
};
};
const
link
ed_ptr
<
R
>
value_
;
const
std
::
shar
ed_ptr
<
R
>
value_
;
GTEST_DISALLOW_ASSIGN_
(
ReturnAction
);
GTEST_DISALLOW_ASSIGN_
(
ReturnAction
);
};
};
...
@@ -866,7 +865,7 @@ class SetArgumentPointeeAction<N, Proto, true> {
...
@@ -866,7 +865,7 @@ class SetArgumentPointeeAction<N, Proto, true> {
}
}
private:
private:
const
internal
::
link
ed_ptr
<
Proto
>
proto_
;
const
std
::
shar
ed_ptr
<
Proto
>
proto_
;
GTEST_DISALLOW_ASSIGN_
(
SetArgumentPointeeAction
);
GTEST_DISALLOW_ASSIGN_
(
SetArgumentPointeeAction
);
};
};
...
@@ -931,7 +930,7 @@ class InvokeCallbackWithoutArgsAction {
...
@@ -931,7 +930,7 @@ class InvokeCallbackWithoutArgsAction {
Result
Perform
(
const
ArgumentTuple
&
)
const
{
return
callback_
->
Run
();
}
Result
Perform
(
const
ArgumentTuple
&
)
const
{
return
callback_
->
Run
();
}
private:
private:
const
internal
::
link
ed_ptr
<
CallbackType
>
callback_
;
const
std
::
shar
ed_ptr
<
CallbackType
>
callback_
;
GTEST_DISALLOW_ASSIGN_
(
InvokeCallbackWithoutArgsAction
);
GTEST_DISALLOW_ASSIGN_
(
InvokeCallbackWithoutArgsAction
);
};
};
...
...
googlemock/include/gmock/gmock-cardinalities.h
View file @
3896e3b5
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
#include <limits.h>
#include <limits.h>
#include <memory>
#include <ostream> // NOLINT
#include <ostream> // NOLINT
#include "gmock/internal/gmock-port.h"
#include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
...
@@ -81,9 +82,8 @@ class CardinalityInterface {
...
@@ -81,9 +82,8 @@ class CardinalityInterface {
// A Cardinality is a copyable and IMMUTABLE (except by assignment)
// A Cardinality is a copyable and IMMUTABLE (except by assignment)
// object that specifies how many times a mock function is expected to
// object that specifies how many times a mock function is expected to
// be called. The implementation of Cardinality is just a linked_ptr
// be called. The implementation of Cardinality is just a std::shared_ptr
// to const CardinalityInterface, so copying is fairly cheap.
// to const CardinalityInterface. Don't inherit from Cardinality!
// Don't inherit from Cardinality!
class
GTEST_API_
Cardinality
{
class
GTEST_API_
Cardinality
{
public:
public:
// Constructs a null cardinality. Needed for storing Cardinality
// Constructs a null cardinality. Needed for storing Cardinality
...
@@ -123,7 +123,7 @@ class GTEST_API_ Cardinality {
...
@@ -123,7 +123,7 @@ class GTEST_API_ Cardinality {
::
std
::
ostream
*
os
);
::
std
::
ostream
*
os
);
private:
private:
internal
::
link
ed_ptr
<
const
CardinalityInterface
>
impl_
;
std
::
shar
ed_ptr
<
const
CardinalityInterface
>
impl_
;
};
};
// Creates a cardinality that allows at least n calls.
// Creates a cardinality that allows at least n calls.
...
...
googlemock/include/gmock/gmock-generated-actions.h
View file @
3896e3b5
...
@@ -41,6 +41,7 @@
...
@@ -41,6 +41,7 @@
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
#include <memory>
#include <utility>
#include <utility>
#include "gmock/gmock-actions.h"
#include "gmock/gmock-actions.h"
...
@@ -348,7 +349,7 @@ class InvokeCallbackAction {
...
@@ -348,7 +349,7 @@ class InvokeCallbackAction {
callback_
.
get
(),
args
);
callback_
.
get
(),
args
);
}
}
private:
private:
const
link
ed_ptr
<
CallbackType
>
callback_
;
const
std
::
shar
ed_ptr
<
CallbackType
>
callback_
;
};
};
// An INTERNAL macro for extracting the type of a tuple field. It's
// An INTERNAL macro for extracting the type of a tuple field. It's
...
...
googlemock/include/gmock/gmock-generated-actions.h.pump
View file @
3896e3b5
...
@@ -43,6 +43,7 @@ $$}} This meta comment fixes auto-indentation in editors.
...
@@ -43,6 +43,7 @@ $$}} This meta comment fixes auto-indentation in editors.
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
#include <memory>
#include <utility>
#include <utility>
#include "gmock/gmock-actions.h"
#include "gmock/gmock-actions.h"
...
@@ -118,7 +119,7 @@ class InvokeCallbackAction {
...
@@ -118,7 +119,7 @@ class InvokeCallbackAction {
callback_
.
get
(),
args
);
callback_
.
get
(),
args
);
}
}
private:
private:
const
link
ed_ptr
<
CallbackType
>
callback_
;
const
std
::
shar
ed_ptr
<
CallbackType
>
callback_
;
};
};
// An INTERNAL macro for extracting the type of a tuple field. It's
// An INTERNAL macro for extracting the type of a tuple field. It's
...
...
googlemock/include/gmock/gmock-matchers.h
View file @
3896e3b5
...
@@ -43,14 +43,15 @@
...
@@ -43,14 +43,15 @@
#include <algorithm>
#include <algorithm>
#include <iterator>
#include <iterator>
#include <limits>
#include <limits>
#include <memory>
#include <ostream> // NOLINT
#include <ostream> // NOLINT
#include <sstream>
#include <sstream>
#include <string>
#include <string>
#include <utility>
#include <utility>
#include <vector>
#include <vector>
#include "gtest/gtest.h"
#include "gmock/internal/gmock-internal-utils.h"
#include "gmock/internal/gmock-internal-utils.h"
#include "gmock/internal/gmock-port.h"
#include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h"
#if GTEST_HAS_STD_INITIALIZER_LIST_
#if GTEST_HAS_STD_INITIALIZER_LIST_
# include <initializer_list> // NOLINT -- must be after gtest.h
# include <initializer_list> // NOLINT -- must be after gtest.h
...
@@ -338,29 +339,15 @@ class MatcherBase {
...
@@ -338,29 +339,15 @@ class MatcherBase {
virtual
~
MatcherBase
()
{}
virtual
~
MatcherBase
()
{}
private:
private:
// shared_ptr (util/gtl/shared_ptr.h) and linked_ptr have similar
std
::
shared_ptr
<
const
MatcherInterface
<
GTEST_REFERENCE_TO_CONST_
(
T
)
>>
impl_
;
// interfaces. The former dynamically allocates a chunk of memory
// to hold the reference count, while the latter tracks all
// references using a circular linked list without allocating
// memory. It has been observed that linked_ptr performs better in
// typical scenarios. However, shared_ptr can out-perform
// linked_ptr when there are many more uses of the copy constructor
// than the default constructor.
//
// If performance becomes a problem, we should see if using
// shared_ptr helps.
::
testing
::
internal
::
linked_ptr
<
const
MatcherInterface
<
GTEST_REFERENCE_TO_CONST_
(
T
)
>
>
impl_
;
};
};
}
// namespace internal
}
// namespace internal
// A Matcher<T> is a copyable and IMMUTABLE (except by assignment)
// A Matcher<T> is a copyable and IMMUTABLE (except by assignment)
// object that can check whether a value of type T matches. The
// object that can check whether a value of type T matches. The
// implementation of Matcher<T> is just a linked_ptr to const
// implementation of Matcher<T> is just a std::shared_ptr to const
// MatcherInterface<T>, so copying is fairly cheap. Don't inherit
// MatcherInterface<T>. Don't inherit from Matcher!
// from Matcher!
template
<
typename
T
>
template
<
typename
T
>
class
Matcher
:
public
internal
::
MatcherBase
<
T
>
{
class
Matcher
:
public
internal
::
MatcherBase
<
T
>
{
public:
public:
...
@@ -1586,7 +1573,7 @@ class MatchesRegexMatcher {
...
@@ -1586,7 +1573,7 @@ class MatchesRegexMatcher {
}
}
private:
private:
const
internal
::
link
ed_ptr
<
const
RE
>
regex_
;
const
std
::
shar
ed_ptr
<
const
RE
>
regex_
;
const
bool
full_match_
;
const
bool
full_match_
;
GTEST_DISALLOW_ASSIGN_
(
MatchesRegexMatcher
);
GTEST_DISALLOW_ASSIGN_
(
MatchesRegexMatcher
);
...
...
googlemock/include/gmock/gmock-spec-builders.h
View file @
3896e3b5
...
@@ -62,6 +62,7 @@
...
@@ -62,6 +62,7 @@
#define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
#include <map>
#include <map>
#include <memory>
#include <set>
#include <set>
#include <sstream>
#include <sstream>
#include <string>
#include <string>
...
@@ -219,8 +220,7 @@ class GTEST_API_ UntypedFunctionMockerBase {
...
@@ -219,8 +220,7 @@ class GTEST_API_ UntypedFunctionMockerBase {
protected:
protected:
typedef
std
::
vector
<
const
void
*>
UntypedOnCallSpecs
;
typedef
std
::
vector
<
const
void
*>
UntypedOnCallSpecs
;
typedef
std
::
vector
<
internal
::
linked_ptr
<
ExpectationBase
>
>
using
UntypedExpectations
=
std
::
vector
<
std
::
shared_ptr
<
ExpectationBase
>>
;
UntypedExpectations
;
// Returns an Expectation object that references and co-owns exp,
// Returns an Expectation object that references and co-owns exp,
// which must be an expectation on this mock function.
// which must be an expectation on this mock function.
...
@@ -498,12 +498,7 @@ class GTEST_API_ Mock {
...
@@ -498,12 +498,7 @@ class GTEST_API_ Mock {
// - Constness is shallow: a const Expectation object itself cannot
// - Constness is shallow: a const Expectation object itself cannot
// be modified, but the mutable methods of the ExpectationBase
// be modified, but the mutable methods of the ExpectationBase
// object it references can be called via expectation_base().
// object it references can be called via expectation_base().
// - The constructors and destructor are defined out-of-line because
// the Symbian WINSCW compiler wants to otherwise instantiate them
// when it sees this class definition, at which point it doesn't have
// ExpectationBase available yet, leading to incorrect destruction
// in the linked_ptr (or compilation errors if using a checking
// linked_ptr).
class
GTEST_API_
Expectation
{
class
GTEST_API_
Expectation
{
public:
public:
// Constructs a null object that doesn't reference any expectation.
// Constructs a null object that doesn't reference any expectation.
...
@@ -555,16 +550,15 @@ class GTEST_API_ Expectation {
...
@@ -555,16 +550,15 @@ class GTEST_API_ Expectation {
typedef
::
std
::
set
<
Expectation
,
Less
>
Set
;
typedef
::
std
::
set
<
Expectation
,
Less
>
Set
;
Expectation
(
Expectation
(
const
internal
::
link
ed_ptr
<
internal
::
ExpectationBase
>&
expectation_base
);
const
std
::
shar
ed_ptr
<
internal
::
ExpectationBase
>&
expectation_base
);
// Returns the expectation this object references.
// Returns the expectation this object references.
const
internal
::
linked_ptr
<
internal
::
ExpectationBase
>&
const
std
::
shared_ptr
<
internal
::
ExpectationBase
>&
expectation_base
()
const
{
expectation_base
()
const
{
return
expectation_base_
;
return
expectation_base_
;
}
}
// A
link
ed_ptr that co-owns the expectation this handle references.
// A
shar
ed_ptr that co-owns the expectation this handle references.
internal
::
link
ed_ptr
<
internal
::
ExpectationBase
>
expectation_base_
;
std
::
shar
ed_ptr
<
internal
::
ExpectationBase
>
expectation_base_
;
};
};
// A set of expectation handles. Useful in the .After() clause of
// A set of expectation handles. Useful in the .After() clause of
...
@@ -646,11 +640,8 @@ class GTEST_API_ Sequence {
...
@@ -646,11 +640,8 @@ class GTEST_API_ Sequence {
void
AddExpectation
(
const
Expectation
&
expectation
)
const
;
void
AddExpectation
(
const
Expectation
&
expectation
)
const
;
private:
private:
// The last expectation in this sequence. We use a linked_ptr here
// The last expectation in this sequence.
// because Sequence objects are copyable and we want the copies to
std
::
shared_ptr
<
Expectation
>
last_expectation_
;
// be aliases. The linked_ptr allows the copies to co-own and share
// the same Expectation object.
internal
::
linked_ptr
<
Expectation
>
last_expectation_
;
};
// class Sequence
};
// class Sequence
// An object of this type causes all EXPECT_CALL() statements
// An object of this type causes all EXPECT_CALL() statements
...
@@ -873,7 +864,7 @@ class GTEST_API_ ExpectationBase {
...
@@ -873,7 +864,7 @@ class GTEST_API_ ExpectationBase {
Cardinality
cardinality_
;
// The cardinality of the expectation.
Cardinality
cardinality_
;
// The cardinality of the expectation.
// The immediate pre-requisites (i.e. expectations that must be
// The immediate pre-requisites (i.e. expectations that must be
// satisfied before this expectation can be matched) of this
// satisfied before this expectation can be matched) of this
// expectation. We use
link
ed_ptr in the set because we want an
// expectation. We use
std::shar
ed_ptr in the set because we want an
// Expectation object to be co-owned by its FunctionMocker and its
// Expectation object to be co-owned by its FunctionMocker and its
// successors. This allows multiple mock objects to be deleted at
// successors. This allows multiple mock objects to be deleted at
// different times.
// different times.
...
@@ -1631,7 +1622,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1631,7 +1622,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
Mock
::
RegisterUseByOnCallOrExpectCall
(
MockObject
(),
file
,
line
);
Mock
::
RegisterUseByOnCallOrExpectCall
(
MockObject
(),
file
,
line
);
TypedExpectation
<
F
>*
const
expectation
=
TypedExpectation
<
F
>*
const
expectation
=
new
TypedExpectation
<
F
>
(
this
,
file
,
line
,
source_text
,
m
);
new
TypedExpectation
<
F
>
(
this
,
file
,
line
,
source_text
,
m
);
const
link
ed_ptr
<
ExpectationBase
>
untyped_expectation
(
expectation
);
const
std
::
shar
ed_ptr
<
ExpectationBase
>
untyped_expectation
(
expectation
);
// See the definition of untyped_expectations_ for why access to
// See the definition of untyped_expectations_ for why access to
// it is unprotected here.
// it is unprotected here.
untyped_expectations_
.
push_back
(
untyped_expectation
);
untyped_expectations_
.
push_back
(
untyped_expectation
);
...
@@ -1913,8 +1904,9 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
...
@@ -1913,8 +1904,9 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
// second argument is an internal type derived from the method signature. The
// second argument is an internal type derived from the method signature. The
// failure to disambiguate two overloads of this method in the ON_CALL statement
// failure to disambiguate two overloads of this method in the ON_CALL statement
// is how we block callers from setting expectations on overloaded methods.
// is how we block callers from setting expectations on overloaded methods.
#define GMOCK_ON_CALL_IMPL_(mock_expr, Setter, call) \
#define GMOCK_ON_CALL_IMPL_(mock_expr, Setter, call) \
((mock_expr).gmock_##call)(::testing::internal::GetWithoutMatchers(), NULL) \
((mock_expr).gmock_##call)(::testing::internal::GetWithoutMatchers(), \
nullptr) \
.Setter(__FILE__, __LINE__, #mock_expr, #call)
.Setter(__FILE__, __LINE__, #mock_expr, #call)
#define ON_CALL(obj, call) \
#define ON_CALL(obj, call) \
...
...
googlemock/include/gmock/internal/gmock-internal-utils.h
View file @
3896e3b5
...
@@ -92,15 +92,6 @@ inline const typename Pointer::element_type* GetRawPointer(const Pointer& p) {
...
@@ -92,15 +92,6 @@ inline const typename Pointer::element_type* GetRawPointer(const Pointer& p) {
template
<
typename
Element
>
template
<
typename
Element
>
inline
Element
*
GetRawPointer
(
Element
*
p
)
{
return
p
;
}
inline
Element
*
GetRawPointer
(
Element
*
p
)
{
return
p
;
}
// This comparator allows linked_ptr to be stored in sets.
template
<
typename
T
>
struct
LinkedPtrLessThan
{
bool
operator
()(
const
::
testing
::
internal
::
linked_ptr
<
T
>&
lhs
,
const
::
testing
::
internal
::
linked_ptr
<
T
>&
rhs
)
const
{
return
lhs
.
get
()
<
rhs
.
get
();
}
};
// Symbian compilation can be done with wchar_t being either a native
// Symbian compilation can be done with wchar_t being either a native
// type or a typedef. Using Google Mock with OpenC without wchar_t
// type or a typedef. Using Google Mock with OpenC without wchar_t
// should require the definition of _STLP_NO_WCHAR_T.
// should require the definition of _STLP_NO_WCHAR_T.
...
...
googlemock/include/gmock/internal/gmock-port.h
View file @
3896e3b5
...
@@ -52,7 +52,6 @@
...
@@ -52,7 +52,6 @@
// here, as Google Mock depends on Google Test. Only add a utility
// here, as Google Mock depends on Google Test. Only add a utility
// here if it's truly specific to Google Mock.
// here if it's truly specific to Google Mock.
#include "gtest/internal/gtest-linked_ptr.h"
#include "gtest/internal/gtest-port.h"
#include "gtest/internal/gtest-port.h"
#include "gmock/internal/custom/gmock-port.h"
#include "gmock/internal/custom/gmock-port.h"
...
...
googlemock/src/gmock-spec-builders.cc
View file @
3896e3b5
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
#include <stdlib.h>
#include <stdlib.h>
#include <iostream> // NOLINT
#include <iostream> // NOLINT
#include <map>
#include <map>
#include <memory>
#include <set>
#include <set>
#include <string>
#include <string>
#include <vector>
#include <vector>
...
@@ -848,7 +849,7 @@ void Mock::ClearDefaultActionsLocked(void* mock_obj)
...
@@ -848,7 +849,7 @@ void Mock::ClearDefaultActionsLocked(void* mock_obj)
Expectation
::
Expectation
()
{}
Expectation
::
Expectation
()
{}
Expectation
::
Expectation
(
Expectation
::
Expectation
(
const
internal
::
link
ed_ptr
<
internal
::
ExpectationBase
>&
an_expectation_base
)
const
std
::
shar
ed_ptr
<
internal
::
ExpectationBase
>&
an_expectation_base
)
:
expectation_base_
(
an_expectation_base
)
{}
:
expectation_base_
(
an_expectation_base
)
{}
Expectation
::~
Expectation
()
{}
Expectation
::~
Expectation
()
{}
...
@@ -866,7 +867,7 @@ void Sequence::AddExpectation(const Expectation& expectation) const {
...
@@ -866,7 +867,7 @@ void Sequence::AddExpectation(const Expectation& expectation) const {
// Creates the implicit sequence if there isn't one.
// Creates the implicit sequence if there isn't one.
InSequence
::
InSequence
()
{
InSequence
::
InSequence
()
{
if
(
internal
::
g_gmock_implicit_sequence
.
get
()
==
NULL
)
{
if
(
internal
::
g_gmock_implicit_sequence
.
get
()
==
nullptr
)
{
internal
::
g_gmock_implicit_sequence
.
set
(
new
Sequence
);
internal
::
g_gmock_implicit_sequence
.
set
(
new
Sequence
);
sequence_created_
=
true
;
sequence_created_
=
true
;
}
else
{
}
else
{
...
@@ -879,7 +880,7 @@ InSequence::InSequence() {
...
@@ -879,7 +880,7 @@ InSequence::InSequence() {
InSequence
::~
InSequence
()
{
InSequence
::~
InSequence
()
{
if
(
sequence_created_
)
{
if
(
sequence_created_
)
{
delete
internal
::
g_gmock_implicit_sequence
.
get
();
delete
internal
::
g_gmock_implicit_sequence
.
get
();
internal
::
g_gmock_implicit_sequence
.
set
(
NULL
);
internal
::
g_gmock_implicit_sequence
.
set
(
nullptr
);
}
}
}
}
...
...
googlemock/test/gmock-generated-actions_test.cc
View file @
3896e3b5
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#include "gmock/gmock-generated-actions.h"
#include "gmock/gmock-generated-actions.h"
#include <functional>
#include <functional>
#include <memory>
#include <sstream>
#include <sstream>
#include <string>
#include <string>
#include "gmock/gmock.h"
#include "gmock/gmock.h"
...
@@ -1129,9 +1130,9 @@ ACTION_TEMPLATE(ReturnSmartPointer,
...
@@ -1129,9 +1130,9 @@ ACTION_TEMPLATE(ReturnSmartPointer,
}
}
TEST
(
ActionTemplateTest
,
WorksForTemplateTemplateParameters
)
{
TEST
(
ActionTemplateTest
,
WorksForTemplateTemplateParameters
)
{
using
::
testing
::
internal
::
linked_ptr
;
const
Action
<
std
::
shared_ptr
<
int
>
()
>
a
=
const
Action
<
linked_ptr
<
int
>
()
>
a
=
ReturnSmartPointer
<
link
ed_ptr
>
(
42
);
ReturnSmartPointer
<
std
::
shar
ed_ptr
>
(
42
);
link
ed_ptr
<
int
>
p
=
a
.
Perform
(
std
::
make_tuple
());
std
::
shar
ed_ptr
<
int
>
p
=
a
.
Perform
(
std
::
make_tuple
());
EXPECT_EQ
(
42
,
*
p
);
EXPECT_EQ
(
42
,
*
p
);
}
}
...
@@ -1161,11 +1162,10 @@ ACTION_TEMPLATE(ReturnGiant,
...
@@ -1161,11 +1162,10 @@ ACTION_TEMPLATE(ReturnGiant,
}
}
TEST
(
ActionTemplateTest
,
WorksFor10TemplateParameters
)
{
TEST
(
ActionTemplateTest
,
WorksFor10TemplateParameters
)
{
using
::
testing
::
internal
::
linked_ptr
;
using
Giant
=
GiantTemplate
<
std
::
shared_ptr
<
int
>
,
bool
,
double
,
5
,
true
,
6
,
typedef
GiantTemplate
<
linked_ptr
<
int
>
,
bool
,
double
,
5
,
char
,
unsigned
,
int
>
;
true
,
6
,
char
,
unsigned
,
int
>
Giant
;
const
Action
<
Giant
()
>
a
=
ReturnGiant
<
int
,
bool
,
double
,
5
,
true
,
6
,
char
,
const
Action
<
Giant
()
>
a
=
ReturnGiant
<
unsigned
,
int
,
std
::
shared_ptr
>
(
42
);
int
,
bool
,
double
,
5
,
true
,
6
,
char
,
unsigned
,
int
,
linked_ptr
>
(
42
);
Giant
giant
=
a
.
Perform
(
std
::
make_tuple
());
Giant
giant
=
a
.
Perform
(
std
::
make_tuple
());
EXPECT_EQ
(
42
,
giant
.
value
);
EXPECT_EQ
(
42
,
giant
.
value
);
}
}
...
...
googlemock/test/gmock-generated-function-mockers_test.cc
View file @
3896e3b5
...
@@ -224,8 +224,8 @@ TEST_F(FunctionMockerTest, MocksBinaryFunction) {
...
@@ -224,8 +224,8 @@ TEST_F(FunctionMockerTest, MocksBinaryFunction) {
// Tests mocking a decimal function.
// Tests mocking a decimal function.
TEST_F
(
FunctionMockerTest
,
MocksDecimalFunction
)
{
TEST_F
(
FunctionMockerTest
,
MocksDecimalFunction
)
{
EXPECT_CALL
(
mock_foo_
,
Decimal
(
true
,
'a'
,
0
,
0
,
1L
,
A
<
float
>
(),
EXPECT_CALL
(
mock_foo_
,
Decimal
(
true
,
'a'
,
0
,
0
,
1L
,
A
<
float
>
(),
Lt
(
100
),
5U
,
Lt
(
100
),
5U
,
NULL
,
"hi"
))
nullptr
,
"hi"
))
.
WillOnce
(
Return
(
5
));
.
WillOnce
(
Return
(
5
));
EXPECT_EQ
(
5
,
foo_
->
Decimal
(
true
,
'a'
,
0
,
0
,
1
,
0
,
0
,
5
,
nullptr
,
"hi"
));
EXPECT_EQ
(
5
,
foo_
->
Decimal
(
true
,
'a'
,
0
,
0
,
1
,
0
,
0
,
5
,
nullptr
,
"hi"
));
...
@@ -326,11 +326,11 @@ TEST_F(FunctionMockerTest, MocksUnaryFunctionWithCallType) {
...
@@ -326,11 +326,11 @@ TEST_F(FunctionMockerTest, MocksUnaryFunctionWithCallType) {
// Tests mocking a decimal function with calltype.
// Tests mocking a decimal function with calltype.
TEST_F
(
FunctionMockerTest
,
MocksDecimalFunctionWithCallType
)
{
TEST_F
(
FunctionMockerTest
,
MocksDecimalFunctionWithCallType
)
{
EXPECT_CALL
(
mock_foo_
,
CTDecimal
(
true
,
'a'
,
0
,
0
,
1L
,
A
<
float
>
(),
EXPECT_CALL
(
mock_foo_
,
CTDecimal
(
true
,
'a'
,
0
,
0
,
1L
,
A
<
float
>
(),
Lt
(
100
),
5U
,
Lt
(
100
),
5U
,
NULL
,
"hi"
))
nullptr
,
"hi"
))
.
WillOnce
(
Return
(
10
));
.
WillOnce
(
Return
(
10
));
EXPECT_EQ
(
10
,
foo_
->
CTDecimal
(
true
,
'a'
,
0
,
0
,
1
,
0
,
0
,
5
,
NULL
,
"hi"
));
EXPECT_EQ
(
10
,
foo_
->
CTDecimal
(
true
,
'a'
,
0
,
0
,
1
,
0
,
0
,
5
,
nullptr
,
"hi"
));
}
}
// Tests mocking functions overloaded on the const-ness of this object.
// Tests mocking functions overloaded on the const-ness of this object.
...
...
googlemock/test/gmock-internal-utils_test.cc
View file @
3896e3b5
...
@@ -123,8 +123,6 @@ TEST(ConvertIdentifierNameToWordsTest, WorksWhenNameIsMixture) {
...
@@ -123,8 +123,6 @@ TEST(ConvertIdentifierNameToWordsTest, WorksWhenNameIsMixture) {
}
}
TEST
(
PointeeOfTest
,
WorksForSmartPointers
)
{
TEST
(
PointeeOfTest
,
WorksForSmartPointers
)
{
CompileAssertTypesEqual
<
const
char
,
PointeeOf
<
internal
::
linked_ptr
<
const
char
>
>::
type
>
();
#if GTEST_HAS_STD_UNIQUE_PTR_
#if GTEST_HAS_STD_UNIQUE_PTR_
CompileAssertTypesEqual
<
int
,
PointeeOf
<
std
::
unique_ptr
<
int
>
>::
type
>
();
CompileAssertTypesEqual
<
int
,
PointeeOf
<
std
::
unique_ptr
<
int
>
>::
type
>
();
#endif // GTEST_HAS_STD_UNIQUE_PTR_
#endif // GTEST_HAS_STD_UNIQUE_PTR_
...
@@ -151,10 +149,6 @@ TEST(GetRawPointerTest, WorksForSmartPointers) {
...
@@ -151,10 +149,6 @@ TEST(GetRawPointerTest, WorksForSmartPointers) {
const
std
::
shared_ptr
<
double
>
p2
(
raw_p2
);
const
std
::
shared_ptr
<
double
>
p2
(
raw_p2
);
EXPECT_EQ
(
raw_p2
,
GetRawPointer
(
p2
));
EXPECT_EQ
(
raw_p2
,
GetRawPointer
(
p2
));
#endif // GTEST_HAS_STD_SHARED_PTR_
#endif // GTEST_HAS_STD_SHARED_PTR_
const
char
*
const
raw_p4
=
new
const
char
(
'a'
);
// NOLINT
const
internal
::
linked_ptr
<
const
char
>
p4
(
raw_p4
);
EXPECT_EQ
(
raw_p4
,
GetRawPointer
(
p4
));
}
}
TEST
(
GetRawPointerTest
,
WorksForRawPointers
)
{
TEST
(
GetRawPointerTest
,
WorksForRawPointers
)
{
...
@@ -687,7 +681,7 @@ TEST(StlContainerViewTest, WorksForDynamicNativeArray) {
...
@@ -687,7 +681,7 @@ TEST(StlContainerViewTest, WorksForDynamicNativeArray) {
StlContainerView
<
std
::
tuple
<
const
int
*
,
size_t
>
>::
type
>
();
StlContainerView
<
std
::
tuple
<
const
int
*
,
size_t
>
>::
type
>
();
StaticAssertTypeEq
<
StaticAssertTypeEq
<
NativeArray
<
double
>
,
NativeArray
<
double
>
,
StlContainerView
<
std
::
tuple
<
link
ed_ptr
<
double
>
,
int
>
>::
type
>
();
StlContainerView
<
std
::
tuple
<
std
::
shar
ed_ptr
<
double
>
,
int
>
>::
type
>
();
StaticAssertTypeEq
<
StaticAssertTypeEq
<
const
NativeArray
<
int
>
,
const
NativeArray
<
int
>
,
...
...
googlemock/test/gmock-matchers_test.cc
View file @
3896e3b5
...
@@ -143,13 +143,11 @@ using testing::internal::ExplainMatchFailureTupleTo;
...
@@ -143,13 +143,11 @@ using testing::internal::ExplainMatchFailureTupleTo;
using
testing
::
internal
::
FloatingEqMatcher
;
using
testing
::
internal
::
FloatingEqMatcher
;
using
testing
::
internal
::
FormatMatcherDescription
;
using
testing
::
internal
::
FormatMatcherDescription
;
using
testing
::
internal
::
IsReadableTypeName
;
using
testing
::
internal
::
IsReadableTypeName
;
using
testing
::
internal
::
linked_ptr
;
using
testing
::
internal
::
MatchMatrix
;
using
testing
::
internal
::
MatchMatrix
;
using
testing
::
internal
::
RE
;
using
testing
::
internal
::
RE
;
using
testing
::
internal
::
scoped_ptr
;
using
testing
::
internal
::
scoped_ptr
;
using
testing
::
internal
::
StreamMatchResultListener
;
using
testing
::
internal
::
StreamMatchResultListener
;
using
testing
::
internal
::
Strings
;
using
testing
::
internal
::
Strings
;
using
testing
::
internal
::
linked_ptr
;
using
testing
::
internal
::
scoped_ptr
;
using
testing
::
internal
::
scoped_ptr
;
using
testing
::
internal
::
string
;
using
testing
::
internal
::
string
;
...
@@ -323,7 +321,7 @@ TEST(MatcherTest, CanBeImplicitlyConstructedFromValue) {
...
@@ -323,7 +321,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
=
nullptr
;
EXPECT_TRUE
(
m1
.
Matches
(
nullptr
));
EXPECT_TRUE
(
m1
.
Matches
(
nullptr
));
int
n
=
0
;
int
n
=
0
;
EXPECT_FALSE
(
m1
.
Matches
(
&
n
));
EXPECT_FALSE
(
m1
.
Matches
(
&
n
));
...
@@ -1177,24 +1175,6 @@ TEST(IsNullTest, MatchesNullPointer) {
...
@@ -1177,24 +1175,6 @@ TEST(IsNullTest, MatchesNullPointer) {
#endif
#endif
}
}
TEST
(
IsNullTest
,
LinkedPtr
)
{
const
Matcher
<
linked_ptr
<
int
>
>
m
=
IsNull
();
const
linked_ptr
<
int
>
null_p
;
const
linked_ptr
<
int
>
non_null_p
(
new
int
);
EXPECT_TRUE
(
m
.
Matches
(
null_p
));
EXPECT_FALSE
(
m
.
Matches
(
non_null_p
));
}
TEST
(
IsNullTest
,
ReferenceToConstLinkedPtr
)
{
const
Matcher
<
const
linked_ptr
<
double
>&>
m
=
IsNull
();
const
linked_ptr
<
double
>
null_p
;
const
linked_ptr
<
double
>
non_null_p
(
new
double
);
EXPECT_TRUE
(
m
.
Matches
(
null_p
));
EXPECT_FALSE
(
m
.
Matches
(
non_null_p
));
}
#if GTEST_LANG_CXX11
#if GTEST_LANG_CXX11
TEST
(
IsNullTest
,
StdFunction
)
{
TEST
(
IsNullTest
,
StdFunction
)
{
const
Matcher
<
std
::
function
<
void
()
>>
m
=
IsNull
();
const
Matcher
<
std
::
function
<
void
()
>>
m
=
IsNull
();
...
@@ -1226,18 +1206,18 @@ TEST(NotNullTest, MatchesNonNullPointer) {
...
@@ -1226,18 +1206,18 @@ TEST(NotNullTest, MatchesNonNullPointer) {
}
}
TEST
(
NotNullTest
,
LinkedPtr
)
{
TEST
(
NotNullTest
,
LinkedPtr
)
{
const
Matcher
<
link
ed_ptr
<
int
>
>
m
=
NotNull
();
const
Matcher
<
std
::
shar
ed_ptr
<
int
>>
m
=
NotNull
();
const
link
ed_ptr
<
int
>
null_p
;
const
std
::
shar
ed_ptr
<
int
>
null_p
;
const
link
ed_ptr
<
int
>
non_null_p
(
new
int
);
const
std
::
shar
ed_ptr
<
int
>
non_null_p
(
new
int
);
EXPECT_FALSE
(
m
.
Matches
(
null_p
));
EXPECT_FALSE
(
m
.
Matches
(
null_p
));
EXPECT_TRUE
(
m
.
Matches
(
non_null_p
));
EXPECT_TRUE
(
m
.
Matches
(
non_null_p
));
}
}
TEST
(
NotNullTest
,
ReferenceToConstLinkedPtr
)
{
TEST
(
NotNullTest
,
ReferenceToConstLinkedPtr
)
{
const
Matcher
<
const
link
ed_ptr
<
double
>&>
m
=
NotNull
();
const
Matcher
<
const
std
::
shar
ed_ptr
<
double
>&>
m
=
NotNull
();
const
link
ed_ptr
<
double
>
null_p
;
const
std
::
shar
ed_ptr
<
double
>
null_p
;
const
link
ed_ptr
<
double
>
non_null_p
(
new
double
);
const
std
::
shar
ed_ptr
<
double
>
non_null_p
(
new
double
);
EXPECT_FALSE
(
m
.
Matches
(
null_p
));
EXPECT_FALSE
(
m
.
Matches
(
null_p
));
EXPECT_TRUE
(
m
.
Matches
(
non_null_p
));
EXPECT_TRUE
(
m
.
Matches
(
non_null_p
));
...
@@ -4779,8 +4759,8 @@ TEST(IsTrueTest, IsTrueIsFalse) {
...
@@ -4779,8 +4759,8 @@ TEST(IsTrueTest, IsTrueIsFalse) {
EXPECT_THAT
(
false
,
Not
(
IsTrue
()));
EXPECT_THAT
(
false
,
Not
(
IsTrue
()));
EXPECT_THAT
(
0
,
Not
(
IsTrue
()));
EXPECT_THAT
(
0
,
Not
(
IsTrue
()));
EXPECT_THAT
(
0
,
IsFalse
());
EXPECT_THAT
(
0
,
IsFalse
());
EXPECT_THAT
(
NULL
,
Not
(
IsTrue
()));
EXPECT_THAT
(
nullptr
,
Not
(
IsTrue
()));
EXPECT_THAT
(
NULL
,
IsFalse
());
EXPECT_THAT
(
nullptr
,
IsFalse
());
EXPECT_THAT
(
-
1
,
IsTrue
());
EXPECT_THAT
(
-
1
,
IsTrue
());
EXPECT_THAT
(
-
1
,
Not
(
IsFalse
()));
EXPECT_THAT
(
-
1
,
Not
(
IsFalse
()));
EXPECT_THAT
(
1
,
IsTrue
());
EXPECT_THAT
(
1
,
IsTrue
());
...
...
googlemock/test/gmock-more-actions_test.cc
View file @
3896e3b5
...
@@ -35,11 +35,11 @@
...
@@ -35,11 +35,11 @@
#include "gmock/gmock-more-actions.h"
#include "gmock/gmock-more-actions.h"
#include <functional>
#include <functional>
#include <memory>
#include <sstream>
#include <sstream>
#include <string>
#include <string>
#include "gmock/gmock.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include "gtest/internal/gtest-linked_ptr.h"
namespace
testing
{
namespace
testing
{
namespace
gmock_more_actions_test
{
namespace
gmock_more_actions_test
{
...
@@ -61,7 +61,6 @@ using testing::StaticAssertTypeEq;
...
@@ -61,7 +61,6 @@ using testing::StaticAssertTypeEq;
using
testing
::
Unused
;
using
testing
::
Unused
;
using
testing
::
WithArg
;
using
testing
::
WithArg
;
using
testing
::
WithoutArgs
;
using
testing
::
WithoutArgs
;
using
testing
::
internal
::
linked_ptr
;
// For suppressing compiler warnings on conversion possibly losing precision.
// For suppressing compiler warnings on conversion possibly losing precision.
inline
short
Short
(
short
n
)
{
return
n
;
}
// NOLINT
inline
short
Short
(
short
n
)
{
return
n
;
}
// NOLINT
...
@@ -529,14 +528,6 @@ TEST(SaveArgPointeeActionTest, WorksForCompatibleType) {
...
@@ -529,14 +528,6 @@ TEST(SaveArgPointeeActionTest, WorksForCompatibleType) {
EXPECT_EQ
(
'a'
,
result
);
EXPECT_EQ
(
'a'
,
result
);
}
}
TEST
(
SaveArgPointeeActionTest
,
WorksForLinkedPtr
)
{
int
result
=
0
;
linked_ptr
<
int
>
value
(
new
int
(
5
));
const
Action
<
void
(
linked_ptr
<
int
>
)
>
a1
=
SaveArgPointee
<
0
>
(
&
result
);
a1
.
Perform
(
std
::
make_tuple
(
value
));
EXPECT_EQ
(
5
,
result
);
}
TEST
(
SetArgRefereeActionTest
,
WorksForSameType
)
{
TEST
(
SetArgRefereeActionTest
,
WorksForSameType
)
{
int
value
=
0
;
int
value
=
0
;
const
Action
<
void
(
int
&
)
>
a1
=
SetArgReferee
<
0
>
(
1
);
const
Action
<
void
(
int
&
)
>
a1
=
SetArgReferee
<
0
>
(
1
);
...
...
googlemock/test/gmock-spec-builders_test.cc
View file @
3896e3b5
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "gmock/gmock-spec-builders.h"
#include "gmock/gmock-spec-builders.h"
#include <memory>
#include <ostream> // NOLINT
#include <ostream> // NOLINT
#include <sstream>
#include <sstream>
#include <string>
#include <string>
...
@@ -99,7 +100,6 @@ using testing::internal::kFail;
...
@@ -99,7 +100,6 @@ using testing::internal::kFail;
using
testing
::
internal
::
kInfoVerbosity
;
using
testing
::
internal
::
kInfoVerbosity
;
using
testing
::
internal
::
kWarn
;
using
testing
::
internal
::
kWarn
;
using
testing
::
internal
::
kWarningVerbosity
;
using
testing
::
internal
::
kWarningVerbosity
;
using
testing
::
internal
::
linked_ptr
;
#if GTEST_HAS_STREAM_REDIRECTION
#if GTEST_HAS_STREAM_REDIRECTION
using
testing
::
HasSubstr
;
using
testing
::
HasSubstr
;
...
@@ -172,7 +172,7 @@ class ReferenceHoldingMock {
...
@@ -172,7 +172,7 @@ class ReferenceHoldingMock {
public:
public:
ReferenceHoldingMock
()
{}
ReferenceHoldingMock
()
{}
MOCK_METHOD1
(
AcceptReference
,
void
(
link
ed_ptr
<
MockA
>*
));
MOCK_METHOD1
(
AcceptReference
,
void
(
std
::
shar
ed_ptr
<
MockA
>*
));
private:
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
ReferenceHoldingMock
);
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
ReferenceHoldingMock
);
...
@@ -2619,7 +2619,7 @@ TEST(VerifyAndClearTest, DoesNotAffectOtherMockObjects) {
...
@@ -2619,7 +2619,7 @@ TEST(VerifyAndClearTest, DoesNotAffectOtherMockObjects) {
TEST
(
VerifyAndClearTest
,
TEST
(
VerifyAndClearTest
,
DestroyingChainedMocksDoesNotDeadlockThroughExpectations
)
{
DestroyingChainedMocksDoesNotDeadlockThroughExpectations
)
{
link
ed_ptr
<
MockA
>
a
(
new
MockA
);
std
::
shar
ed_ptr
<
MockA
>
a
(
new
MockA
);
ReferenceHoldingMock
test_mock
;
ReferenceHoldingMock
test_mock
;
// EXPECT_CALL stores a reference to a inside test_mock.
// EXPECT_CALL stores a reference to a inside test_mock.
...
@@ -2639,7 +2639,7 @@ TEST(VerifyAndClearTest,
...
@@ -2639,7 +2639,7 @@ TEST(VerifyAndClearTest,
TEST
(
VerifyAndClearTest
,
TEST
(
VerifyAndClearTest
,
DestroyingChainedMocksDoesNotDeadlockThroughDefaultAction
)
{
DestroyingChainedMocksDoesNotDeadlockThroughDefaultAction
)
{
link
ed_ptr
<
MockA
>
a
(
new
MockA
);
std
::
shar
ed_ptr
<
MockA
>
a
(
new
MockA
);
ReferenceHoldingMock
test_mock
;
ReferenceHoldingMock
test_mock
;
// ON_CALL stores a reference to a inside test_mock.
// ON_CALL stores a reference to a inside test_mock.
...
...
googlemock/test/gmock_link_test.h
View file @
3896e3b5
...
@@ -414,7 +414,7 @@ TEST(LinkTest, TestThrow) {
...
@@ -414,7 +414,7 @@ TEST(LinkTest, TestThrow) {
Mock
mock
;
Mock
mock
;
EXPECT_CALL
(
mock
,
VoidFromString
(
_
)).
WillOnce
(
Throw
(
42
));
EXPECT_CALL
(
mock
,
VoidFromString
(
_
)).
WillOnce
(
Throw
(
42
));
EXPECT_THROW
(
mock
.
VoidFromString
(
NULL
),
int
);
EXPECT_THROW
(
mock
.
VoidFromString
(
nullptr
),
int
);
}
}
#endif // GTEST_HAS_EXCEPTIONS
#endif // GTEST_HAS_EXCEPTIONS
...
...
googlemock/test/gmock_stress_test.cc
View file @
3896e3b5
...
@@ -60,87 +60,8 @@ void JoinAndDelete(ThreadWithParam<T>* t) {
...
@@ -60,87 +60,8 @@ void JoinAndDelete(ThreadWithParam<T>* t) {
delete
t
;
delete
t
;
}
}
using
internal
::
linked_ptr
;
// Helper classes for testing using linked_ptr concurrently.
class
Base
{
public:
explicit
Base
(
int
a_x
)
:
x_
(
a_x
)
{}
virtual
~
Base
()
{}
int
x
()
const
{
return
x_
;
}
private:
int
x_
;
};
class
Derived1
:
public
Base
{
public:
Derived1
(
int
a_x
,
int
a_y
)
:
Base
(
a_x
),
y_
(
a_y
)
{}
int
y
()
const
{
return
y_
;
}
private:
int
y_
;
};
class
Derived2
:
public
Base
{
public:
Derived2
(
int
a_x
,
int
a_z
)
:
Base
(
a_x
),
z_
(
a_z
)
{}
int
z
()
const
{
return
z_
;
}
private:
int
z_
;
};
linked_ptr
<
Derived1
>
pointer1
(
new
Derived1
(
1
,
2
));
linked_ptr
<
Derived2
>
pointer2
(
new
Derived2
(
3
,
4
));
struct
Dummy
{};
struct
Dummy
{};
// Tests that we can copy from a linked_ptr and read it concurrently.
void
TestConcurrentCopyAndReadLinkedPtr
(
Dummy
/* dummy */
)
{
// Reads pointer1 and pointer2 while they are being copied from in
// another thread.
EXPECT_EQ
(
1
,
pointer1
->
x
());
EXPECT_EQ
(
2
,
pointer1
->
y
());
EXPECT_EQ
(
3
,
pointer2
->
x
());
EXPECT_EQ
(
4
,
pointer2
->
z
());
// Copies from pointer1.
linked_ptr
<
Derived1
>
p1
(
pointer1
);
EXPECT_EQ
(
1
,
p1
->
x
());
EXPECT_EQ
(
2
,
p1
->
y
());
// Assigns from pointer2 where the LHS was empty.
linked_ptr
<
Base
>
p2
;
p2
=
pointer1
;
EXPECT_EQ
(
1
,
p2
->
x
());
// Assigns from pointer2 where the LHS was not empty.
p2
=
pointer2
;
EXPECT_EQ
(
3
,
p2
->
x
());
}
const
linked_ptr
<
Derived1
>
p0
(
new
Derived1
(
1
,
2
));
// Tests that we can concurrently modify two linked_ptrs that point to
// the same object.
void
TestConcurrentWriteToEqualLinkedPtr
(
Dummy
/* dummy */
)
{
// p1 and p2 point to the same, shared thing. One thread resets p1.
// Another thread assigns to p2. This will cause the same
// underlying "ring" to be updated concurrently.
linked_ptr
<
Derived1
>
p1
(
p0
);
linked_ptr
<
Derived1
>
p2
(
p0
);
EXPECT_EQ
(
1
,
p1
->
x
());
EXPECT_EQ
(
2
,
p1
->
y
());
EXPECT_EQ
(
1
,
p2
->
x
());
EXPECT_EQ
(
2
,
p2
->
y
());
p1
.
reset
();
p2
=
p0
;
EXPECT_EQ
(
1
,
p2
->
x
());
EXPECT_EQ
(
2
,
p2
->
y
());
}
// Tests that different mock objects can be used in their respective
// Tests that different mock objects can be used in their respective
// threads. This should generate no Google Test failure.
// threads. This should generate no Google Test failure.
...
@@ -275,8 +196,6 @@ void TestPartiallyOrderedExpectationsWithThreads(Dummy /* dummy */) {
...
@@ -275,8 +196,6 @@ void TestPartiallyOrderedExpectationsWithThreads(Dummy /* dummy */) {
// Tests using Google Mock constructs in many threads concurrently.
// Tests using Google Mock constructs in many threads concurrently.
TEST
(
StressTest
,
CanUseGMockWithThreads
)
{
TEST
(
StressTest
,
CanUseGMockWithThreads
)
{
void
(
*
test_routines
[])(
Dummy
dummy
)
=
{
void
(
*
test_routines
[])(
Dummy
dummy
)
=
{
&
TestConcurrentCopyAndReadLinkedPtr
,
&
TestConcurrentWriteToEqualLinkedPtr
,
&
TestConcurrentMockObjects
,
&
TestConcurrentMockObjects
,
&
TestConcurrentCallsOnSameObject
,
&
TestConcurrentCallsOnSameObject
,
&
TestPartiallyOrderedExpectationsWithThreads
,
&
TestPartiallyOrderedExpectationsWithThreads
,
...
...
googletest/CMakeLists.txt
View file @
3896e3b5
...
@@ -195,7 +195,6 @@ $env:Path = \"$project_bin;$env:Path\"
...
@@ -195,7 +195,6 @@ $env:Path = \"$project_bin;$env:Path\"
cxx_test
(
googletest-death-test-test gtest_main
)
cxx_test
(
googletest-death-test-test gtest_main
)
cxx_test
(
gtest_environment_test gtest
)
cxx_test
(
gtest_environment_test gtest
)
cxx_test
(
googletest-filepath-test gtest_main
)
cxx_test
(
googletest-filepath-test gtest_main
)
cxx_test
(
googletest-linked-ptr-test gtest_main
)
cxx_test
(
googletest-listener-test gtest_main
)
cxx_test
(
googletest-listener-test gtest_main
)
cxx_test
(
gtest_main_unittest gtest_main
)
cxx_test
(
gtest_main_unittest gtest_main
)
cxx_test
(
googletest-message-test gtest_main
)
cxx_test
(
googletest-message-test gtest_main
)
...
...
googletest/Makefile.am
View file @
3896e3b5
...
@@ -48,7 +48,6 @@ EXTRA_DIST += \
...
@@ -48,7 +48,6 @@ EXTRA_DIST += \
test
/gtest-death-test_ex_test.cc
\
test
/gtest-death-test_ex_test.cc
\
test
/gtest-death-test_test.cc
\
test
/gtest-death-test_test.cc
\
test
/gtest-filepath_test.cc
\
test
/gtest-filepath_test.cc
\
test
/gtest-linked_ptr_test.cc
\
test
/gtest-listener_test.cc
\
test
/gtest-listener_test.cc
\
test
/gtest-message_test.cc
\
test
/gtest-message_test.cc
\
test
/gtest-options_test.cc
\
test
/gtest-options_test.cc
\
...
@@ -200,7 +199,6 @@ pkginclude_internal_HEADERS = \
...
@@ -200,7 +199,6 @@ pkginclude_internal_HEADERS = \
include/gtest/internal/gtest-death-test-internal.h
\
include/gtest/internal/gtest-death-test-internal.h
\
include/gtest/internal/gtest-filepath.h
\
include/gtest/internal/gtest-filepath.h
\
include/gtest/internal/gtest-internal.h
\
include/gtest/internal/gtest-internal.h
\
include/gtest/internal/gtest-linked_ptr.h
\
include/gtest/internal/gtest-param-util-generated.h
\
include/gtest/internal/gtest-param-util-generated.h
\
include/gtest/internal/gtest-param-util.h
\
include/gtest/internal/gtest-param-util.h
\
include/gtest/internal/gtest-port.h
\
include/gtest/internal/gtest-port.h
\
...
...
googletest/include/gtest/gtest-message.h
View file @
3896e3b5
...
@@ -207,7 +207,7 @@ class GTEST_API_ Message {
...
@@ -207,7 +207,7 @@ class GTEST_API_ Message {
// tr1::type_traits-like is_pointer works, and we can overload on that.
// tr1::type_traits-like is_pointer works, and we can overload on that.
template
<
typename
T
>
template
<
typename
T
>
inline
void
StreamHelper
(
internal
::
true_type
/*is_pointer*/
,
T
*
pointer
)
{
inline
void
StreamHelper
(
internal
::
true_type
/*is_pointer*/
,
T
*
pointer
)
{
if
(
pointer
==
NULL
)
{
if
(
pointer
==
nullptr
)
{
*
ss_
<<
"(null)"
;
*
ss_
<<
"(null)"
;
}
else
{
}
else
{
*
ss_
<<
pointer
;
*
ss_
<<
pointer
;
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment