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
9e712372
Unverified
Commit
9e712372
authored
Mar 18, 2022
by
Brad Messer
Committed by
GitHub
Mar 18, 2022
Browse files
Merge branch 'main' into promote-inclusive-behavior
parents
794da715
b007c54f
Changes
135
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
796 additions
and
773 deletions
+796
-773
CONTRIBUTORS
CONTRIBUTORS
+1
-0
docs/advanced.md
docs/advanced.md
+17
-4
docs/reference/testing.md
docs/reference/testing.md
+2
-2
googlemock/include/gmock/gmock-actions.h
googlemock/include/gmock/gmock-actions.h
+86
-81
googlemock/include/gmock/gmock-cardinalities.h
googlemock/include/gmock/gmock-cardinalities.h
+3
-1
googlemock/include/gmock/gmock-function-mocker.h
googlemock/include/gmock/gmock-function-mocker.h
+1
-1
googlemock/include/gmock/gmock-more-actions.h
googlemock/include/gmock/gmock-more-actions.h
+342
-254
googlemock/include/gmock/gmock-more-matchers.h
googlemock/include/gmock/gmock-more-matchers.h
+5
-6
googlemock/include/gmock/gmock-spec-builders.h
googlemock/include/gmock/gmock-spec-builders.h
+88
-120
googlemock/include/gmock/internal/gmock-internal-utils.h
googlemock/include/gmock/internal/gmock-internal-utils.h
+36
-35
googlemock/include/gmock/internal/gmock-port.h
googlemock/include/gmock/internal/gmock-port.h
+15
-8
googlemock/src/gmock-cardinalities.cc
googlemock/src/gmock-cardinalities.cc
+4
-5
googlemock/src/gmock-internal-utils.cc
googlemock/src/gmock-internal-utils.cc
+9
-15
googlemock/src/gmock-matchers.cc
googlemock/src/gmock-matchers.cc
+0
-1
googlemock/src/gmock-spec-builders.cc
googlemock/src/gmock-spec-builders.cc
+29
-33
googlemock/src/gmock.cc
googlemock/src/gmock.cc
+1
-1
googlemock/src/gmock_main.cc
googlemock/src/gmock_main.cc
+2
-2
googlemock/test/gmock-actions_test.cc
googlemock/test/gmock-actions_test.cc
+73
-95
googlemock/test/gmock-cardinalities_test.cc
googlemock/test/gmock-cardinalities_test.cc
+50
-58
googlemock/test/gmock-function-mocker_test.cc
googlemock/test/gmock-function-mocker_test.cc
+32
-51
No files found.
CONTRIBUTORS
View file @
9e712372
...
@@ -56,6 +56,7 @@ Russ Rufer <russ@pentad.com>
...
@@ -56,6 +56,7 @@ Russ Rufer <russ@pentad.com>
Sean Mcafee <eefacm@gmail.com>
Sean Mcafee <eefacm@gmail.com>
Sigurður Ásgeirsson <siggi@google.com>
Sigurður Ásgeirsson <siggi@google.com>
Sverre Sundsdal <sundsdal@gmail.com>
Sverre Sundsdal <sundsdal@gmail.com>
Szymon Sobik <sobik.szymon@gmail.com>
Takeshi Yoshino <tyoshino@google.com>
Takeshi Yoshino <tyoshino@google.com>
Tracy Bialik <tracy@pentad.com>
Tracy Bialik <tracy@pentad.com>
Vadim Berman <vadimb@google.com>
Vadim Berman <vadimb@google.com>
...
...
docs/advanced.md
View file @
9e712372
...
@@ -839,7 +839,7 @@ will output XML like this:
...
@@ -839,7 +839,7 @@ will output XML like this:
```
xml
```
xml
...
...
<testcase
name=
"MinAndMaxWidgets"
status=
"run"
time=
"0.006"
classname=
"WidgetUsageTest"
MaximumWidgets=
"12"
MinimumWidgets=
"9"
/>
<testcase
name=
"MinAndMaxWidgets"
file=
"test.cpp"
line=
"1"
status=
"run"
time=
"0.006"
classname=
"WidgetUsageTest"
MaximumWidgets=
"12"
MinimumWidgets=
"9"
/>
...
...
```
```
...
@@ -2082,15 +2082,15 @@ could generate this report:
...
@@ -2082,15 +2082,15 @@ could generate this report:
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<testsuites
tests=
"3"
failures=
"1"
errors=
"0"
time=
"0.035"
timestamp=
"2011-10-31T18:52:42"
name=
"AllTests"
>
<testsuites
tests=
"3"
failures=
"1"
errors=
"0"
time=
"0.035"
timestamp=
"2011-10-31T18:52:42"
name=
"AllTests"
>
<testsuite
name=
"MathTest"
tests=
"2"
failures=
"1"
errors=
"0"
time=
"0.015"
>
<testsuite
name=
"MathTest"
tests=
"2"
failures=
"1"
errors=
"0"
time=
"0.015"
>
<testcase
name=
"Addition"
status=
"run"
time=
"0.007"
classname=
""
>
<testcase
name=
"Addition"
file=
"test.cpp"
line=
"1"
status=
"run"
time=
"0.007"
classname=
""
>
<failure
message=
"Value of: add(1, 1)
 Actual: 3
Expected: 2"
type=
""
>
...
</failure>
<failure
message=
"Value of: add(1, 1)
 Actual: 3
Expected: 2"
type=
""
>
...
</failure>
<failure
message=
"Value of: add(1, -1)
 Actual: 1
Expected: 0"
type=
""
>
...
</failure>
<failure
message=
"Value of: add(1, -1)
 Actual: 1
Expected: 0"
type=
""
>
...
</failure>
</testcase>
</testcase>
<testcase
name=
"Subtraction"
status=
"run"
time=
"0.005"
classname=
""
>
<testcase
name=
"Subtraction"
file=
"test.cpp"
line=
"2"
status=
"run"
time=
"0.005"
classname=
""
>
</testcase>
</testcase>
</testsuite>
</testsuite>
<testsuite
name=
"LogicTest"
tests=
"1"
failures=
"0"
errors=
"0"
time=
"0.005"
>
<testsuite
name=
"LogicTest"
tests=
"1"
failures=
"0"
errors=
"0"
time=
"0.005"
>
<testcase
name=
"NonContradiction"
status=
"run"
time=
"0.005"
classname=
""
>
<testcase
name=
"NonContradiction"
file=
"test.cpp"
line=
"3"
status=
"run"
time=
"0.005"
classname=
""
>
</testcase>
</testcase>
</testsuite>
</testsuite>
</testsuites>
</testsuites>
...
@@ -2108,6 +2108,9 @@ Things to note:
...
@@ -2108,6 +2108,9 @@ Things to note:
*
The
`timestamp`
attribute records the local date and time of the test
*
The
`timestamp`
attribute records the local date and time of the test
execution.
execution.
*
The
`file`
and
`line`
attributes record the source file location, where the
test was defined.
*
Each
`<failure>`
element corresponds to a single failed googletest
*
Each
`<failure>`
element corresponds to a single failed googletest
assertion.
assertion.
...
@@ -2147,6 +2150,8 @@ The report format conforms to the following JSON Schema:
...
@@ -2147,6 +2150,8 @@ The report format conforms to the following JSON Schema:
"type"
:
"object"
,
"type"
:
"object"
,
"properties"
:
{
"properties"
:
{
"name"
:
{
"type"
:
"string"
},
"name"
:
{
"type"
:
"string"
},
"file"
:
{
"type"
:
"string"
},
"line"
:
{
"type"
:
"integer"
},
"status"
:
{
"status"
:
{
"type"
:
"string"
,
"type"
:
"string"
,
"enum"
:
[
"RUN"
,
"NOTRUN"
]
"enum"
:
[
"RUN"
,
"NOTRUN"
]
...
@@ -2224,6 +2229,8 @@ message TestCase {
...
@@ -2224,6 +2229,8 @@ message TestCase {
message
TestInfo
{
message
TestInfo
{
string
name
=
1
;
string
name
=
1
;
string
file
=
6
;
int32
line
=
7
;
enum
Status
{
enum
Status
{
RUN
=
0
;
RUN
=
0
;
NOTRUN
=
1
;
NOTRUN
=
1
;
...
@@ -2267,6 +2274,8 @@ could generate this report:
...
@@ -2267,6 +2274,8 @@ could generate this report:
"testsuite"
:
[
"testsuite"
:
[
{
{
"name"
:
"Addition"
,
"name"
:
"Addition"
,
"file"
:
"test.cpp"
,
"line"
:
1
,
"status"
:
"RUN"
,
"status"
:
"RUN"
,
"time"
:
"0.007s"
,
"time"
:
"0.007s"
,
"classname"
:
""
,
"classname"
:
""
,
...
@@ -2283,6 +2292,8 @@ could generate this report:
...
@@ -2283,6 +2292,8 @@ could generate this report:
},
},
{
{
"name"
:
"Subtraction"
,
"name"
:
"Subtraction"
,
"file"
:
"test.cpp"
,
"line"
:
2
,
"status"
:
"RUN"
,
"status"
:
"RUN"
,
"time"
:
"0.005s"
,
"time"
:
"0.005s"
,
"classname"
:
""
"classname"
:
""
...
@@ -2298,6 +2309,8 @@ could generate this report:
...
@@ -2298,6 +2309,8 @@ could generate this report:
"testsuite"
:
[
"testsuite"
:
[
{
{
"name"
:
"NonContradiction"
,
"name"
:
"NonContradiction"
,
"file"
:
"test.cpp"
,
"line"
:
3
,
"status"
:
"RUN"
,
"status"
:
"RUN"
,
"time"
:
"0.005s"
,
"time"
:
"0.005s"
,
"classname"
:
""
"classname"
:
""
...
...
docs/reference/testing.md
View file @
9e712372
...
@@ -518,8 +518,8 @@ Logs a property for the current test, test suite, or entire invocation of the
...
@@ -518,8 +518,8 @@ Logs a property for the current test, test suite, or entire invocation of the
test program. Only the last value for a given key is logged.
test program. Only the last value for a given key is logged.
The key must be a valid XML attribute name, and cannot conflict with the ones
The key must be a valid XML attribute name, and cannot conflict with the ones
already used by GoogleTest (
`name`
,
`
status
`
,
`
tim
e`
,
`
classname`
,
`type_param
`
,
already used by GoogleTest (
`name`
,
`
file
`
,
`
lin
e`
,
`
status`
,
`time
`
,
and
`value_param`
).
`classname`
,
`type_param`
,
and
`value_param`
).
`RecordProperty`
is
`public static`
so it can be called from utility functions
`RecordProperty`
is
`public static`
so it can be called from utility functions
that are not members of the test fixture.
that are not members of the test fixture.
...
...
googlemock/include/gmock/gmock-actions.h
View file @
9e712372
...
@@ -131,7 +131,7 @@
...
@@ -131,7 +131,7 @@
#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
#ifndef _WIN32_WCE
#ifndef _WIN32_WCE
#
include <errno.h>
#include <errno.h>
#endif
#endif
#include <algorithm>
#include <algorithm>
...
@@ -147,8 +147,8 @@
...
@@ -147,8 +147,8 @@
#include "gmock/internal/gmock-pp.h"
#include "gmock/internal/gmock-pp.h"
#ifdef _MSC_VER
#ifdef _MSC_VER
#
pragma warning(push)
#pragma warning(push)
#
pragma warning(disable
:
4100)
#pragma warning(disable
:
4100)
#endif
#endif
namespace
testing
{
namespace
testing
{
...
@@ -196,9 +196,7 @@ class BuiltInDefaultValue {
...
@@ -196,9 +196,7 @@ class BuiltInDefaultValue {
public:
public:
// This function returns true if and only if type T has a built-in default
// This function returns true if and only if type T has a built-in default
// value.
// value.
static
bool
Exists
()
{
static
bool
Exists
()
{
return
::
std
::
is_default_constructible
<
T
>::
value
;
}
return
::
std
::
is_default_constructible
<
T
>::
value
;
}
static
T
Get
()
{
static
T
Get
()
{
return
BuiltInDefaultValueGetter
<
return
BuiltInDefaultValueGetter
<
...
@@ -227,11 +225,11 @@ class BuiltInDefaultValue<T*> {
...
@@ -227,11 +225,11 @@ class BuiltInDefaultValue<T*> {
// The following specializations define the default values for
// The following specializations define the default values for
// specific types we care about.
// specific types we care about.
#define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \
#define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \
template <> \
template <>
\
class BuiltInDefaultValue<type> { \
class BuiltInDefaultValue<type> {
\
public: \
public:
\
static bool Exists() { return true; } \
static bool Exists() { return true; }
\
static type Get() { return value; } \
static type Get() { return value; }
\
}
}
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
void
,
);
// NOLINT
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
void
,
);
// NOLINT
...
@@ -255,10 +253,10 @@ GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned short, 0U); // NOLINT
...
@@ -255,10 +253,10 @@ GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned short, 0U); // NOLINT
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
signed
short
,
0
);
// NOLINT
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
signed
short
,
0
);
// NOLINT
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
unsigned
int
,
0U
);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
unsigned
int
,
0U
);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
signed
int
,
0
);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
signed
int
,
0
);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
unsigned
long
,
0UL
);
// NOLINT
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
unsigned
long
,
0UL
);
// NOLINT
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
signed
long
,
0L
);
// NOLINT
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
signed
long
,
0L
);
// NOLINT
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
unsigned
long
long
,
0
);
// NOLINT
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
unsigned
long
long
,
0
);
// NOLINT
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
signed
long
long
,
0
);
// NOLINT
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
signed
long
long
,
0
);
// NOLINT
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
float
,
0
);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
float
,
0
);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
double
,
0
);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_
(
double
,
0
);
...
@@ -839,7 +837,7 @@ class ReturnRoundRobinAction {
...
@@ -839,7 +837,7 @@ class ReturnRoundRobinAction {
template
<
typename
...
Args
>
template
<
typename
...
Args
>
T
operator
()(
Args
&&
...)
const
{
T
operator
()(
Args
&&
...)
const
{
return
state_
->
Next
();
return
state_
->
Next
();
}
}
private:
private:
...
@@ -862,7 +860,9 @@ class DoDefaultAction {
...
@@ -862,7 +860,9 @@ class DoDefaultAction {
// This template type conversion operator allows DoDefault() to be
// This template type conversion operator allows DoDefault() to be
// used in any function.
// used in any function.
template
<
typename
F
>
template
<
typename
F
>
operator
Action
<
F
>
()
const
{
return
Action
<
F
>
();
}
// NOLINT
operator
Action
<
F
>
()
const
{
return
Action
<
F
>
();
}
// NOLINT
};
};
// Implements the Assign action to set a given pointer referent to a
// Implements the Assign action to set a given pointer referent to a
...
@@ -890,8 +890,7 @@ template <typename T>
...
@@ -890,8 +890,7 @@ template <typename T>
class
SetErrnoAndReturnAction
{
class
SetErrnoAndReturnAction
{
public:
public:
SetErrnoAndReturnAction
(
int
errno_value
,
T
result
)
SetErrnoAndReturnAction
(
int
errno_value
,
T
result
)
:
errno_
(
errno_value
),
:
errno_
(
errno_value
),
result_
(
result
)
{}
result_
(
result
)
{}
template
<
typename
Result
,
typename
ArgumentTuple
>
template
<
typename
Result
,
typename
ArgumentTuple
>
Result
Perform
(
const
ArgumentTuple
&
/* args */
)
const
{
Result
Perform
(
const
ArgumentTuple
&
/* args */
)
const
{
errno
=
errno_
;
errno
=
errno_
;
...
@@ -1002,8 +1001,8 @@ class IgnoreResultAction {
...
@@ -1002,8 +1001,8 @@ class IgnoreResultAction {
private:
private:
// Type OriginalFunction is the same as F except that its return
// Type OriginalFunction is the same as F except that its return
// type is IgnoredValue.
// type is IgnoredValue.
typedef
typename
internal
::
Function
<
F
>::
MakeResultIgnoredValue
typedef
OriginalFunction
;
typename
internal
::
Function
<
F
>::
MakeResultIgnoredValue
OriginalFunction
;
const
Action
<
OriginalFunction
>
action_
;
const
Action
<
OriginalFunction
>
action_
;
};
};
...
@@ -1020,12 +1019,12 @@ struct WithArgsAction {
...
@@ -1020,12 +1019,12 @@ struct WithArgsAction {
template
<
typename
R
,
typename
...
Args
>
template
<
typename
R
,
typename
...
Args
>
operator
Action
<
R
(
Args
...)
>
()
const
{
// NOLINT
operator
Action
<
R
(
Args
...)
>
()
const
{
// NOLINT
using
TupleType
=
std
::
tuple
<
Args
...
>
;
using
TupleType
=
std
::
tuple
<
Args
...
>
;
Action
<
R
(
typename
std
::
tuple_element
<
I
,
TupleType
>::
type
...)
>
Action
<
R
(
typename
std
::
tuple_element
<
I
,
TupleType
>::
type
...)
>
converted
(
converted
(
action
);
action
);
return
[
converted
](
Args
...
args
)
->
R
{
return
[
converted
](
Args
...
args
)
->
R
{
return
converted
.
Perform
(
std
::
forward_as_tuple
(
return
converted
.
Perform
(
std
::
forward_as_tuple
(
std
::
get
<
I
>
(
std
::
forward_as_tuple
(
std
::
forward
<
Args
>
(
args
)...))...));
std
::
get
<
I
>
(
std
::
forward_as_tuple
(
std
::
forward
<
Args
>
(
args
)...))...));
};
};
}
}
};
};
...
@@ -1212,8 +1211,8 @@ internal::DoAllAction<typename std::decay<Action>::type...> DoAll(
...
@@ -1212,8 +1211,8 @@ internal::DoAllAction<typename std::decay<Action>::type...> DoAll(
// multiple arguments. For convenience, we also provide
// multiple arguments. For convenience, we also provide
// WithArgs<k>(an_action) (defined below) as a synonym.
// WithArgs<k>(an_action) (defined below) as a synonym.
template
<
size_t
k
,
typename
InnerAction
>
template
<
size_t
k
,
typename
InnerAction
>
internal
::
WithArgsAction
<
typename
std
::
decay
<
InnerAction
>::
type
,
k
>
internal
::
WithArgsAction
<
typename
std
::
decay
<
InnerAction
>::
type
,
k
>
WithArg
(
WithArg
(
InnerAction
&&
action
)
{
InnerAction
&&
action
)
{
return
{
std
::
forward
<
InnerAction
>
(
action
)};
return
{
std
::
forward
<
InnerAction
>
(
action
)};
}
}
...
@@ -1232,8 +1231,8 @@ WithArgs(InnerAction&& action) {
...
@@ -1232,8 +1231,8 @@ WithArgs(InnerAction&& action) {
// argument. In other words, it adapts an action accepting no
// argument. In other words, it adapts an action accepting no
// argument to one that accepts (and ignores) arguments.
// argument to one that accepts (and ignores) arguments.
template
<
typename
InnerAction
>
template
<
typename
InnerAction
>
internal
::
WithArgsAction
<
typename
std
::
decay
<
InnerAction
>::
type
>
internal
::
WithArgsAction
<
typename
std
::
decay
<
InnerAction
>::
type
>
WithoutArgs
(
WithoutArgs
(
InnerAction
&&
action
)
{
InnerAction
&&
action
)
{
return
{
std
::
forward
<
InnerAction
>
(
action
)};
return
{
std
::
forward
<
InnerAction
>
(
action
)};
}
}
...
@@ -1319,7 +1318,7 @@ internal::SetArgumentPointeeAction<N, T> SetArgumentPointee(T value) {
...
@@ -1319,7 +1318,7 @@ internal::SetArgumentPointeeAction<N, T> SetArgumentPointee(T value) {
// Creates an action that sets a pointer referent to a given value.
// Creates an action that sets a pointer referent to a given value.
template
<
typename
T1
,
typename
T2
>
template
<
typename
T1
,
typename
T2
>
PolymorphicAction
<
internal
::
AssignAction
<
T1
,
T2
>
>
Assign
(
T1
*
ptr
,
T2
val
)
{
PolymorphicAction
<
internal
::
AssignAction
<
T1
,
T2
>>
Assign
(
T1
*
ptr
,
T2
val
)
{
return
MakePolymorphicAction
(
internal
::
AssignAction
<
T1
,
T2
>
(
ptr
,
val
));
return
MakePolymorphicAction
(
internal
::
AssignAction
<
T1
,
T2
>
(
ptr
,
val
));
}
}
...
@@ -1327,8 +1326,8 @@ PolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) {
...
@@ -1327,8 +1326,8 @@ PolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) {
// Creates an action that sets errno and returns the appropriate error.
// Creates an action that sets errno and returns the appropriate error.
template
<
typename
T
>
template
<
typename
T
>
PolymorphicAction
<
internal
::
SetErrnoAndReturnAction
<
T
>
>
PolymorphicAction
<
internal
::
SetErrnoAndReturnAction
<
T
>>
SetErrnoAndReturn
(
SetErrnoAndReturn
(
int
errval
,
T
result
)
{
int
errval
,
T
result
)
{
return
MakePolymorphicAction
(
return
MakePolymorphicAction
(
internal
::
SetErrnoAndReturnAction
<
T
>
(
errval
,
result
));
internal
::
SetErrnoAndReturnAction
<
T
>
(
errval
,
result
));
}
}
...
@@ -1482,7 +1481,8 @@ struct ExcessiveArg {};
...
@@ -1482,7 +1481,8 @@ struct ExcessiveArg {};
// Builds an implementation of an Action<> for some particular signature, using
// Builds an implementation of an Action<> for some particular signature, using
// a class defined by an ACTION* macro.
// a class defined by an ACTION* macro.
template
<
typename
F
,
typename
Impl
>
struct
ActionImpl
;
template
<
typename
F
,
typename
Impl
>
struct
ActionImpl
;
template
<
typename
Impl
>
template
<
typename
Impl
>
struct
ImplBase
{
struct
ImplBase
{
...
@@ -1502,7 +1502,7 @@ struct ActionImpl<R(Args...), Impl> : ImplBase<Impl>::type {
...
@@ -1502,7 +1502,7 @@ struct ActionImpl<R(Args...), Impl> : ImplBase<Impl>::type {
using
args_type
=
std
::
tuple
<
Args
...
>
;
using
args_type
=
std
::
tuple
<
Args
...
>
;
ActionImpl
()
=
default
;
// Only defined if appropriate for Base.
ActionImpl
()
=
default
;
// Only defined if appropriate for Base.
explicit
ActionImpl
(
std
::
shared_ptr
<
Impl
>
impl
)
:
Base
{
std
::
move
(
impl
)}
{
}
explicit
ActionImpl
(
std
::
shared_ptr
<
Impl
>
impl
)
:
Base
{
std
::
move
(
impl
)}
{}
R
operator
()(
Args
&&
...
arg
)
const
{
R
operator
()(
Args
&&
...
arg
)
const
{
static
constexpr
size_t
kMaxArgs
=
static
constexpr
size_t
kMaxArgs
=
...
@@ -1521,12 +1521,14 @@ struct ActionImpl<R(Args...), Impl> : ImplBase<Impl>::type {
...
@@ -1521,12 +1521,14 @@ struct ActionImpl<R(Args...), Impl> : ImplBase<Impl>::type {
// args_type get passed, followed by a dummy of unspecified type for the
// args_type get passed, followed by a dummy of unspecified type for the
// remainder up to 10 explicit args.
// remainder up to 10 explicit args.
static
constexpr
ExcessiveArg
kExcessArg
{};
static
constexpr
ExcessiveArg
kExcessArg
{};
return
static_cast
<
const
Impl
&>
(
*
this
).
template
gmock_PerformImpl
<
return
static_cast
<
const
Impl
&>
(
*
this
)
/*function_type=*/
function_type
,
/*return_type=*/
R
,
.
template
gmock_PerformImpl
<
/*args_type=*/
args_type
,
/*function_type=*/
function_type
,
/*return_type=*/
R
,
/*argN_type=*/
typename
std
::
tuple_element
<
arg_id
,
args_type
>
::
type
...
>
(
/*args_type=*/
args_type
,
/*args=*/
args
,
std
::
get
<
arg_id
>
(
args
)...,
/*argN_type=*/
((
void
)
excess_id
,
kExcessArg
)...);
typename
std
::
tuple_element
<
arg_id
,
args_type
>
::
type
...
>
(
/*args=*/
args
,
std
::
get
<
arg_id
>
(
args
)...,
((
void
)
excess_id
,
kExcessArg
)...);
}
}
};
};
...
@@ -1545,7 +1547,7 @@ template <typename F, typename Impl>
...
@@ -1545,7 +1547,7 @@ template <typename F, typename Impl>
#define GMOCK_INTERNAL_ARG_UNUSED(i, data, el) \
#define GMOCK_INTERNAL_ARG_UNUSED(i, data, el) \
, const arg##i##_type& arg##i GTEST_ATTRIBUTE_UNUSED_
, const arg##i##_type& arg##i GTEST_ATTRIBUTE_UNUSED_
#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_ \
#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_
\
const args_type& args GTEST_ATTRIBUTE_UNUSED_ GMOCK_PP_REPEAT( \
const args_type& args GTEST_ATTRIBUTE_UNUSED_ GMOCK_PP_REPEAT( \
GMOCK_INTERNAL_ARG_UNUSED, , 10)
GMOCK_INTERNAL_ARG_UNUSED, , 10)
...
@@ -1584,45 +1586,47 @@ template <typename F, typename Impl>
...
@@ -1584,45 +1586,47 @@ template <typename F, typename Impl>
#define GMOCK_ACTION_FIELD_PARAMS_(params) \
#define GMOCK_ACTION_FIELD_PARAMS_(params) \
GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_FIELD_PARAM, , params)
GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_FIELD_PARAM, , params)
#define GMOCK_INTERNAL_ACTION(name, full_name, params) \
#define GMOCK_INTERNAL_ACTION(name, full_name, params) \
template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
class full_name { \
class full_name { \
public: \
public: \
explicit full_name(GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) \
explicit full_name(GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) \
: impl_(std::make_shared<gmock_Impl>( \
: impl_(std::make_shared<gmock_Impl>( \
GMOCK_ACTION_GVALUE_PARAMS_(params))) { } \
GMOCK_ACTION_GVALUE_PARAMS_(params))) {} \
full_name(const full_name&) = default; \
full_name(const full_name&) = default; \
full_name(full_name&&) noexcept = default; \
full_name(full_name&&) noexcept = default; \
template <typename F> \
template <typename F> \
operator ::testing::Action<F>() const { \
operator ::testing::Action<F>() const { \
return ::testing::internal::MakeAction<F>(impl_); \
return ::testing::internal::MakeAction<F>(impl_); \
} \
} \
private: \
\
class gmock_Impl { \
private: \
public: \
class gmock_Impl { \
explicit gmock_Impl(GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) \
public: \
: GMOCK_ACTION_INIT_PARAMS_(params) {} \
explicit gmock_Impl(GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) \
template <typename function_type, typename return_type, \
: GMOCK_ACTION_INIT_PARAMS_(params) {} \
typename args_type, GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
template <typename function_type, typename return_type, \
return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \
typename args_type, GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
GMOCK_ACTION_FIELD_PARAMS_(params) \
return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \
}; \
GMOCK_ACTION_FIELD_PARAMS_(params) \
std::shared_ptr<const gmock_Impl> impl_; \
}; \
}; \
std::shared_ptr<const gmock_Impl> impl_; \
template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
}; \
inline full_name<GMOCK_ACTION_TYPE_PARAMS_(params)> name( \
template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) GTEST_MUST_USE_RESULT_; \
inline full_name<GMOCK_ACTION_TYPE_PARAMS_(params)> name( \
template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) GTEST_MUST_USE_RESULT_; \
inline full_name<GMOCK_ACTION_TYPE_PARAMS_(params)> name( \
template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) { \
inline full_name<GMOCK_ACTION_TYPE_PARAMS_(params)> name( \
return full_name<GMOCK_ACTION_TYPE_PARAMS_(params)>( \
GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) { \
GMOCK_ACTION_GVALUE_PARAMS_(params)); \
return full_name<GMOCK_ACTION_TYPE_PARAMS_(params)>( \
} \
GMOCK_ACTION_GVALUE_PARAMS_(params)); \
template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
} \
template <typename function_type, typename return_type, typename args_type, \
template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
template <typename function_type, typename return_type, typename args_type, \
return_type full_name<GMOCK_ACTION_TYPE_PARAMS_(params)>::gmock_Impl:: \
GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
return_type \
full_name<GMOCK_ACTION_TYPE_PARAMS_(params)>::gmock_Impl::gmock_PerformImpl( \
GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
}
// namespace internal
}
// namespace internal
...
@@ -1630,12 +1634,13 @@ template <typename F, typename Impl>
...
@@ -1630,12 +1634,13 @@ template <typename F, typename Impl>
#define ACTION(name) \
#define ACTION(name) \
class name##Action { \
class name##Action { \
public: \
public: \
explicit name##Action() noexcept {}
\
explicit name##Action() noexcept {} \
name##Action(const name##Action&) noexcept {}
\
name##Action(const name##Action&) noexcept {} \
template <typename F> \
template <typename F> \
operator ::testing::Action<F>() const { \
operator ::testing::Action<F>() const { \
return ::testing::internal::MakeAction<F, gmock_Impl>(); \
return ::testing::internal::MakeAction<F, gmock_Impl>(); \
} \
} \
\
private: \
private: \
class gmock_Impl { \
class gmock_Impl { \
public: \
public: \
...
@@ -1684,7 +1689,7 @@ template <typename F, typename Impl>
...
@@ -1684,7 +1689,7 @@ template <typename F, typename Impl>
}
// namespace testing
}
// namespace testing
#ifdef _MSC_VER
#ifdef _MSC_VER
#
pragma warning(pop)
#pragma warning(pop)
#endif
#endif
#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
googlemock/include/gmock/gmock-cardinalities.h
View file @
9e712372
...
@@ -40,8 +40,10 @@
...
@@ -40,8 +40,10 @@
#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
#include <limits.h>
#include <limits.h>
#include <memory>
#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"
...
@@ -116,7 +118,7 @@ class GTEST_API_ Cardinality {
...
@@ -116,7 +118,7 @@ class GTEST_API_ Cardinality {
// cardinality, i.e. exceed the maximum number of allowed calls.
// cardinality, i.e. exceed the maximum number of allowed calls.
bool
IsOverSaturatedByCallCount
(
int
call_count
)
const
{
bool
IsOverSaturatedByCallCount
(
int
call_count
)
const
{
return
impl_
->
IsSaturatedByCallCount
(
call_count
)
&&
return
impl_
->
IsSaturatedByCallCount
(
call_count
)
&&
!
impl_
->
IsSatisfiedByCallCount
(
call_count
);
!
impl_
->
IsSatisfiedByCallCount
(
call_count
);
}
}
// Describes self to an ostream
// Describes self to an ostream
...
...
googlemock/include/gmock/gmock-function-mocker.h
View file @
9e712372
...
@@ -201,7 +201,7 @@ using internal::FunctionMocker;
...
@@ -201,7 +201,7 @@ using internal::FunctionMocker;
GMOCK_INTERNAL_A_MATCHER_ARGUMENT, _Signature, _N)); \
GMOCK_INTERNAL_A_MATCHER_ARGUMENT, _Signature, _N)); \
} \
} \
mutable ::testing::FunctionMocker<GMOCK_PP_REMOVE_PARENS(_Signature)> \
mutable ::testing::FunctionMocker<GMOCK_PP_REMOVE_PARENS(_Signature)> \
GMOCK_MOCKER_(_N, _Constness, _MethodName)
GMOCK_MOCKER_(_N, _Constness, _MethodName)
#define GMOCK_INTERNAL_EXPAND(...) __VA_ARGS__
#define GMOCK_INTERNAL_EXPAND(...) __VA_ARGS__
...
...
googlemock/include/gmock/gmock-more-actions.h
View file @
9e712372
...
@@ -129,170 +129,207 @@
...
@@ -129,170 +129,207 @@
// Declares the template parameters.
// Declares the template parameters.
#define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0
#define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0
#define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
#define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1,
name1)
\
name1)
kind0 name0, kind1 name1
kind0 name0, kind1 name1
#define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
#define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
kind2, name2) kind0 name0, kind1 name1, kind2 name2
kind2, name2) \
kind0 name0, kind1 name1, kind2 name2
#define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
#define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2,
\
kind2, name2, kind3, name3)
\
kind3 name3
kind0 name0, kind1 name1, kind2 name2,
kind3 name3
#define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(
kind0, name0, kind1, name1,
\
#define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(
\
kind2, name2, kind3, name3, kind4, name4)
kind0 name0, kind1 name1,
\
kind0, name0, kind1, name1,
kind2, name2, kind3, name3, kind4, name4) \
kind2 name2, kind3 name3, kind4 name4
kind0 name0, kind1 name1,
kind2 name2, kind3 name3, kind4 name4
#define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
#define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \
kind2, name2, kind3, name3, \
kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5
kind4, name4, kind5, name5) \
#define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5
kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
#define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS( \
name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \
kind5 name5, kind6 name6
kind5, name5, kind6, name6) \
#define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
kind5 name5, kind6 name6
kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \
#define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS( \
kind4 name4, kind5 name5, kind6 name6, kind7 name7
kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \
#define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
kind5, name5, kind6, name6, kind7, name7) \
kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \
kind5 name5, kind6 name6, kind7 name7
kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \
#define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS( \
kind8 name8
kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \
#define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
kind5, name5, kind6, name6, kind7, name7, kind8, name8) \
name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \
kind5 name5, kind6 name6, kind7 name7, kind8 name8
kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \
#define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS( \
kind6 name6, kind7 name7, kind8 name8, kind9 name9
kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \
kind5, name5, kind6, name6, kind7, name7, kind8, name8, kind9, name9) \
kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
kind5 name5, kind6 name6, kind7 name7, kind8 name8, kind9 name9
// Lists the template parameters.
// Lists the template parameters.
#define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0
#define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0
#define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
#define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1,
name1)
\
name1)
name0, name1
name0, name1
#define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
#define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
kind2, name2) name0, name1, name2
kind2, name2) \
name0, name1, name2
#define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
#define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
kind2, name2, kind3, name3) name0, name1, name2, name3
kind2, name2, kind3, name3) \
#define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
name0, name1, name2, name3
kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \
#define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS( \
name4
kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4) \
name0, name1, name2, name3, name4
#define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
#define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \
kind2, name2, kind3, name3, \
name2, name3, name4, name5
kind4, name4, kind5, name5) \
#define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
name0, name1, name2, name3, name4, name5
kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
#define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS( \
name6) name0, name1, name2, name3, name4, name5, name6
kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \
#define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
kind5, name5, kind6, name6) \
kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
name0, name1, name2, name3, name4, name5, name6
kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7
#define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS( \
#define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \
kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
kind5, name5, kind6, name6, kind7, name7) \
kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \
name0, name1, name2, name3, name4, name5, name6, name7
name6, name7, name8
#define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS( \
#define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \
name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
kind5, name5, kind6, name6, kind7, name7, kind8, name8) \
name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \
name0, name1, name2, name3, name4, name5, name6, name7, name8
name3, name4, name5, name6, name7, name8, name9
#define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS( \
kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \
kind5, name5, kind6, name6, kind7, name7, kind8, name8, kind9, name9) \
name0, name1, name2, name3, name4, name5, name6, name7, name8, name9
// Declares the types of value parameters.
// Declares the types of value parameters.
#define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1)
,
\
#define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) \
typename p0##_type, typename p1##_type
,
typename p0##_type, typename p1##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2)
,
\
#define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) \
typename p0##_type, typename p1##_type, typename p2##_type
,
typename p0##_type, typename p1##_type, typename p2##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3)
,
\
#define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) \
typename p0##_type, typename p1##_type, typename p2##_type, \
,
typename p0##_type, typename p1##_type, typename p2##_type,
\
typename p3##_type
typename p3##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)
,
\
#define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \
typename p0##_type, typename p1##_type, typename p2##_type, \
,
typename p0##_type, typename p1##_type, typename p2##_type,
\
typename p3##_type, typename p4##_type
typename p3##_type, typename p4##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)
,
\
#define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \
typename p0##_type, typename p1##_type, typename p2##_type, \
,
typename p0##_type, typename p1##_type, typename p2##_type,
\
typename p3##_type, typename p4##_type, typename p5##_type
typename p3##_type, typename p4##_type, typename p5##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
#define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
p6) , typename p0##_type, typename p1##_type, typename p2##_type, \
p6) \
typename p3##_type, typename p4##_type, typename p5##_type, \
, typename p0##_type, typename p1##_type, typename p2##_type, \
typename p6##_type
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
#define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \
p6, p7) \
typename p3##_type, typename p4##_type, typename p5##_type, \
, typename p0##_type, typename p1##_type, typename p2##_type, \
typename p6##_type, typename p7##_type
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
#define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \
p6, p7, p8) \
typename p3##_type, typename p4##_type, typename p5##_type, \
, typename p0##_type, typename p1##_type, typename p2##_type, \
typename p6##_type, typename p7##_type, typename p8##_type
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p6##_type, typename p7##_type, typename p8##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
#define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \
p6, p7, p8, p9) \
typename p2##_type, typename p3##_type, typename p4##_type, \
, typename p0##_type, typename p1##_type, typename p2##_type, \
typename p5##_type, typename p6##_type, typename p7##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
typename p8##_type, typename p9##_type
typename p6##_type, typename p7##_type, typename p8##_type, \
typename p9##_type
// Initializes the value parameters.
// Initializes the value parameters.
#define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\
#define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS() ()
()
#define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0) \
#define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\
(p0##_type gmock_p0) : p0(::std::move(gmock_p0))
(p0##_type gmock_p0) : p0(::std::move(gmock_p0))
#define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1) \
#define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\
(p0##_type gmock_p0, p1##_type gmock_p1) \
(p0##_type gmock_p0, p1##_type gmock_p1) : p0(::std::move(gmock_p0)), \
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1))
p1(::std::move(gmock_p1))
#define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2) \
#define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\
(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2) \
(p0##_type gmock_p0, p1##_type gmock_p1, \
: p0(::std::move(gmock_p0)), \
p2##_type gmock_p2) : p0(::std::move(gmock_p0)), \
p1(::std::move(gmock_p1)), \
p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2))
p2(::std::move(gmock_p2))
#define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\
#define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) \
(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p3##_type gmock_p3) : p0(::std::move(gmock_p0)), \
p3##_type gmock_p3) \
p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
: p0(::std::move(gmock_p0)), \
p1(::std::move(gmock_p1)), \
p2(::std::move(gmock_p2)), \
p3(::std::move(gmock_p3))
p3(::std::move(gmock_p3))
#define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\
#define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \
(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p3##_type gmock_p3, p4##_type gmock_p4) : p0(::std::move(gmock_p0)), \
p3##_type gmock_p3, p4##_type gmock_p4) \
p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
: p0(::std::move(gmock_p0)), \
p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4))
p1(::std::move(gmock_p1)), \
#define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\
p2(::std::move(gmock_p2)), \
(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p3(::std::move(gmock_p3)), \
p3##_type gmock_p3, p4##_type gmock_p4, \
p4(::std::move(gmock_p4))
p5##_type gmock_p5) : p0(::std::move(gmock_p0)), \
#define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \
p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5) \
: p0(::std::move(gmock_p0)), \
p1(::std::move(gmock_p1)), \
p2(::std::move(gmock_p2)), \
p3(::std::move(gmock_p3)), \
p4(::std::move(gmock_p4)), \
p5(::std::move(gmock_p5))
p5(::std::move(gmock_p5))
#define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\
#define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) \
(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p6##_type gmock_p6) : p0(::std::move(gmock_p0)), \
p6##_type gmock_p6) \
p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
: p0(::std::move(gmock_p0)), \
p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
p1(::std::move(gmock_p1)), \
p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6))
p2(::std::move(gmock_p2)), \
#define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\
p3(::std::move(gmock_p3)), \
(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p4(::std::move(gmock_p4)), \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p5(::std::move(gmock_p5)), \
p6##_type gmock_p6, p7##_type gmock_p7) : p0(::std::move(gmock_p0)), \
p6(::std::move(gmock_p6))
p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
#define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7) \
p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p6##_type gmock_p6, p7##_type gmock_p7) \
: p0(::std::move(gmock_p0)), \
p1(::std::move(gmock_p1)), \
p2(::std::move(gmock_p2)), \
p3(::std::move(gmock_p3)), \
p4(::std::move(gmock_p4)), \
p5(::std::move(gmock_p5)), \
p6(::std::move(gmock_p6)), \
p7(::std::move(gmock_p7))
p7(::std::move(gmock_p7))
#define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
#define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, \
p7, p8)\
p8) \
(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p6##_type gmock_p6, p7##_type gmock_p7, \
p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8) \
p8##_type gmock_p8) : p0(::std::move(gmock_p0)), \
: p0(::std::move(gmock_p0)), \
p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
p1(::std::move(gmock_p1)), \
p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
p2(::std::move(gmock_p2)), \
p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \
p3(::std::move(gmock_p3)), \
p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8))
p4(::std::move(gmock_p4)), \
p5(::std::move(gmock_p5)), \
p6(::std::move(gmock_p6)), \
p7(::std::move(gmock_p7)), \
p8(::std::move(gmock_p8))
#define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
#define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
p7, p8, p9)\
p7, p8, p9) \
(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
p9##_type gmock_p9) : p0(::std::move(gmock_p0)), \
p9##_type gmock_p9) \
p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
: p0(::std::move(gmock_p0)), \
p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
p1(::std::move(gmock_p1)), \
p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \
p2(::std::move(gmock_p2)), \
p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8)), \
p3(::std::move(gmock_p3)), \
p4(::std::move(gmock_p4)), \
p5(::std::move(gmock_p5)), \
p6(::std::move(gmock_p6)), \
p7(::std::move(gmock_p7)), \
p8(::std::move(gmock_p8)), \
p9(::std::move(gmock_p9))
p9(::std::move(gmock_p9))
// Defines the copy constructor
// Defines the copy constructor
#define GMOCK_INTERNAL_DEFN_COPY_AND_0_VALUE_PARAMS() \
#define GMOCK_INTERNAL_DEFN_COPY_AND_0_VALUE_PARAMS() \
{} // Avoid https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82134
{} // Avoid https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82134
#define GMOCK_INTERNAL_DEFN_COPY_AND_1_VALUE_PARAMS(...) = default;
#define GMOCK_INTERNAL_DEFN_COPY_AND_1_VALUE_PARAMS(...) = default;
#define GMOCK_INTERNAL_DEFN_COPY_AND_2_VALUE_PARAMS(...) = default;
#define GMOCK_INTERNAL_DEFN_COPY_AND_2_VALUE_PARAMS(...) = default;
#define GMOCK_INTERNAL_DEFN_COPY_AND_3_VALUE_PARAMS(...) = default;
#define GMOCK_INTERNAL_DEFN_COPY_AND_3_VALUE_PARAMS(...) = default;
...
@@ -307,30 +344,71 @@
...
@@ -307,30 +344,71 @@
// Declares the fields for storing the value parameters.
// Declares the fields for storing the value parameters.
#define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0;
#define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0;
#define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \
#define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) \
p1##_type p1;
p0##_type p0; \
#define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \
p1##_type p1;
p1##_type p1; p2##_type p2;
#define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) \
#define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \
p0##_type p0; \
p1##_type p1; p2##_type p2; p3##_type p3;
p1##_type p1; \
#define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
p2##_type p2;
p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4;
#define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) \
#define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
p0##_type p0; \
p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
p1##_type p1; \
p5##_type p5;
p2##_type p2; \
#define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
p3##_type p3;
p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
#define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \
p5##_type p5; p6##_type p6;
p0##_type p0; \
#define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
p1##_type p1; \
p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
p2##_type p2; \
p5##_type p5; p6##_type p6; p7##_type p7;
p3##_type p3; \
#define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
p4##_type p4;
p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
#define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \
p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8;
p0##_type p0; \
p1##_type p1; \
p2##_type p2; \
p3##_type p3; \
p4##_type p4; \
p5##_type p5;
#define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) \
p0##_type p0; \
p1##_type p1; \
p2##_type p2; \
p3##_type p3; \
p4##_type p4; \
p5##_type p5; \
p6##_type p6;
#define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7) \
p0##_type p0; \
p1##_type p1; \
p2##_type p2; \
p3##_type p3; \
p4##_type p4; \
p5##_type p5; \
p6##_type p6; \
p7##_type p7;
#define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, \
p8) \
p0##_type p0; \
p1##_type p1; \
p2##_type p2; \
p3##_type p3; \
p4##_type p4; \
p5##_type p5; \
p6##_type p6; \
p7##_type p7; \
p8##_type p8;
#define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
#define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
p7, p8, p9) \
p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \
p0##_type p0; \
p9##_type p9;
p1##_type p1; \
p2##_type p2; \
p3##_type p3; \
p4##_type p4; \
p5##_type p5; \
p6##_type p6; \
p7##_type p7; \
p8##_type p8; \
p9##_type p9;
// Lists the value parameters.
// Lists the value parameters.
#define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS()
...
@@ -338,72 +416,78 @@
...
@@ -338,72 +416,78 @@
#define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1
#define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1
#define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2
#define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2
#define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3
#define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3
#define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \
#define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \
p2, p3, p4
p0, p1, p2, p3, p4
#define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \
#define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \
p1, p2, p3, p4, p5
p0, p1, p2, p3, p4, p5
#define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
#define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) \
p6) p0, p1, p2, p3, p4, p5, p6
p0, p1, p2, p3, p4, p5, p6
#define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
#define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7) \
p7) p0, p1, p2, p3, p4, p5, p6, p7
p0, p1, p2, p3, p4, p5, p6, p7
#define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
#define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, \
p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8
p8) \
p0, p1, p2, p3, p4, p5, p6, p7, p8
#define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
#define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9
p7, p8, p9) \
p0, p1, p2, p3, p4, p5, p6, p7, p8, p9
// Lists the value parameter types.
// Lists the value parameter types.
#define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1)
, p0##_type,
\
#define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) \
p1##_type
, p0##_type,
p1##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2)
, p0##_type,
\
#define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) \
p1##_type, p2##_type
, p0##_type,
p1##_type, p2##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3)
,
\
#define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) \
p0##_type, p1##_type, p2##_type, p3##_type
,
p0##_type, p1##_type, p2##_type, p3##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)
,
\
#define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \
p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
,
p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)
,
\
#define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \
p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type
,
p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
#define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type,
\
p6)
\
p6##_type
, p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type,
p6##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
#define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
p6, p7) \
p5##_type, p6##_type, p7##_type
, p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \
p6##_type, p7##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
#define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
p6, p7, p8) \
p5##_type, p6##_type, p7##_type, p8##_type
, p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \
p6##_type, p7##_type, p8##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
#define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
p6, p7, p8, p9) \
p5##_type, p6##_type, p7##_type, p8##_type, p9##_type
, p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \
p6##_type, p7##_type, p8##_type, p9##_type
// Declares the value parameters.
// Declares the value parameters.
#define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0
#define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0
#define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \
#define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) \
p1##_type p1
p0##_type p0, p1##_type p1
#define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \
#define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) \
p1##_type p1, p2##_type p2
p0##_type p0, p1##_type p1, p2##_type p2
#define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \
#define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) \
p1##_type p1, p2##_type p2, p3##_type p3
p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3
#define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
#define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \
p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4
p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4
#define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
#define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \
p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
p5##_type p5
p5##_type p5
#define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
#define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) \
p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
p5##_type p5, p6##_type p6
p5##_type p5, p6##_type p6
#define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
#define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7) \
p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
p5##_type p5, p6##_type p6, p7##_type p7
p5##_type p5, p6##_type p6, p7##_type p7
#define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
#define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, \
p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
p8) \
p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8
p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8
#define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
#define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3,
\
p7, p8, p9)
\
p
4
##_type p
4
, p
5
##_type p
5
, p
6
##_type p
6
, p
7
##_type p
7
, p
8
##_type p
8,
\
p
0
##_type p
0
, p
1
##_type p
1
, p
2
##_type p
2
, p
3
##_type p
3
, p
4
##_type p
4,
\
p9##_type p9
p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8,
p9##_type p9
// The suffix of the class template implementing the action template.
// The suffix of the class template implementing the action template.
#define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS()
...
@@ -415,40 +499,43 @@
...
@@ -415,40 +499,43 @@
#define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6
#define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6
#define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7
#define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7
#define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
#define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
p7) P8
p7) \
P8
#define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
#define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
p7, p8) P9
p7, p8) \
P9
#define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
#define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
p7, p8, p9) P10
p7, p8, p9) \
P10
// The name of the class template implementing the action template.
// The name of the class template implementing the action template.
#define GMOCK_ACTION_CLASS_(name, value_params)\
#define GMOCK_ACTION_CLASS_(name, value_params)
\
GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
#define ACTION_TEMPLATE(name, template_params, value_params) \
#define ACTION_TEMPLATE(name, template_params, value_params) \
template <GMOCK_INTERNAL_DECL_##template_params \
template <GMOCK_INTERNAL_DECL_##template_params \
GMOCK_INTERNAL_DECL_TYPE_##value_params>
\
GMOCK_INTERNAL_DECL_TYPE_##value_params> \
class GMOCK_ACTION_CLASS_(name, value_params) { \
class GMOCK_ACTION_CLASS_(name, value_params) { \
public: \
public: \
explicit GMOCK_ACTION_CLASS_(name, value_params)( \
explicit GMOCK_ACTION_CLASS_(name, value_params)( \
GMOCK_INTERNAL_DECL_##value_params) \
GMOCK_INTERNAL_DECL_##value_params) \
GMOCK_PP_IF(GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params), \
GMOCK_PP_IF(GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params), \
= default; , \
= default; \
, \
: impl_(std::make_shared<gmock_Impl>( \
: impl_(std::make_shared<gmock_Impl>( \
GMOCK_INTERNAL_LIST_##value_params)) { }) \
GMOCK_INTERNAL_LIST_##value_params)){}) \
GMOCK_ACTION_CLASS_(name, value_params)( \
GMOCK_ACTION_CLASS_(name, value_params)(const GMOCK_ACTION_CLASS_( \
const GMOCK_ACTION_CLASS_(name, value_params)&) noexcept \
name, value_params) &) noexcept GMOCK_INTERNAL_DEFN_COPY_ \
GMOCK_INTERNAL_DEFN_COPY_##value_params \
##value_params GMOCK_ACTION_CLASS_(name, value_params)( \
GMOCK_ACTION_CLASS_(name, value_params)( \
GMOCK_ACTION_CLASS_(name, value_params) &&) noexcept \
GMOCK_ACTION_CLASS_(name, value_params)&&) noexcept \
GMOCK_INTERNAL_DEFN_COPY_##value_params template <typename F> \
GMOCK_INTERNAL_DEFN_COPY_##value_params \
operator ::testing::Action<F>() const { \
template <typename F> \
operator ::testing::Action<F>() const { \
return GMOCK_PP_IF( \
return GMOCK_PP_IF( \
GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params), \
GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params), \
(::testing::internal::MakeAction<F, gmock_Impl>()), \
(::testing::internal::MakeAction<F, gmock_Impl>()),
\
(::testing::internal::MakeAction<F>(impl_))); \
(::testing::internal::MakeAction<F>(impl_)));
\
} \
} \
\
private: \
private: \
class gmock_Impl { \
class gmock_Impl { \
public: \
public: \
...
@@ -458,34 +545,35 @@
...
@@ -458,34 +545,35 @@
return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \
return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \
GMOCK_INTERNAL_DEFN_##value_params \
GMOCK_INTERNAL_DEFN_##value_params \
}; \
}; \
GMOCK_PP_IF(GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params),
\
GMOCK_PP_IF(GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params),
,
\
,
std::shared_ptr<const gmock_Impl> impl_;) \
std::shared_ptr<const gmock_Impl> impl_;)
\
}; \
}; \
template <GMOCK_INTERNAL_DECL_##template_params \
template <GMOCK_INTERNAL_DECL_##template_params \
GMOCK_INTERNAL_DECL_TYPE_##value_params>
\
GMOCK_INTERNAL_DECL_TYPE_##value_params> \
GMOCK_ACTION_CLASS_(
name, value_params)<
\
GMOCK_ACTION_CLASS_(
\
GMOCK_INTERNAL_LIST_##template_params
\
name, value_params)<
GMOCK_INTERNAL_LIST_##template_params \
GMOCK_INTERNAL_LIST_TYPE_##value_params>
name(
\
GMOCK_INTERNAL_LIST_TYPE_##value_params> \
GMOCK_INTERNAL_DECL_##value_params) GTEST_MUST_USE_RESULT_;
\
name(
GMOCK_INTERNAL_DECL_##value_params) GTEST_MUST_USE_RESULT_; \
template <GMOCK_INTERNAL_DECL_##template_params \
template <GMOCK_INTERNAL_DECL_##template_params \
GMOCK_INTERNAL_DECL_TYPE_##value_params>
\
GMOCK_INTERNAL_DECL_TYPE_##value_params> \
inline GMOCK_ACTION_CLASS_(
name, value_params)<
\
inline GMOCK_ACTION_CLASS_(
\
GMOCK_INTERNAL_LIST_##template_params
\
name, value_params)<
GMOCK_INTERNAL_LIST_##template_params \
GMOCK_INTERNAL_LIST_TYPE_##value_params>
name(
\
GMOCK_INTERNAL_LIST_TYPE_##value_params> \
GMOCK_INTERNAL_DECL_##value_params) { \
name(
GMOCK_INTERNAL_DECL_##value_params) {
\
return GMOCK_ACTION_CLASS_(
name, value_params)<
\
return GMOCK_ACTION_CLASS_(
\
GMOCK_INTERNAL_LIST_##template_params
\
name, value_params)<
GMOCK_INTERNAL_LIST_##template_params \
GMOCK_INTERNAL_LIST_TYPE_##value_params>(
\
GMOCK_INTERNAL_LIST_TYPE_##value_params>( \
GMOCK_INTERNAL_LIST_##value_params); \
GMOCK_INTERNAL_LIST_##value_params);
\
} \
} \
template <GMOCK_INTERNAL_DECL_##template_params \
template <GMOCK_INTERNAL_DECL_##template_params \
GMOCK_INTERNAL_DECL_TYPE_##value_params>
\
GMOCK_INTERNAL_DECL_TYPE_##value_params> \
template <typename function_type, typename return_type, typename args_type, \
template <typename function_type, typename return_type, typename args_type, \
GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
return_type GMOCK_ACTION_CLASS_(name, value_params)< \
return_type GMOCK_ACTION_CLASS_( \
GMOCK_INTERNAL_LIST_##template_params \
name, value_params)<GMOCK_INTERNAL_LIST_##template_params \
GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl::gmock_PerformImpl( \
GMOCK_INTERNAL_LIST_TYPE_##value_params>:: \
GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
gmock_Impl::gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) \
const
namespace
testing
{
namespace
testing
{
...
@@ -495,8 +583,8 @@ namespace testing {
...
@@ -495,8 +583,8 @@ namespace testing {
// is expanded and macro expansion cannot contain #pragma. Therefore
// is expanded and macro expansion cannot contain #pragma. Therefore
// we suppress them here.
// we suppress them here.
#ifdef _MSC_VER
#ifdef _MSC_VER
#
pragma warning(push)
#pragma warning(push)
#
pragma warning(disable
:
4100)
#pragma warning(disable
:
4100)
#endif
#endif
namespace
internal
{
namespace
internal
{
...
@@ -565,7 +653,7 @@ InvokeArgument(Params&&... params) {
...
@@ -565,7 +653,7 @@ InvokeArgument(Params&&... params) {
}
}
#ifdef _MSC_VER
#ifdef _MSC_VER
#
pragma warning(pop)
#pragma warning(pop)
#endif
#endif
}
// namespace testing
}
// namespace testing
...
...
googlemock/include/gmock/gmock-more-matchers.h
View file @
9e712372
...
@@ -47,13 +47,13 @@ namespace testing {
...
@@ -47,13 +47,13 @@ namespace testing {
// Silence C4100 (unreferenced formal
// Silence C4100 (unreferenced formal
// parameter) for MSVC
// parameter) for MSVC
#ifdef _MSC_VER
#ifdef _MSC_VER
#
pragma warning(push)
#pragma warning(push)
#
pragma warning(disable
:
4100)
#pragma warning(disable
:
4100)
#if (_MSC_VER == 1900)
#if (_MSC_VER == 1900)
// and silence C4800 (C4800: 'int *const ': forcing value
// and silence C4800 (C4800: 'int *const ': forcing value
// to bool 'true' or 'false') for MSVC 14
// to bool 'true' or 'false') for MSVC 14
#
pragma warning(disable
:
4800)
#pragma warning(disable
:
4800)
#endif
#endif
#endif
#endif
// Defines a matcher that matches an empty container. The container must
// Defines a matcher that matches an empty container. The container must
...
@@ -83,10 +83,9 @@ MATCHER(IsFalse, negation ? "is true" : "is false") {
...
@@ -83,10 +83,9 @@ MATCHER(IsFalse, negation ? "is true" : "is false") {
}
}
#ifdef _MSC_VER
#ifdef _MSC_VER
#
pragma warning(pop)
#pragma warning(pop)
#endif
#endif
}
// namespace testing
}
// namespace testing
#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_MATCHERS_H_
#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_MATCHERS_H_
googlemock/include/gmock/gmock-spec-builders.h
View file @
9e712372
...
@@ -70,6 +70,7 @@
...
@@ -70,6 +70,7 @@
#include <type_traits>
#include <type_traits>
#include <utility>
#include <utility>
#include <vector>
#include <vector>
#include "gmock/gmock-actions.h"
#include "gmock/gmock-actions.h"
#include "gmock/gmock-cardinalities.h"
#include "gmock/gmock-cardinalities.h"
#include "gmock/gmock-matchers.h"
#include "gmock/gmock-matchers.h"
...
@@ -78,7 +79,7 @@
...
@@ -78,7 +79,7 @@
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#if GTEST_HAS_EXCEPTIONS
#if GTEST_HAS_EXCEPTIONS
#
include <stdexcept> // NOLINT
#include <stdexcept> // NOLINT
#endif
#endif
GTEST_DISABLE_MSC_WARNINGS_PUSH_
(
4251
\
GTEST_DISABLE_MSC_WARNINGS_PUSH_
(
4251
\
...
@@ -97,13 +98,15 @@ class ExpectationSet;
...
@@ -97,13 +98,15 @@ class ExpectationSet;
namespace
internal
{
namespace
internal
{
// Implements a mock function.
// Implements a mock function.
template
<
typename
F
>
class
FunctionMocker
;
template
<
typename
F
>
class
FunctionMocker
;
// Base class for expectations.
// Base class for expectations.
class
ExpectationBase
;
class
ExpectationBase
;
// Implements an expectation.
// Implements an expectation.
template
<
typename
F
>
class
TypedExpectation
;
template
<
typename
F
>
class
TypedExpectation
;
// Helper class for testing the Expectation class template.
// Helper class for testing the Expectation class template.
class
ExpectationTester
;
class
ExpectationTester
;
...
@@ -171,10 +174,9 @@ class GTEST_API_ UntypedFunctionMockerBase {
...
@@ -171,10 +174,9 @@ class GTEST_API_ UntypedFunctionMockerBase {
// Writes a message that the call is uninteresting (i.e. neither
// Writes a message that the call is uninteresting (i.e. neither
// explicitly expected nor explicitly unexpected) to the given
// explicitly expected nor explicitly unexpected) to the given
// ostream.
// ostream.
virtual
void
UntypedDescribeUninterestingCall
(
virtual
void
UntypedDescribeUninterestingCall
(
const
void
*
untyped_args
,
const
void
*
untyped_args
,
::
std
::
ostream
*
os
)
const
::
std
::
ostream
*
os
)
const
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
)
=
0
;
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
)
=
0
;
// Returns the expectation that matches the given function arguments
// Returns the expectation that matches the given function arguments
// (or NULL is there's no match); when a match is found,
// (or NULL is there's no match); when a match is found,
...
@@ -183,10 +185,9 @@ class GTEST_API_ UntypedFunctionMockerBase {
...
@@ -183,10 +185,9 @@ class GTEST_API_ UntypedFunctionMockerBase {
// is_excessive is modified to indicate whether the call exceeds the
// is_excessive is modified to indicate whether the call exceeds the
// expected number.
// expected number.
virtual
const
ExpectationBase
*
UntypedFindMatchingExpectation
(
virtual
const
ExpectationBase
*
UntypedFindMatchingExpectation
(
const
void
*
untyped_args
,
const
void
*
untyped_args
,
const
void
**
untyped_action
,
bool
*
is_excessive
,
const
void
**
untyped_action
,
bool
*
is_excessive
,
::
std
::
ostream
*
what
,
::
std
::
ostream
*
why
)
::
std
::
ostream
*
what
,
::
std
::
ostream
*
why
)
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
)
=
0
;
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
)
=
0
;
// Prints the given function arguments to the ostream.
// Prints the given function arguments to the ostream.
virtual
void
UntypedPrintArgs
(
const
void
*
untyped_args
,
virtual
void
UntypedPrintArgs
(
const
void
*
untyped_args
,
...
@@ -196,8 +197,7 @@ class GTEST_API_ UntypedFunctionMockerBase {
...
@@ -196,8 +197,7 @@ class GTEST_API_ UntypedFunctionMockerBase {
// this information in the global mock registry. Will be called
// this information in the global mock registry. Will be called
// whenever an EXPECT_CALL() or ON_CALL() is executed on this mock
// whenever an EXPECT_CALL() or ON_CALL() is executed on this mock
// method.
// method.
void
RegisterOwner
(
const
void
*
mock_obj
)
void
RegisterOwner
(
const
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
);
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
);
// Sets the mock object this mock method belongs to, and sets the
// Sets the mock object this mock method belongs to, and sets the
// name of the mock function. Will be called upon each invocation
// name of the mock function. Will be called upon each invocation
...
@@ -208,13 +208,11 @@ class GTEST_API_ UntypedFunctionMockerBase {
...
@@ -208,13 +208,11 @@ class GTEST_API_ UntypedFunctionMockerBase {
// Returns the mock object this mock method belongs to. Must be
// Returns the mock object this mock method belongs to. Must be
// called after RegisterOwner() or SetOwnerAndName() has been
// called after RegisterOwner() or SetOwnerAndName() has been
// called.
// called.
const
void
*
MockObject
()
const
const
void
*
MockObject
()
const
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
);
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
);
// Returns the name of this mock method. Must be called after
// Returns the name of this mock method. Must be called after
// SetOwnerAndName() has been called.
// SetOwnerAndName() has been called.
const
char
*
Name
()
const
const
char
*
Name
()
const
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
);
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
);
// Returns the result of invoking this mock function with the given
// Returns the result of invoking this mock function with the given
// arguments. This function can be safely called from multiple
// arguments. This function can be safely called from multiple
...
@@ -451,8 +449,7 @@ class GTEST_API_ Mock {
...
@@ -451,8 +449,7 @@ class GTEST_API_ Mock {
// Returns the reaction Google Mock will have on uninteresting calls
// Returns the reaction Google Mock will have on uninteresting calls
// made on the given mock object.
// made on the given mock object.
static
internal
::
CallReaction
GetReactionOnUninterestingCalls
(
static
internal
::
CallReaction
GetReactionOnUninterestingCalls
(
const
void
*
mock_obj
)
const
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
);
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
);
// Verifies that all expectations on the given mock object have been
// Verifies that all expectations on the given mock object have been
// satisfied. Reports one or more Google Test non-fatal failures
// satisfied. Reports one or more Google Test non-fatal failures
...
@@ -465,17 +462,16 @@ class GTEST_API_ Mock {
...
@@ -465,17 +462,16 @@ class GTEST_API_ Mock {
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
internal
::
g_gmock_mutex
);
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
internal
::
g_gmock_mutex
);
// Registers a mock object and a mock method it owns.
// Registers a mock object and a mock method it owns.
static
void
Register
(
static
void
Register
(
const
void
*
mock_obj
,
const
void
*
mock_obj
,
internal
::
UntypedFunctionMockerBase
*
mocker
)
internal
::
UntypedFunctionMockerBase
*
mocker
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
);
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
);
// Tells Google Mock where in the source code mock_obj is used in an
// Tells Google Mock where in the source code mock_obj is used in an
// ON_CALL or EXPECT_CALL. In case mock_obj is leaked, this
// ON_CALL or EXPECT_CALL. In case mock_obj is leaked, this
// information helps the user identify which object it is.
// information helps the user identify which object it is.
static
void
RegisterUseByOnCallOrExpectCall
(
static
void
RegisterUseByOnCallOrExpectCall
(
const
void
*
mock_obj
,
const
void
*
mock_obj
,
const
char
*
file
,
int
line
)
const
char
*
file
,
int
line
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
);
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
);
// Unregisters a mock method; removes the owning mock object from
// Unregisters a mock method; removes the owning mock object from
// the registry when the last mock method associated with it has
// the registry when the last mock method associated with it has
...
@@ -632,7 +628,6 @@ class ExpectationSet {
...
@@ -632,7 +628,6 @@ class ExpectationSet {
Expectation
::
Set
expectations_
;
Expectation
::
Set
expectations_
;
};
};
// Sequence objects are used by a user to specify the relative order
// Sequence objects are used by a user to specify the relative order
// in which the expectations should match. They are copyable (we rely
// in which the expectations should match. They are copyable (we rely
// on the compiler-defined copy constructor and assignment operator).
// on the compiler-defined copy constructor and assignment operator).
...
@@ -678,6 +673,7 @@ class GTEST_API_ InSequence {
...
@@ -678,6 +673,7 @@ class GTEST_API_ InSequence {
public:
public:
InSequence
();
InSequence
();
~
InSequence
();
~
InSequence
();
private:
private:
bool
sequence_created_
;
bool
sequence_created_
;
...
@@ -784,40 +780,34 @@ class GTEST_API_ ExpectationBase {
...
@@ -784,40 +780,34 @@ class GTEST_API_ ExpectationBase {
// the current thread.
// the current thread.
// Retires all pre-requisites of this expectation.
// Retires all pre-requisites of this expectation.
void
RetireAllPreRequisites
()
void
RetireAllPreRequisites
()
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
);
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
);
// Returns true if and only if this expectation is retired.
// Returns true if and only if this expectation is retired.
bool
is_retired
()
const
bool
is_retired
()
const
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
g_gmock_mutex
.
AssertHeld
();
g_gmock_mutex
.
AssertHeld
();
return
retired_
;
return
retired_
;
}
}
// Retires this expectation.
// Retires this expectation.
void
Retire
()
void
Retire
()
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
g_gmock_mutex
.
AssertHeld
();
g_gmock_mutex
.
AssertHeld
();
retired_
=
true
;
retired_
=
true
;
}
}
// Returns true if and only if this expectation is satisfied.
// Returns true if and only if this expectation is satisfied.
bool
IsSatisfied
()
const
bool
IsSatisfied
()
const
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
g_gmock_mutex
.
AssertHeld
();
g_gmock_mutex
.
AssertHeld
();
return
cardinality
().
IsSatisfiedByCallCount
(
call_count_
);
return
cardinality
().
IsSatisfiedByCallCount
(
call_count_
);
}
}
// Returns true if and only if this expectation is saturated.
// Returns true if and only if this expectation is saturated.
bool
IsSaturated
()
const
bool
IsSaturated
()
const
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
g_gmock_mutex
.
AssertHeld
();
g_gmock_mutex
.
AssertHeld
();
return
cardinality
().
IsSaturatedByCallCount
(
call_count_
);
return
cardinality
().
IsSaturatedByCallCount
(
call_count_
);
}
}
// Returns true if and only if this expectation is over-saturated.
// Returns true if and only if this expectation is over-saturated.
bool
IsOverSaturated
()
const
bool
IsOverSaturated
()
const
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
g_gmock_mutex
.
AssertHeld
();
g_gmock_mutex
.
AssertHeld
();
return
cardinality
().
IsOverSaturatedByCallCount
(
call_count_
);
return
cardinality
().
IsOverSaturatedByCallCount
(
call_count_
);
}
}
...
@@ -832,15 +822,13 @@ class GTEST_API_ ExpectationBase {
...
@@ -832,15 +822,13 @@ class GTEST_API_ ExpectationBase {
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
);
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
);
// Returns the number this expectation has been invoked.
// Returns the number this expectation has been invoked.
int
call_count
()
const
int
call_count
()
const
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
g_gmock_mutex
.
AssertHeld
();
g_gmock_mutex
.
AssertHeld
();
return
call_count_
;
return
call_count_
;
}
}
// Increments the number this expectation has been invoked.
// Increments the number this expectation has been invoked.
void
IncrementCallCount
()
void
IncrementCallCount
()
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
g_gmock_mutex
.
AssertHeld
();
g_gmock_mutex
.
AssertHeld
();
call_count_
++
;
call_count_
++
;
}
}
...
@@ -849,8 +837,7 @@ class GTEST_API_ ExpectationBase {
...
@@ -849,8 +837,7 @@ class GTEST_API_ ExpectationBase {
// WillRepeatedly() clauses) against the cardinality if this hasn't
// WillRepeatedly() clauses) against the cardinality if this hasn't
// been done before. Prints a warning if there are too many or too
// been done before. Prints a warning if there are too many or too
// few actions.
// few actions.
void
CheckActionCountIfNotDone
()
const
void
CheckActionCountIfNotDone
()
const
GTEST_LOCK_EXCLUDED_
(
mutex_
);
GTEST_LOCK_EXCLUDED_
(
mutex_
);
friend
class
::
testing
::
Sequence
;
friend
class
::
testing
::
Sequence
;
friend
class
::
testing
::
internal
::
ExpectationTester
;
friend
class
::
testing
::
internal
::
ExpectationTester
;
...
@@ -863,12 +850,12 @@ class GTEST_API_ ExpectationBase {
...
@@ -863,12 +850,12 @@ class GTEST_API_ ExpectationBase {
// This group of fields are part of the spec and won't change after
// This group of fields are part of the spec and won't change after
// an EXPECT_CALL() statement finishes.
// an EXPECT_CALL() statement finishes.
const
char
*
file_
;
// The file that contains the expectation.
const
char
*
file_
;
// The file that contains the expectation.
int
line_
;
// The line number of the expectation.
int
line_
;
// The line number of the expectation.
const
std
::
string
source_text_
;
// The EXPECT_CALL(...) source text.
const
std
::
string
source_text_
;
// The EXPECT_CALL(...) source text.
// True if and only if the cardinality is specified explicitly.
// True if and only if the cardinality is specified explicitly.
bool
cardinality_specified_
;
bool
cardinality_specified_
;
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 std::shared_ptr in the set because we want an
// expectation. We use std::shared_ptr in the set because we want an
...
@@ -887,8 +874,8 @@ class GTEST_API_ ExpectationBase {
...
@@ -887,8 +874,8 @@ class GTEST_API_ ExpectationBase {
bool
retires_on_saturation_
;
bool
retires_on_saturation_
;
Clause
last_clause_
;
Clause
last_clause_
;
mutable
bool
action_count_checked_
;
// Under mutex_.
mutable
bool
action_count_checked_
;
// Under mutex_.
mutable
Mutex
mutex_
;
// Protects action_count_checked_.
mutable
Mutex
mutex_
;
// Protects action_count_checked_.
};
// class ExpectationBase
};
// class ExpectationBase
// Implements an expectation for the given function type.
// Implements an expectation for the given function type.
template
<
typename
F
>
template
<
typename
F
>
...
@@ -945,9 +932,7 @@ class TypedExpectation : public ExpectationBase {
...
@@ -945,9 +932,7 @@ class TypedExpectation : public ExpectationBase {
}
}
// Implements the .Times() clause.
// Implements the .Times() clause.
TypedExpectation
&
Times
(
int
n
)
{
TypedExpectation
&
Times
(
int
n
)
{
return
Times
(
Exactly
(
n
));
}
return
Times
(
Exactly
(
n
));
}
// Implements the .InSequence() clause.
// Implements the .InSequence() clause.
TypedExpectation
&
InSequence
(
const
Sequence
&
s
)
{
TypedExpectation
&
InSequence
(
const
Sequence
&
s
)
{
...
@@ -1062,9 +1047,7 @@ class TypedExpectation : public ExpectationBase {
...
@@ -1062,9 +1047,7 @@ class TypedExpectation : public ExpectationBase {
// Returns the matchers for the arguments as specified inside the
// Returns the matchers for the arguments as specified inside the
// EXPECT_CALL() macro.
// EXPECT_CALL() macro.
const
ArgumentMatcherTuple
&
matchers
()
const
{
const
ArgumentMatcherTuple
&
matchers
()
const
{
return
matchers_
;
}
return
matchers_
;
}
// Returns the matcher specified by the .With() clause.
// Returns the matcher specified by the .With() clause.
const
Matcher
<
const
ArgumentTuple
&>&
extra_matcher
()
const
{
const
Matcher
<
const
ArgumentTuple
&>&
extra_matcher
()
const
{
...
@@ -1119,10 +1102,8 @@ class TypedExpectation : public ExpectationBase {
...
@@ -1119,10 +1102,8 @@ class TypedExpectation : public ExpectationBase {
// Describes the result of matching the arguments against this
// Describes the result of matching the arguments against this
// expectation to the given ostream.
// expectation to the given ostream.
void
ExplainMatchResultTo
(
void
ExplainMatchResultTo
(
const
ArgumentTuple
&
args
,
::
std
::
ostream
*
os
)
const
const
ArgumentTuple
&
args
,
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
::
std
::
ostream
*
os
)
const
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
g_gmock_mutex
.
AssertHeld
();
g_gmock_mutex
.
AssertHeld
();
if
(
is_retired
())
{
if
(
is_retired
())
{
...
@@ -1181,9 +1162,9 @@ class TypedExpectation : public ExpectationBase {
...
@@ -1181,9 +1162,9 @@ class TypedExpectation : public ExpectationBase {
::
std
::
stringstream
ss
;
::
std
::
stringstream
ss
;
DescribeLocationTo
(
&
ss
);
DescribeLocationTo
(
&
ss
);
ss
<<
"Actions ran out in "
<<
source_text
()
<<
"...
\n
"
ss
<<
"Actions ran out in "
<<
source_text
()
<<
"...
\n
"
<<
"Called "
<<
count
<<
" times, but only "
<<
"Called "
<<
count
<<
" times, but only "
<<
action_count
<<
action_count
<<
" WillOnce()"
<<
" WillOnce()"
<<
(
action_count
==
1
?
" is"
:
"s are"
)
<<
(
action_count
==
1
?
" is"
:
"s are"
)
<<
" specified - "
;
<<
" specified - "
;
mocker
->
DescribeDefaultActionTo
(
args
,
&
ss
);
mocker
->
DescribeDefaultActionTo
(
args
,
&
ss
);
Log
(
kWarning
,
ss
.
str
(),
1
);
Log
(
kWarning
,
ss
.
str
(),
1
);
}
}
...
@@ -1225,7 +1206,7 @@ class TypedExpectation : public ExpectationBase {
...
@@ -1225,7 +1206,7 @@ class TypedExpectation : public ExpectationBase {
}
}
// Must be done after IncrementCount()!
// Must be done after IncrementCount()!
*
what
<<
"Mock function call matches "
<<
source_text
()
<<
"...
\n
"
;
*
what
<<
"Mock function call matches "
<<
source_text
()
<<
"...
\n
"
;
return
&
(
GetCurrentAction
(
mocker
,
args
));
return
&
(
GetCurrentAction
(
mocker
,
args
));
}
}
...
@@ -1258,8 +1239,8 @@ template <typename F>
...
@@ -1258,8 +1239,8 @@ template <typename F>
class
MockSpec
{
class
MockSpec
{
public:
public:
typedef
typename
internal
::
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
typedef
typename
internal
::
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
typedef
typename
internal
::
Function
<
F
>::
ArgumentMatcherTuple
typedef
ArgumentMatcherTuple
;
typename
internal
::
Function
<
F
>::
ArgumentMatcherTuple
ArgumentMatcherTuple
;
// Constructs a MockSpec object, given the function mocker object
// Constructs a MockSpec object, given the function mocker object
// that the spec is associated with.
// that the spec is associated with.
...
@@ -1269,8 +1250,9 @@ class MockSpec {
...
@@ -1269,8 +1250,9 @@ class MockSpec {
// Adds a new default action spec to the function mocker and returns
// Adds a new default action spec to the function mocker and returns
// the newly created spec.
// the newly created spec.
internal
::
OnCallSpec
<
F
>&
InternalDefaultActionSetAt
(
internal
::
OnCallSpec
<
F
>&
InternalDefaultActionSetAt
(
const
char
*
file
,
const
char
*
file
,
int
line
,
const
char
*
obj
,
const
char
*
call
)
{
int
line
,
const
char
*
obj
,
const
char
*
call
)
{
LogWithLocation
(
internal
::
kInfo
,
file
,
line
,
LogWithLocation
(
internal
::
kInfo
,
file
,
line
,
std
::
string
(
"ON_CALL("
)
+
obj
+
", "
+
call
+
") invoked"
);
std
::
string
(
"ON_CALL("
)
+
obj
+
", "
+
call
+
") invoked"
);
return
function_mocker_
->
AddNewOnCallSpec
(
file
,
line
,
matchers_
);
return
function_mocker_
->
AddNewOnCallSpec
(
file
,
line
,
matchers_
);
...
@@ -1278,13 +1260,14 @@ class MockSpec {
...
@@ -1278,13 +1260,14 @@ class MockSpec {
// Adds a new expectation spec to the function mocker and returns
// Adds a new expectation spec to the function mocker and returns
// the newly created spec.
// the newly created spec.
internal
::
TypedExpectation
<
F
>&
InternalExpectedAt
(
internal
::
TypedExpectation
<
F
>&
InternalExpectedAt
(
const
char
*
file
,
int
line
,
const
char
*
file
,
int
line
,
const
char
*
obj
,
const
char
*
call
)
{
const
char
*
obj
,
const
char
*
call
)
{
const
std
::
string
source_text
(
std
::
string
(
"EXPECT_CALL("
)
+
obj
+
", "
+
const
std
::
string
source_text
(
std
::
string
(
"EXPECT_CALL("
)
+
obj
+
", "
+
call
+
")"
);
call
+
")"
);
LogWithLocation
(
internal
::
kInfo
,
file
,
line
,
source_text
+
" invoked"
);
LogWithLocation
(
internal
::
kInfo
,
file
,
line
,
source_text
+
" invoked"
);
return
function_mocker_
->
AddNewExpectation
(
return
function_mocker_
->
AddNewExpectation
(
file
,
line
,
source_text
,
file
,
line
,
source_text
,
matchers_
);
matchers_
);
}
}
// This operator overload is used to swallow the superfluous parameter list
// This operator overload is used to swallow the superfluous parameter list
...
@@ -1317,9 +1300,7 @@ template <typename T>
...
@@ -1317,9 +1300,7 @@ template <typename T>
class
ReferenceOrValueWrapper
{
class
ReferenceOrValueWrapper
{
public:
public:
// Constructs a wrapper from the given value/reference.
// Constructs a wrapper from the given value/reference.
explicit
ReferenceOrValueWrapper
(
T
value
)
explicit
ReferenceOrValueWrapper
(
T
value
)
:
value_
(
std
::
move
(
value
))
{}
:
value_
(
std
::
move
(
value
))
{
}
// Unwraps and returns the underlying value/reference, exactly as
// Unwraps and returns the underlying value/reference, exactly as
// originally passed. The behavior of calling this more than once on
// originally passed. The behavior of calling this more than once on
...
@@ -1330,9 +1311,7 @@ class ReferenceOrValueWrapper {
...
@@ -1330,9 +1311,7 @@ class ReferenceOrValueWrapper {
// Always returns a const reference (more precisely,
// Always returns a const reference (more precisely,
// const std::add_lvalue_reference<T>::type). The behavior of calling this
// const std::add_lvalue_reference<T>::type). The behavior of calling this
// after calling Unwrap on the same object is unspecified.
// after calling Unwrap on the same object is unspecified.
const
T
&
Peek
()
const
{
const
T
&
Peek
()
const
{
return
value_
;
}
return
value_
;
}
private:
private:
T
value_
;
T
value_
;
...
@@ -1346,8 +1325,7 @@ class ReferenceOrValueWrapper<T&> {
...
@@ -1346,8 +1325,7 @@ class ReferenceOrValueWrapper<T&> {
// Workaround for debatable pass-by-reference lint warning (c-library-team
// Workaround for debatable pass-by-reference lint warning (c-library-team
// policy precludes NOLINT in this context)
// policy precludes NOLINT in this context)
typedef
T
&
reference
;
typedef
T
&
reference
;
explicit
ReferenceOrValueWrapper
(
reference
ref
)
explicit
ReferenceOrValueWrapper
(
reference
ref
)
:
value_ptr_
(
&
ref
)
{}
:
value_ptr_
(
&
ref
)
{}
T
&
Unwrap
()
{
return
*
value_ptr_
;
}
T
&
Unwrap
()
{
return
*
value_ptr_
;
}
const
T
&
Peek
()
const
{
return
*
value_ptr_
;
}
const
T
&
Peek
()
const
{
return
*
value_ptr_
;
}
...
@@ -1377,9 +1355,7 @@ template <typename T>
...
@@ -1377,9 +1355,7 @@ template <typename T>
class
ActionResultHolder
:
public
UntypedActionResultHolderBase
{
class
ActionResultHolder
:
public
UntypedActionResultHolderBase
{
public:
public:
// Returns the held value. Must not be called more than once.
// Returns the held value. Must not be called more than once.
T
Unwrap
()
{
T
Unwrap
()
{
return
result_
.
Unwrap
();
}
return
result_
.
Unwrap
();
}
// Prints the held value as an action's result to os.
// Prints the held value as an action's result to os.
void
PrintAsActionResult
(
::
std
::
ostream
*
os
)
const
override
{
void
PrintAsActionResult
(
::
std
::
ostream
*
os
)
const
override
{
...
@@ -1395,8 +1371,8 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
...
@@ -1395,8 +1371,8 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
const
FunctionMocker
<
F
>*
func_mocker
,
const
FunctionMocker
<
F
>*
func_mocker
,
typename
Function
<
F
>::
ArgumentTuple
&&
args
,
typename
Function
<
F
>::
ArgumentTuple
&&
args
,
const
std
::
string
&
call_description
)
{
const
std
::
string
&
call_description
)
{
return
new
ActionResultHolder
(
Wrapper
(
func_mocker
->
PerformDefaultAction
(
return
new
ActionResultHolder
(
Wrapper
(
std
::
move
(
args
),
call_description
)));
func_mocker
->
PerformDefaultAction
(
std
::
move
(
args
),
call_description
)));
}
}
// Performs the given action and returns the result in a new-ed
// Performs the given action and returns the result in a new-ed
...
@@ -1404,16 +1380,13 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
...
@@ -1404,16 +1380,13 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
template
<
typename
F
>
template
<
typename
F
>
static
ActionResultHolder
*
PerformAction
(
static
ActionResultHolder
*
PerformAction
(
const
Action
<
F
>&
action
,
typename
Function
<
F
>::
ArgumentTuple
&&
args
)
{
const
Action
<
F
>&
action
,
typename
Function
<
F
>::
ArgumentTuple
&&
args
)
{
return
new
ActionResultHolder
(
return
new
ActionResultHolder
(
Wrapper
(
action
.
Perform
(
std
::
move
(
args
))));
Wrapper
(
action
.
Perform
(
std
::
move
(
args
))));
}
}
private:
private:
typedef
ReferenceOrValueWrapper
<
T
>
Wrapper
;
typedef
ReferenceOrValueWrapper
<
T
>
Wrapper
;
explicit
ActionResultHolder
(
Wrapper
result
)
explicit
ActionResultHolder
(
Wrapper
result
)
:
result_
(
std
::
move
(
result
))
{}
:
result_
(
std
::
move
(
result
))
{
}
Wrapper
result_
;
Wrapper
result_
;
...
@@ -1424,7 +1397,7 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
...
@@ -1424,7 +1397,7 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
template
<
>
template
<
>
class
ActionResultHolder
<
void
>
:
public
UntypedActionResultHolderBase
{
class
ActionResultHolder
<
void
>
:
public
UntypedActionResultHolderBase
{
public:
public:
void
Unwrap
()
{
}
void
Unwrap
()
{}
void
PrintAsActionResult
(
::
std
::
ostream
*
/* os */
)
const
override
{}
void
PrintAsActionResult
(
::
std
::
ostream
*
/* os */
)
const
override
{}
...
@@ -1495,14 +1468,12 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
...
@@ -1495,14 +1468,12 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
// Returns the ON_CALL spec that matches this mock function with the
// Returns the ON_CALL spec that matches this mock function with the
// given arguments; returns NULL if no matching ON_CALL is found.
// given arguments; returns NULL if no matching ON_CALL is found.
// L = *
// L = *
const
OnCallSpec
<
F
>*
FindOnCallSpec
(
const
OnCallSpec
<
F
>*
FindOnCallSpec
(
const
ArgumentTuple
&
args
)
const
{
const
ArgumentTuple
&
args
)
const
{
for
(
UntypedOnCallSpecs
::
const_reverse_iterator
it
=
for
(
UntypedOnCallSpecs
::
const_reverse_iterator
it
untyped_on_call_specs_
.
rbegin
();
=
untyped_on_call_specs_
.
rbegin
();
it
!=
untyped_on_call_specs_
.
rend
();
++
it
)
{
it
!=
untyped_on_call_specs_
.
rend
();
++
it
)
{
const
OnCallSpec
<
F
>*
spec
=
static_cast
<
const
OnCallSpec
<
F
>*>
(
*
it
);
const
OnCallSpec
<
F
>*
spec
=
static_cast
<
const
OnCallSpec
<
F
>*>
(
*
it
);
if
(
spec
->
Matches
(
args
))
if
(
spec
->
Matches
(
args
))
return
spec
;
return
spec
;
}
}
return
nullptr
;
return
nullptr
;
...
@@ -1517,8 +1488,7 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
...
@@ -1517,8 +1488,7 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
// L = *
// L = *
Result
PerformDefaultAction
(
ArgumentTuple
&&
args
,
Result
PerformDefaultAction
(
ArgumentTuple
&&
args
,
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
!=
nullptr
)
{
if
(
spec
!=
nullptr
)
{
return
spec
->
GetAction
().
Perform
(
std
::
move
(
args
));
return
spec
->
GetAction
().
Perform
(
std
::
move
(
args
));
}
}
...
@@ -1579,8 +1549,7 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
...
@@ -1579,8 +1549,7 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
untyped_on_call_specs_
.
swap
(
specs_to_delete
);
untyped_on_call_specs_
.
swap
(
specs_to_delete
);
g_gmock_mutex
.
Unlock
();
g_gmock_mutex
.
Unlock
();
for
(
UntypedOnCallSpecs
::
const_iterator
it
=
for
(
UntypedOnCallSpecs
::
const_iterator
it
=
specs_to_delete
.
begin
();
specs_to_delete
.
begin
();
it
!=
specs_to_delete
.
end
();
++
it
)
{
it
!=
specs_to_delete
.
end
();
++
it
)
{
delete
static_cast
<
const
OnCallSpec
<
F
>*>
(
*
it
);
delete
static_cast
<
const
OnCallSpec
<
F
>*>
(
*
it
);
}
}
...
@@ -1611,10 +1580,9 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
...
@@ -1611,10 +1580,9 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
typedef
ActionResultHolder
<
Result
>
ResultHolder
;
typedef
ActionResultHolder
<
Result
>
ResultHolder
;
// Adds and returns a default action spec for this mock function.
// Adds and returns a default action spec for this mock function.
OnCallSpec
<
F
>&
AddNewOnCallSpec
(
OnCallSpec
<
F
>&
AddNewOnCallSpec
(
const
char
*
file
,
int
line
,
const
char
*
file
,
int
line
,
const
ArgumentMatcherTuple
&
m
)
const
ArgumentMatcherTuple
&
m
)
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
)
{
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
)
{
Mock
::
RegisterUseByOnCallOrExpectCall
(
MockObject
(),
file
,
line
);
Mock
::
RegisterUseByOnCallOrExpectCall
(
MockObject
(),
file
,
line
);
OnCallSpec
<
F
>*
const
on_call_spec
=
new
OnCallSpec
<
F
>
(
file
,
line
,
m
);
OnCallSpec
<
F
>*
const
on_call_spec
=
new
OnCallSpec
<
F
>
(
file
,
line
,
m
);
untyped_on_call_specs_
.
push_back
(
on_call_spec
);
untyped_on_call_specs_
.
push_back
(
on_call_spec
);
...
@@ -1644,7 +1612,8 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
...
@@ -1644,7 +1612,8 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
}
}
private:
private:
template
<
typename
Func
>
friend
class
TypedExpectation
;
template
<
typename
Func
>
friend
class
TypedExpectation
;
// Some utilities needed for implementing UntypedInvokeWith().
// Some utilities needed for implementing UntypedInvokeWith().
...
@@ -1728,9 +1697,8 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
...
@@ -1728,9 +1697,8 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
// Returns the expectation that matches the arguments, or NULL if no
// Returns the expectation that matches the arguments, or NULL if no
// expectation matches them.
// expectation matches them.
TypedExpectation
<
F
>*
FindMatchingExpectationLocked
(
TypedExpectation
<
F
>*
FindMatchingExpectationLocked
(
const
ArgumentTuple
&
args
)
const
ArgumentTuple
&
args
)
const
const
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
g_gmock_mutex
.
AssertHeld
();
g_gmock_mutex
.
AssertHeld
();
// 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.
...
@@ -1747,11 +1715,10 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
...
@@ -1747,11 +1715,10 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
}
}
// Returns a message that the arguments don't match any expectation.
// Returns a message that the arguments don't match any expectation.
void
FormatUnexpectedCallMessageLocked
(
void
FormatUnexpectedCallMessageLocked
(
const
ArgumentTuple
&
args
,
const
ArgumentTuple
&
args
,
::
std
::
ostream
*
os
,
::
std
::
ostream
*
os
,
::
std
::
ostream
*
why
)
const
::
std
::
ostream
*
why
)
const
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
g_gmock_mutex
.
AssertHeld
();
g_gmock_mutex
.
AssertHeld
();
*
os
<<
"
\n
Unexpected mock function call - "
;
*
os
<<
"
\n
Unexpected mock function call - "
;
DescribeDefaultActionTo
(
args
,
os
);
DescribeDefaultActionTo
(
args
,
os
);
...
@@ -1760,15 +1727,14 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
...
@@ -1760,15 +1727,14 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
// Prints a list of expectations that have been tried against the
// Prints a list of expectations that have been tried against the
// current mock function call.
// current mock function call.
void
PrintTriedExpectationsLocked
(
void
PrintTriedExpectationsLocked
(
const
ArgumentTuple
&
args
,
const
ArgumentTuple
&
args
,
::
std
::
ostream
*
why
)
const
::
std
::
ostream
*
why
)
const
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
g_gmock_mutex
.
AssertHeld
();
g_gmock_mutex
.
AssertHeld
();
const
size_t
count
=
untyped_expectations_
.
size
();
const
size_t
count
=
untyped_expectations_
.
size
();
*
why
<<
"Google Mock tried the following "
<<
count
<<
" "
*
why
<<
"Google Mock tried the following "
<<
count
<<
" "
<<
(
count
==
1
?
"expectation, but it didn't match"
:
<<
(
count
==
1
?
"expectation, but it didn't match"
"expectations, but none matched"
)
:
"expectations, but none matched"
)
<<
":
\n
"
;
<<
":
\n
"
;
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
{
TypedExpectation
<
F
>*
const
expectation
=
TypedExpectation
<
F
>*
const
expectation
=
...
@@ -1952,7 +1918,9 @@ using internal::MockSpec;
...
@@ -1952,7 +1918,9 @@ using internal::MockSpec;
// // Expects a call to const MockFoo::Bar().
// // Expects a call to const MockFoo::Bar().
// EXPECT_CALL(Const(foo), Bar());
// EXPECT_CALL(Const(foo), Bar());
template
<
typename
T
>
template
<
typename
T
>
inline
const
T
&
Const
(
const
T
&
x
)
{
return
x
;
}
inline
const
T
&
Const
(
const
T
&
x
)
{
return
x
;
}
// Constructs an Expectation object that references and co-owns exp.
// Constructs an Expectation object that references and co-owns exp.
inline
Expectation
::
Expectation
(
internal
::
ExpectationBase
&
exp
)
// NOLINT
inline
Expectation
::
Expectation
(
internal
::
ExpectationBase
&
exp
)
// NOLINT
...
...
googlemock/include/gmock/internal/gmock-internal-utils.h
View file @
9e712372
...
@@ -59,9 +59,9 @@ namespace internal {
...
@@ -59,9 +59,9 @@ namespace internal {
// Silence MSVC C4100 (unreferenced formal parameter) and
// Silence MSVC C4100 (unreferenced formal parameter) and
// C4805('==': unsafe mix of type 'const int' and type 'const bool')
// C4805('==': unsafe mix of type 'const int' and type 'const bool')
#ifdef _MSC_VER
#ifdef _MSC_VER
#
pragma warning(push)
#pragma warning(push)
#
pragma warning(disable
:
4100)
#pragma warning(disable
:
4100)
#
pragma warning(disable
:
4805)
#pragma warning(disable
:
4805)
#endif
#endif
// Joins a vector of strings as if they are fields of a tuple; returns
// Joins a vector of strings as if they are fields of a tuple; returns
...
@@ -91,7 +91,9 @@ inline const Element* GetRawPointer(const std::reference_wrapper<Element>& r) {
...
@@ -91,7 +91,9 @@ inline const Element* GetRawPointer(const std::reference_wrapper<Element>& r) {
// This overloaded version is for the raw pointer case.
// This overloaded version is for the raw pointer case.
template
<
typename
Element
>
template
<
typename
Element
>
inline
Element
*
GetRawPointer
(
Element
*
p
)
{
return
p
;
}
inline
Element
*
GetRawPointer
(
Element
*
p
)
{
return
p
;
}
// MSVC treats wchar_t as a native type usually, but treats it as the
// MSVC treats wchar_t as a native type usually, but treats it as the
// same as unsigned short when the compiler option /Zc:wchar_t- is
// same as unsigned short when the compiler option /Zc:wchar_t- is
...
@@ -100,7 +102,7 @@ inline Element* GetRawPointer(Element* p) { return p; }
...
@@ -100,7 +102,7 @@ inline Element* GetRawPointer(Element* p) { return p; }
#if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED)
#if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED)
// wchar_t is a typedef.
// wchar_t is a typedef.
#else
#else
#
define GMOCK_WCHAR_T_IS_NATIVE_ 1
#define GMOCK_WCHAR_T_IS_NATIVE_ 1
#endif
#endif
// In what follows, we use the term "kind" to indicate whether a type
// In what follows, we use the term "kind" to indicate whether a type
...
@@ -108,18 +110,20 @@ inline Element* GetRawPointer(Element* p) { return p; }
...
@@ -108,18 +110,20 @@ inline Element* GetRawPointer(Element* p) { return p; }
// or none of them. This categorization is useful for determining
// or none of them. This categorization is useful for determining
// when a matcher argument type can be safely converted to another
// when a matcher argument type can be safely converted to another
// type in the implementation of SafeMatcherCast.
// type in the implementation of SafeMatcherCast.
enum
TypeKind
{
enum
TypeKind
{
kBool
,
kInteger
,
kFloatingPoint
,
kOther
};
kBool
,
kInteger
,
kFloatingPoint
,
kOther
};
// KindOf<T>::value is the kind of type T.
// KindOf<T>::value is the kind of type T.
template
<
typename
T
>
struct
KindOf
{
template
<
typename
T
>
struct
KindOf
{
enum
{
value
=
kOther
};
// The default kind.
enum
{
value
=
kOther
};
// The default kind.
};
};
// This macro declares that the kind of 'type' is 'kind'.
// This macro declares that the kind of 'type' is 'kind'.
#define GMOCK_DECLARE_KIND_(type, kind) \
#define GMOCK_DECLARE_KIND_(type, kind) \
template <> struct KindOf<type> { enum { value = kind }; }
template <> \
struct KindOf<type> { \
enum { value = kind }; \
}
GMOCK_DECLARE_KIND_
(
bool
,
kBool
);
GMOCK_DECLARE_KIND_
(
bool
,
kBool
);
...
@@ -127,13 +131,13 @@ GMOCK_DECLARE_KIND_(bool, kBool);
...
@@ -127,13 +131,13 @@ GMOCK_DECLARE_KIND_(bool, kBool);
GMOCK_DECLARE_KIND_
(
char
,
kInteger
);
GMOCK_DECLARE_KIND_
(
char
,
kInteger
);
GMOCK_DECLARE_KIND_
(
signed
char
,
kInteger
);
GMOCK_DECLARE_KIND_
(
signed
char
,
kInteger
);
GMOCK_DECLARE_KIND_
(
unsigned
char
,
kInteger
);
GMOCK_DECLARE_KIND_
(
unsigned
char
,
kInteger
);
GMOCK_DECLARE_KIND_
(
short
,
kInteger
);
// NOLINT
GMOCK_DECLARE_KIND_
(
short
,
kInteger
);
// NOLINT
GMOCK_DECLARE_KIND_
(
unsigned
short
,
kInteger
);
// NOLINT
GMOCK_DECLARE_KIND_
(
unsigned
short
,
kInteger
);
// NOLINT
GMOCK_DECLARE_KIND_
(
int
,
kInteger
);
GMOCK_DECLARE_KIND_
(
int
,
kInteger
);
GMOCK_DECLARE_KIND_
(
unsigned
int
,
kInteger
);
GMOCK_DECLARE_KIND_
(
unsigned
int
,
kInteger
);
GMOCK_DECLARE_KIND_
(
long
,
kInteger
);
// NOLINT
GMOCK_DECLARE_KIND_
(
long
,
kInteger
);
// NOLINT
GMOCK_DECLARE_KIND_
(
unsigned
long
,
kInteger
);
// NOLINT
GMOCK_DECLARE_KIND_
(
unsigned
long
,
kInteger
);
// NOLINT
GMOCK_DECLARE_KIND_
(
long
long
,
kInteger
);
// NOLINT
GMOCK_DECLARE_KIND_
(
long
long
,
kInteger
);
// NOLINT
GMOCK_DECLARE_KIND_
(
unsigned
long
long
,
kInteger
);
// NOLINT
GMOCK_DECLARE_KIND_
(
unsigned
long
long
,
kInteger
);
// NOLINT
#if GMOCK_WCHAR_T_IS_NATIVE_
#if GMOCK_WCHAR_T_IS_NATIVE_
...
@@ -148,7 +152,7 @@ GMOCK_DECLARE_KIND_(long double, kFloatingPoint);
...
@@ -148,7 +152,7 @@ GMOCK_DECLARE_KIND_(long double, kFloatingPoint);
#undef GMOCK_DECLARE_KIND_
#undef GMOCK_DECLARE_KIND_
// Evaluates to the kind of 'type'.
// Evaluates to the kind of 'type'.
#define GMOCK_KIND_OF_(type) \
#define GMOCK_KIND_OF_(type)
\
static_cast< ::testing::internal::TypeKind>( \
static_cast< ::testing::internal::TypeKind>( \
::testing::internal::KindOf<type>::value)
::testing::internal::KindOf<type>::value)
...
@@ -204,9 +208,7 @@ using LosslessArithmeticConvertible =
...
@@ -204,9 +208,7 @@ using LosslessArithmeticConvertible =
class
FailureReporterInterface
{
class
FailureReporterInterface
{
public:
public:
// The type of a failure (either non-fatal or fatal).
// The type of a failure (either non-fatal or fatal).
enum
FailureType
{
enum
FailureType
{
kNonfatal
,
kFatal
};
kNonfatal
,
kFatal
};
virtual
~
FailureReporterInterface
()
{}
virtual
~
FailureReporterInterface
()
{}
...
@@ -226,8 +228,8 @@ GTEST_API_ FailureReporterInterface* GetFailureReporter();
...
@@ -226,8 +228,8 @@ GTEST_API_ FailureReporterInterface* GetFailureReporter();
inline
void
Assert
(
bool
condition
,
const
char
*
file
,
int
line
,
inline
void
Assert
(
bool
condition
,
const
char
*
file
,
int
line
,
const
std
::
string
&
msg
)
{
const
std
::
string
&
msg
)
{
if
(
!
condition
)
{
if
(
!
condition
)
{
GetFailureReporter
()
->
ReportFailure
(
FailureReporterInterface
::
kFatal
,
GetFailureReporter
()
->
ReportFailure
(
FailureReporterInterface
::
kFatal
,
file
,
file
,
line
,
msg
);
line
,
msg
);
}
}
}
}
inline
void
Assert
(
bool
condition
,
const
char
*
file
,
int
line
)
{
inline
void
Assert
(
bool
condition
,
const
char
*
file
,
int
line
)
{
...
@@ -248,10 +250,7 @@ inline void Expect(bool condition, const char* file, int line) {
...
@@ -248,10 +250,7 @@ inline void Expect(bool condition, const char* file, int line) {
}
}
// Severity level of a log.
// Severity level of a log.
enum
LogSeverity
{
enum
LogSeverity
{
kInfo
=
0
,
kWarning
=
1
};
kInfo
=
0
,
kWarning
=
1
};
// Valid values for the --gmock_verbose flag.
// Valid values for the --gmock_verbose flag.
...
@@ -294,8 +293,8 @@ GTEST_API_ WithoutMatchers GetWithoutMatchers();
...
@@ -294,8 +293,8 @@ GTEST_API_ WithoutMatchers GetWithoutMatchers();
// Disable MSVC warnings for infinite recursion, since in this case the
// Disable MSVC warnings for infinite recursion, since in this case the
// recursion is unreachable.
// recursion is unreachable.
#ifdef _MSC_VER
#ifdef _MSC_VER
#
pragma warning(push)
#pragma warning(push)
#
pragma warning(disable
:
4717)
#pragma warning(disable
:
4717)
#endif
#endif
// Invalid<T>() is usable as an expression of type T, but will terminate
// Invalid<T>() is usable as an expression of type T, but will terminate
...
@@ -313,7 +312,7 @@ inline T Invalid() {
...
@@ -313,7 +312,7 @@ inline T Invalid() {
}
}
#ifdef _MSC_VER
#ifdef _MSC_VER
#
pragma warning(pop)
#pragma warning(pop)
#endif
#endif
// Given a raw type (i.e. having no top-level reference or const
// Given a raw type (i.e. having no top-level reference or const
...
@@ -392,7 +391,8 @@ class StlContainerView< ::std::tuple<ElementPointer, Size> > {
...
@@ -392,7 +391,8 @@ class StlContainerView< ::std::tuple<ElementPointer, Size> > {
// The following specialization prevents the user from instantiating
// The following specialization prevents the user from instantiating
// StlContainer with a reference type.
// StlContainer with a reference type.
template
<
typename
T
>
class
StlContainerView
<
T
&>
;
template
<
typename
T
>
class
StlContainerView
<
T
&>
;
// A type transform to remove constness from the first part of a pair.
// A type transform to remove constness from the first part of a pair.
// Pairs like that are used as the value_type of associative containers,
// Pairs like that are used as the value_type of associative containers,
...
@@ -413,17 +413,18 @@ struct RemoveConstFromKey<std::pair<const K, V> > {
...
@@ -413,17 +413,18 @@ struct RemoveConstFromKey<std::pair<const K, V> > {
GTEST_API_
void
IllegalDoDefault
(
const
char
*
file
,
int
line
);
GTEST_API_
void
IllegalDoDefault
(
const
char
*
file
,
int
line
);
template
<
typename
F
,
typename
Tuple
,
size_t
...
Idx
>
template
<
typename
F
,
typename
Tuple
,
size_t
...
Idx
>
auto
ApplyImpl
(
F
&&
f
,
Tuple
&&
args
,
IndexSequence
<
Idx
...
>
)
->
decltype
(
auto
ApplyImpl
(
F
&&
f
,
Tuple
&&
args
,
IndexSequence
<
Idx
...
>
)
std
::
forward
<
F
>
(
f
)(
std
::
get
<
Idx
>
(
std
::
forward
<
Tuple
>
(
args
))...))
{
->
decltype
(
std
::
forward
<
F
>
(
f
)(
std
::
get
<
Idx
>
(
std
::
forward
<
Tuple
>
(
args
))...))
{
return
std
::
forward
<
F
>
(
f
)(
std
::
get
<
Idx
>
(
std
::
forward
<
Tuple
>
(
args
))...);
return
std
::
forward
<
F
>
(
f
)(
std
::
get
<
Idx
>
(
std
::
forward
<
Tuple
>
(
args
))...);
}
}
// Apply the function to a tuple of arguments.
// Apply the function to a tuple of arguments.
template
<
typename
F
,
typename
Tuple
>
template
<
typename
F
,
typename
Tuple
>
auto
Apply
(
F
&&
f
,
Tuple
&&
args
)
->
decltype
(
auto
Apply
(
F
&&
f
,
Tuple
&&
args
)
->
decltype
(
ApplyImpl
(
ApplyImpl
(
std
::
forward
<
F
>
(
f
),
std
::
forward
<
Tuple
>
(
args
),
std
::
forward
<
F
>
(
f
),
std
::
forward
<
Tuple
>
(
args
),
MakeIndexSequence
<
std
::
tuple_size
<
MakeIndexSequence
<
std
::
tuple_size
<
typename
std
::
remove_reference
<
Tuple
>::
type
>::
value
>
()))
{
typename
std
::
remove_reference
<
Tuple
>::
type
>::
value
>
()))
{
return
ApplyImpl
(
std
::
forward
<
F
>
(
f
),
std
::
forward
<
Tuple
>
(
args
),
return
ApplyImpl
(
std
::
forward
<
F
>
(
f
),
std
::
forward
<
Tuple
>
(
args
),
MakeIndexSequence
<
std
::
tuple_size
<
MakeIndexSequence
<
std
::
tuple_size
<
typename
std
::
remove_reference
<
Tuple
>::
type
>::
value
>
());
typename
std
::
remove_reference
<
Tuple
>::
type
>::
value
>
());
...
@@ -463,7 +464,7 @@ constexpr size_t Function<R(Args...)>::ArgumentCount;
...
@@ -463,7 +464,7 @@ constexpr size_t Function<R(Args...)>::ArgumentCount;
bool
Base64Unescape
(
const
std
::
string
&
encoded
,
std
::
string
*
decoded
);
bool
Base64Unescape
(
const
std
::
string
&
encoded
,
std
::
string
*
decoded
);
#ifdef _MSC_VER
#ifdef _MSC_VER
#
pragma warning(pop)
#pragma warning(pop)
#endif
#endif
}
// namespace internal
}
// namespace internal
...
...
googlemock/include/gmock/internal/gmock-port.h
View file @
9e712372
...
@@ -42,6 +42,7 @@
...
@@ -42,6 +42,7 @@
#include <assert.h>
#include <assert.h>
#include <stdlib.h>
#include <stdlib.h>
#include <cstdint>
#include <cstdint>
#include <iostream>
#include <iostream>
...
@@ -53,13 +54,13 @@
...
@@ -53,13 +54,13 @@
// 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-port.h"
#include "gmock/internal/custom/gmock-port.h"
#include "gmock/internal/custom/gmock-port.h"
#include "gtest/internal/gtest-port.h"
// For MS Visual C++, check the compiler version. At least VS 2015 is
// For MS Visual C++, check the compiler version. At least VS 2015 is
// required to compile Google Mock.
// required to compile Google Mock.
#if defined(_MSC_VER) && _MSC_VER < 1900
#if defined(_MSC_VER) && _MSC_VER < 1900
#
error "At least Visual C++ 2015 (14.0) is required to compile Google Mock."
#error "At least Visual C++ 2015 (14.0) is required to compile Google Mock."
#endif
#endif
// Macro for referencing flags. This is public as we want the user to
// Macro for referencing flags. This is public as we want the user to
...
@@ -72,29 +73,35 @@
...
@@ -72,29 +73,35 @@
#define GMOCK_DECLARE_bool_(name) \
#define GMOCK_DECLARE_bool_(name) \
namespace testing { \
namespace testing { \
GTEST_API_ extern bool GMOCK_FLAG(name); \
GTEST_API_ extern bool GMOCK_FLAG(name); \
} static_assert(true, "no-op to require trailing semicolon")
} \
static_assert(true, "no-op to require trailing semicolon")
#define GMOCK_DECLARE_int32_(name) \
#define GMOCK_DECLARE_int32_(name) \
namespace testing { \
namespace testing { \
GTEST_API_ extern int32_t GMOCK_FLAG(name); \
GTEST_API_ extern int32_t GMOCK_FLAG(name); \
} static_assert(true, "no-op to require trailing semicolon")
} \
static_assert(true, "no-op to require trailing semicolon")
#define GMOCK_DECLARE_string_(name) \
#define GMOCK_DECLARE_string_(name) \
namespace testing { \
namespace testing { \
GTEST_API_ extern ::std::string GMOCK_FLAG(name); \
GTEST_API_ extern ::std::string GMOCK_FLAG(name); \
} static_assert(true, "no-op to require trailing semicolon")
} \
static_assert(true, "no-op to require trailing semicolon")
// Macros for defining flags.
// Macros for defining flags.
#define GMOCK_DEFINE_bool_(name, default_val, doc) \
#define GMOCK_DEFINE_bool_(name, default_val, doc) \
namespace testing { \
namespace testing { \
GTEST_API_ bool GMOCK_FLAG(name) = (default_val); \
GTEST_API_ bool GMOCK_FLAG(name) = (default_val); \
} static_assert(true, "no-op to require trailing semicolon")
} \
static_assert(true, "no-op to require trailing semicolon")
#define GMOCK_DEFINE_int32_(name, default_val, doc) \
#define GMOCK_DEFINE_int32_(name, default_val, doc) \
namespace testing { \
namespace testing { \
GTEST_API_ int32_t GMOCK_FLAG(name) = (default_val); \
GTEST_API_ int32_t GMOCK_FLAG(name) = (default_val); \
} static_assert(true, "no-op to require trailing semicolon")
} \
static_assert(true, "no-op to require trailing semicolon")
#define GMOCK_DEFINE_string_(name, default_val, doc) \
#define GMOCK_DEFINE_string_(name, default_val, doc) \
namespace testing { \
namespace testing { \
GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val); \
GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val); \
} static_assert(true, "no-op to require trailing semicolon")
} \
static_assert(true, "no-op to require trailing semicolon")
#endif // !defined(GMOCK_DECLARE_bool_)
#endif // !defined(GMOCK_DECLARE_bool_)
#if !defined(GMOCK_FLAG_GET)
#if !defined(GMOCK_FLAG_GET)
...
...
googlemock/src/gmock-cardinalities.cc
View file @
9e712372
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes.
// Google Mock - a framework for writing C++ mock classes.
//
//
// This file implements cardinalities.
// This file implements cardinalities.
...
@@ -35,9 +34,11 @@
...
@@ -35,9 +34,11 @@
#include "gmock/gmock-cardinalities.h"
#include "gmock/gmock-cardinalities.h"
#include <limits.h>
#include <limits.h>
#include <ostream> // NOLINT
#include <ostream> // NOLINT
#include <sstream>
#include <sstream>
#include <string>
#include <string>
#include "gmock/internal/gmock-internal-utils.h"
#include "gmock/internal/gmock-internal-utils.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
...
@@ -49,8 +50,7 @@ namespace {
...
@@ -49,8 +50,7 @@ namespace {
class
BetweenCardinalityImpl
:
public
CardinalityInterface
{
class
BetweenCardinalityImpl
:
public
CardinalityInterface
{
public:
public:
BetweenCardinalityImpl
(
int
min
,
int
max
)
BetweenCardinalityImpl
(
int
min
,
int
max
)
:
min_
(
min
>=
0
?
min
:
0
),
:
min_
(
min
>=
0
?
min
:
0
),
max_
(
max
>=
min_
?
max
:
min_
)
{
max_
(
max
>=
min_
?
max
:
min_
)
{
std
::
stringstream
ss
;
std
::
stringstream
ss
;
if
(
min
<
0
)
{
if
(
min
<
0
)
{
ss
<<
"The invocation lower bound must be >= 0, "
ss
<<
"The invocation lower bound must be >= 0, "
...
@@ -62,8 +62,7 @@ class BetweenCardinalityImpl : public CardinalityInterface {
...
@@ -62,8 +62,7 @@ class BetweenCardinalityImpl : public CardinalityInterface {
internal
::
Expect
(
false
,
__FILE__
,
__LINE__
,
ss
.
str
());
internal
::
Expect
(
false
,
__FILE__
,
__LINE__
,
ss
.
str
());
}
else
if
(
min
>
max
)
{
}
else
if
(
min
>
max
)
{
ss
<<
"The invocation upper bound ("
<<
max
ss
<<
"The invocation upper bound ("
<<
max
<<
") must be >= the invocation lower bound ("
<<
min
<<
") must be >= the invocation lower bound ("
<<
min
<<
")."
;
<<
")."
;
internal
::
Expect
(
false
,
__FILE__
,
__LINE__
,
ss
.
str
());
internal
::
Expect
(
false
,
__FILE__
,
__LINE__
,
ss
.
str
());
}
}
}
}
...
...
googlemock/src/gmock-internal-utils.cc
View file @
9e712372
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes.
// Google Mock - a framework for writing C++ mock classes.
//
//
// This file defines some utilities useful for implementing Google
// This file defines some utilities useful for implementing Google
...
@@ -84,12 +83,11 @@ GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name) {
...
@@ -84,12 +83,11 @@ GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name) {
// We don't care about the current locale as the input is
// We don't care about the current locale as the input is
// guaranteed to be a valid C++ identifier name.
// guaranteed to be a valid C++ identifier name.
const
bool
starts_new_word
=
IsUpper
(
*
p
)
||
const
bool
starts_new_word
=
IsUpper
(
*
p
)
||
(
!
IsAlpha
(
prev_char
)
&&
IsLower
(
*
p
))
||
(
!
IsAlpha
(
prev_char
)
&&
IsLower
(
*
p
))
||
(
!
IsDigit
(
prev_char
)
&&
IsDigit
(
*
p
));
(
!
IsDigit
(
prev_char
)
&&
IsDigit
(
*
p
));
if
(
IsAlNum
(
*
p
))
{
if
(
IsAlNum
(
*
p
))
{
if
(
starts_new_word
&&
result
!=
""
)
if
(
starts_new_word
&&
result
!=
""
)
result
+=
' '
;
result
+=
' '
;
result
+=
ToLower
(
*
p
);
result
+=
ToLower
(
*
p
);
}
}
}
}
...
@@ -103,12 +101,9 @@ class GoogleTestFailureReporter : public FailureReporterInterface {
...
@@ -103,12 +101,9 @@ class GoogleTestFailureReporter : public FailureReporterInterface {
public:
public:
void
ReportFailure
(
FailureType
type
,
const
char
*
file
,
int
line
,
void
ReportFailure
(
FailureType
type
,
const
char
*
file
,
int
line
,
const
std
::
string
&
message
)
override
{
const
std
::
string
&
message
)
override
{
AssertHelper
(
type
==
kFatal
?
AssertHelper
(
type
==
kFatal
?
TestPartResult
::
kFatalFailure
TestPartResult
::
kFatalFailure
:
:
TestPartResult
::
kNonFatalFailure
,
TestPartResult
::
kNonFatalFailure
,
file
,
line
,
message
.
c_str
())
=
Message
();
file
,
line
,
message
.
c_str
())
=
Message
();
if
(
type
==
kFatal
)
{
if
(
type
==
kFatal
)
{
posix
::
Abort
();
posix
::
Abort
();
}
}
...
@@ -156,8 +151,7 @@ GTEST_API_ bool LogIsVisible(LogSeverity severity) {
...
@@ -156,8 +151,7 @@ GTEST_API_ bool LogIsVisible(LogSeverity severity) {
// conservative.
// conservative.
GTEST_API_
void
Log
(
LogSeverity
severity
,
const
std
::
string
&
message
,
GTEST_API_
void
Log
(
LogSeverity
severity
,
const
std
::
string
&
message
,
int
stack_frames_to_skip
)
{
int
stack_frames_to_skip
)
{
if
(
!
LogIsVisible
(
severity
))
if
(
!
LogIsVisible
(
severity
))
return
;
return
;
// Ensures that logs from different threads don't interleave.
// Ensures that logs from different threads don't interleave.
MutexLock
l
(
&
g_log_mutex
);
MutexLock
l
(
&
g_log_mutex
);
...
@@ -186,8 +180,8 @@ GTEST_API_ void Log(LogSeverity severity, const std::string& message,
...
@@ -186,8 +180,8 @@ GTEST_API_ void Log(LogSeverity severity, const std::string& message,
std
::
cout
<<
"
\n
"
;
std
::
cout
<<
"
\n
"
;
}
}
std
::
cout
<<
"Stack trace:
\n
"
std
::
cout
<<
"Stack trace:
\n
"
<<
::
testing
::
internal
::
GetCurrentOsStackTraceExceptTop
(
<<
::
testing
::
internal
::
GetCurrentOsStackTraceExceptTop
(
::
testing
::
UnitTest
::
GetInstance
(),
actual_to_skip
);
::
testing
::
UnitTest
::
GetInstance
(),
actual_to_skip
);
}
}
std
::
cout
<<
::
std
::
flush
;
std
::
cout
<<
::
std
::
flush
;
}
}
...
...
googlemock/src/gmock-matchers.cc
View file @
9e712372
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes.
// Google Mock - a framework for writing C++ mock classes.
//
//
// This file implements Matcher<const string&>, Matcher<string>, and
// This file implements Matcher<const string&>, Matcher<string>, and
...
...
googlemock/src/gmock-spec-builders.cc
View file @
9e712372
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes.
// Google Mock - a framework for writing C++ mock classes.
//
//
// This file implements the spec builder syntax (ON_CALL and
// This file implements the spec builder syntax (ON_CALL and
...
@@ -49,15 +48,15 @@
...
@@ -49,15 +48,15 @@
#include "gtest/internal/gtest-port.h"
#include "gtest/internal/gtest-port.h"
#if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC
#if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC
#
include <unistd.h> // NOLINT
#include <unistd.h> // NOLINT
#endif
#endif
// Silence C4800 (C4800: 'int *const ': forcing value
// Silence C4800 (C4800: 'int *const ': forcing value
// to bool 'true' or 'false') for MSVC 15
// to bool 'true' or 'false') for MSVC 15
#ifdef _MSC_VER
#ifdef _MSC_VER
#if _MSC_VER == 1900
#if _MSC_VER == 1900
#
pragma warning(push)
#pragma warning(push)
#
pragma warning(disable
:
4800)
#pragma warning(disable
:
4800)
#endif
#endif
#endif
#endif
...
@@ -195,11 +194,12 @@ void ExpectationBase::DescribeCallCountTo(::std::ostream* os) const
...
@@ -195,11 +194,12 @@ void ExpectationBase::DescribeCallCountTo(::std::ostream* os) const
// Describes the state of the expectation (e.g. is it satisfied?
// Describes the state of the expectation (e.g. is it satisfied?
// is it active?).
// is it active?).
*
os
<<
" - "
<<
(
IsOverSaturated
()
?
"over-saturated"
:
*
os
<<
" - "
IsSaturated
()
?
"saturated"
:
<<
(
IsOverSaturated
()
?
"over-saturated"
IsSatisfied
()
?
"satisfied"
:
"unsatisfied"
)
:
IsSaturated
()
?
"saturated"
<<
" and "
:
IsSatisfied
()
?
"satisfied"
<<
(
is_retired
()
?
"retired"
:
"active"
);
:
"unsatisfied"
)
<<
" and "
<<
(
is_retired
()
?
"retired"
:
"active"
);
}
}
// Checks the action count (i.e. the number of WillOnce() and
// Checks the action count (i.e. the number of WillOnce() and
...
@@ -242,13 +242,12 @@ void ExpectationBase::CheckActionCountIfNotDone() const
...
@@ -242,13 +242,12 @@ void ExpectationBase::CheckActionCountIfNotDone() const
::
std
::
stringstream
ss
;
::
std
::
stringstream
ss
;
DescribeLocationTo
(
&
ss
);
DescribeLocationTo
(
&
ss
);
ss
<<
"Too "
<<
(
too_many
?
"many"
:
"few"
)
ss
<<
"Too "
<<
(
too_many
?
"many"
:
"few"
)
<<
" actions specified in "
<<
" actions specified in "
<<
source_text
()
<<
"...
\n
"
<<
source_text
()
<<
"...
\n
"
<<
"Expected to be "
;
<<
"Expected to be "
;
cardinality
().
DescribeTo
(
&
ss
);
cardinality
().
DescribeTo
(
&
ss
);
ss
<<
", but has "
<<
(
too_many
?
""
:
"only "
)
ss
<<
", but has "
<<
(
too_many
?
""
:
"only "
)
<<
action_count
<<
action_count
<<
" WillOnce()"
<<
" WillOnce()"
<<
(
action_count
==
1
?
""
:
"s"
);
<<
(
action_count
==
1
?
""
:
"s"
);
if
(
repeated_action_specified_
)
{
if
(
repeated_action_specified_
)
{
ss
<<
" and a WillRepeatedly()"
;
ss
<<
" and a WillRepeatedly()"
;
}
}
...
@@ -398,11 +397,11 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
...
@@ -398,11 +397,11 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
// If the user wants this to be a warning, we print
// If the user wants this to be a warning, we print
// it only when they want to see warnings.
// it only when they want to see warnings.
reaction
==
kWarn
reaction
==
kWarn
?
LogIsVisible
(
kWarning
)
?
LogIsVisible
(
kWarning
)
:
:
// Otherwise, the user wants this to be an error, and we
// Otherwise, the user wants this to be an error, and we
// should always print detailed information in the error.
// should always print detailed information in the error.
true
;
true
;
if
(
!
need_to_report_uninteresting_call
)
{
if
(
!
need_to_report_uninteresting_call
)
{
// Perform the action without printing the call information.
// Perform the action without printing the call information.
...
@@ -505,8 +504,7 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
...
@@ -505,8 +504,7 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
Expectation
UntypedFunctionMockerBase
::
GetHandleOf
(
ExpectationBase
*
exp
)
{
Expectation
UntypedFunctionMockerBase
::
GetHandleOf
(
ExpectationBase
*
exp
)
{
// See the definition of untyped_expectations_ for why access to it
// See the definition of untyped_expectations_ for why access to it
// is unprotected here.
// is unprotected here.
for
(
UntypedExpectations
::
const_iterator
it
=
for
(
UntypedExpectations
::
const_iterator
it
=
untyped_expectations_
.
begin
();
untyped_expectations_
.
begin
();
it
!=
untyped_expectations_
.
end
();
++
it
)
{
it
!=
untyped_expectations_
.
end
();
++
it
)
{
if
(
it
->
get
()
==
exp
)
{
if
(
it
->
get
()
==
exp
)
{
return
Expectation
(
*
it
);
return
Expectation
(
*
it
);
...
@@ -526,8 +524,7 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()
...
@@ -526,8 +524,7 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
g_gmock_mutex
.
AssertHeld
();
g_gmock_mutex
.
AssertHeld
();
bool
expectations_met
=
true
;
bool
expectations_met
=
true
;
for
(
UntypedExpectations
::
const_iterator
it
=
for
(
UntypedExpectations
::
const_iterator
it
=
untyped_expectations_
.
begin
();
untyped_expectations_
.
begin
();
it
!=
untyped_expectations_
.
end
();
++
it
)
{
it
!=
untyped_expectations_
.
end
();
++
it
)
{
ExpectationBase
*
const
untyped_expectation
=
it
->
get
();
ExpectationBase
*
const
untyped_expectation
=
it
->
get
();
if
(
untyped_expectation
->
IsOverSaturated
())
{
if
(
untyped_expectation
->
IsOverSaturated
())
{
...
@@ -538,15 +535,15 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()
...
@@ -538,15 +535,15 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()
}
else
if
(
!
untyped_expectation
->
IsSatisfied
())
{
}
else
if
(
!
untyped_expectation
->
IsSatisfied
())
{
expectations_met
=
false
;
expectations_met
=
false
;
::
std
::
stringstream
ss
;
::
std
::
stringstream
ss
;
ss
<<
"Actual function call count doesn't match "
ss
<<
"Actual function call count doesn't match "
<<
untyped_expectation
->
source_text
()
<<
"...
\n
"
;
<<
untyped_expectation
->
source_text
()
<<
"...
\n
"
;
// No need to show the source file location of the expectation
// No need to show the source file location of the expectation
// in the description, as the Expect() call that follows already
// in the description, as the Expect() call that follows already
// takes care of it.
// takes care of it.
untyped_expectation
->
MaybeDescribeExtraMatcherTo
(
&
ss
);
untyped_expectation
->
MaybeDescribeExtraMatcherTo
(
&
ss
);
untyped_expectation
->
DescribeCallCountTo
(
&
ss
);
untyped_expectation
->
DescribeCallCountTo
(
&
ss
);
Expect
(
false
,
untyped_expectation
->
file
(),
Expect
(
false
,
untyped_expectation
->
file
(),
untyped_expectation
->
line
(),
untyped_expectation
->
line
(),
ss
.
str
());
ss
.
str
());
}
}
}
}
...
@@ -633,7 +630,7 @@ class MockObjectRegistry {
...
@@ -633,7 +630,7 @@ class MockObjectRegistry {
<<
state
.
first_used_test
<<
")"
;
<<
state
.
first_used_test
<<
")"
;
}
}
std
::
cout
<<
" should be deleted but never is. Its address is @"
std
::
cout
<<
" should be deleted but never is. Its address is @"
<<
it
->
first
<<
"."
;
<<
it
->
first
<<
"."
;
leaked_count
++
;
leaked_count
++
;
}
}
if
(
leaked_count
>
0
)
{
if
(
leaked_count
>
0
)
{
...
@@ -712,8 +709,7 @@ void Mock::UnregisterCallReaction(const void* mock_obj)
...
@@ -712,8 +709,7 @@ void Mock::UnregisterCallReaction(const void* mock_obj)
// Returns the reaction Google Mock will have on uninteresting calls
// Returns the reaction Google Mock will have on uninteresting calls
// made on the given mock object.
// made on the given mock object.
internal
::
CallReaction
Mock
::
GetReactionOnUninterestingCalls
(
internal
::
CallReaction
Mock
::
GetReactionOnUninterestingCalls
(
const
void
*
mock_obj
)
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
);
return
(
g_uninteresting_call_reaction
.
count
(
mock_obj
)
==
0
)
return
(
g_uninteresting_call_reaction
.
count
(
mock_obj
)
==
0
)
?
internal
::
intToCallReaction
(
?
internal
::
intToCallReaction
(
...
@@ -873,8 +869,8 @@ Expectation::~Expectation() {}
...
@@ -873,8 +869,8 @@ Expectation::~Expectation() {}
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
()
!=
nullptr
)
{
if
(
last_expectation_
->
expectation_base
()
!=
nullptr
)
{
expectation
.
expectation_base
()
->
immediate_prerequisites_
expectation
.
expectation_base
()
->
immediate_prerequisites_
+=
+=
*
last_expectation_
;
*
last_expectation_
;
}
}
*
last_expectation_
=
expectation
;
*
last_expectation_
=
expectation
;
}
}
...
@@ -903,6 +899,6 @@ InSequence::~InSequence() {
...
@@ -903,6 +899,6 @@ InSequence::~InSequence() {
#ifdef _MSC_VER
#ifdef _MSC_VER
#if _MSC_VER == 1900
#if _MSC_VER == 1900
#
pragma warning(pop)
#pragma warning(pop)
#endif
#endif
#endif
#endif
googlemock/src/gmock.cc
View file @
9e712372
...
@@ -27,8 +27,8 @@
...
@@ -27,8 +27,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "gmock/gmock.h"
#include "gmock/gmock.h"
#include "gmock/internal/gmock-port.h"
#include "gmock/internal/gmock-port.h"
GMOCK_DEFINE_bool_
(
catch_leaked_mocks
,
true
,
GMOCK_DEFINE_bool_
(
catch_leaked_mocks
,
true
,
...
...
googlemock/src/gmock_main.cc
View file @
9e712372
...
@@ -27,8 +27,8 @@
...
@@ -27,8 +27,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iostream>
#include <iostream>
#include "gmock/gmock.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
...
@@ -56,7 +56,7 @@ void loop() { RUN_ALL_TESTS(); }
...
@@ -56,7 +56,7 @@ void loop() { RUN_ALL_TESTS(); }
// https://web.archive.org/web/20170912203238/connect.microsoft.com/VisualStudio/feedback/details/394464/wmain-link-error-in-the-static-library
// https://web.archive.org/web/20170912203238/connect.microsoft.com/VisualStudio/feedback/details/394464/wmain-link-error-in-the-static-library
// // NOLINT
// // NOLINT
#if GTEST_OS_WINDOWS_MOBILE
#if GTEST_OS_WINDOWS_MOBILE
#
include <tchar.h> // NOLINT
#include <tchar.h> // NOLINT
GTEST_API_
int
_tmain
(
int
argc
,
TCHAR
**
argv
)
{
GTEST_API_
int
_tmain
(
int
argc
,
TCHAR
**
argv
)
{
#else
#else
...
...
googlemock/test/gmock-actions_test.cc
View file @
9e712372
...
@@ -27,32 +27,33 @@
...
@@ -27,32 +27,33 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes.
// Google Mock - a framework for writing C++ mock classes.
//
//
// This file tests the built-in actions.
// This file tests the built-in actions.
// Silence C4100 (unreferenced formal parameter) for MSVC
// Silence C4100 (unreferenced formal parameter) for MSVC
#ifdef _MSC_VER
#ifdef _MSC_VER
#
pragma warning(push)
#pragma warning(push)
#
pragma warning(disable
:
4100)
#pragma warning(disable
:
4100)
#if _MSC_VER == 1900
#if _MSC_VER == 1900
// and silence C4800 (C4800: 'int *const ': forcing value
// and silence C4800 (C4800: 'int *const ': forcing value
// to bool 'true' or 'false') for MSVC 15
// to bool 'true' or 'false') for MSVC 15
#
pragma warning(disable
:
4800)
#pragma warning(disable
:
4800)
#endif
#endif
#endif
#endif
#include "gmock/gmock-actions.h"
#include "gmock/gmock-actions.h"
#include <algorithm>
#include <algorithm>
#include <iterator>
#include <iterator>
#include <memory>
#include <memory>
#include <string>
#include <string>
#include <type_traits>
#include <type_traits>
#include "gmock/gmock.h"
#include "gmock/gmock.h"
#include "gmock/internal/gmock-port.h"
#include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h"
#include "gtest/gtest-spi.h"
#include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
namespace
{
namespace
{
...
@@ -114,17 +115,17 @@ TEST(BuiltInDefaultValueTest, IsZeroForNumericTypes) {
...
@@ -114,17 +115,17 @@ TEST(BuiltInDefaultValueTest, IsZeroForNumericTypes) {
#endif
#endif
#endif
#endif
EXPECT_EQ
(
0U
,
BuiltInDefaultValue
<
unsigned
short
>::
Get
());
// NOLINT
EXPECT_EQ
(
0U
,
BuiltInDefaultValue
<
unsigned
short
>::
Get
());
// NOLINT
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
signed
short
>::
Get
());
// NOLINT
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
signed
short
>::
Get
());
// NOLINT
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
short
>::
Get
());
// NOLINT
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
short
>::
Get
());
// NOLINT
EXPECT_EQ
(
0U
,
BuiltInDefaultValue
<
unsigned
int
>::
Get
());
EXPECT_EQ
(
0U
,
BuiltInDefaultValue
<
unsigned
int
>::
Get
());
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
signed
int
>::
Get
());
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
signed
int
>::
Get
());
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
int
>::
Get
());
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
int
>::
Get
());
EXPECT_EQ
(
0U
,
BuiltInDefaultValue
<
unsigned
long
>::
Get
());
// NOLINT
EXPECT_EQ
(
0U
,
BuiltInDefaultValue
<
unsigned
long
>::
Get
());
// NOLINT
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
signed
long
>::
Get
());
// NOLINT
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
signed
long
>::
Get
());
// NOLINT
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
long
>::
Get
());
// NOLINT
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
long
>::
Get
());
// NOLINT
EXPECT_EQ
(
0U
,
BuiltInDefaultValue
<
unsigned
long
long
>::
Get
());
// NOLINT
EXPECT_EQ
(
0U
,
BuiltInDefaultValue
<
unsigned
long
long
>::
Get
());
// NOLINT
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
signed
long
long
>::
Get
());
// NOLINT
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
signed
long
long
>::
Get
());
// NOLINT
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
long
long
>::
Get
());
// NOLINT
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
long
long
>::
Get
());
// NOLINT
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
float
>::
Get
());
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
float
>::
Get
());
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
double
>::
Get
());
EXPECT_EQ
(
0
,
BuiltInDefaultValue
<
double
>::
Get
());
}
}
...
@@ -139,17 +140,17 @@ TEST(BuiltInDefaultValueTest, ExistsForNumericTypes) {
...
@@ -139,17 +140,17 @@ TEST(BuiltInDefaultValueTest, ExistsForNumericTypes) {
EXPECT_TRUE
(
BuiltInDefaultValue
<
wchar_t
>::
Exists
());
EXPECT_TRUE
(
BuiltInDefaultValue
<
wchar_t
>::
Exists
());
#endif
#endif
EXPECT_TRUE
(
BuiltInDefaultValue
<
unsigned
short
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
unsigned
short
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
signed
short
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
signed
short
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
short
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
short
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
unsigned
int
>::
Exists
());
EXPECT_TRUE
(
BuiltInDefaultValue
<
unsigned
int
>::
Exists
());
EXPECT_TRUE
(
BuiltInDefaultValue
<
signed
int
>::
Exists
());
EXPECT_TRUE
(
BuiltInDefaultValue
<
signed
int
>::
Exists
());
EXPECT_TRUE
(
BuiltInDefaultValue
<
int
>::
Exists
());
EXPECT_TRUE
(
BuiltInDefaultValue
<
int
>::
Exists
());
EXPECT_TRUE
(
BuiltInDefaultValue
<
unsigned
long
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
unsigned
long
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
signed
long
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
signed
long
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
long
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
long
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
unsigned
long
long
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
unsigned
long
long
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
signed
long
long
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
signed
long
long
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
long
long
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
long
long
>::
Exists
());
// NOLINT
EXPECT_TRUE
(
BuiltInDefaultValue
<
float
>::
Exists
());
EXPECT_TRUE
(
BuiltInDefaultValue
<
float
>::
Exists
());
EXPECT_TRUE
(
BuiltInDefaultValue
<
double
>::
Exists
());
EXPECT_TRUE
(
BuiltInDefaultValue
<
double
>::
Exists
());
}
}
...
@@ -167,13 +168,13 @@ TEST(BuiltInDefaultValueTest, BoolExists) {
...
@@ -167,13 +168,13 @@ TEST(BuiltInDefaultValueTest, BoolExists) {
// Tests that BuiltInDefaultValue<T>::Get() returns "" when T is a
// Tests that BuiltInDefaultValue<T>::Get() returns "" when T is a
// string type.
// string type.
TEST
(
BuiltInDefaultValueTest
,
IsEmptyStringForString
)
{
TEST
(
BuiltInDefaultValueTest
,
IsEmptyStringForString
)
{
EXPECT_EQ
(
""
,
BuiltInDefaultValue
<
::
std
::
string
>::
Get
());
EXPECT_EQ
(
""
,
BuiltInDefaultValue
<::
std
::
string
>::
Get
());
}
}
// Tests that BuiltInDefaultValue<T>::Exists() returns true when T is a
// Tests that BuiltInDefaultValue<T>::Exists() returns true when T is a
// string type.
// string type.
TEST
(
BuiltInDefaultValueTest
,
ExistsForString
)
{
TEST
(
BuiltInDefaultValueTest
,
ExistsForString
)
{
EXPECT_TRUE
(
BuiltInDefaultValue
<
::
std
::
string
>::
Exists
());
EXPECT_TRUE
(
BuiltInDefaultValue
<::
std
::
string
>::
Exists
());
}
}
// Tests that BuiltInDefaultValue<const T>::Get() returns the same
// Tests that BuiltInDefaultValue<const T>::Get() returns the same
...
@@ -208,7 +209,6 @@ class MyNonDefaultConstructible {
...
@@ -208,7 +209,6 @@ class MyNonDefaultConstructible {
int
value_
;
int
value_
;
};
};
TEST
(
BuiltInDefaultValueTest
,
ExistsForDefaultConstructibleType
)
{
TEST
(
BuiltInDefaultValueTest
,
ExistsForDefaultConstructibleType
)
{
EXPECT_TRUE
(
BuiltInDefaultValue
<
MyDefaultConstructible
>::
Exists
());
EXPECT_TRUE
(
BuiltInDefaultValue
<
MyDefaultConstructible
>::
Exists
());
}
}
...
@@ -217,25 +217,19 @@ TEST(BuiltInDefaultValueTest, IsDefaultConstructedForDefaultConstructibleType) {
...
@@ -217,25 +217,19 @@ TEST(BuiltInDefaultValueTest, IsDefaultConstructedForDefaultConstructibleType) {
EXPECT_EQ
(
42
,
BuiltInDefaultValue
<
MyDefaultConstructible
>::
Get
().
value
());
EXPECT_EQ
(
42
,
BuiltInDefaultValue
<
MyDefaultConstructible
>::
Get
().
value
());
}
}
TEST
(
BuiltInDefaultValueTest
,
DoesNotExistForNonDefaultConstructibleType
)
{
TEST
(
BuiltInDefaultValueTest
,
DoesNotExistForNonDefaultConstructibleType
)
{
EXPECT_FALSE
(
BuiltInDefaultValue
<
MyNonDefaultConstructible
>::
Exists
());
EXPECT_FALSE
(
BuiltInDefaultValue
<
MyNonDefaultConstructible
>::
Exists
());
}
}
// Tests that BuiltInDefaultValue<T&>::Get() aborts the program.
// Tests that BuiltInDefaultValue<T&>::Get() aborts the program.
TEST
(
BuiltInDefaultValueDeathTest
,
IsUndefinedForReferences
)
{
TEST
(
BuiltInDefaultValueDeathTest
,
IsUndefinedForReferences
)
{
EXPECT_DEATH_IF_SUPPORTED
({
EXPECT_DEATH_IF_SUPPORTED
({
BuiltInDefaultValue
<
int
&>::
Get
();
},
""
);
BuiltInDefaultValue
<
int
&>::
Get
();
EXPECT_DEATH_IF_SUPPORTED
({
BuiltInDefaultValue
<
const
char
&>::
Get
();
},
""
);
},
""
);
EXPECT_DEATH_IF_SUPPORTED
({
BuiltInDefaultValue
<
const
char
&>::
Get
();
},
""
);
}
}
TEST
(
BuiltInDefaultValueDeathTest
,
IsUndefinedForNonDefaultConstructibleType
)
{
TEST
(
BuiltInDefaultValueDeathTest
,
IsUndefinedForNonDefaultConstructibleType
)
{
EXPECT_DEATH_IF_SUPPORTED
({
EXPECT_DEATH_IF_SUPPORTED
(
BuiltInDefaultValue
<
MyNonDefaultConstructible
>::
Get
();
{
BuiltInDefaultValue
<
MyNonDefaultConstructible
>::
Get
();
},
""
);
},
""
);
}
}
// Tests that DefaultValue<T>::IsSet() is false initially.
// Tests that DefaultValue<T>::IsSet() is false initially.
...
@@ -281,26 +275,22 @@ TEST(DefaultValueDeathTest, GetReturnsBuiltInDefaultValueWhenUnset) {
...
@@ -281,26 +275,22 @@ TEST(DefaultValueDeathTest, GetReturnsBuiltInDefaultValueWhenUnset) {
EXPECT_EQ
(
0
,
DefaultValue
<
int
>::
Get
());
EXPECT_EQ
(
0
,
DefaultValue
<
int
>::
Get
());
EXPECT_DEATH_IF_SUPPORTED
({
EXPECT_DEATH_IF_SUPPORTED
({
DefaultValue
<
MyNonDefaultConstructible
>::
Get
();
},
DefaultValue
<
MyNonDefaultConstructible
>::
Get
();
""
);
},
""
);
}
}
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
()
==
nullptr
);
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
));
});
});
EXPECT_TRUE
(
DefaultValue
<
std
::
unique_ptr
<
int
>>::
Exists
());
EXPECT_TRUE
(
DefaultValue
<
std
::
unique_ptr
<
int
>>::
Exists
());
std
::
unique_ptr
<
int
>
i
=
DefaultValue
<
std
::
unique_ptr
<
int
>>::
Get
();
std
::
unique_ptr
<
int
>
i
=
DefaultValue
<
std
::
unique_ptr
<
int
>>::
Get
();
EXPECT_EQ
(
42
,
*
i
);
EXPECT_EQ
(
42
,
*
i
);
}
}
// Tests that DefaultValue<void>::Get() returns void.
// Tests that DefaultValue<void>::Get() returns void.
TEST
(
DefaultValueTest
,
GetWorksForVoid
)
{
TEST
(
DefaultValueTest
,
GetWorksForVoid
)
{
return
DefaultValue
<
void
>::
Get
();
}
return
DefaultValue
<
void
>::
Get
();
}
// Tests using DefaultValue with a reference type.
// Tests using DefaultValue with a reference type.
...
@@ -348,12 +338,9 @@ TEST(DefaultValueOfReferenceDeathTest, GetReturnsBuiltInDefaultValueWhenUnset) {
...
@@ -348,12 +338,9 @@ TEST(DefaultValueOfReferenceDeathTest, GetReturnsBuiltInDefaultValueWhenUnset) {
EXPECT_FALSE
(
DefaultValue
<
int
&>::
IsSet
());
EXPECT_FALSE
(
DefaultValue
<
int
&>::
IsSet
());
EXPECT_FALSE
(
DefaultValue
<
MyNonDefaultConstructible
&>::
IsSet
());
EXPECT_FALSE
(
DefaultValue
<
MyNonDefaultConstructible
&>::
IsSet
());
EXPECT_DEATH_IF_SUPPORTED
({
EXPECT_DEATH_IF_SUPPORTED
({
DefaultValue
<
int
&>::
Get
();
},
""
);
DefaultValue
<
int
&>::
Get
();
EXPECT_DEATH_IF_SUPPORTED
({
DefaultValue
<
MyNonDefaultConstructible
>::
Get
();
},
},
""
);
""
);
EXPECT_DEATH_IF_SUPPORTED
({
DefaultValue
<
MyNonDefaultConstructible
>::
Get
();
},
""
);
}
}
// Tests that ActionInterface can be implemented by defining the
// Tests that ActionInterface can be implemented by defining the
...
@@ -433,7 +420,7 @@ class IsNotZero : public ActionInterface<bool(int)> { // NOLINT
...
@@ -433,7 +420,7 @@ class IsNotZero : public ActionInterface<bool(int)> { // NOLINT
};
};
TEST
(
ActionTest
,
CanBeConvertedToOtherActionType
)
{
TEST
(
ActionTest
,
CanBeConvertedToOtherActionType
)
{
const
Action
<
bool
(
int
)
>
a1
(
new
IsNotZero
);
// NOLINT
const
Action
<
bool
(
int
)
>
a1
(
new
IsNotZero
);
// NOLINT
const
Action
<
int
(
char
)
>
a2
=
Action
<
int
(
char
)
>
(
a1
);
// NOLINT
const
Action
<
int
(
char
)
>
a2
=
Action
<
int
(
char
)
>
(
a1
);
// NOLINT
EXPECT_EQ
(
1
,
a2
.
Perform
(
std
::
make_tuple
(
'a'
)));
EXPECT_EQ
(
1
,
a2
.
Perform
(
std
::
make_tuple
(
'a'
)));
EXPECT_EQ
(
0
,
a2
.
Perform
(
std
::
make_tuple
(
'\0'
)));
EXPECT_EQ
(
0
,
a2
.
Perform
(
std
::
make_tuple
(
'\0'
)));
...
@@ -528,7 +515,7 @@ TEST(ReturnTest, AcceptsStringLiteral) {
...
@@ -528,7 +515,7 @@ TEST(ReturnTest, AcceptsStringLiteral) {
// Test struct which wraps a vector of integers. Used in
// Test struct which wraps a vector of integers. Used in
// 'SupportsWrapperReturnType' test.
// 'SupportsWrapperReturnType' test.
struct
IntegerVectorWrapper
{
struct
IntegerVectorWrapper
{
std
::
vector
<
int
>
*
v
;
std
::
vector
<
int
>*
v
;
IntegerVectorWrapper
(
std
::
vector
<
int
>&
_v
)
:
v
(
&
_v
)
{}
// NOLINT
IntegerVectorWrapper
(
std
::
vector
<
int
>&
_v
)
:
v
(
&
_v
)
{}
// NOLINT
};
};
...
@@ -648,7 +635,9 @@ TEST(ReturnRefTest, IsCovariant) {
...
@@ -648,7 +635,9 @@ TEST(ReturnRefTest, IsCovariant) {
}
}
template
<
typename
T
,
typename
=
decltype
(
ReturnRef
(
std
::
declval
<
T
&&
>()))
>
template
<
typename
T
,
typename
=
decltype
(
ReturnRef
(
std
::
declval
<
T
&&
>()))
>
bool
CanCallReturnRef
(
T
&&
)
{
return
true
;
}
bool
CanCallReturnRef
(
T
&&
)
{
return
true
;
}
bool
CanCallReturnRef
(
Unused
)
{
return
false
;
}
bool
CanCallReturnRef
(
Unused
)
{
return
false
;
}
// Tests that ReturnRef(v) is working with non-temporaries (T&)
// Tests that ReturnRef(v) is working with non-temporaries (T&)
...
@@ -668,7 +657,7 @@ TEST(ReturnRefTest, WorksForNonTemporary) {
...
@@ -668,7 +657,7 @@ TEST(ReturnRefTest, WorksForNonTemporary) {
// Tests that ReturnRef(v) is not working with temporaries (T&&)
// Tests that ReturnRef(v) is not working with temporaries (T&&)
TEST
(
ReturnRefTest
,
DoesNotWorkForTemporary
)
{
TEST
(
ReturnRefTest
,
DoesNotWorkForTemporary
)
{
auto
scalar_value
=
[]()
->
int
{
return
123
;
};
auto
scalar_value
=
[]()
->
int
{
return
123
;
};
EXPECT_FALSE
(
CanCallReturnRef
(
scalar_value
()));
EXPECT_FALSE
(
CanCallReturnRef
(
scalar_value
()));
auto
non_scalar_value
=
[]()
->
std
::
string
{
return
"ABC"
;
};
auto
non_scalar_value
=
[]()
->
std
::
string
{
return
"ABC"
;
};
...
@@ -754,8 +743,7 @@ class MockClass {
...
@@ -754,8 +743,7 @@ class MockClass {
// return type by default.
// return type by default.
TEST
(
DoDefaultTest
,
ReturnsBuiltInDefaultValueByDefault
)
{
TEST
(
DoDefaultTest
,
ReturnsBuiltInDefaultValueByDefault
)
{
MockClass
mock
;
MockClass
mock
;
EXPECT_CALL
(
mock
,
IntFunc
(
_
))
EXPECT_CALL
(
mock
,
IntFunc
(
_
)).
WillOnce
(
DoDefault
());
.
WillOnce
(
DoDefault
());
EXPECT_EQ
(
0
,
mock
.
IntFunc
(
true
));
EXPECT_EQ
(
0
,
mock
.
IntFunc
(
true
));
}
}
...
@@ -763,14 +751,11 @@ TEST(DoDefaultTest, ReturnsBuiltInDefaultValueByDefault) {
...
@@ -763,14 +751,11 @@ TEST(DoDefaultTest, ReturnsBuiltInDefaultValueByDefault) {
// the process when there is no built-in default value for the return type.
// the process when there is no built-in default value for the return type.
TEST
(
DoDefaultDeathTest
,
DiesForUnknowType
)
{
TEST
(
DoDefaultDeathTest
,
DiesForUnknowType
)
{
MockClass
mock
;
MockClass
mock
;
EXPECT_CALL
(
mock
,
Foo
())
EXPECT_CALL
(
mock
,
Foo
()).
WillRepeatedly
(
DoDefault
());
.
WillRepeatedly
(
DoDefault
());
#if GTEST_HAS_EXCEPTIONS
#if GTEST_HAS_EXCEPTIONS
EXPECT_ANY_THROW
(
mock
.
Foo
());
EXPECT_ANY_THROW
(
mock
.
Foo
());
#else
#else
EXPECT_DEATH_IF_SUPPORTED
({
EXPECT_DEATH_IF_SUPPORTED
({
mock
.
Foo
();
},
""
);
mock
.
Foo
();
},
""
);
#endif
#endif
}
}
...
@@ -782,16 +767,13 @@ void VoidFunc(bool /* flag */) {}
...
@@ -782,16 +767,13 @@ void VoidFunc(bool /* flag */) {}
TEST
(
DoDefaultDeathTest
,
DiesIfUsedInCompositeAction
)
{
TEST
(
DoDefaultDeathTest
,
DiesIfUsedInCompositeAction
)
{
MockClass
mock
;
MockClass
mock
;
EXPECT_CALL
(
mock
,
IntFunc
(
_
))
EXPECT_CALL
(
mock
,
IntFunc
(
_
))
.
WillRepeatedly
(
DoAll
(
Invoke
(
VoidFunc
),
.
WillRepeatedly
(
DoAll
(
Invoke
(
VoidFunc
),
DoDefault
()));
DoDefault
()));
// Ideally we should verify the error message as well. Sadly,
// Ideally we should verify the error message as well. Sadly,
// EXPECT_DEATH() can only capture stderr, while Google Mock's
// EXPECT_DEATH() can only capture stderr, while Google Mock's
// errors are printed on stdout. Therefore we have to settle for
// errors are printed on stdout. Therefore we have to settle for
// not verifying the message.
// not verifying the message.
EXPECT_DEATH_IF_SUPPORTED
({
EXPECT_DEATH_IF_SUPPORTED
({
mock
.
IntFunc
(
true
);
},
""
);
mock
.
IntFunc
(
true
);
},
""
);
}
}
// Tests that DoDefault() returns the default value set by
// Tests that DoDefault() returns the default value set by
...
@@ -799,8 +781,7 @@ TEST(DoDefaultDeathTest, DiesIfUsedInCompositeAction) {
...
@@ -799,8 +781,7 @@ TEST(DoDefaultDeathTest, DiesIfUsedInCompositeAction) {
TEST
(
DoDefaultTest
,
ReturnsUserSpecifiedPerTypeDefaultValueWhenThereIsOne
)
{
TEST
(
DoDefaultTest
,
ReturnsUserSpecifiedPerTypeDefaultValueWhenThereIsOne
)
{
DefaultValue
<
int
>::
Set
(
1
);
DefaultValue
<
int
>::
Set
(
1
);
MockClass
mock
;
MockClass
mock
;
EXPECT_CALL
(
mock
,
IntFunc
(
_
))
EXPECT_CALL
(
mock
,
IntFunc
(
_
)).
WillOnce
(
DoDefault
());
.
WillOnce
(
DoDefault
());
EXPECT_EQ
(
1
,
mock
.
IntFunc
(
false
));
EXPECT_EQ
(
1
,
mock
.
IntFunc
(
false
));
DefaultValue
<
int
>::
Clear
();
DefaultValue
<
int
>::
Clear
();
}
}
...
@@ -808,20 +789,19 @@ TEST(DoDefaultTest, ReturnsUserSpecifiedPerTypeDefaultValueWhenThereIsOne) {
...
@@ -808,20 +789,19 @@ TEST(DoDefaultTest, ReturnsUserSpecifiedPerTypeDefaultValueWhenThereIsOne) {
// Tests that DoDefault() does the action specified by ON_CALL().
// Tests that DoDefault() does the action specified by ON_CALL().
TEST
(
DoDefaultTest
,
DoesWhatOnCallSpecifies
)
{
TEST
(
DoDefaultTest
,
DoesWhatOnCallSpecifies
)
{
MockClass
mock
;
MockClass
mock
;
ON_CALL
(
mock
,
IntFunc
(
_
))
ON_CALL
(
mock
,
IntFunc
(
_
)).
WillByDefault
(
Return
(
2
));
.
WillByDefault
(
Return
(
2
));
EXPECT_CALL
(
mock
,
IntFunc
(
_
)).
WillOnce
(
DoDefault
());
EXPECT_CALL
(
mock
,
IntFunc
(
_
))
.
WillOnce
(
DoDefault
());
EXPECT_EQ
(
2
,
mock
.
IntFunc
(
false
));
EXPECT_EQ
(
2
,
mock
.
IntFunc
(
false
));
}
}
// Tests that using DoDefault() in ON_CALL() leads to a run-time failure.
// Tests that using DoDefault() in ON_CALL() leads to a run-time failure.
TEST
(
DoDefaultTest
,
CannotBeUsedInOnCall
)
{
TEST
(
DoDefaultTest
,
CannotBeUsedInOnCall
)
{
MockClass
mock
;
MockClass
mock
;
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_NONFATAL_FAILURE
(
ON_CALL
(
mock
,
IntFunc
(
_
))
{
// NOLINT
.
WillByDefault
(
DoDefault
());
ON_CALL
(
mock
,
IntFunc
(
_
)).
WillByDefault
(
DoDefault
());
},
"DoDefault() cannot be used in ON_CALL()"
);
},
"DoDefault() cannot be used in ON_CALL()"
);
}
}
// Tests that SetArgPointee<N>(v) sets the variable pointed to by
// Tests that SetArgPointee<N>(v) sets the variable pointed to by
...
@@ -868,7 +848,7 @@ TEST(SetArgPointeeTest, AcceptsWideStringLiteral) {
...
@@ -868,7 +848,7 @@ TEST(SetArgPointeeTest, AcceptsWideStringLiteral) {
a
.
Perform
(
std
::
make_tuple
(
&
ptr
));
a
.
Perform
(
std
::
make_tuple
(
&
ptr
));
EXPECT_STREQ
(
L"world"
,
ptr
);
EXPECT_STREQ
(
L"world"
,
ptr
);
#
if GTEST_HAS_STD_WSTRING
#if GTEST_HAS_STD_WSTRING
typedef
void
MyStringFunction
(
std
::
wstring
*
);
typedef
void
MyStringFunction
(
std
::
wstring
*
);
Action
<
MyStringFunction
>
a2
=
SetArgPointee
<
0
>
(
L"world"
);
Action
<
MyStringFunction
>
a2
=
SetArgPointee
<
0
>
(
L"world"
);
...
@@ -876,7 +856,7 @@ TEST(SetArgPointeeTest, AcceptsWideStringLiteral) {
...
@@ -876,7 +856,7 @@ TEST(SetArgPointeeTest, AcceptsWideStringLiteral) {
a2
.
Perform
(
std
::
make_tuple
(
&
str
));
a2
.
Perform
(
std
::
make_tuple
(
&
str
));
EXPECT_EQ
(
L"world"
,
str
);
EXPECT_EQ
(
L"world"
,
str
);
#
endif
#endif
}
}
// Tests that SetArgPointee<N>() accepts a char pointer.
// Tests that SetArgPointee<N>() accepts a char pointer.
...
@@ -907,7 +887,7 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) {
...
@@ -907,7 +887,7 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) {
a
.
Perform
(
std
::
make_tuple
(
true
,
&
ptr
));
a
.
Perform
(
std
::
make_tuple
(
true
,
&
ptr
));
EXPECT_EQ
(
hi
,
ptr
);
EXPECT_EQ
(
hi
,
ptr
);
#
if GTEST_HAS_STD_WSTRING
#if GTEST_HAS_STD_WSTRING
typedef
void
MyStringFunction
(
bool
,
std
::
wstring
*
);
typedef
void
MyStringFunction
(
bool
,
std
::
wstring
*
);
wchar_t
world_array
[]
=
L"world"
;
wchar_t
world_array
[]
=
L"world"
;
...
@@ -916,7 +896,7 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) {
...
@@ -916,7 +896,7 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) {
std
::
wstring
str
;
std
::
wstring
str
;
a2
.
Perform
(
std
::
make_tuple
(
true
,
&
str
));
a2
.
Perform
(
std
::
make_tuple
(
true
,
&
str
));
EXPECT_EQ
(
world_array
,
str
);
EXPECT_EQ
(
world_array
,
str
);
#
endif
#endif
}
}
// Tests that SetArgumentPointee<N>(v) sets the variable pointed to by
// Tests that SetArgumentPointee<N>(v) sets the variable pointed to by
...
@@ -1079,7 +1059,6 @@ TEST(AssignTest, CompatibleTypes) {
...
@@ -1079,7 +1059,6 @@ TEST(AssignTest, CompatibleTypes) {
EXPECT_DOUBLE_EQ
(
5
,
x
);
EXPECT_DOUBLE_EQ
(
5
,
x
);
}
}
// Tests using WithArgs and with an action that takes 1 argument.
// Tests using WithArgs and with an action that takes 1 argument.
TEST
(
WithArgsTest
,
OneArg
)
{
TEST
(
WithArgsTest
,
OneArg
)
{
Action
<
bool
(
double
x
,
int
n
)
>
a
=
WithArgs
<
1
>
(
Invoke
(
Unary
));
// NOLINT
Action
<
bool
(
double
x
,
int
n
)
>
a
=
WithArgs
<
1
>
(
Invoke
(
Unary
));
// NOLINT
...
@@ -1235,7 +1214,7 @@ TEST(ByRefTest, IsCopyable) {
...
@@ -1235,7 +1214,7 @@ TEST(ByRefTest, IsCopyable) {
TEST
(
ByRefTest
,
ConstValue
)
{
TEST
(
ByRefTest
,
ConstValue
)
{
const
int
n
=
0
;
const
int
n
=
0
;
// int& ref = ByRef(n); // This shouldn't compile - we have a
// int& ref = ByRef(n); // This shouldn't compile - we have a
// negative compilation test to catch it.
// negative compilation test to catch it.
const
int
&
const_ref
=
ByRef
(
n
);
const
int
&
const_ref
=
ByRef
(
n
);
EXPECT_EQ
(
&
n
,
&
const_ref
);
EXPECT_EQ
(
&
n
,
&
const_ref
);
}
}
...
@@ -1260,7 +1239,7 @@ TEST(ByRefTest, ExplicitType) {
...
@@ -1260,7 +1239,7 @@ TEST(ByRefTest, ExplicitType) {
EXPECT_EQ
(
&
n
,
&
r1
);
EXPECT_EQ
(
&
n
,
&
r1
);
// ByRef<char>(n); // This shouldn't compile - we have a negative
// ByRef<char>(n); // This shouldn't compile - we have a negative
// compilation test to catch it.
// compilation test to catch it.
Derived
d
;
Derived
d
;
Derived
&
r2
=
ByRef
<
Derived
>
(
d
);
Derived
&
r2
=
ByRef
<
Derived
>
(
d
);
...
@@ -1375,9 +1354,10 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_DoAllReturn) {
...
@@ -1375,9 +1354,10 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_DoAllReturn) {
MockClass
mock
;
MockClass
mock
;
std
::
unique_ptr
<
int
>
i
(
new
int
(
19
));
std
::
unique_ptr
<
int
>
i
(
new
int
(
19
));
EXPECT_CALL
(
mock_function
,
Call
());
EXPECT_CALL
(
mock_function
,
Call
());
EXPECT_CALL
(
mock
,
MakeUnique
()).
WillOnce
(
DoAll
(
EXPECT_CALL
(
mock
,
MakeUnique
())
InvokeWithoutArgs
(
&
mock_function
,
&
testing
::
MockFunction
<
void
()
>::
Call
),
.
WillOnce
(
DoAll
(
InvokeWithoutArgs
(
&
mock_function
,
Return
(
ByMove
(
std
::
move
(
i
)))));
&
testing
::
MockFunction
<
void
()
>::
Call
),
Return
(
ByMove
(
std
::
move
(
i
)))));
std
::
unique_ptr
<
int
>
result1
=
mock
.
MakeUnique
();
std
::
unique_ptr
<
int
>
result1
=
mock
.
MakeUnique
();
EXPECT_EQ
(
19
,
*
result1
);
EXPECT_EQ
(
19
,
*
result1
);
...
@@ -1387,9 +1367,8 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) {
...
@@ -1387,9 +1367,8 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) {
MockClass
mock
;
MockClass
mock
;
// Check default value
// Check default value
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
));
});
});
EXPECT_EQ
(
42
,
*
mock
.
MakeUnique
());
EXPECT_EQ
(
42
,
*
mock
.
MakeUnique
());
EXPECT_CALL
(
mock
,
MakeUnique
()).
WillRepeatedly
(
Invoke
(
UniquePtrSource
));
EXPECT_CALL
(
mock
,
MakeUnique
()).
WillRepeatedly
(
Invoke
(
UniquePtrSource
));
...
@@ -1449,7 +1428,6 @@ TEST(MockMethodTest, CanTakeMoveOnlyValue) {
...
@@ -1449,7 +1428,6 @@ TEST(MockMethodTest, CanTakeMoveOnlyValue) {
EXPECT_EQ
(
42
,
*
saved
);
EXPECT_EQ
(
42
,
*
saved
);
}
}
// Tests for std::function based action.
// Tests for std::function based action.
int
Add
(
int
val
,
int
&
ref
,
int
*
ptr
)
{
// NOLINT
int
Add
(
int
val
,
int
&
ref
,
int
*
ptr
)
{
// NOLINT
...
@@ -1463,7 +1441,9 @@ int Deref(std::unique_ptr<int> ptr) { return *ptr; }
...
@@ -1463,7 +1441,9 @@ int Deref(std::unique_ptr<int> ptr) { return *ptr; }
struct
Double
{
struct
Double
{
template
<
typename
T
>
template
<
typename
T
>
T
operator
()(
T
t
)
{
return
2
*
t
;
}
T
operator
()(
T
t
)
{
return
2
*
t
;
}
};
};
std
::
unique_ptr
<
int
>
UniqueInt
(
int
i
)
{
std
::
unique_ptr
<
int
>
UniqueInt
(
int
i
)
{
...
@@ -1532,8 +1512,9 @@ TEST(FunctorActionTest, TypeConversion) {
...
@@ -1532,8 +1512,9 @@ TEST(FunctorActionTest, TypeConversion) {
TEST
(
FunctorActionTest
,
UnusedArguments
)
{
TEST
(
FunctorActionTest
,
UnusedArguments
)
{
// Verify that users can ignore uninteresting arguments.
// Verify that users can ignore uninteresting arguments.
Action
<
int
(
int
,
double
y
,
double
z
)
>
a
=
Action
<
int
(
int
,
double
y
,
double
z
)
>
a
=
[](
int
i
,
Unused
,
Unused
)
{
[](
int
i
,
Unused
,
Unused
)
{
return
2
*
i
;
};
return
2
*
i
;
};
std
::
tuple
<
int
,
double
,
double
>
dummy
=
std
::
make_tuple
(
3
,
7.3
,
9.44
);
std
::
tuple
<
int
,
double
,
double
>
dummy
=
std
::
make_tuple
(
3
,
7.3
,
9.44
);
EXPECT_EQ
(
6
,
a
.
Perform
(
dummy
));
EXPECT_EQ
(
6
,
a
.
Perform
(
dummy
));
}
}
...
@@ -1552,9 +1533,7 @@ TEST(MoveOnlyArgumentsTest, ReturningActions) {
...
@@ -1552,9 +1533,7 @@ TEST(MoveOnlyArgumentsTest, ReturningActions) {
EXPECT_EQ
(
x
,
3
);
EXPECT_EQ
(
x
,
3
);
}
}
ACTION
(
ReturnArity
)
{
ACTION
(
ReturnArity
)
{
return
std
::
tuple_size
<
args_type
>::
value
;
}
return
std
::
tuple_size
<
args_type
>::
value
;
}
TEST
(
ActionMacro
,
LargeArity
)
{
TEST
(
ActionMacro
,
LargeArity
)
{
EXPECT_EQ
(
EXPECT_EQ
(
...
@@ -1577,7 +1556,6 @@ TEST(ActionMacro, LargeArity) {
...
@@ -1577,7 +1556,6 @@ TEST(ActionMacro, LargeArity) {
#ifdef _MSC_VER
#ifdef _MSC_VER
#if _MSC_VER == 1900
#if _MSC_VER == 1900
#
pragma warning(pop)
#pragma warning(pop)
#endif
#endif
#endif
#endif
googlemock/test/gmock-cardinalities_test.cc
View file @
9e712372
...
@@ -27,14 +27,13 @@
...
@@ -27,14 +27,13 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes.
// Google Mock - a framework for writing C++ mock classes.
//
//
// This file tests the built-in cardinalities.
// This file tests the built-in cardinalities.
#include "gmock/gmock.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "gtest/gtest-spi.h"
#include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
namespace
{
namespace
{
...
@@ -59,9 +58,7 @@ class MockFoo {
...
@@ -59,9 +58,7 @@ class MockFoo {
};
};
// Tests that Cardinality objects can be default constructed.
// Tests that Cardinality objects can be default constructed.
TEST
(
CardinalityTest
,
IsDefaultConstructable
)
{
TEST
(
CardinalityTest
,
IsDefaultConstructable
)
{
Cardinality
c
;
}
Cardinality
c
;
}
// Tests that Cardinality objects are copyable.
// Tests that Cardinality objects are copyable.
TEST
(
CardinalityTest
,
IsCopyable
)
{
TEST
(
CardinalityTest
,
IsCopyable
)
{
...
@@ -119,8 +116,7 @@ TEST(AnyNumber, Works) {
...
@@ -119,8 +116,7 @@ TEST(AnyNumber, Works) {
stringstream
ss
;
stringstream
ss
;
c
.
DescribeTo
(
&
ss
);
c
.
DescribeTo
(
&
ss
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called any number of times"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called any number of times"
,
ss
.
str
());
ss
.
str
());
}
}
TEST
(
AnyNumberTest
,
HasCorrectBounds
)
{
TEST
(
AnyNumberTest
,
HasCorrectBounds
)
{
...
@@ -132,9 +128,11 @@ TEST(AnyNumberTest, HasCorrectBounds) {
...
@@ -132,9 +128,11 @@ TEST(AnyNumberTest, HasCorrectBounds) {
// Tests AtLeast(n).
// Tests AtLeast(n).
TEST
(
AtLeastTest
,
OnNegativeNumber
)
{
TEST
(
AtLeastTest
,
OnNegativeNumber
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_NONFATAL_FAILURE
(
AtLeast
(
-
1
);
{
// NOLINT
},
"The invocation lower bound must be >= 0"
);
AtLeast
(
-
1
);
},
"The invocation lower bound must be >= 0"
);
}
}
TEST
(
AtLeastTest
,
OnZero
)
{
TEST
(
AtLeastTest
,
OnZero
)
{
...
@@ -147,8 +145,7 @@ TEST(AtLeastTest, OnZero) {
...
@@ -147,8 +145,7 @@ TEST(AtLeastTest, OnZero) {
stringstream
ss
;
stringstream
ss
;
c
.
DescribeTo
(
&
ss
);
c
.
DescribeTo
(
&
ss
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"any number of times"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"any number of times"
,
ss
.
str
());
ss
.
str
());
}
}
TEST
(
AtLeastTest
,
OnPositiveNumber
)
{
TEST
(
AtLeastTest
,
OnPositiveNumber
)
{
...
@@ -164,18 +161,15 @@ TEST(AtLeastTest, OnPositiveNumber) {
...
@@ -164,18 +161,15 @@ TEST(AtLeastTest, OnPositiveNumber) {
stringstream
ss1
;
stringstream
ss1
;
AtLeast
(
1
).
DescribeTo
(
&
ss1
);
AtLeast
(
1
).
DescribeTo
(
&
ss1
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"at least once"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"at least once"
,
ss1
.
str
());
ss1
.
str
());
stringstream
ss2
;
stringstream
ss2
;
c
.
DescribeTo
(
&
ss2
);
c
.
DescribeTo
(
&
ss2
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"at least twice"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"at least twice"
,
ss2
.
str
());
ss2
.
str
());
stringstream
ss3
;
stringstream
ss3
;
AtLeast
(
3
).
DescribeTo
(
&
ss3
);
AtLeast
(
3
).
DescribeTo
(
&
ss3
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"at least 3 times"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"at least 3 times"
,
ss3
.
str
());
ss3
.
str
());
}
}
TEST
(
AtLeastTest
,
HasCorrectBounds
)
{
TEST
(
AtLeastTest
,
HasCorrectBounds
)
{
...
@@ -187,9 +181,11 @@ TEST(AtLeastTest, HasCorrectBounds) {
...
@@ -187,9 +181,11 @@ TEST(AtLeastTest, HasCorrectBounds) {
// Tests AtMost(n).
// Tests AtMost(n).
TEST
(
AtMostTest
,
OnNegativeNumber
)
{
TEST
(
AtMostTest
,
OnNegativeNumber
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_NONFATAL_FAILURE
(
AtMost
(
-
1
);
{
// NOLINT
},
"The invocation upper bound must be >= 0"
);
AtMost
(
-
1
);
},
"The invocation upper bound must be >= 0"
);
}
}
TEST
(
AtMostTest
,
OnZero
)
{
TEST
(
AtMostTest
,
OnZero
)
{
...
@@ -202,8 +198,7 @@ TEST(AtMostTest, OnZero) {
...
@@ -202,8 +198,7 @@ TEST(AtMostTest, OnZero) {
stringstream
ss
;
stringstream
ss
;
c
.
DescribeTo
(
&
ss
);
c
.
DescribeTo
(
&
ss
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"never called"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"never called"
,
ss
.
str
());
ss
.
str
());
}
}
TEST
(
AtMostTest
,
OnPositiveNumber
)
{
TEST
(
AtMostTest
,
OnPositiveNumber
)
{
...
@@ -219,18 +214,15 @@ TEST(AtMostTest, OnPositiveNumber) {
...
@@ -219,18 +214,15 @@ TEST(AtMostTest, OnPositiveNumber) {
stringstream
ss1
;
stringstream
ss1
;
AtMost
(
1
).
DescribeTo
(
&
ss1
);
AtMost
(
1
).
DescribeTo
(
&
ss1
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called at most once"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called at most once"
,
ss1
.
str
());
ss1
.
str
());
stringstream
ss2
;
stringstream
ss2
;
c
.
DescribeTo
(
&
ss2
);
c
.
DescribeTo
(
&
ss2
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called at most twice"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called at most twice"
,
ss2
.
str
());
ss2
.
str
());
stringstream
ss3
;
stringstream
ss3
;
AtMost
(
3
).
DescribeTo
(
&
ss3
);
AtMost
(
3
).
DescribeTo
(
&
ss3
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called at most 3 times"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called at most 3 times"
,
ss3
.
str
());
ss3
.
str
());
}
}
TEST
(
AtMostTest
,
HasCorrectBounds
)
{
TEST
(
AtMostTest
,
HasCorrectBounds
)
{
...
@@ -242,22 +234,28 @@ TEST(AtMostTest, HasCorrectBounds) {
...
@@ -242,22 +234,28 @@ TEST(AtMostTest, HasCorrectBounds) {
// Tests Between(m, n).
// Tests Between(m, n).
TEST
(
BetweenTest
,
OnNegativeStart
)
{
TEST
(
BetweenTest
,
OnNegativeStart
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_NONFATAL_FAILURE
(
Between
(
-
1
,
2
);
{
// NOLINT
},
"The invocation lower bound must be >= 0, but is actually -1"
);
Between
(
-
1
,
2
);
},
"The invocation lower bound must be >= 0, but is actually -1"
);
}
}
TEST
(
BetweenTest
,
OnNegativeEnd
)
{
TEST
(
BetweenTest
,
OnNegativeEnd
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_NONFATAL_FAILURE
(
Between
(
1
,
-
2
);
{
// NOLINT
},
"The invocation upper bound must be >= 0, but is actually -2"
);
Between
(
1
,
-
2
);
},
"The invocation upper bound must be >= 0, but is actually -2"
);
}
}
TEST
(
BetweenTest
,
OnStartBiggerThanEnd
)
{
TEST
(
BetweenTest
,
OnStartBiggerThanEnd
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_NONFATAL_FAILURE
(
Between
(
2
,
1
);
{
// NOLINT
},
"The invocation upper bound (1) must be >= "
Between
(
2
,
1
);
"the invocation lower bound (2)"
);
},
"The invocation upper bound (1) must be >= "
"the invocation lower bound (2)"
);
}
}
TEST
(
BetweenTest
,
OnZeroStartAndZeroEnd
)
{
TEST
(
BetweenTest
,
OnZeroStartAndZeroEnd
)
{
...
@@ -271,8 +269,7 @@ TEST(BetweenTest, OnZeroStartAndZeroEnd) {
...
@@ -271,8 +269,7 @@ TEST(BetweenTest, OnZeroStartAndZeroEnd) {
stringstream
ss
;
stringstream
ss
;
c
.
DescribeTo
(
&
ss
);
c
.
DescribeTo
(
&
ss
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"never called"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"never called"
,
ss
.
str
());
ss
.
str
());
}
}
TEST
(
BetweenTest
,
OnZeroStartAndNonZeroEnd
)
{
TEST
(
BetweenTest
,
OnZeroStartAndNonZeroEnd
)
{
...
@@ -289,8 +286,7 @@ TEST(BetweenTest, OnZeroStartAndNonZeroEnd) {
...
@@ -289,8 +286,7 @@ TEST(BetweenTest, OnZeroStartAndNonZeroEnd) {
stringstream
ss
;
stringstream
ss
;
c
.
DescribeTo
(
&
ss
);
c
.
DescribeTo
(
&
ss
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called at most twice"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called at most twice"
,
ss
.
str
());
ss
.
str
());
}
}
TEST
(
BetweenTest
,
OnSameStartAndEnd
)
{
TEST
(
BetweenTest
,
OnSameStartAndEnd
)
{
...
@@ -307,8 +303,7 @@ TEST(BetweenTest, OnSameStartAndEnd) {
...
@@ -307,8 +303,7 @@ TEST(BetweenTest, OnSameStartAndEnd) {
stringstream
ss
;
stringstream
ss
;
c
.
DescribeTo
(
&
ss
);
c
.
DescribeTo
(
&
ss
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called 3 times"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called 3 times"
,
ss
.
str
());
ss
.
str
());
}
}
TEST
(
BetweenTest
,
OnDifferentStartAndEnd
)
{
TEST
(
BetweenTest
,
OnDifferentStartAndEnd
)
{
...
@@ -328,8 +323,7 @@ TEST(BetweenTest, OnDifferentStartAndEnd) {
...
@@ -328,8 +323,7 @@ TEST(BetweenTest, OnDifferentStartAndEnd) {
stringstream
ss
;
stringstream
ss
;
c
.
DescribeTo
(
&
ss
);
c
.
DescribeTo
(
&
ss
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called between 3 and 5 times"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called between 3 and 5 times"
,
ss
.
str
());
ss
.
str
());
}
}
TEST
(
BetweenTest
,
HasCorrectBounds
)
{
TEST
(
BetweenTest
,
HasCorrectBounds
)
{
...
@@ -341,9 +335,11 @@ TEST(BetweenTest, HasCorrectBounds) {
...
@@ -341,9 +335,11 @@ TEST(BetweenTest, HasCorrectBounds) {
// Tests Exactly(n).
// Tests Exactly(n).
TEST
(
ExactlyTest
,
OnNegativeNumber
)
{
TEST
(
ExactlyTest
,
OnNegativeNumber
)
{
EXPECT_NONFATAL_FAILURE
({
// NOLINT
EXPECT_NONFATAL_FAILURE
(
Exactly
(
-
1
);
{
// NOLINT
},
"The invocation lower bound must be >= 0"
);
Exactly
(
-
1
);
},
"The invocation lower bound must be >= 0"
);
}
}
TEST
(
ExactlyTest
,
OnZero
)
{
TEST
(
ExactlyTest
,
OnZero
)
{
...
@@ -356,8 +352,7 @@ TEST(ExactlyTest, OnZero) {
...
@@ -356,8 +352,7 @@ TEST(ExactlyTest, OnZero) {
stringstream
ss
;
stringstream
ss
;
c
.
DescribeTo
(
&
ss
);
c
.
DescribeTo
(
&
ss
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"never called"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"never called"
,
ss
.
str
());
ss
.
str
());
}
}
TEST
(
ExactlyTest
,
OnPositiveNumber
)
{
TEST
(
ExactlyTest
,
OnPositiveNumber
)
{
...
@@ -370,18 +365,15 @@ TEST(ExactlyTest, OnPositiveNumber) {
...
@@ -370,18 +365,15 @@ TEST(ExactlyTest, OnPositiveNumber) {
stringstream
ss1
;
stringstream
ss1
;
Exactly
(
1
).
DescribeTo
(
&
ss1
);
Exactly
(
1
).
DescribeTo
(
&
ss1
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called once"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called once"
,
ss1
.
str
());
ss1
.
str
());
stringstream
ss2
;
stringstream
ss2
;
c
.
DescribeTo
(
&
ss2
);
c
.
DescribeTo
(
&
ss2
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called twice"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called twice"
,
ss2
.
str
());
ss2
.
str
());
stringstream
ss3
;
stringstream
ss3
;
Exactly
(
3
).
DescribeTo
(
&
ss3
);
Exactly
(
3
).
DescribeTo
(
&
ss3
);
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called 3 times"
,
EXPECT_PRED_FORMAT2
(
IsSubstring
,
"called 3 times"
,
ss3
.
str
());
ss3
.
str
());
}
}
TEST
(
ExactlyTest
,
HasCorrectBounds
)
{
TEST
(
ExactlyTest
,
HasCorrectBounds
)
{
...
...
googlemock/test/gmock-function-mocker_test.cc
View file @
9e712372
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes.
// Google Mock - a framework for writing C++ mock classes.
//
//
// This file tests the function mocker classes.
// This file tests the function mocker classes.
...
@@ -37,7 +36,7 @@
...
@@ -37,7 +36,7 @@
// MSDN says the header file to be included for STDMETHOD is BaseTyps.h but
// MSDN says the header file to be included for STDMETHOD is BaseTyps.h but
// we are getting compiler errors if we use basetyps.h, hence including
// we are getting compiler errors if we use basetyps.h, hence including
// objbase.h for definition of STDMETHOD.
// objbase.h for definition of STDMETHOD.
#
include <objbase.h>
#include <objbase.h>
#endif // GTEST_OS_WINDOWS
#endif // GTEST_OS_WINDOWS
#include <functional>
#include <functional>
...
@@ -65,7 +64,7 @@ using testing::Return;
...
@@ -65,7 +64,7 @@ using testing::Return;
using
testing
::
ReturnRef
;
using
testing
::
ReturnRef
;
using
testing
::
TypedEq
;
using
testing
::
TypedEq
;
template
<
typename
T
>
template
<
typename
T
>
class
TemplatedCopyable
{
class
TemplatedCopyable
{
public:
public:
TemplatedCopyable
()
{}
TemplatedCopyable
()
{}
...
@@ -82,7 +81,7 @@ class FooInterface {
...
@@ -82,7 +81,7 @@ class FooInterface {
virtual
int
Nullary
()
=
0
;
virtual
int
Nullary
()
=
0
;
virtual
bool
Unary
(
int
x
)
=
0
;
virtual
bool
Unary
(
int
x
)
=
0
;
virtual
long
Binary
(
short
x
,
int
y
)
=
0
;
// NOLINT
virtual
long
Binary
(
short
x
,
int
y
)
=
0
;
// NOLINT
virtual
int
Decimal
(
bool
b
,
char
c
,
short
d
,
int
e
,
long
f
,
// NOLINT
virtual
int
Decimal
(
bool
b
,
char
c
,
short
d
,
int
e
,
long
f
,
// NOLINT
float
g
,
double
h
,
unsigned
i
,
char
*
j
,
float
g
,
double
h
,
unsigned
i
,
char
*
j
,
const
std
::
string
&
k
)
=
0
;
const
std
::
string
&
k
)
=
0
;
...
@@ -133,8 +132,8 @@ class FooInterface {
...
@@ -133,8 +132,8 @@ class FooInterface {
// signature. This was fixed in Visual Studio 2008. However, the compiler
// signature. This was fixed in Visual Studio 2008. However, the compiler
// still emits a warning that alerts about this change in behavior.
// still emits a warning that alerts about this change in behavior.
#ifdef _MSC_VER
#ifdef _MSC_VER
#
pragma warning(push)
#pragma warning(push)
#
pragma warning(disable : 4373)
#pragma warning(disable : 4373)
#endif
#endif
class
MockFoo
:
public
FooInterface
{
class
MockFoo
:
public
FooInterface
{
public:
public:
...
@@ -279,7 +278,7 @@ class LegacyMockFoo : public FooInterface {
...
@@ -279,7 +278,7 @@ class LegacyMockFoo : public FooInterface {
};
};
#ifdef _MSC_VER
#ifdef _MSC_VER
#
pragma warning(pop)
#pragma warning(pop)
#endif
#endif
template
<
class
T
>
template
<
class
T
>
...
@@ -595,10 +594,8 @@ TYPED_TEST(TemplateMockTest, Works) {
...
@@ -595,10 +594,8 @@ TYPED_TEST(TemplateMockTest, Works) {
.
WillOnce
(
Return
(
0
));
.
WillOnce
(
Return
(
0
));
EXPECT_CALL
(
mock
,
Push
(
_
));
EXPECT_CALL
(
mock
,
Push
(
_
));
int
n
=
5
;
int
n
=
5
;
EXPECT_CALL
(
mock
,
GetTop
())
EXPECT_CALL
(
mock
,
GetTop
()).
WillOnce
(
ReturnRef
(
n
));
.
WillOnce
(
ReturnRef
(
n
));
EXPECT_CALL
(
mock
,
Pop
()).
Times
(
AnyNumber
());
EXPECT_CALL
(
mock
,
Pop
())
.
Times
(
AnyNumber
());
EXPECT_EQ
(
0
,
mock
.
GetSize
());
EXPECT_EQ
(
0
,
mock
.
GetSize
());
mock
.
Push
(
5
);
mock
.
Push
(
5
);
...
@@ -612,10 +609,8 @@ TYPED_TEST(TemplateMockTest, MethodWithCommaInReturnTypeWorks) {
...
@@ -612,10 +609,8 @@ TYPED_TEST(TemplateMockTest, MethodWithCommaInReturnTypeWorks) {
TypeParam
mock
;
TypeParam
mock
;
const
std
::
map
<
int
,
int
>
a_map
;
const
std
::
map
<
int
,
int
>
a_map
;
EXPECT_CALL
(
mock
,
ReturnTypeWithComma
())
EXPECT_CALL
(
mock
,
ReturnTypeWithComma
()).
WillOnce
(
Return
(
a_map
));
.
WillOnce
(
Return
(
a_map
));
EXPECT_CALL
(
mock
,
ReturnTypeWithComma
(
1
)).
WillOnce
(
Return
(
a_map
));
EXPECT_CALL
(
mock
,
ReturnTypeWithComma
(
1
))
.
WillOnce
(
Return
(
a_map
));
EXPECT_EQ
(
a_map
,
mock
.
ReturnTypeWithComma
());
EXPECT_EQ
(
a_map
,
mock
.
ReturnTypeWithComma
());
EXPECT_EQ
(
a_map
,
mock
.
ReturnTypeWithComma
(
1
));
EXPECT_EQ
(
a_map
,
mock
.
ReturnTypeWithComma
(
1
));
...
@@ -685,10 +680,8 @@ TYPED_TEST(TemplateMockTestWithCallType, Works) {
...
@@ -685,10 +680,8 @@ TYPED_TEST(TemplateMockTestWithCallType, Works) {
.
WillOnce
(
Return
(
0
));
.
WillOnce
(
Return
(
0
));
EXPECT_CALL
(
mock
,
Push
(
_
));
EXPECT_CALL
(
mock
,
Push
(
_
));
int
n
=
5
;
int
n
=
5
;
EXPECT_CALL
(
mock
,
GetTop
())
EXPECT_CALL
(
mock
,
GetTop
()).
WillOnce
(
ReturnRef
(
n
));
.
WillOnce
(
ReturnRef
(
n
));
EXPECT_CALL
(
mock
,
Pop
()).
Times
(
AnyNumber
());
EXPECT_CALL
(
mock
,
Pop
())
.
Times
(
AnyNumber
());
EXPECT_EQ
(
0
,
mock
.
GetSize
());
EXPECT_EQ
(
0
,
mock
.
GetSize
());
mock
.
Push
(
5
);
mock
.
Push
(
5
);
...
@@ -747,9 +740,9 @@ TYPED_TEST(OverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody) {
...
@@ -747,9 +740,9 @@ TYPED_TEST(OverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody) {
EXPECT_TRUE
(
mock
.
Overloaded
(
true
,
1
));
EXPECT_TRUE
(
mock
.
Overloaded
(
true
,
1
));
}
}
#define MY_MOCK_METHODS2_ \
#define MY_MOCK_METHODS2_
\
MOCK_CONST_METHOD1(Overloaded, int(int n)); \
MOCK_CONST_METHOD1(Overloaded, int(int n)); \
MOCK_METHOD1(Overloaded, int(int n))
MOCK_METHOD1(Overloaded, int(int n))
class
MockOverloadedOnConstness
{
class
MockOverloadedOnConstness
{
public:
public:
...
@@ -779,9 +772,7 @@ TEST(MockMethodMockFunctionTest, WorksForVoidNullary) {
...
@@ -779,9 +772,7 @@ TEST(MockMethodMockFunctionTest, WorksForVoidNullary) {
TEST
(
MockMethodMockFunctionTest
,
WorksForNonVoidNullary
)
{
TEST
(
MockMethodMockFunctionTest
,
WorksForNonVoidNullary
)
{
MockFunction
<
int
()
>
foo
;
MockFunction
<
int
()
>
foo
;
EXPECT_CALL
(
foo
,
Call
())
EXPECT_CALL
(
foo
,
Call
()).
WillOnce
(
Return
(
1
)).
WillOnce
(
Return
(
2
));
.
WillOnce
(
Return
(
1
))
.
WillOnce
(
Return
(
2
));
EXPECT_EQ
(
1
,
foo
.
Call
());
EXPECT_EQ
(
1
,
foo
.
Call
());
EXPECT_EQ
(
2
,
foo
.
Call
());
EXPECT_EQ
(
2
,
foo
.
Call
());
}
}
...
@@ -794,19 +785,17 @@ TEST(MockMethodMockFunctionTest, WorksForVoidUnary) {
...
@@ -794,19 +785,17 @@ TEST(MockMethodMockFunctionTest, WorksForVoidUnary) {
TEST
(
MockMethodMockFunctionTest
,
WorksForNonVoidBinary
)
{
TEST
(
MockMethodMockFunctionTest
,
WorksForNonVoidBinary
)
{
MockFunction
<
int
(
bool
,
int
)
>
foo
;
MockFunction
<
int
(
bool
,
int
)
>
foo
;
EXPECT_CALL
(
foo
,
Call
(
false
,
42
))
EXPECT_CALL
(
foo
,
Call
(
false
,
42
)).
WillOnce
(
Return
(
1
)).
WillOnce
(
Return
(
2
));
.
WillOnce
(
Return
(
1
))
EXPECT_CALL
(
foo
,
Call
(
true
,
Ge
(
100
))).
WillOnce
(
Return
(
3
));
.
WillOnce
(
Return
(
2
));
EXPECT_CALL
(
foo
,
Call
(
true
,
Ge
(
100
)))
.
WillOnce
(
Return
(
3
));
EXPECT_EQ
(
1
,
foo
.
Call
(
false
,
42
));
EXPECT_EQ
(
1
,
foo
.
Call
(
false
,
42
));
EXPECT_EQ
(
2
,
foo
.
Call
(
false
,
42
));
EXPECT_EQ
(
2
,
foo
.
Call
(
false
,
42
));
EXPECT_EQ
(
3
,
foo
.
Call
(
true
,
120
));
EXPECT_EQ
(
3
,
foo
.
Call
(
true
,
120
));
}
}
TEST
(
MockMethodMockFunctionTest
,
WorksFor10Arguments
)
{
TEST
(
MockMethodMockFunctionTest
,
WorksFor10Arguments
)
{
MockFunction
<
int
(
bool
a0
,
char
a1
,
int
a2
,
int
a3
,
int
a4
,
MockFunction
<
int
(
bool
a0
,
char
a1
,
int
a2
,
int
a3
,
int
a4
,
int
a5
,
int
a6
,
int
a5
,
int
a6
,
char
a7
,
int
a8
,
bool
a9
)
>
foo
;
char
a7
,
int
a8
,
bool
a9
)
>
foo
;
EXPECT_CALL
(
foo
,
Call
(
_
,
'a'
,
_
,
_
,
_
,
_
,
_
,
_
,
_
,
_
))
EXPECT_CALL
(
foo
,
Call
(
_
,
'a'
,
_
,
_
,
_
,
_
,
_
,
_
,
_
,
_
))
.
WillOnce
(
Return
(
1
))
.
WillOnce
(
Return
(
1
))
.
WillOnce
(
Return
(
2
));
.
WillOnce
(
Return
(
2
));
...
@@ -816,9 +805,7 @@ TEST(MockMethodMockFunctionTest, WorksFor10Arguments) {
...
@@ -816,9 +805,7 @@ TEST(MockMethodMockFunctionTest, WorksFor10Arguments) {
TEST
(
MockMethodMockFunctionTest
,
AsStdFunction
)
{
TEST
(
MockMethodMockFunctionTest
,
AsStdFunction
)
{
MockFunction
<
int
(
int
)
>
foo
;
MockFunction
<
int
(
int
)
>
foo
;
auto
call
=
[](
const
std
::
function
<
int
(
int
)
>
&
f
,
int
i
)
{
auto
call
=
[](
const
std
::
function
<
int
(
int
)
>&
f
,
int
i
)
{
return
f
(
i
);
};
return
f
(
i
);
};
EXPECT_CALL
(
foo
,
Call
(
1
)).
WillOnce
(
Return
(
-
1
));
EXPECT_CALL
(
foo
,
Call
(
1
)).
WillOnce
(
Return
(
-
1
));
EXPECT_CALL
(
foo
,
Call
(
2
)).
WillOnce
(
Return
(
-
2
));
EXPECT_CALL
(
foo
,
Call
(
2
)).
WillOnce
(
Return
(
-
2
));
EXPECT_EQ
(
-
1
,
call
(
foo
.
AsStdFunction
(),
1
));
EXPECT_EQ
(
-
1
,
call
(
foo
.
AsStdFunction
(),
1
));
...
@@ -836,10 +823,8 @@ TEST(MockMethodMockFunctionTest, AsStdFunctionReturnsReference) {
...
@@ -836,10 +823,8 @@ TEST(MockMethodMockFunctionTest, AsStdFunctionReturnsReference) {
}
}
TEST
(
MockMethodMockFunctionTest
,
AsStdFunctionWithReferenceParameter
)
{
TEST
(
MockMethodMockFunctionTest
,
AsStdFunctionWithReferenceParameter
)
{
MockFunction
<
int
(
int
&
)
>
foo
;
MockFunction
<
int
(
int
&
)
>
foo
;
auto
call
=
[](
const
std
::
function
<
int
(
int
&
)
>
&
f
,
int
&
i
)
{
auto
call
=
[](
const
std
::
function
<
int
(
int
&
)
>&
f
,
int
&
i
)
{
return
f
(
i
);
};
return
f
(
i
);
};
int
i
=
42
;
int
i
=
42
;
EXPECT_CALL
(
foo
,
Call
(
i
)).
WillOnce
(
Return
(
-
1
));
EXPECT_CALL
(
foo
,
Call
(
i
)).
WillOnce
(
Return
(
-
1
));
EXPECT_EQ
(
-
1
,
call
(
foo
.
AsStdFunction
(),
i
));
EXPECT_EQ
(
-
1
,
call
(
foo
.
AsStdFunction
(),
i
));
...
@@ -888,8 +873,7 @@ TYPED_TEST(
...
@@ -888,8 +873,7 @@ TYPED_TEST(
}
}
template
<
typename
F
>
template
<
typename
F
>
struct
AlternateCallable
{
struct
AlternateCallable
{};
};
TYPED_TEST
(
MockMethodMockFunctionSignatureTest
,
TYPED_TEST
(
MockMethodMockFunctionSignatureTest
,
IsMockFunctionTemplateArgumentDeducedForAlternateCallable
)
{
IsMockFunctionTemplateArgumentDeducedForAlternateCallable
)
{
...
@@ -898,16 +882,14 @@ TYPED_TEST(MockMethodMockFunctionSignatureTest,
...
@@ -898,16 +882,14 @@ TYPED_TEST(MockMethodMockFunctionSignatureTest,
EXPECT_TRUE
(
IsMockFunctionTemplateArgumentDeducedTo
<
TypeParam
>
(
foo
));
EXPECT_TRUE
(
IsMockFunctionTemplateArgumentDeducedTo
<
TypeParam
>
(
foo
));
}
}
TYPED_TEST
(
TYPED_TEST
(
MockMethodMockFunctionSignatureTest
,
MockMethodMockFunctionSignatureTest
,
IsMockFunctionCallMethodSignatureTheSameForAlternateCallable
)
{
IsMockFunctionCallMethodSignatureTheSameForAlternateCallable
)
{
using
ForRawSignature
=
decltype
(
&
MockFunction
<
TypeParam
>::
Call
);
using
ForRawSignature
=
decltype
(
&
MockFunction
<
TypeParam
>::
Call
);
using
ForStdFunction
=
using
ForStdFunction
=
decltype
(
&
MockFunction
<
std
::
function
<
TypeParam
>>::
Call
);
decltype
(
&
MockFunction
<
std
::
function
<
TypeParam
>>::
Call
);
EXPECT_TRUE
((
std
::
is_same
<
ForRawSignature
,
ForStdFunction
>::
value
));
EXPECT_TRUE
((
std
::
is_same
<
ForRawSignature
,
ForStdFunction
>::
value
));
}
}
struct
MockMethodSizes0
{
struct
MockMethodSizes0
{
MOCK_METHOD
(
void
,
func
,
());
MOCK_METHOD
(
void
,
func
,
());
};
};
...
@@ -925,22 +907,21 @@ struct MockMethodSizes4 {
...
@@ -925,22 +907,21 @@ struct MockMethodSizes4 {
};
};
struct
LegacyMockMethodSizes0
{
struct
LegacyMockMethodSizes0
{
MOCK_METHOD0
(
func
,
void
());
MOCK_METHOD0
(
func
,
void
());
};
};
struct
LegacyMockMethodSizes1
{
struct
LegacyMockMethodSizes1
{
MOCK_METHOD1
(
func
,
void
(
int
));
MOCK_METHOD1
(
func
,
void
(
int
));
};
};
struct
LegacyMockMethodSizes2
{
struct
LegacyMockMethodSizes2
{
MOCK_METHOD2
(
func
,
void
(
int
,
int
));
MOCK_METHOD2
(
func
,
void
(
int
,
int
));
};
};
struct
LegacyMockMethodSizes3
{
struct
LegacyMockMethodSizes3
{
MOCK_METHOD3
(
func
,
void
(
int
,
int
,
int
));
MOCK_METHOD3
(
func
,
void
(
int
,
int
,
int
));
};
};
struct
LegacyMockMethodSizes4
{
struct
LegacyMockMethodSizes4
{
MOCK_METHOD4
(
func
,
void
(
int
,
int
,
int
,
int
));
MOCK_METHOD4
(
func
,
void
(
int
,
int
,
int
,
int
));
};
};
TEST
(
MockMethodMockFunctionTest
,
MockMethodSizeOverhead
)
{
TEST
(
MockMethodMockFunctionTest
,
MockMethodSizeOverhead
)
{
EXPECT_EQ
(
sizeof
(
MockMethodSizes0
),
sizeof
(
MockMethodSizes1
));
EXPECT_EQ
(
sizeof
(
MockMethodSizes0
),
sizeof
(
MockMethodSizes1
));
EXPECT_EQ
(
sizeof
(
MockMethodSizes0
),
sizeof
(
MockMethodSizes2
));
EXPECT_EQ
(
sizeof
(
MockMethodSizes0
),
sizeof
(
MockMethodSizes2
));
...
...
Prev
1
2
3
4
5
…
7
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