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
1246e580
Unverified
Commit
1246e580
authored
Aug 15, 2018
by
Gennadiy Civil
Committed by
GitHub
Aug 15, 2018
Browse files
Merge branch 'master' into cleanup-cmake
parents
4b6a7a49
2172c08c
Changes
217
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
540 additions
and
375 deletions
+540
-375
googlemock/include/gmock/gmock-generated-nice-strict.h
googlemock/include/gmock/gmock-generated-nice-strict.h
+177
-145
googlemock/include/gmock/gmock-generated-nice-strict.h.pump
googlemock/include/gmock/gmock-generated-nice-strict.h.pump
+36
-18
googlemock/include/gmock/gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+144
-143
googlemock/include/gmock/gmock-more-actions.h
googlemock/include/gmock/gmock-more-actions.h
+3
-2
googlemock/include/gmock/gmock-more-matchers.h
googlemock/include/gmock/gmock-more-matchers.h
+11
-2
googlemock/include/gmock/gmock-spec-builders.h
googlemock/include/gmock/gmock-spec-builders.h
+86
-24
googlemock/include/gmock/gmock.h
googlemock/include/gmock/gmock.h
+3
-2
googlemock/include/gmock/internal/custom/README.md
googlemock/include/gmock/internal/custom/README.md
+16
-0
googlemock/include/gmock/internal/custom/gmock-generated-actions.h
...k/include/gmock/internal/custom/gmock-generated-actions.h
+2
-0
googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump
...lude/gmock/internal/custom/gmock-generated-actions.h.pump
+3
-1
googlemock/include/gmock/internal/custom/gmock-matchers.h
googlemock/include/gmock/internal/custom/gmock-matchers.h
+3
-5
googlemock/include/gmock/internal/custom/gmock-port.h
googlemock/include/gmock/internal/custom/gmock-port.h
+3
-10
googlemock/include/gmock/internal/gmock-generated-internal-utils.h
...k/include/gmock/internal/gmock-generated-internal-utils.h
+3
-2
googlemock/include/gmock/internal/gmock-generated-internal-utils.h.pump
...lude/gmock/internal/gmock-generated-internal-utils.h.pump
+3
-2
googlemock/include/gmock/internal/gmock-internal-utils.h
googlemock/include/gmock/internal/gmock-internal-utils.h
+34
-4
googlemock/include/gmock/internal/gmock-port.h
googlemock/include/gmock/internal/gmock-port.h
+3
-2
googlemock/scripts/generator/README
googlemock/scripts/generator/README
+4
-5
googlemock/scripts/upload.py
googlemock/scripts/upload.py
+4
-4
googlemock/src/gmock-all.cc
googlemock/src/gmock-all.cc
+1
-2
googlemock/src/gmock-cardinalities.cc
googlemock/src/gmock-cardinalities.cc
+1
-2
No files found.
googlemock/include/gmock/gmock-generated-nice-strict.h
View file @
1246e580
...
...
@@ -30,8 +30,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Implements class templates NiceMock, NaggyMock, and StrictMock.
//
...
...
@@ -63,6 +62,8 @@
// In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT
// supported.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
...
...
@@ -71,25 +72,13 @@
namespace
testing
{
namespace
internal
{
// NiceMockBase serves as a mix-in to establish the "uninteresting call"
// behavior for NiceMock on construction. It accomplishes this via CRTP to get
// access to the derived MockClass.
template
<
class
MockClass
>
class
NiceMockBase
{
protected:
NiceMockBase
();
~
NiceMockBase
();
};
}
// namespace internal
template
<
class
MockClass
>
class
NiceMock
:
public
MockClass
,
public
internal
::
NiceMockBase
<
MockClass
>
{
class
NiceMock
:
public
MockClass
{
public:
NiceMock
()
:
MockClass
()
{}
NiceMock
()
:
MockClass
()
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
#if GTEST_LANG_CXX11
// Ideally, we would inherit base class's constructors through a using
...
...
@@ -100,103 +89,114 @@ class NiceMock : public MockClass, public internal::NiceMockBase<MockClass> {
// Single argument constructor is special-cased so that it can be
// made explicit.
template
<
typename
A
>
explicit
NiceMock
(
A
&&
arg
)
:
MockClass
(
std
::
forward
<
A
>
(
arg
))
{}
explicit
NiceMock
(
A
&&
arg
)
:
MockClass
(
std
::
forward
<
A
>
(
arg
))
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
...
An
>
NiceMock
(
A1
&&
arg1
,
A2
&&
arg2
,
An
&&
...
args
)
:
MockClass
(
std
::
forward
<
A1
>
(
arg1
),
std
::
forward
<
A2
>
(
arg2
),
std
::
forward
<
An
>
(
args
)...)
{}
std
::
forward
<
An
>
(
args
)...)
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
#else
// C++98 doesn't have variadic templates, so we have to define one
// for each arity.
template
<
typename
A1
>
explicit
NiceMock
(
const
A1
&
a1
)
:
MockClass
(
a1
)
{}
explicit
NiceMock
(
const
A1
&
a1
)
:
MockClass
(
a1
)
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
>
NiceMock
(
const
A1
&
a1
,
const
A2
&
a2
)
:
MockClass
(
a1
,
a2
)
{}
NiceMock
(
const
A1
&
a1
,
const
A2
&
a2
)
:
MockClass
(
a1
,
a2
)
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
>
NiceMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
)
:
MockClass
(
a1
,
a2
,
a3
)
{}
NiceMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
)
:
MockClass
(
a1
,
a2
,
a3
)
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
>
NiceMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
)
{}
const
A4
&
a4
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
)
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
>
NiceMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
)
{}
const
A5
&
a5
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
)
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
>
NiceMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
,
const
A6
&
a6
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
)
{}
const
A5
&
a5
,
const
A6
&
a6
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
)
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
>
NiceMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
,
const
A6
&
a6
,
const
A7
&
a7
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
)
{}
a6
,
a7
)
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
>
NiceMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
,
const
A6
&
a6
,
const
A7
&
a7
,
const
A8
&
a8
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
)
{}
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
)
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
,
typename
A9
>
NiceMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
,
const
A6
&
a6
,
const
A7
&
a7
,
const
A8
&
a8
,
const
A9
&
a9
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
)
{}
const
A9
&
a9
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
)
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
,
typename
A9
,
typename
A10
>
NiceMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
,
const
A6
&
a6
,
const
A7
&
a7
,
const
A8
&
a8
,
const
A9
&
a9
,
const
A10
&
a10
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
,
a10
)
{}
const
A10
&
a10
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
,
a10
)
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
#endif // GTEST_LANG_CXX11
~
NiceMock
()
{
::
testing
::
Mock
::
UnregisterCallReaction
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
NiceMock
);
};
namespace
internal
{
template
<
typename
MockClass
>
NiceMockBase
<
MockClass
>::
NiceMockBase
()
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
static_cast
<
NiceMock
<
MockClass
>
*>
(
this
)));
}
template
<
typename
MockClass
>
NiceMockBase
<
MockClass
>::~
NiceMockBase
()
{
::
testing
::
Mock
::
UnregisterCallReaction
(
internal
::
ImplicitCast_
<
MockClass
*>
(
static_cast
<
NiceMock
<
MockClass
>*>
(
this
)));
}
}
// namespace internal
namespace
internal
{
// NaggyMockBase serves as a mix-in to establish the "uninteresting call"
// behavior for NaggyMock on construction. It accomplishes this via CRTP to get
// access to the derived MockClass.
template
<
class
MockClass
>
class
NaggyMockBase
{
protected:
NaggyMockBase
();
~
NaggyMockBase
();
};
}
// namespace internal
template
<
class
MockClass
>
class
NaggyMock
:
public
MockClass
,
public
internal
::
NaggyMockBase
<
MockClass
>
{
class
NaggyMock
:
public
MockClass
{
public:
NaggyMock
()
:
MockClass
()
{}
NaggyMock
()
:
MockClass
()
{
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
#if GTEST_LANG_CXX11
// Ideally, we would inherit base class's constructors through a using
...
...
@@ -207,104 +207,114 @@ class NaggyMock : public MockClass, public internal::NaggyMockBase<MockClass> {
// Single argument constructor is special-cased so that it can be
// made explicit.
template
<
typename
A
>
explicit
NaggyMock
(
A
&&
arg
)
:
MockClass
(
std
::
forward
<
A
>
(
arg
))
{}
explicit
NaggyMock
(
A
&&
arg
)
:
MockClass
(
std
::
forward
<
A
>
(
arg
))
{
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
...
An
>
NaggyMock
(
A1
&&
arg1
,
A2
&&
arg2
,
An
&&
...
args
)
:
MockClass
(
std
::
forward
<
A1
>
(
arg1
),
std
::
forward
<
A2
>
(
arg2
),
std
::
forward
<
An
>
(
args
)...)
{}
std
::
forward
<
An
>
(
args
)...)
{
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
#else
// C++98 doesn't have variadic templates, so we have to define one
// for each arity.
template
<
typename
A1
>
explicit
NaggyMock
(
const
A1
&
a1
)
:
MockClass
(
a1
)
{}
explicit
NaggyMock
(
const
A1
&
a1
)
:
MockClass
(
a1
)
{
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
>
NaggyMock
(
const
A1
&
a1
,
const
A2
&
a2
)
:
MockClass
(
a1
,
a2
)
{}
NaggyMock
(
const
A1
&
a1
,
const
A2
&
a2
)
:
MockClass
(
a1
,
a2
)
{
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
>
NaggyMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
)
:
MockClass
(
a1
,
a2
,
a3
)
{}
NaggyMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
)
:
MockClass
(
a1
,
a2
,
a3
)
{
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
>
NaggyMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
)
{}
const
A4
&
a4
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
)
{
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
>
NaggyMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
)
{}
const
A5
&
a5
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
)
{
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
>
NaggyMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
,
const
A6
&
a6
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
)
{}
const
A5
&
a5
,
const
A6
&
a6
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
)
{
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
>
NaggyMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
,
const
A6
&
a6
,
const
A7
&
a7
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
)
{}
a6
,
a7
)
{
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
>
NaggyMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
,
const
A6
&
a6
,
const
A7
&
a7
,
const
A8
&
a8
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
)
{}
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
)
{
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
,
typename
A9
>
NaggyMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
,
const
A6
&
a6
,
const
A7
&
a7
,
const
A8
&
a8
,
const
A9
&
a9
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
)
{}
const
A9
&
a9
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
)
{
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
,
typename
A9
,
typename
A10
>
NaggyMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
,
const
A6
&
a6
,
const
A7
&
a7
,
const
A8
&
a8
,
const
A9
&
a9
,
const
A10
&
a10
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
,
a10
)
{}
const
A10
&
a10
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
,
a10
)
{
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
#endif // GTEST_LANG_CXX11
~
NaggyMock
()
{
::
testing
::
Mock
::
UnregisterCallReaction
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
NaggyMock
);
};
namespace
internal
{
template
<
typename
MockClass
>
NaggyMockBase
<
MockClass
>::
NaggyMockBase
()
{
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
static_cast
<
NaggyMock
<
MockClass
>
*>
(
this
)));
}
template
<
typename
MockClass
>
NaggyMockBase
<
MockClass
>::~
NaggyMockBase
()
{
::
testing
::
Mock
::
UnregisterCallReaction
(
internal
::
ImplicitCast_
<
MockClass
*>
(
static_cast
<
NaggyMock
<
MockClass
>*>
(
this
)));
}
}
// namespace internal
namespace
internal
{
// StrictMockBase serves as a mix-in to establish the "uninteresting call"
// behavior for StrictMock on construction. It accomplishes this via CRTP to get
// access to the derived MockClass.
template
<
class
MockClass
>
class
StrictMockBase
{
protected:
StrictMockBase
();
~
StrictMockBase
();
};
}
// namespace internal
template
<
class
MockClass
>
class
StrictMock
:
public
MockClass
,
public
internal
::
StrictMockBase
<
MockClass
>
{
class
StrictMock
:
public
MockClass
{
public:
StrictMock
()
:
MockClass
()
{}
StrictMock
()
:
MockClass
()
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
#if GTEST_LANG_CXX11
// Ideally, we would inherit base class's constructors through a using
...
...
@@ -315,85 +325,107 @@ class StrictMock : public MockClass,
// Single argument constructor is special-cased so that it can be
// made explicit.
template
<
typename
A
>
explicit
StrictMock
(
A
&&
arg
)
:
MockClass
(
std
::
forward
<
A
>
(
arg
))
{}
explicit
StrictMock
(
A
&&
arg
)
:
MockClass
(
std
::
forward
<
A
>
(
arg
))
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
...
An
>
StrictMock
(
A1
&&
arg1
,
A2
&&
arg2
,
An
&&
...
args
)
:
MockClass
(
std
::
forward
<
A1
>
(
arg1
),
std
::
forward
<
A2
>
(
arg2
),
std
::
forward
<
An
>
(
args
)...)
{}
std
::
forward
<
An
>
(
args
)...)
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
#else
// C++98 doesn't have variadic templates, so we have to define one
// for each arity.
template
<
typename
A1
>
explicit
StrictMock
(
const
A1
&
a1
)
:
MockClass
(
a1
)
{}
explicit
StrictMock
(
const
A1
&
a1
)
:
MockClass
(
a1
)
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
>
StrictMock
(
const
A1
&
a1
,
const
A2
&
a2
)
:
MockClass
(
a1
,
a2
)
{}
StrictMock
(
const
A1
&
a1
,
const
A2
&
a2
)
:
MockClass
(
a1
,
a2
)
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
>
StrictMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
)
:
MockClass
(
a1
,
a2
,
a3
)
{}
StrictMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
)
:
MockClass
(
a1
,
a2
,
a3
)
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
>
StrictMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
)
{}
const
A4
&
a4
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
)
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
>
StrictMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
)
{}
const
A5
&
a5
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
)
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
>
StrictMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
,
const
A6
&
a6
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
)
{}
const
A5
&
a5
,
const
A6
&
a6
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
)
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
>
StrictMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
,
const
A6
&
a6
,
const
A7
&
a7
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
)
{}
a6
,
a7
)
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
>
StrictMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
,
const
A6
&
a6
,
const
A7
&
a7
,
const
A8
&
a8
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
)
{}
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
)
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
,
typename
A9
>
StrictMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
,
const
A6
&
a6
,
const
A7
&
a7
,
const
A8
&
a8
,
const
A9
&
a9
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
)
{}
const
A9
&
a9
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
)
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
,
typename
A9
,
typename
A10
>
StrictMock
(
const
A1
&
a1
,
const
A2
&
a2
,
const
A3
&
a3
,
const
A4
&
a4
,
const
A5
&
a5
,
const
A6
&
a6
,
const
A7
&
a7
,
const
A8
&
a8
,
const
A9
&
a9
,
const
A10
&
a10
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
,
a10
)
{}
const
A10
&
a10
)
:
MockClass
(
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
,
a10
)
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
#endif // GTEST_LANG_CXX11
~
StrictMock
()
{
::
testing
::
Mock
::
UnregisterCallReaction
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
StrictMock
);
};
namespace
internal
{
template
<
typename
MockClass
>
StrictMockBase
<
MockClass
>::
StrictMockBase
()
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
static_cast
<
StrictMock
<
MockClass
>
*>
(
this
)));
}
template
<
typename
MockClass
>
StrictMockBase
<
MockClass
>::~
StrictMockBase
()
{
::
testing
::
Mock
::
UnregisterCallReaction
(
internal
::
ImplicitCast_
<
MockClass
*>
(
static_cast
<
StrictMock
<
MockClass
>*>
(
this
)));
}
}
// namespace internal
// The following specializations catch some (relatively more common)
// user errors of nesting nice and strict mocks. They do NOT catch
// all possible errors.
...
...
googlemock/include/gmock/gmock-generated-nice-strict.h.pump
View file @
1246e580
$$
-*-
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.
...
...
@@ -31,8 +31,7 @@ $var n = 10 $$ The maximum arity we support.
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Implements class templates NiceMock, NaggyMock, and StrictMock.
//
...
...
@@ -52,10 +51,9 @@ $var n = 10 $$ The maximum arity we support.
// NiceMock<MockFoo>.
//
// NiceMock, NaggyMock, and StrictMock "inherit" the constructors of
// their respective base class, with up-to $n arguments. Therefore
// you can write NiceMock<MockFoo>(5, "a") to construct a nice mock
// where MockFoo has a constructor that accepts (int, const char*),
// for example.
// their respective base class. Therefore you can write
// NiceMock<MockFoo>(5, "a") to construct a nice mock where MockFoo
// has a constructor that accepts (int, const char*), for example.
//
// A known limitation is that NiceMock<MockFoo>, NaggyMock<MockFoo>,
// and StrictMock<MockFoo> only works for mock methods defined using
...
...
@@ -64,10 +62,8 @@ $var n = 10 $$ The maximum arity we support.
// or "strict" modifier may not affect it, depending on the compiler.
// In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT
// supported.
//
// Another known limitation is that the constructors of the base mock
// cannot have arguments passed by non-const reference, which are
// banned by the Google C++ style guide anyway.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
...
...
@@ -91,15 +87,35 @@ $var method=[[$if kind==0 [[AllowUninterestingCalls]]
template
<
class
MockClass
>
class
$
clazz
:
public
MockClass
{
public:
// We don't factor out the constructor body to a common method, as
// we have to avoid a possible clash with members of MockClass.
$
clazz
()
{
$
clazz
()
:
MockClass
()
{
::
testing
::
Mock
::
$
method
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
// C++ doesn't (yet) allow inheritance of constructors, so we have
// to define it for each arity.
#if GTEST_LANG_CXX11
// Ideally, we would inherit base class's constructors through a using
// declaration, which would preserve their visibility. However, many existing
// tests rely on the fact that current implementation reexports protected
// constructors as public. These tests would need to be cleaned up first.
// Single argument constructor is special-cased so that it can be
// made explicit.
template
<
typename
A
>
explicit
$
clazz
(
A
&&
arg
)
:
MockClass
(
std
::
forward
<
A
>
(
arg
))
{
::
testing
::
Mock
::
$
method
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
A2
,
typename
...
An
>
$
clazz
(
A1
&&
arg1
,
A2
&&
arg2
,
An
&&
...
args
)
:
MockClass
(
std
::
forward
<
A1
>
(
arg1
),
std
::
forward
<
A2
>
(
arg2
),
std
::
forward
<
An
>
(
args
)...)
{
::
testing
::
Mock
::
$
method
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
#else
// C++98 doesn't have variadic templates, so we have to define one
// for each arity.
template
<
typename
A1
>
explicit
$
clazz
(
const
A1
&
a1
)
:
MockClass
(
a1
)
{
::
testing
::
Mock
::
$
method
(
...
...
@@ -117,7 +133,9 @@ $range j 1..i
]]
virtual
~
$
clazz
()
{
#endif // GTEST_LANG_CXX11
~
$
clazz
()
{
::
testing
::
Mock
::
UnregisterCallReaction
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
...
...
googlemock/include/gmock/gmock-matchers.h
View file @
1246e580
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes.
//
...
...
@@ -35,6 +34,8 @@
// matchers can be defined by the user implementing the
// MatcherInterface<T> interface if necessary.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
...
...
@@ -72,7 +73,7 @@ namespace testing {
// MatchResultListener is an abstract class. Its << operator can be
// used by a matcher to explain why a value matches or doesn't match.
//
//
TODO(wan@google.com)
: add method
//
FIXME
: add method
// bool InterestedInWhy(bool result) const;
// to indicate whether the listener is interested in why the match
// result is 'result'.
...
...
@@ -921,7 +922,7 @@ class TuplePrefix {
GTEST_REFERENCE_TO_CONST_
(
Value
)
value
=
get
<
N
-
1
>
(
values
);
StringMatchResultListener
listener
;
if
(
!
matcher
.
MatchAndExplain
(
value
,
&
listener
))
{
//
TODO(wan)
: include in the message the name of the parameter
//
FIXME
: include in the message the name of the parameter
// as used in MOCK_METHOD*() when possible.
*
os
<<
" Expected arg #"
<<
N
-
1
<<
": "
;
get
<
N
-
1
>
(
matchers
).
DescribeTo
(
os
);
...
...
@@ -1718,25 +1719,27 @@ class NotMatcher {
// that will prevent different instantiations of BothOfMatcher from
// sharing the same BothOfMatcherImpl<T> class.
template
<
typename
T
>
class
Both
OfMatcherImpl
class
All
OfMatcherImpl
:
public
MatcherInterface
<
GTEST_REFERENCE_TO_CONST_
(
T
)
>
{
public:
Both
OfMatcherImpl
(
const
Matcher
<
T
>&
matcher1
,
const
Matcher
<
T
>
&
matcher
2
)
:
matcher
1
_
(
matcher1
),
matcher2_
(
matcher
2
)
{}
explicit
All
OfMatcherImpl
(
std
::
vector
<
Matcher
<
T
>
>
matcher
s
)
:
matcher
s
_
(
internal
::
move
(
matcher
s
)
)
{}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"("
;
matcher1_
.
DescribeTo
(
os
);
*
os
<<
") and ("
;
matcher2_
.
DescribeTo
(
os
);
for
(
size_t
i
=
0
;
i
<
matchers_
.
size
();
++
i
)
{
if
(
i
!=
0
)
*
os
<<
") and ("
;
matchers_
[
i
].
DescribeTo
(
os
);
}
*
os
<<
")"
;
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"("
;
matcher1_
.
DescribeNegationTo
(
os
);
*
os
<<
") or ("
;
matcher2_
.
DescribeNegationTo
(
os
);
for
(
size_t
i
=
0
;
i
<
matchers_
.
size
();
++
i
)
{
if
(
i
!=
0
)
*
os
<<
") or ("
;
matchers_
[
i
].
DescribeNegationTo
(
os
);
}
*
os
<<
")"
;
}
...
...
@@ -1744,93 +1747,38 @@ class BothOfMatcherImpl
MatchResultListener
*
listener
)
const
{
// If either matcher1_ or matcher2_ doesn't match x, we only need
// to explain why one of them fails.
StringMatchResultListener
listener1
;
if
(
!
matcher1_
.
MatchAndExplain
(
x
,
&
listener1
))
{
*
listener
<<
listener1
.
str
();
return
false
;
}
std
::
string
all_match_result
;
StringMatchResultListener
listener2
;
if
(
!
matcher2_
.
MatchAndExplain
(
x
,
&
listener2
))
{
*
listener
<<
listener2
.
str
();
return
false
;
for
(
size_t
i
=
0
;
i
<
matchers_
.
size
();
++
i
)
{
StringMatchResultListener
slistener
;
if
(
matchers_
[
i
].
MatchAndExplain
(
x
,
&
slistener
))
{
if
(
all_match_result
.
empty
())
{
all_match_result
=
slistener
.
str
();
}
else
{
std
::
string
result
=
slistener
.
str
();
if
(
!
result
.
empty
())
{
all_match_result
+=
", and "
;
all_match_result
+=
result
;
}
}
}
else
{
*
listener
<<
slistener
.
str
();
return
false
;
}
}
// Otherwise we need to explain why *both* of them match.
const
std
::
string
s1
=
listener1
.
str
();
const
std
::
string
s2
=
listener2
.
str
();
if
(
s1
==
""
)
{
*
listener
<<
s2
;
}
else
{
*
listener
<<
s1
;
if
(
s2
!=
""
)
{
*
listener
<<
", and "
<<
s2
;
}
}
*
listener
<<
all_match_result
;
return
true
;
}
private:
const
Matcher
<
T
>
matcher1_
;
const
Matcher
<
T
>
matcher2_
;
const
std
::
vector
<
Matcher
<
T
>
>
matchers_
;
GTEST_DISALLOW_ASSIGN_
(
Both
OfMatcherImpl
);
GTEST_DISALLOW_ASSIGN_
(
All
OfMatcherImpl
);
};
#if GTEST_LANG_CXX11
// MatcherList provides mechanisms for storing a variable number of matchers in
// a list structure (ListType) and creating a combining matcher from such a
// list.
// The template is defined recursively using the following template parameters:
// * kSize is the length of the MatcherList.
// * Head is the type of the first matcher of the list.
// * Tail denotes the types of the remaining matchers of the list.
template
<
int
kSize
,
typename
Head
,
typename
...
Tail
>
struct
MatcherList
{
typedef
MatcherList
<
kSize
-
1
,
Tail
...
>
MatcherListTail
;
typedef
::
std
::
pair
<
Head
,
typename
MatcherListTail
::
ListType
>
ListType
;
// BuildList stores variadic type values in a nested pair structure.
// Example:
// MatcherList<3, int, string, float>::BuildList(5, "foo", 2.0) will return
// the corresponding result of type pair<int, pair<string, float>>.
static
ListType
BuildList
(
const
Head
&
matcher
,
const
Tail
&
...
tail
)
{
return
ListType
(
matcher
,
MatcherListTail
::
BuildList
(
tail
...));
}
// CreateMatcher<T> creates a Matcher<T> from a given list of matchers (built
// by BuildList()). CombiningMatcher<T> is used to combine the matchers of the
// list. CombiningMatcher<T> must implement MatcherInterface<T> and have a
// constructor taking two Matcher<T>s as input.
template
<
typename
T
,
template
<
typename
/* T */
>
class
CombiningMatcher
>
static
Matcher
<
T
>
CreateMatcher
(
const
ListType
&
matchers
)
{
return
Matcher
<
T
>
(
new
CombiningMatcher
<
T
>
(
SafeMatcherCast
<
T
>
(
matchers
.
first
),
MatcherListTail
::
template
CreateMatcher
<
T
,
CombiningMatcher
>
(
matchers
.
second
)));
}
};
// The following defines the base case for the recursive definition of
// MatcherList.
template
<
typename
Matcher1
,
typename
Matcher2
>
struct
MatcherList
<
2
,
Matcher1
,
Matcher2
>
{
typedef
::
std
::
pair
<
Matcher1
,
Matcher2
>
ListType
;
static
ListType
BuildList
(
const
Matcher1
&
matcher1
,
const
Matcher2
&
matcher2
)
{
return
::
std
::
pair
<
Matcher1
,
Matcher2
>
(
matcher1
,
matcher2
);
}
template
<
typename
T
,
template
<
typename
/* T */
>
class
CombiningMatcher
>
static
Matcher
<
T
>
CreateMatcher
(
const
ListType
&
matchers
)
{
return
Matcher
<
T
>
(
new
CombiningMatcher
<
T
>
(
SafeMatcherCast
<
T
>
(
matchers
.
first
),
SafeMatcherCast
<
T
>
(
matchers
.
second
)));
}
};
// VariadicMatcher is used for the variadic implementation of
// AllOf(m_1, m_2, ...) and AnyOf(m_1, m_2, ...).
// CombiningMatcher<T> is used to recursively combine the provided matchers
...
...
@@ -1839,27 +1787,40 @@ template <template <typename T> class CombiningMatcher, typename... Args>
class
VariadicMatcher
{
public:
VariadicMatcher
(
const
Args
&
...
matchers
)
// NOLINT
:
matchers_
(
MatcherListType
::
BuildList
(
matchers
...))
{}
:
matchers_
(
matchers
...)
{
static_assert
(
sizeof
...(
Args
)
>
0
,
"Must have at least one matcher."
);
}
// This template type conversion operator allows an
// VariadicMatcher<Matcher1, Matcher2...> object to match any type that
// all of the provided matchers (Matcher1, Matcher2, ...) can match.
template
<
typename
T
>
operator
Matcher
<
T
>
()
const
{
return
MatcherListType
::
template
CreateMatcher
<
T
,
CombiningMatcher
>
(
matchers_
);
std
::
vector
<
Matcher
<
T
>
>
values
;
CreateVariadicMatcher
<
T
>
(
&
values
,
std
::
integral_constant
<
size_t
,
0
>
());
return
Matcher
<
T
>
(
new
CombiningMatcher
<
T
>
(
internal
::
move
(
values
)));
}
private:
typedef
MatcherList
<
sizeof
...(
Args
),
Args
...
>
MatcherListType
;
template
<
typename
T
,
size_t
I
>
void
CreateVariadicMatcher
(
std
::
vector
<
Matcher
<
T
>
>*
values
,
std
::
integral_constant
<
size_t
,
I
>
)
const
{
values
->
push_back
(
SafeMatcherCast
<
T
>
(
std
::
get
<
I
>
(
matchers_
)));
CreateVariadicMatcher
<
T
>
(
values
,
std
::
integral_constant
<
size_t
,
I
+
1
>
());
}
template
<
typename
T
>
void
CreateVariadicMatcher
(
std
::
vector
<
Matcher
<
T
>
>*
,
std
::
integral_constant
<
size_t
,
sizeof
...(
Args
)
>
)
const
{}
const
typename
MatcherListType
::
ListType
matchers_
;
tuple
<
Args
...
>
matchers_
;
GTEST_DISALLOW_ASSIGN_
(
VariadicMatcher
);
};
template
<
typename
...
Args
>
using
AllOfMatcher
=
VariadicMatcher
<
Both
OfMatcherImpl
,
Args
...
>
;
using
AllOfMatcher
=
VariadicMatcher
<
All
OfMatcherImpl
,
Args
...
>
;
#endif // GTEST_LANG_CXX11
...
...
@@ -1876,8 +1837,10 @@ class BothOfMatcher {
// both Matcher1 and Matcher2 can match.
template
<
typename
T
>
operator
Matcher
<
T
>
()
const
{
return
Matcher
<
T
>
(
new
BothOfMatcherImpl
<
T
>
(
SafeMatcherCast
<
T
>
(
matcher1_
),
SafeMatcherCast
<
T
>
(
matcher2_
)));
std
::
vector
<
Matcher
<
T
>
>
values
;
values
.
push_back
(
SafeMatcherCast
<
T
>
(
matcher1_
));
values
.
push_back
(
SafeMatcherCast
<
T
>
(
matcher2_
));
return
Matcher
<
T
>
(
new
AllOfMatcherImpl
<
T
>
(
internal
::
move
(
values
)));
}
private:
...
...
@@ -1892,70 +1855,69 @@ class BothOfMatcher {
// that will prevent different instantiations of AnyOfMatcher from
// sharing the same EitherOfMatcherImpl<T> class.
template
<
typename
T
>
class
Either
OfMatcherImpl
class
Any
OfMatcherImpl
:
public
MatcherInterface
<
GTEST_REFERENCE_TO_CONST_
(
T
)
>
{
public:
Either
OfMatcherImpl
(
const
Matcher
<
T
>&
matcher1
,
const
Matcher
<
T
>
&
matcher
2
)
:
matcher
1
_
(
matcher1
),
matcher2_
(
matcher
2
)
{}
explicit
Any
OfMatcherImpl
(
std
::
vector
<
Matcher
<
T
>
>
matcher
s
)
:
matcher
s
_
(
internal
::
move
(
matcher
s
)
)
{}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"("
;
matcher1_
.
DescribeTo
(
os
);
*
os
<<
") or ("
;
matcher2_
.
DescribeTo
(
os
);
for
(
size_t
i
=
0
;
i
<
matchers_
.
size
();
++
i
)
{
if
(
i
!=
0
)
*
os
<<
") or ("
;
matchers_
[
i
].
DescribeTo
(
os
);
}
*
os
<<
")"
;
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"("
;
matcher1_
.
DescribeNegationTo
(
os
);
*
os
<<
") and ("
;
matcher2_
.
DescribeNegationTo
(
os
);
for
(
size_t
i
=
0
;
i
<
matchers_
.
size
();
++
i
)
{
if
(
i
!=
0
)
*
os
<<
") and ("
;
matchers_
[
i
].
DescribeNegationTo
(
os
);
}
*
os
<<
")"
;
}
virtual
bool
MatchAndExplain
(
GTEST_REFERENCE_TO_CONST_
(
T
)
x
,
MatchResultListener
*
listener
)
const
{
std
::
string
no_match_result
;
// If either matcher1_ or matcher2_ matches x, we just need to
// explain why *one* of them matches.
StringMatchResultListener
listener1
;
if
(
matcher1_
.
MatchAndExplain
(
x
,
&
listener1
))
{
*
listener
<<
listener1
.
str
();
return
true
;
}
StringMatchResultListener
listener2
;
if
(
matcher2_
.
MatchAndExplain
(
x
,
&
listener2
))
{
*
listener
<<
listener2
.
str
();
return
true
;
for
(
size_t
i
=
0
;
i
<
matchers_
.
size
();
++
i
)
{
StringMatchResultListener
slistener
;
if
(
matchers_
[
i
].
MatchAndExplain
(
x
,
&
slistener
))
{
*
listener
<<
slistener
.
str
();
return
true
;
}
else
{
if
(
no_match_result
.
empty
())
{
no_match_result
=
slistener
.
str
();
}
else
{
std
::
string
result
=
slistener
.
str
();
if
(
!
result
.
empty
())
{
no_match_result
+=
", and "
;
no_match_result
+=
result
;
}
}
}
}
// Otherwise we need to explain why *both* of them fail.
const
std
::
string
s1
=
listener1
.
str
();
const
std
::
string
s2
=
listener2
.
str
();
if
(
s1
==
""
)
{
*
listener
<<
s2
;
}
else
{
*
listener
<<
s1
;
if
(
s2
!=
""
)
{
*
listener
<<
", and "
<<
s2
;
}
}
*
listener
<<
no_match_result
;
return
false
;
}
private:
const
Matcher
<
T
>
matcher1_
;
const
Matcher
<
T
>
matcher2_
;
const
std
::
vector
<
Matcher
<
T
>
>
matchers_
;
GTEST_DISALLOW_ASSIGN_
(
Either
OfMatcherImpl
);
GTEST_DISALLOW_ASSIGN_
(
Any
OfMatcherImpl
);
};
#if GTEST_LANG_CXX11
// AnyOfMatcher is used for the variadic implementation of AnyOf(m_1, m_2, ...).
template
<
typename
...
Args
>
using
AnyOfMatcher
=
VariadicMatcher
<
Either
OfMatcherImpl
,
Args
...
>
;
using
AnyOfMatcher
=
VariadicMatcher
<
Any
OfMatcherImpl
,
Args
...
>
;
#endif // GTEST_LANG_CXX11
...
...
@@ -1973,8 +1935,10 @@ class EitherOfMatcher {
// both Matcher1 and Matcher2 can match.
template
<
typename
T
>
operator
Matcher
<
T
>
()
const
{
return
Matcher
<
T
>
(
new
EitherOfMatcherImpl
<
T
>
(
SafeMatcherCast
<
T
>
(
matcher1_
),
SafeMatcherCast
<
T
>
(
matcher2_
)));
std
::
vector
<
Matcher
<
T
>
>
values
;
values
.
push_back
(
SafeMatcherCast
<
T
>
(
matcher1_
));
values
.
push_back
(
SafeMatcherCast
<
T
>
(
matcher2_
));
return
Matcher
<
T
>
(
new
AnyOfMatcherImpl
<
T
>
(
internal
::
move
(
values
)));
}
private:
...
...
@@ -2408,6 +2372,7 @@ class PointeeMatcher {
GTEST_DISALLOW_ASSIGN_
(
PointeeMatcher
);
};
#if GTEST_HAS_RTTI
// Implements the WhenDynamicCastTo<T>(m) matcher that matches a pointer or
// reference that matches inner_matcher when dynamic_cast<T> is applied.
// The result of dynamic_cast<To> is forwarded to the inner matcher.
...
...
@@ -2434,11 +2399,7 @@ class WhenDynamicCastToMatcherBase {
const
Matcher
<
To
>
matcher_
;
static
std
::
string
GetToName
()
{
#if GTEST_HAS_RTTI
return
GetTypeName
<
To
>
();
#else // GTEST_HAS_RTTI
return
"the target type"
;
#endif // GTEST_HAS_RTTI
}
private:
...
...
@@ -2459,7 +2420,7 @@ class WhenDynamicCastToMatcher : public WhenDynamicCastToMatcherBase<To> {
template
<
typename
From
>
bool
MatchAndExplain
(
From
from
,
MatchResultListener
*
listener
)
const
{
//
TODO(sbenza)
: Add more detail on failures. ie did the dyn_cast fail?
//
FIXME
: Add more detail on failures. ie did the dyn_cast fail?
To
to
=
dynamic_cast
<
To
>
(
from
);
return
MatchPrintAndExplain
(
to
,
this
->
matcher_
,
listener
);
}
...
...
@@ -2484,6 +2445,7 @@ class WhenDynamicCastToMatcher<To&> : public WhenDynamicCastToMatcherBase<To&> {
return
MatchPrintAndExplain
(
*
to
,
this
->
matcher_
,
listener
);
}
};
#endif // GTEST_HAS_RTTI
// Implements the Field() matcher for matching a field (i.e. member
// variable) of an object.
...
...
@@ -4140,7 +4102,8 @@ class VariantMatcher {
private:
static
std
::
string
GetTypeName
()
{
#if GTEST_HAS_RTTI
return
internal
::
GetTypeName
<
T
>
();
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_
(
return
internal
::
GetTypeName
<
T
>
());
#endif
return
"the element type"
;
}
...
...
@@ -4200,7 +4163,8 @@ class AnyCastMatcher {
private:
static
std
::
string
GetTypeName
()
{
#if GTEST_HAS_RTTI
return
internal
::
GetTypeName
<
T
>
();
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_
(
return
internal
::
GetTypeName
<
T
>
());
#endif
return
"the element type"
;
}
...
...
@@ -4476,6 +4440,7 @@ inline internal::PointeeMatcher<InnerMatcher> Pointee(
return
internal
::
PointeeMatcher
<
InnerMatcher
>
(
inner_matcher
);
}
#if GTEST_HAS_RTTI
// Creates a matcher that matches a pointer or reference that matches
// inner_matcher when dynamic_cast<To> is applied.
// The result of dynamic_cast<To> is forwarded to the inner matcher.
...
...
@@ -4488,6 +4453,7 @@ WhenDynamicCastTo(const Matcher<To>& inner_matcher) {
return
MakePolymorphicMatcher
(
internal
::
WhenDynamicCastToMatcher
<
To
>
(
inner_matcher
));
}
#endif // GTEST_HAS_RTTI
// Creates a matcher that matches an object whose given field matches
// 'matcher'. For example,
...
...
@@ -4564,6 +4530,20 @@ Property(PropertyType (Class::*property)() const &,
property
,
MatcherCast
<
GTEST_REFERENCE_TO_CONST_
(
PropertyType
)
>
(
matcher
)));
}
// Three-argument form for reference-qualified member functions.
template
<
typename
Class
,
typename
PropertyType
,
typename
PropertyMatcher
>
inline
PolymorphicMatcher
<
internal
::
PropertyMatcher
<
Class
,
PropertyType
,
PropertyType
(
Class
::*
)()
const
&>
>
Property
(
const
std
::
string
&
property_name
,
PropertyType
(
Class
::*
property
)()
const
&
,
const
PropertyMatcher
&
matcher
)
{
return
MakePolymorphicMatcher
(
internal
::
PropertyMatcher
<
Class
,
PropertyType
,
PropertyType
(
Class
::*
)()
const
&>
(
property_name
,
property
,
MatcherCast
<
GTEST_REFERENCE_TO_CONST_
(
PropertyType
)
>
(
matcher
)));
}
#endif
// Creates a matcher that matches an object iff the result of applying
...
...
@@ -5200,13 +5180,34 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) {
// Define variadic matcher versions. They are overloaded in
// gmock-generated-matchers.h for the cases supported by pre C++11 compilers.
template
<
typename
...
Args
>
inline
internal
::
AllOfMatcher
<
Args
...
>
AllOf
(
const
Args
&
...
matchers
)
{
return
internal
::
AllOfMatcher
<
Args
...
>
(
matchers
...);
internal
::
AllOfMatcher
<
typename
std
::
decay
<
const
Args
&>::
type
...
>
AllOf
(
const
Args
&
...
matchers
)
{
return
internal
::
AllOfMatcher
<
typename
std
::
decay
<
const
Args
&>::
type
...
>
(
matchers
...);
}
template
<
typename
...
Args
>
internal
::
AnyOfMatcher
<
typename
std
::
decay
<
const
Args
&>::
type
...
>
AnyOf
(
const
Args
&
...
matchers
)
{
return
internal
::
AnyOfMatcher
<
typename
std
::
decay
<
const
Args
&>::
type
...
>
(
matchers
...);
}
template
<
typename
...
Args
>
internal
::
ElementsAreMatcher
<
tuple
<
typename
std
::
decay
<
const
Args
&>::
type
...
>>
ElementsAre
(
const
Args
&
...
matchers
)
{
return
internal
::
ElementsAreMatcher
<
tuple
<
typename
std
::
decay
<
const
Args
&>::
type
...
>>
(
make_tuple
(
matchers
...));
}
template
<
typename
...
Args
>
inline
internal
::
AnyOfMatcher
<
Args
...
>
AnyOf
(
const
Args
&
...
matchers
)
{
return
internal
::
AnyOfMatcher
<
Args
...
>
(
matchers
...);
internal
::
UnorderedElementsAreMatcher
<
tuple
<
typename
std
::
decay
<
const
Args
&>::
type
...
>>
UnorderedElementsAre
(
const
Args
&
...
matchers
)
{
return
internal
::
UnorderedElementsAreMatcher
<
tuple
<
typename
std
::
decay
<
const
Args
&>::
type
...
>>
(
make_tuple
(
matchers
...));
}
#endif // GTEST_LANG_CXX11
...
...
googlemock/include/gmock/gmock-more-actions.h
View file @
1246e580
...
...
@@ -26,13 +26,14 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes.
//
// This file implements some actions that depend on gmock-generated-actions.h.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
...
...
googlemock/include/gmock/gmock-more-matchers.h
View file @
1246e580
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: marcus.boerger@google.com (Marcus Boerger)
// Google Mock - a framework for writing C++ mock classes.
//
...
...
@@ -36,6 +35,8 @@
// Note that tests are implemented in gmock-matchers_test.cc rather than
// gmock-more-matchers-test.cc.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_GMOCK_MORE_MATCHERS_H_
#define GMOCK_GMOCK_MORE_MATCHERS_H_
...
...
@@ -46,8 +47,11 @@ namespace testing {
// Silence C4100 (unreferenced formal
// parameter) for MSVC
#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable:4100)
#if (_MSC_VER == 1900)
// and silence C4800 (C4800: 'int *const ': forcing value
// to bool 'true' or 'false') for MSVC 14
# pragma warning(disable:4800)
#endif
#endif
...
...
@@ -78,6 +82,11 @@ MATCHER(IsFalse, negation ? "is true" : "is false") {
return
!
static_cast
<
bool
>
(
arg
);
}
#ifdef _MSC_VER
# pragma warning(pop)
#endif
}
// namespace testing
#endif // GMOCK_GMOCK_MORE_MATCHERS_H_
googlemock/include/gmock/gmock-spec-builders.h
View file @
1246e580
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes.
//
...
...
@@ -57,6 +56,8 @@
// where all clauses are optional, and .InSequence()/.After()/
// .WillOnce() can appear any number of times.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
...
...
@@ -103,11 +104,6 @@ class ExpectationTester;
// Base class for function mockers.
template
<
typename
F
>
class
FunctionMockerBase
;
// Uninteresting call behavior mixins.
template
<
typename
M
>
class
NiceMockBase
;
template
<
typename
M
>
class
NaggyMockBase
;
template
<
typename
M
>
class
StrictMockBase
;
// Protects the mock object registry (in class Mock), all function
// mockers, and all expectations.
//
...
...
@@ -188,7 +184,7 @@ class GTEST_API_ UntypedFunctionMockerBase {
// this information in the global mock registry. Will be called
// whenever an EXPECT_CALL() or ON_CALL() is executed on this mock
// method.
//
TODO(wan@google.com)
: rename to SetAndRegisterOwner().
//
FIXME
: rename to SetAndRegisterOwner().
void
RegisterOwner
(
const
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
);
...
...
@@ -408,13 +404,13 @@ class GTEST_API_ Mock {
friend
class
internal
::
FunctionMockerBase
;
template
<
typename
M
>
friend
class
internal
::
NiceMock
Base
;
friend
class
NiceMock
;
template
<
typename
M
>
friend
class
internal
::
NaggyMock
Base
;
friend
class
NaggyMock
;
template
<
typename
M
>
friend
class
internal
::
StrictMock
Base
;
friend
class
StrictMock
;
// Tells Google Mock to allow uninteresting calls on the given mock
// object.
...
...
@@ -1211,7 +1207,7 @@ class TypedExpectation : public ExpectationBase {
mocker
->
DescribeDefaultActionTo
(
args
,
what
);
DescribeCallCountTo
(
why
);
//
TODO(wan@google.com)
: allow the user to control whether
//
FIXME
: allow the user to control whether
// unexpected calls should fail immediately or continue using a
// flag --gmock_unexpected_calls_are_fatal.
return
NULL
;
...
...
@@ -1287,6 +1283,13 @@ class MockSpec {
file
,
line
,
source_text
,
matchers_
);
}
// This operator overload is used to swallow the superfluous parameter list
// introduced by the ON/EXPECT_CALL macros. See the macro comments for more
// explanation.
MockSpec
<
F
>&
operator
()(
const
internal
::
WithoutMatchers
&
,
void
*
const
)
{
return
*
this
;
}
private:
template
<
typename
Function
>
friend
class
internal
::
FunctionMocker
;
...
...
@@ -1841,17 +1844,76 @@ inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT
}
// namespace testing
// A separate macro is required to avoid compile errors when the name
// of the method used in call is a result of macro expansion.
// See CompilesWithMethodNameExpandedFromMacro tests in
// internal/gmock-spec-builders_test.cc for more details.
#define GMOCK_ON_CALL_IMPL_(obj, call) \
((obj).gmock_##call).InternalDefaultActionSetAt(__FILE__, __LINE__, \
#obj, #call)
#define ON_CALL(obj, call) GMOCK_ON_CALL_IMPL_(obj, call)
#define GMOCK_EXPECT_CALL_IMPL_(obj, call) \
((obj).gmock_##call).InternalExpectedAt(__FILE__, __LINE__, #obj, #call)
#define EXPECT_CALL(obj, call) GMOCK_EXPECT_CALL_IMPL_(obj, call)
// Implementation for ON_CALL and EXPECT_CALL macros. A separate macro is
// required to avoid compile errors when the name of the method used in call is
// a result of macro expansion. See CompilesWithMethodNameExpandedFromMacro
// tests in internal/gmock-spec-builders_test.cc for more details.
//
// This macro supports statements both with and without parameter matchers. If
// the parameter list is omitted, gMock will accept any parameters, which allows
// tests to be written that don't need to encode the number of method
// parameter. This technique may only be used for non-overloaded methods.
//
// // These are the same:
// ON_CALL(mock, NoArgsMethod()).WillByDefault(...);
// ON_CALL(mock, NoArgsMethod).WillByDefault(...);
//
// // As are these:
// ON_CALL(mock, TwoArgsMethod(_, _)).WillByDefault(...);
// ON_CALL(mock, TwoArgsMethod).WillByDefault(...);
//
// // Can also specify args if you want, of course:
// ON_CALL(mock, TwoArgsMethod(_, 45)).WillByDefault(...);
//
// // Overloads work as long as you specify parameters:
// ON_CALL(mock, OverloadedMethod(_)).WillByDefault(...);
// ON_CALL(mock, OverloadedMethod(_, _)).WillByDefault(...);
//
// // Oops! Which overload did you want?
// ON_CALL(mock, OverloadedMethod).WillByDefault(...);
// => ERROR: call to member function 'gmock_OverloadedMethod' is ambiguous
//
// How this works: The mock class uses two overloads of the gmock_Method
// expectation setter method plus an operator() overload on the MockSpec object.
// In the matcher list form, the macro expands to:
//
// // This statement:
// ON_CALL(mock, TwoArgsMethod(_, 45))...
//
// // ...expands to:
// mock.gmock_TwoArgsMethod(_, 45)(WithoutMatchers(), nullptr)...
// |-------------v---------------||------------v-------------|
// invokes first overload swallowed by operator()
//
// // ...which is essentially:
// mock.gmock_TwoArgsMethod(_, 45)...
//
// Whereas the form without a matcher list:
//
// // This statement:
// ON_CALL(mock, TwoArgsMethod)...
//
// // ...expands to:
// mock.gmock_TwoArgsMethod(WithoutMatchers(), nullptr)...
// |-----------------------v--------------------------|
// invokes second overload
//
// // ...which is essentially:
// mock.gmock_TwoArgsMethod(_, _)...
//
// The WithoutMatchers() argument is used to disambiguate overloads and to
// block the caller from accidentally invoking the second overload directly. The
// second argument is an internal type derived from the method signature. The
// failure to disambiguate two overloads of this method in the ON_CALL statement
// is how we block callers from setting expectations on overloaded methods.
#define GMOCK_ON_CALL_IMPL_(mock_expr, Setter, call) \
((mock_expr).gmock_##call)(::testing::internal::GetWithoutMatchers(), NULL) \
.Setter(__FILE__, __LINE__, #mock_expr, #call)
#define ON_CALL(obj, call) \
GMOCK_ON_CALL_IMPL_(obj, InternalDefaultActionSetAt, call)
#define EXPECT_CALL(obj, call) \
GMOCK_ON_CALL_IMPL_(obj, InternalExpectedAt, call)
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
googlemock/include/gmock/gmock.h
View file @
1246e580
...
...
@@ -26,13 +26,14 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes.
//
// This is the main header file a user should include.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_H_
...
...
googlemock/include/gmock/internal/custom/README.md
0 → 100644
View file @
1246e580
# Customization Points
The custom directory is an injection point for custom user configurations.
## Header `gmock-port.h`
The following macros can be defined:
### Flag related macros:
*
`GMOCK_DECLARE_bool_(name)`
*
`GMOCK_DECLARE_int32_(name)`
*
`GMOCK_DECLARE_string_(name)`
*
`GMOCK_DEFINE_bool_(name, default_val, doc)`
*
`GMOCK_DEFINE_int32_(name, default_val, doc)`
*
`GMOCK_DEFINE_string_(name, default_val, doc)`
googlemock/include/gmock/internal/custom/gmock-generated-actions.h
View file @
1246e580
...
...
@@ -2,6 +2,8 @@
// pump.py gmock-generated-actions.h.pump
// DO NOT EDIT BY HAND!!!
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
...
...
googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump
View file @
1246e580
$$
-*-
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
$$}}
This
meta
comment
fixes
auto
-
indentation
in
editors
.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
...
...
googlemock/include/gmock/internal/custom/gmock-matchers.h
View file @
1246e580
...
...
@@ -27,12 +27,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ============================================================
// An installation-specific extension point for gmock-matchers.h.
// ============================================================
//
// Adds google3 callback support to CallableTraits.
// Injection point for custom user configurations. See README for details
//
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
googlemock/include/gmock/internal/custom/gmock-port.h
View file @
1246e580
...
...
@@ -27,19 +27,12 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Injection point for custom user configurations.
// The following macros can be defined:
//
// Flag related macros:
// GMOCK_DECLARE_bool_(name)
// GMOCK_DECLARE_int32_(name)
// GMOCK_DECLARE_string_(name)
// GMOCK_DEFINE_bool_(name, default_val, doc)
// GMOCK_DEFINE_int32_(name, default_val, doc)
// GMOCK_DEFINE_string_(name, default_val, doc)
// Injection point for custom user configurations. See README for details
//
// ** Custom implementation starts here **
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_
...
...
googlemock/include/gmock/internal/gmock-generated-internal-utils.h
View file @
1246e580
...
...
@@ -30,14 +30,15 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes.
//
// This file contains template meta-programming utility classes needed
// for implementing Google Mock.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
...
...
googlemock/include/gmock/internal/gmock-generated-internal-utils.h.pump
View file @
1246e580
...
...
@@ -31,14 +31,15 @@ $var n = 10 $$ The maximum arity we support.
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes.
//
// This file contains template meta-programming utility classes needed
// for implementing Google Mock.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
...
...
googlemock/include/gmock/internal/gmock-internal-utils.h
View file @
1246e580
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes.
//
...
...
@@ -35,6 +34,8 @@
// Mock. They are subject to change without notice, so please DO NOT
// USE THEM IN USER CODE.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
...
...
@@ -48,6 +49,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
);
...
...
@@ -336,7 +345,22 @@ GTEST_API_ bool LogIsVisible(LogSeverity severity);
GTEST_API_
void
Log
(
LogSeverity
severity
,
const
std
::
string
&
message
,
int
stack_frames_to_skip
);
// TODO(wan@google.com): group all type utilities together.
// A marker class that is used to resolve parameterless expectations to the
// correct overload. This must not be instantiable, to prevent client code from
// accidentally resolving to the overload; for example:
//
// ON_CALL(mock, Method({}, nullptr))...
//
class
WithoutMatchers
{
private:
WithoutMatchers
()
{}
friend
GTEST_API_
WithoutMatchers
GetWithoutMatchers
();
};
// Internal use only: access the singleton instance of WithoutMatchers.
GTEST_API_
WithoutMatchers
GetWithoutMatchers
();
// FIXME: group all type utilities together.
// Type traits.
...
...
@@ -510,7 +534,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 +563,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/include/gmock/internal/gmock-port.h
View file @
1246e580
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: vadimb@google.com (Vadim Berman)
//
// Low-level types and utilities for porting Google Mock to various
// platforms. All macros ending with _ and symbols defined in an
...
...
@@ -36,6 +35,8 @@
// end with _ are part of Google Mock's public API and can be used by
// code outside Google Mock.
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
...
...
googlemock/scripts/generator/README
View file @
1246e580
The Google Mock class generator is an application that is part of cppclean.
For more information about cppclean, see the README.cppclean file or
visit http://code.google.com/p/cppclean/
For more information about cppclean, visit http://code.google.com/p/cppclean/
cppclean
requires Python 2.3.5 or later. If you don't have Python
installed
on your system, you will also need to install it. You can download
Python
from: http://www.python.org/download/releases/
The mock generator
requires Python 2.3.5 or later. If you don't have Python
installed
on your system, you will also need to install it. You can download
Python
from: http://www.python.org/download/releases/
To use the Google Mock class generator, you need to call it
on the command line passing the header file and class for which you want
...
...
googlemock/scripts/upload.py
View file @
1246e580
...
...
@@ -242,7 +242,7 @@ class AbstractRpcServer(object):
The authentication process works as follows:
1) We get a username and password from the user
2) We use ClientLogin to obtain an AUTH token for the user
(see http://
co
de.google.com/
apis/account
s/AuthForInstalledApps
.html
).
(see http
s
://de
velopers
.google.com/
identity/protocol
s/AuthForInstalledApps).
3) We pass the auth token to /_ah/login on the server to obtain an
authentication cookie. If login was successful, it tries to redirect
us to the URL we provided.
...
...
@@ -506,7 +506,7 @@ def EncodeMultipartFormData(fields, files):
(content_type, body) ready for httplib.HTTP instance.
Source:
http://
aspn.activestate.com/ASPN/Cookbook/Python/R
ecipe/146306
http
s
://
web.archive.org/web/20160116052001/code.activestate.com/r
ecipe
s
/146306
"""
BOUNDARY
=
'-M-A-G-I-C---B-O-U-N-D-A-R-Y-'
CRLF
=
'
\r\n
'
...
...
@@ -807,7 +807,7 @@ class SubversionVCS(VersionControlSystem):
# svn cat translates keywords but svn diff doesn't. As a result of this
# behavior patching.PatchChunks() fails with a chunk mismatch error.
# This part was originally written by the Review Board development team
# who had the same problem (http://reviews.review
-
board.org/r/276/).
# who had the same problem (http
s
://reviews.reviewboard.org/r/276/).
# Mapping of keywords to known aliases
svn_keywords
=
{
# Standard keywords
...
...
@@ -860,7 +860,7 @@ class SubversionVCS(VersionControlSystem):
status_lines
=
status
.
splitlines
()
# If file is in a cl, the output will begin with
# "\n--- Changelist 'cl_name':\n". See
# http://svn.collab.net/repos/svn/trunk/notes/changelist-design.txt
# http
s
://
web.archive.org/web/20090918234815/
svn.collab.net/repos/svn/trunk/notes/changelist-design.txt
if
(
len
(
status_lines
)
==
3
and
not
status_lines
[
0
]
and
status_lines
[
1
].
startswith
(
"--- Changelist"
)):
...
...
googlemock/src/gmock-all.cc
View file @
1246e580
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
//
// Google C++ Mocking Framework (Google Mock)
//
...
...
googlemock/src/gmock-cardinalities.cc
View file @
1246e580
...
...
@@ -26,8 +26,7 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Google Mock - a framework for writing C++ mock classes.
//
...
...
Prev
1
2
3
4
5
6
…
11
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