Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
e1071eb9
Commit
e1071eb9
authored
Apr 10, 2018
by
Gennadiy Civil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RE-Doing the merge, this time with gcc on mac in the PR so I can catch errors before merging the PR
parent
d0de1180
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
85 additions
and
29 deletions
+85
-29
gmock-generated-actions.h
googlemock/include/gmock/gmock-generated-actions.h
+0
-0
gmock-generated-actions.h.pump
googlemock/include/gmock/gmock-generated-actions.h.pump
+44
-5
gmock-generated-matchers.h.pump
googlemock/include/gmock/gmock-generated-matchers.h.pump
+2
-2
gmock-generated-nice-strict.h.pump
googlemock/include/gmock/gmock-generated-nice-strict.h.pump
+2
-2
gmock-generated-actions.h.pump
...lude/gmock/internal/custom/gmock-generated-actions.h.pump
+1
-1
gmock-spec-builders.cc
googlemock/src/gmock-spec-builders.cc
+10
-7
gmock-actions_test.cc
googlemock/test/gmock-actions_test.cc
+16
-0
gmock-generated-actions_test.cc
googlemock/test/gmock-generated-actions_test.cc
+5
-6
gmock_output_test_.cc
googlemock/test/gmock_output_test_.cc
+1
-3
gtest.h
googletest/include/gtest/gtest.h
+4
-3
No files found.
googlemock/include/gmock/gmock-generated-actions.h
View file @
e1071eb9
This diff is collapsed.
Click to expand it.
googlemock/include/gmock/gmock-generated-actions.h.pump
View file @
e1071eb9
$$
-*-
mode
:
c
++
;
-*-
$$
This
is
a
Pump
source
file
.
Please
use
Pump
to
convert
it
to
$$
This
is
a
Pump
source
file
.
Please
use
Pump
to
convert
it
to
$$
gmock
-
generated
-
actions
.
h
.
$$
$
var
n
=
10
$$
The
maximum
arity
we
support
.
...
...
@@ -49,12 +49,13 @@ namespace testing {
namespace
internal
{
// InvokeHelper<F> knows how to unpack an N-tuple and invoke an N-ary
// function
or method with the unpacked values, where F is a function
// type that takes N arguments.
// function
, method, or callback with the unpacked values, where F is
//
a function
type that takes N arguments.
template
<
typename
Result
,
typename
ArgumentTuple
>
class
InvokeHelper
;
$
var
max_callback_arity
=
5
$
range
i
0.
.
n
$
for
i
[[
$
range
j
1.
.
i
...
...
@@ -76,10 +77,48 @@ class InvokeHelper<R, ::testing::tuple<$as> > {
const
::
testing
::
tuple
<
$
as
>&
$
args
)
{
return
(
obj_ptr
->*
method_ptr
)(
$
gets
);
}
$
if
i
<=
max_callback_arity
[[
template
<
typename
CallbackType
>
static
R
InvokeCallback
(
CallbackType
*
callback
,
const
::
testing
::
tuple
<
$
as
>&
$
args
)
{
return
callback
->
Run
(
$
gets
);
}
]]
$
else
[[
// There is no InvokeCallback() for $i-tuples, as google3 callbacks
// support $max_callback_arity arguments at most.
]]
};
]]
// Implements the Invoke(callback) action.
template
<
typename
CallbackType
>
class
InvokeCallbackAction
{
public
:
// The c'tor takes ownership of the callback.
explicit
InvokeCallbackAction
(
CallbackType
*
callback
)
:
callback_
(
callback
)
{
callback
->
CheckIsRepeatable
();
// Makes sure the callback is permanent.
}
// This type conversion operator template allows Invoke(callback) to
// be used wherever the callback's type is compatible with that of
// the mock function, i.e. if the mock function's arguments can be
// implicitly converted to the callback's arguments and the
// callback's result can be implicitly converted to the mock
// function's result.
template
<
typename
Result
,
typename
ArgumentTuple
>
Result
Perform
(
const
ArgumentTuple
&
args
)
const
{
return
InvokeHelper
<
Result
,
ArgumentTuple
>::
InvokeCallback
(
callback_
.
get
(),
args
);
}
private
:
const
linked_ptr
<
CallbackType
>
callback_
;
};
// An INTERNAL macro for extracting the type of a tuple field. It's
// subject to change without notice - DO NOT USE IN USER CODE!
#define GMOCK_FIELD_(Tuple, N) \
...
...
@@ -486,7 +525,7 @@ _VALUE_PARAMS($for j, [[p$j]]) $for j [[, typename p$j##_type]]
$
for
i
[[
$
range
j
0.
.
i
-
1
#define GMOCK_INTERNAL_INIT_AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]])\
($for j, [[p$j##_type gmock_p$j]])$if i>0 [[ : ]]$for j, [[p$j(
gmock_p$j
)]]
($for j, [[p$j##_type gmock_p$j]])$if i>0 [[ : ]]$for j, [[p$j(
::testing::internal::move(gmock_p$j)
)]]
]]
...
...
@@ -619,7 +658,7 @@ $var class_name = [[name##Action[[$if i==0 [[]] $elif i==1 [[P]]
$
range
j
0.
.
i
-
1
$
var
ctor_param_list
=
[[
$
for
j
,
[[
p
$
j
##
_type
gmock_p
$
j
]]]]
$
var
param_types_and_names
=
[[
$
for
j
,
[[
p
$
j
##
_type
p
$
j
]]]]
$
var
inits
=
[[
$
if
i
==
0
[[]]
$
else
[[
:
$
for
j
,
[[
p
$
j
(
gmock_p
$
j
)]]]]]]
$
var
inits
=
[[
$
if
i
==
0
[[]]
$
else
[[
:
$
for
j
,
[[
p
$
j
(
::
testing
::
internal
::
forward
<
p
$
j
##
_type
>
(
gmock_p
$
j
)
)]]]]]]
$
var
param_field_decls
=
[[
$
for
j
[[
...
...
googlemock/include/gmock/gmock-generated-matchers.h.pump
View file @
e1071eb9
$$
-*-
mode
:
c
++
;
-*-
$$
This
is
a
Pump
source
file
.
Please
use
Pump
to
convert
it
to
$$
gmock
-
generated
-
action
s
.
h
.
$$
This
is
a
Pump
source
file
.
Please
use
Pump
to
convert
$$
it
to
gmock
-
generated
-
matcher
s
.
h
.
$$
$
var
n
=
10
$$
The
maximum
arity
we
support
.
$$
}}
This
line
fixes
auto
-
indentation
of
the
following
code
in
Emacs
.
...
...
googlemock/include/gmock/gmock-generated-nice-strict.h.pump
View file @
e1071eb9
$$
-*-
mode
:
c
++
;
-*-
$$
This
is
a
Pump
source
file
.
Please
use
Pump
to
convert
it
to
$$
gmock
-
generated
-
nice
-
strict
.
h
.
$$
This
is
a
Pump
source
file
.
Please
use
Pump
to
convert
$$
it
to
gmock
-
generated
-
nice
-
strict
.
h
.
$$
$
var
n
=
10
$$
The
maximum
arity
we
support
.
// Copyright 2008, Google Inc.
...
...
googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump
View file @
e1071eb9
$$
-*-
mode
:
c
++
;
-*-
$$
This
is
a
Pump
source
file
(
http
:
//go/pump).
Please use Pump to convert
$$
This
is
a
Pump
source
file
.
Please
use
Pump
to
convert
$$
it
to
callback
-
actions
.
h
.
$$
$
var
max_callback_arity
=
5
...
...
googlemock/src/gmock-spec-builders.cc
View file @
e1071eb9
...
...
@@ -50,12 +50,13 @@
#endif
// Silence C4800 (C4800: 'int *const ': forcing value
// to bool 'true' or 'false') for MSVC 14
#ifdef _MSC_VER && _MSC_VER == 1900
# pragma warning(push)
# pragma warning(disable:4800)
// to bool 'true' or 'false') for MSVC 14,15
#ifdef _MSC_VER
#if _MSC_VER <= 1900
# pragma warning(push)
# pragma warning(disable:4800)
#endif
#endif
namespace
testing
{
namespace
internal
{
...
...
@@ -875,6 +876,8 @@ InSequence::~InSequence() {
}
// namespace testing
#ifdef _MSC_VER && _MSC_VER == 1900
# pragma warning(pop)
#ifdef _MSC_VER
#if _MSC_VER <= 1900
# pragma warning(pop)
#endif
#endif
googlemock/test/gmock-actions_test.cc
View file @
e1071eb9
...
...
@@ -33,6 +33,15 @@
//
// This file tests the built-in actions.
// Silence C4800 (C4800: 'int *const ': forcing value
// to bool 'true' or 'false') for MSVC 14,15
#ifdef _MSC_VER
#if _MSC_VER <= 1900
# pragma warning(push)
# pragma warning(disable:4800)
#endif
#endif
#include "gmock/gmock-actions.h"
#include <algorithm>
#include <iterator>
...
...
@@ -1556,3 +1565,10 @@ TEST(MoveOnlyArgumentsTest, ReturningActions) {
#endif // GTEST_LANG_CXX11
}
// Unnamed namespace
#ifdef _MSC_VER
#if _MSC_VER == 1900
# pragma warning(pop)
#endif
#endif
googlemock/test/gmock-generated-actions_test.cc
View file @
e1071eb9
...
...
@@ -374,10 +374,9 @@ class SubstractAction : public ActionInterface<int(int, int)> { // NOLINT
};
TEST
(
WithArgsTest
,
NonInvokeAction
)
{
Action
<
int
(
const
string
&
,
int
,
int
)
>
a
=
// NOLINT
Action
<
int
(
const
st
d
::
st
ring
&
,
int
,
int
)
>
a
=
// NOLINT
WithArgs
<
2
,
1
>
(
MakeAction
(
new
SubstractAction
));
string
s
(
"hello"
);
EXPECT_EQ
(
8
,
a
.
Perform
(
tuple
<
const
string
&
,
int
,
int
>
(
s
,
2
,
10
)));
EXPECT_EQ
(
8
,
a
.
Perform
(
make_tuple
(
std
::
string
(
"hi"
),
2
,
10
)));
}
// Tests using WithArgs to pass all original arguments in the original order.
...
...
@@ -754,7 +753,7 @@ TEST(ActionPMacroTest, CanReferenceArgumentAndParameterTypes) {
TEST
(
ActionPMacroTest
,
WorksInCompatibleMockFunction
)
{
Action
<
std
::
string
(
const
std
::
string
&
s
)
>
a1
=
Plus
(
"tail"
);
const
std
::
string
re
=
"re"
;
EXPECT_EQ
(
"retail"
,
a1
.
Perform
(
tuple
<
const
std
::
string
&>
(
re
)));
EXPECT_EQ
(
"retail"
,
a1
.
Perform
(
make_tuple
(
re
)));
}
// Tests that we can use ACTION*() to define actions overloaded on the
...
...
@@ -796,7 +795,7 @@ TEST(ActionPnMacroTest, WorksFor3Parameters) {
Action
<
std
::
string
(
const
std
::
string
&
s
)
>
a2
=
Plus
(
"tail"
,
"-"
,
">"
);
const
std
::
string
re
=
"re"
;
EXPECT_EQ
(
"retail->"
,
a2
.
Perform
(
tuple
<
const
std
::
string
&>
(
re
)));
EXPECT_EQ
(
"retail->"
,
a2
.
Perform
(
make_tuple
(
re
)));
}
ACTION_P4
(
Plus
,
p0
,
p1
,
p2
,
p3
)
{
return
arg0
+
p0
+
p1
+
p2
+
p3
;
}
...
...
@@ -1120,7 +1119,7 @@ TEST(ActionTemplateTest, WorksForIntegralTemplateParams) {
EXPECT_FALSE
(
b
);
// Verifies that resetter is deleted.
}
// Tests that ACTION_TEMPLATE
works for a template with
template parameters.
// Tests that ACTION_TEMPLATE
S works for template
template parameters.
ACTION_TEMPLATE
(
ReturnSmartPointer
,
HAS_1_TEMPLATE_PARAMS
(
template
<
typename
Pointee
>
class
,
Pointer
),
...
...
googlemock/test/gmock_output_test_.cc
View file @
e1071eb9
...
...
@@ -39,14 +39,12 @@
#include "gtest/gtest.h"
// Silence C4100 (unreferenced formal parameter) for MSVC
// Silence C4100 (unreferenced formal parameter)
#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable:4100)
#endif
using
testing
::
_
;
using
testing
::
AnyNumber
;
using
testing
::
Ge
;
...
...
googletest/include/gtest/gtest.h
View file @
e1071eb9
...
...
@@ -82,11 +82,12 @@
namespace
testing
{
// Silence C4100 (unreferenced formal parameter) for MSVC
// Silence C4100 (unreferenced formal parameter) and 4805
// unsafe mix of type 'const int' and type 'const bool'
#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable:4100)
# pragma warning(disable:4805)
# pragma warning(disable:4100)
#endif
...
...
@@ -2307,7 +2308,7 @@ bool StaticAssertTypeEq() {
GTEST_API_
std
::
string
TempDir
();
#ifdef _MSC_VER
# pragma warning(pop)
#
pragma warning(pop)
#endif
}
// namespace testing
...
...
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