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
d5988e7d
Unverified
Commit
d5988e7d
authored
Apr 11, 2018
by
Gennadiy Civil
Committed by
GitHub
Apr 11, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1558 from gennadiycivil/master
RE-Doing the merge, this time with gcc on mac in the PR
parents
8fbb4194
5cd213ea
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
127 additions
and
18 deletions
+127
-18
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-internal-utils.h
googlemock/include/gmock/internal/gmock-internal-utils.h
+15
-1
gmock-spec-builders.cc
googlemock/src/gmock-spec-builders.cc
+15
-0
gmock-actions_test.cc
googlemock/test/gmock-actions_test.cc
+16
-0
gmock-generated-actions_test.cc
googlemock/test/gmock-generated-actions_test.cc
+8
-6
gmock_output_test_.cc
googlemock/test/gmock_output_test_.cc
+10
-0
gtest.h
googletest/include/gtest/gtest.h
+13
-0
gtest-internal.h
googletest/include/gtest/internal/gtest-internal.h
+1
-1
No files found.
googlemock/include/gmock/gmock-generated-actions.h
View file @
d5988e7d
This diff is collapsed.
Click to expand it.
googlemock/include/gmock/gmock-generated-actions.h.pump
View file @
d5988e7d
$$
-*-
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 @
d5988e7d
$$
-*-
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 @
d5988e7d
$$
-*-
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 @
d5988e7d
$$
-*-
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/include/gmock/internal/gmock-internal-utils.h
View file @
d5988e7d
...
...
@@ -48,6 +48,14 @@
namespace
testing
{
namespace
internal
{
// Silence MSVC C4100 (unreferenced formal parameter) and
// C4805('==': unsafe mix of type 'const int' and type 'const bool')
#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable:4100)
# pragma warning(disable:4805)
#endif
// Joins a vector of strings as if they are fields of a tuple; returns
// the joined string.
GTEST_API_
std
::
string
JoinAsTuple
(
const
Strings
&
fields
);
...
...
@@ -510,7 +518,7 @@ struct BooleanConstant {};
// Emit an assertion failure due to incorrect DoDefault() usage. Out-of-lined to
// reduce code size.
void
IllegalDoDefault
(
const
char
*
file
,
int
line
);
GTEST_API_
void
IllegalDoDefault
(
const
char
*
file
,
int
line
);
#if GTEST_LANG_CXX11
// Helper types for Apply() below.
...
...
@@ -539,6 +547,12 @@ auto Apply(F&& f, Tuple&& args)
make_int_pack
<
std
::
tuple_size
<
Tuple
>::
value
>
());
}
#endif
#ifdef _MSC_VER
# pragma warning(pop)
#endif
}
// namespace internal
}
// namespace testing
...
...
googlemock/src/gmock-spec-builders.cc
View file @
d5988e7d
...
...
@@ -49,6 +49,15 @@
# include <unistd.h> // NOLINT
#endif
// 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
namespace
testing
{
namespace
internal
{
...
...
@@ -866,3 +875,9 @@ InSequence::~InSequence() {
}
}
// namespace testing
#ifdef _MSC_VER
#if _MSC_VER <= 1900
# pragma warning(pop)
#endif
#endif
googlemock/test/gmock-actions_test.cc
View file @
d5988e7d
...
...
@@ -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>
...
...
@@ -1414,3 +1423,10 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) {
#endif // GTEST_HAS_STD_UNIQUE_PTR_
}
// Unnamed namespace
#ifdef _MSC_VER
#if _MSC_VER == 1900
# pragma warning(pop)
#endif
#endif
googlemock/test/gmock-generated-actions_test.cc
View file @
d5988e7d
...
...
@@ -374,10 +374,10 @@ 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
)
));
tuple
<
std
::
string
,
int
,
int
>
dummy
=
make_tuple
(
std
::
string
(
"hi"
),
2
,
10
);
EXPECT_EQ
(
8
,
a
.
Perform
(
dummy
));
}
// Tests using WithArgs to pass all original arguments in the original order.
...
...
@@ -754,7 +754,8 @@ 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
)));
tuple
<
const
std
::
string
>
dummy
=
make_tuple
(
re
);
EXPECT_EQ
(
"retail"
,
a1
.
Perform
(
dummy
));
}
// Tests that we can use ACTION*() to define actions overloaded on the
...
...
@@ -796,7 +797,8 @@ 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
)));
tuple
<
const
std
::
string
>
dummy
=
make_tuple
(
re
);
EXPECT_EQ
(
"retail->"
,
a2
.
Perform
(
dummy
));
}
ACTION_P4
(
Plus
,
p0
,
p1
,
p2
,
p3
)
{
return
arg0
+
p0
+
p1
+
p2
+
p3
;
}
...
...
@@ -1120,7 +1122,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 @
d5988e7d
...
...
@@ -39,6 +39,12 @@
#include "gtest/gtest.h"
// Silence C4100 (unreferenced formal parameter)
#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable:4100)
#endif
using
testing
::
_
;
using
testing
::
AnyNumber
;
using
testing
::
Ge
;
...
...
@@ -298,3 +304,7 @@ int main(int argc, char **argv) {
TestCatchesLeakedMocksInAdHocTests
();
return
RUN_ALL_TESTS
();
}
#ifdef _MSC_VER
# pragma warning(pop)
#endif
googletest/include/gtest/gtest.h
View file @
d5988e7d
...
...
@@ -82,6 +82,15 @@
namespace
testing
{
// 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:4805)
# pragma warning(disable:4100)
#endif
// Declares the flags.
// This flag temporary enables the disabled tests.
...
...
@@ -2298,6 +2307,10 @@ bool StaticAssertTypeEq() {
// Tries to determine an appropriate directory for the platform.
GTEST_API_
std
::
string
TempDir
();
#ifdef _MSC_VER
# pragma warning(pop)
#endif
}
// namespace testing
// Use this function in main() to run all tests. It returns 0 if all
...
...
googletest/include/gtest/internal/gtest-internal.h
View file @
d5988e7d
...
...
@@ -1155,7 +1155,7 @@ class NativeArray {
#define GTEST_SUCCESS_(message) \
GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)
// Suppress
es MSVC warnings 407
2 (unreachable code) for the code following
// Suppress
MSVC warning 470
2 (unreachable code) for the code following
// statement if it returns or throws (or doesn't return or throw in some
// situations).
#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
...
...
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