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
25905b9f
Commit
25905b9f
authored
Jan 02, 2019
by
Gennadiy Civil
Browse files
Merge branch 'master' of
https://github.com/google/googletest
parents
4665eee1
3bedb5a9
Changes
143
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1530 additions
and
3996 deletions
+1530
-3996
googlemock/include/gmock/gmock-generated-function-mockers.h
googlemock/include/gmock/gmock-generated-function-mockers.h
+454
-1079
googlemock/include/gmock/gmock-generated-function-mockers.h.pump
...ock/include/gmock/gmock-generated-function-mockers.h.pump
+5
-124
googlemock/include/gmock/gmock-generated-matchers.h
googlemock/include/gmock/gmock-generated-matchers.h
+78
-633
googlemock/include/gmock/gmock-generated-matchers.h.pump
googlemock/include/gmock/gmock-generated-matchers.h.pump
+4
-215
googlemock/include/gmock/gmock-generated-nice-strict.h
googlemock/include/gmock/gmock-generated-nice-strict.h
+0
-459
googlemock/include/gmock/gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+277
-1078
googlemock/include/gmock/gmock-more-actions.h
googlemock/include/gmock/gmock-more-actions.h
+8
-29
googlemock/include/gmock/gmock-nice-strict.h
googlemock/include/gmock/gmock-nice-strict.h
+78
-42
googlemock/include/gmock/gmock-spec-builders.h
googlemock/include/gmock/gmock-spec-builders.h
+209
-139
googlemock/include/gmock/gmock.h
googlemock/include/gmock/gmock.h
+2
-1
googlemock/include/gmock/internal/gmock-generated-internal-utils.h
...k/include/gmock/internal/gmock-generated-internal-utils.h
+41
-50
googlemock/include/gmock/internal/gmock-generated-internal-utils.h.pump
...lude/gmock/internal/gmock-generated-internal-utils.h.pump
+4
-4
googlemock/include/gmock/internal/gmock-internal-utils.h
googlemock/include/gmock/internal/gmock-internal-utils.h
+6
-16
googlemock/include/gmock/internal/gmock-port.h
googlemock/include/gmock/internal/gmock-port.h
+3
-4
googlemock/include/gmock/internal/gmock-pp.h
googlemock/include/gmock/internal/gmock-pp.h
+317
-0
googlemock/src/gmock-cardinalities.cc
googlemock/src/gmock-cardinalities.cc
+5
-5
googlemock/src/gmock-internal-utils.cc
googlemock/src/gmock-internal-utils.cc
+2
-2
googlemock/src/gmock-matchers.cc
googlemock/src/gmock-matchers.cc
+0
-110
googlemock/src/gmock-spec-builders.cc
googlemock/src/gmock-spec-builders.cc
+20
-6
googlemock/src/gmock_main.cc
googlemock/src/gmock_main.cc
+17
-0
No files found.
googlemock/include/gmock/gmock-generated-function-mockers.h
View file @
25905b9f
...
@@ -41,298 +41,14 @@
...
@@ -41,298 +41,14 @@
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
#include <functional>
#include <utility>
#include "gmock/gmock-spec-builders.h"
#include "gmock/gmock-spec-builders.h"
#include "gmock/internal/gmock-internal-utils.h"
#include "gmock/internal/gmock-internal-utils.h"
#if GTEST_HAS_STD_FUNCTION_
# include <functional>
#endif
namespace
testing
{
namespace
testing
{
namespace
internal
{
namespace
internal
{
template
<
typename
F
>
class
FunctionMockerBase
;
// Note: class FunctionMocker really belongs to the ::testing
// namespace. However if we define it in ::testing, MSVC will
// complain when classes in ::testing::internal declare it as a
// friend class template. To workaround this compiler bug, we define
// FunctionMocker in ::testing::internal and import it into ::testing.
template
<
typename
F
>
class
FunctionMocker
;
template
<
typename
R
>
class
FunctionMocker
<
R
()
>
:
public
internal
::
FunctionMockerBase
<
R
()
>
{
public:
typedef
R
F
();
typedef
typename
internal
::
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
MockSpec
<
F
>
With
()
{
return
MockSpec
<
F
>
(
this
,
::
testing
::
make_tuple
());
}
R
Invoke
()
{
// Even though gcc and MSVC don't enforce it, 'this->' is required
// by the C++ standard [14.6.4] here, as the base class type is
// dependent on the template argument (and thus shouldn't be
// looked into when resolving InvokeWith).
return
this
->
InvokeWith
(
ArgumentTuple
());
}
};
template
<
typename
R
,
typename
A1
>
class
FunctionMocker
<
R
(
A1
)
>
:
public
internal
::
FunctionMockerBase
<
R
(
A1
)
>
{
public:
typedef
R
F
(
A1
);
typedef
typename
internal
::
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
MockSpec
<
F
>
With
(
const
Matcher
<
A1
>&
m1
)
{
return
MockSpec
<
F
>
(
this
,
::
testing
::
make_tuple
(
m1
));
}
R
Invoke
(
A1
a1
)
{
// Even though gcc and MSVC don't enforce it, 'this->' is required
// by the C++ standard [14.6.4] here, as the base class type is
// dependent on the template argument (and thus shouldn't be
// looked into when resolving InvokeWith).
return
this
->
InvokeWith
(
ArgumentTuple
(
internal
::
forward
<
A1
>
(
a1
)));
}
};
template
<
typename
R
,
typename
A1
,
typename
A2
>
class
FunctionMocker
<
R
(
A1
,
A2
)
>
:
public
internal
::
FunctionMockerBase
<
R
(
A1
,
A2
)
>
{
public:
typedef
R
F
(
A1
,
A2
);
typedef
typename
internal
::
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
MockSpec
<
F
>
With
(
const
Matcher
<
A1
>&
m1
,
const
Matcher
<
A2
>&
m2
)
{
return
MockSpec
<
F
>
(
this
,
::
testing
::
make_tuple
(
m1
,
m2
));
}
R
Invoke
(
A1
a1
,
A2
a2
)
{
// Even though gcc and MSVC don't enforce it, 'this->' is required
// by the C++ standard [14.6.4] here, as the base class type is
// dependent on the template argument (and thus shouldn't be
// looked into when resolving InvokeWith).
return
this
->
InvokeWith
(
ArgumentTuple
(
internal
::
forward
<
A1
>
(
a1
),
internal
::
forward
<
A2
>
(
a2
)));
}
};
template
<
typename
R
,
typename
A1
,
typename
A2
,
typename
A3
>
class
FunctionMocker
<
R
(
A1
,
A2
,
A3
)
>
:
public
internal
::
FunctionMockerBase
<
R
(
A1
,
A2
,
A3
)
>
{
public:
typedef
R
F
(
A1
,
A2
,
A3
);
typedef
typename
internal
::
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
MockSpec
<
F
>
With
(
const
Matcher
<
A1
>&
m1
,
const
Matcher
<
A2
>&
m2
,
const
Matcher
<
A3
>&
m3
)
{
return
MockSpec
<
F
>
(
this
,
::
testing
::
make_tuple
(
m1
,
m2
,
m3
));
}
R
Invoke
(
A1
a1
,
A2
a2
,
A3
a3
)
{
// Even though gcc and MSVC don't enforce it, 'this->' is required
// by the C++ standard [14.6.4] here, as the base class type is
// dependent on the template argument (and thus shouldn't be
// looked into when resolving InvokeWith).
return
this
->
InvokeWith
(
ArgumentTuple
(
internal
::
forward
<
A1
>
(
a1
),
internal
::
forward
<
A2
>
(
a2
),
internal
::
forward
<
A3
>
(
a3
)));
}
};
template
<
typename
R
,
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
>
class
FunctionMocker
<
R
(
A1
,
A2
,
A3
,
A4
)
>
:
public
internal
::
FunctionMockerBase
<
R
(
A1
,
A2
,
A3
,
A4
)
>
{
public:
typedef
R
F
(
A1
,
A2
,
A3
,
A4
);
typedef
typename
internal
::
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
MockSpec
<
F
>
With
(
const
Matcher
<
A1
>&
m1
,
const
Matcher
<
A2
>&
m2
,
const
Matcher
<
A3
>&
m3
,
const
Matcher
<
A4
>&
m4
)
{
return
MockSpec
<
F
>
(
this
,
::
testing
::
make_tuple
(
m1
,
m2
,
m3
,
m4
));
}
R
Invoke
(
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
)
{
// Even though gcc and MSVC don't enforce it, 'this->' is required
// by the C++ standard [14.6.4] here, as the base class type is
// dependent on the template argument (and thus shouldn't be
// looked into when resolving InvokeWith).
return
this
->
InvokeWith
(
ArgumentTuple
(
internal
::
forward
<
A1
>
(
a1
),
internal
::
forward
<
A2
>
(
a2
),
internal
::
forward
<
A3
>
(
a3
),
internal
::
forward
<
A4
>
(
a4
)));
}
};
template
<
typename
R
,
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
>
class
FunctionMocker
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
)
>
:
public
internal
::
FunctionMockerBase
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
)
>
{
public:
typedef
R
F
(
A1
,
A2
,
A3
,
A4
,
A5
);
typedef
typename
internal
::
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
MockSpec
<
F
>
With
(
const
Matcher
<
A1
>&
m1
,
const
Matcher
<
A2
>&
m2
,
const
Matcher
<
A3
>&
m3
,
const
Matcher
<
A4
>&
m4
,
const
Matcher
<
A5
>&
m5
)
{
return
MockSpec
<
F
>
(
this
,
::
testing
::
make_tuple
(
m1
,
m2
,
m3
,
m4
,
m5
));
}
R
Invoke
(
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
)
{
// Even though gcc and MSVC don't enforce it, 'this->' is required
// by the C++ standard [14.6.4] here, as the base class type is
// dependent on the template argument (and thus shouldn't be
// looked into when resolving InvokeWith).
return
this
->
InvokeWith
(
ArgumentTuple
(
internal
::
forward
<
A1
>
(
a1
),
internal
::
forward
<
A2
>
(
a2
),
internal
::
forward
<
A3
>
(
a3
),
internal
::
forward
<
A4
>
(
a4
),
internal
::
forward
<
A5
>
(
a5
)));
}
};
template
<
typename
R
,
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
>
class
FunctionMocker
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
)
>
:
public
internal
::
FunctionMockerBase
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
)
>
{
public:
typedef
R
F
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
);
typedef
typename
internal
::
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
MockSpec
<
F
>
With
(
const
Matcher
<
A1
>&
m1
,
const
Matcher
<
A2
>&
m2
,
const
Matcher
<
A3
>&
m3
,
const
Matcher
<
A4
>&
m4
,
const
Matcher
<
A5
>&
m5
,
const
Matcher
<
A6
>&
m6
)
{
return
MockSpec
<
F
>
(
this
,
::
testing
::
make_tuple
(
m1
,
m2
,
m3
,
m4
,
m5
,
m6
));
}
R
Invoke
(
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
,
A6
a6
)
{
// Even though gcc and MSVC don't enforce it, 'this->' is required
// by the C++ standard [14.6.4] here, as the base class type is
// dependent on the template argument (and thus shouldn't be
// looked into when resolving InvokeWith).
return
this
->
InvokeWith
(
ArgumentTuple
(
internal
::
forward
<
A1
>
(
a1
),
internal
::
forward
<
A2
>
(
a2
),
internal
::
forward
<
A3
>
(
a3
),
internal
::
forward
<
A4
>
(
a4
),
internal
::
forward
<
A5
>
(
a5
),
internal
::
forward
<
A6
>
(
a6
)));
}
};
template
<
typename
R
,
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
>
class
FunctionMocker
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
)
>
:
public
internal
::
FunctionMockerBase
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
)
>
{
public:
typedef
R
F
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
);
typedef
typename
internal
::
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
MockSpec
<
F
>
With
(
const
Matcher
<
A1
>&
m1
,
const
Matcher
<
A2
>&
m2
,
const
Matcher
<
A3
>&
m3
,
const
Matcher
<
A4
>&
m4
,
const
Matcher
<
A5
>&
m5
,
const
Matcher
<
A6
>&
m6
,
const
Matcher
<
A7
>&
m7
)
{
return
MockSpec
<
F
>
(
this
,
::
testing
::
make_tuple
(
m1
,
m2
,
m3
,
m4
,
m5
,
m6
,
m7
));
}
R
Invoke
(
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
,
A6
a6
,
A7
a7
)
{
// Even though gcc and MSVC don't enforce it, 'this->' is required
// by the C++ standard [14.6.4] here, as the base class type is
// dependent on the template argument (and thus shouldn't be
// looked into when resolving InvokeWith).
return
this
->
InvokeWith
(
ArgumentTuple
(
internal
::
forward
<
A1
>
(
a1
),
internal
::
forward
<
A2
>
(
a2
),
internal
::
forward
<
A3
>
(
a3
),
internal
::
forward
<
A4
>
(
a4
),
internal
::
forward
<
A5
>
(
a5
),
internal
::
forward
<
A6
>
(
a6
),
internal
::
forward
<
A7
>
(
a7
)));
}
};
template
<
typename
R
,
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
>
class
FunctionMocker
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
)
>
:
public
internal
::
FunctionMockerBase
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
)
>
{
public:
typedef
R
F
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
);
typedef
typename
internal
::
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
MockSpec
<
F
>
With
(
const
Matcher
<
A1
>&
m1
,
const
Matcher
<
A2
>&
m2
,
const
Matcher
<
A3
>&
m3
,
const
Matcher
<
A4
>&
m4
,
const
Matcher
<
A5
>&
m5
,
const
Matcher
<
A6
>&
m6
,
const
Matcher
<
A7
>&
m7
,
const
Matcher
<
A8
>&
m8
)
{
return
MockSpec
<
F
>
(
this
,
::
testing
::
make_tuple
(
m1
,
m2
,
m3
,
m4
,
m5
,
m6
,
m7
,
m8
));
}
R
Invoke
(
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
,
A6
a6
,
A7
a7
,
A8
a8
)
{
// Even though gcc and MSVC don't enforce it, 'this->' is required
// by the C++ standard [14.6.4] here, as the base class type is
// dependent on the template argument (and thus shouldn't be
// looked into when resolving InvokeWith).
return
this
->
InvokeWith
(
ArgumentTuple
(
internal
::
forward
<
A1
>
(
a1
),
internal
::
forward
<
A2
>
(
a2
),
internal
::
forward
<
A3
>
(
a3
),
internal
::
forward
<
A4
>
(
a4
),
internal
::
forward
<
A5
>
(
a5
),
internal
::
forward
<
A6
>
(
a6
),
internal
::
forward
<
A7
>
(
a7
),
internal
::
forward
<
A8
>
(
a8
)));
}
};
template
<
typename
R
,
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
,
typename
A9
>
class
FunctionMocker
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
)
>
:
public
internal
::
FunctionMockerBase
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
)
>
{
public:
typedef
R
F
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
);
typedef
typename
internal
::
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
MockSpec
<
F
>
With
(
const
Matcher
<
A1
>&
m1
,
const
Matcher
<
A2
>&
m2
,
const
Matcher
<
A3
>&
m3
,
const
Matcher
<
A4
>&
m4
,
const
Matcher
<
A5
>&
m5
,
const
Matcher
<
A6
>&
m6
,
const
Matcher
<
A7
>&
m7
,
const
Matcher
<
A8
>&
m8
,
const
Matcher
<
A9
>&
m9
)
{
return
MockSpec
<
F
>
(
this
,
::
testing
::
make_tuple
(
m1
,
m2
,
m3
,
m4
,
m5
,
m6
,
m7
,
m8
,
m9
));
}
R
Invoke
(
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
,
A6
a6
,
A7
a7
,
A8
a8
,
A9
a9
)
{
// Even though gcc and MSVC don't enforce it, 'this->' is required
// by the C++ standard [14.6.4] here, as the base class type is
// dependent on the template argument (and thus shouldn't be
// looked into when resolving InvokeWith).
return
this
->
InvokeWith
(
ArgumentTuple
(
internal
::
forward
<
A1
>
(
a1
),
internal
::
forward
<
A2
>
(
a2
),
internal
::
forward
<
A3
>
(
a3
),
internal
::
forward
<
A4
>
(
a4
),
internal
::
forward
<
A5
>
(
a5
),
internal
::
forward
<
A6
>
(
a6
),
internal
::
forward
<
A7
>
(
a7
),
internal
::
forward
<
A8
>
(
a8
),
internal
::
forward
<
A9
>
(
a9
)));
}
};
template
<
typename
R
,
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
,
typename
A9
,
typename
A10
>
class
FunctionMocker
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
A10
)
>
:
public
internal
::
FunctionMockerBase
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
A10
)
>
{
public:
typedef
R
F
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
A10
);
typedef
typename
internal
::
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
MockSpec
<
F
>
With
(
const
Matcher
<
A1
>&
m1
,
const
Matcher
<
A2
>&
m2
,
const
Matcher
<
A3
>&
m3
,
const
Matcher
<
A4
>&
m4
,
const
Matcher
<
A5
>&
m5
,
const
Matcher
<
A6
>&
m6
,
const
Matcher
<
A7
>&
m7
,
const
Matcher
<
A8
>&
m8
,
const
Matcher
<
A9
>&
m9
,
const
Matcher
<
A10
>&
m10
)
{
return
MockSpec
<
F
>
(
this
,
::
testing
::
make_tuple
(
m1
,
m2
,
m3
,
m4
,
m5
,
m6
,
m7
,
m8
,
m9
,
m10
));
}
R
Invoke
(
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
,
A6
a6
,
A7
a7
,
A8
a8
,
A9
a9
,
A10
a10
)
{
// Even though gcc and MSVC don't enforce it, 'this->' is required
// by the C++ standard [14.6.4] here, as the base class type is
// dependent on the template argument (and thus shouldn't be
// looked into when resolving InvokeWith).
return
this
->
InvokeWith
(
ArgumentTuple
(
internal
::
forward
<
A1
>
(
a1
),
internal
::
forward
<
A2
>
(
a2
),
internal
::
forward
<
A3
>
(
a3
),
internal
::
forward
<
A4
>
(
a4
),
internal
::
forward
<
A5
>
(
a5
),
internal
::
forward
<
A6
>
(
a6
),
internal
::
forward
<
A7
>
(
a7
),
internal
::
forward
<
A8
>
(
a8
),
internal
::
forward
<
A9
>
(
a9
),
internal
::
forward
<
A10
>
(
a10
)));
}
};
// Removes the given pointer; this is a helper for the expectation setter method
// Removes the given pointer; this is a helper for the expectation setter method
// for parameterless matchers.
// for parameterless matchers.
//
//
...
@@ -418,534 +134,478 @@ using internal::FunctionMocker;
...
@@ -418,534 +134,478 @@ using internal::FunctionMocker;
GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD0_(tn, constness, ct, Method, ...) \
#define GMOCK_METHOD0_(tn, constness, ct, Method, ...) \
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method() constness { \
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
GTEST_COMPILE_ASSERT_( \
) constness { \
(::testing::tuple_size<tn ::testing::internal::Function< \
GTEST_COMPILE_ASSERT_((::std::tuple_size< \
__VA_ARGS__>::ArgumentTuple>::value == 0), \
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
this_method_does_not_take_0_arguments); \
== 0), \
GMOCK_MOCKER_(0, constness, Method).SetOwnerAndName(this, #Method); \
this_method_does_not_take_0_arguments); \
return GMOCK_MOCKER_(0, constness, Method).Invoke(); \
GMOCK_MOCKER_(0, constness, Method).SetOwnerAndName(this, #Method); \
} \
return GMOCK_MOCKER_(0, constness, Method).Invoke(); \
::testing::MockSpec<__VA_ARGS__> gmock_##Method() constness { \
} \
GMOCK_MOCKER_(0, constness, Method).RegisterOwner(this); \
::testing::MockSpec<__VA_ARGS__> \
return GMOCK_MOCKER_(0, constness, Method).With(); \
gmock_##Method() constness { \
} \
GMOCK_MOCKER_(0, constness, Method).RegisterOwner(this); \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
return GMOCK_MOCKER_(0, constness, Method).With(); \
const ::testing::internal::WithoutMatchers&, \
} \
constness ::testing::internal::Function<__VA_ARGS__>*) const { \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
return ::testing::internal::AdjustConstness_##constness(this) \
const ::testing::internal::WithoutMatchers&, \
->gmock_##Method(); \
constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
} \
return ::testing::internal::AdjustConstness_##constness(this)-> \
gmock_##Method(); \
} \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(0, constness, \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(0, constness, \
Method)
Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD1_(tn, constness, ct, Method, ...)
\
#define GMOCK_METHOD1_(tn, constness, ct, Method, ...) \
GMOCK_RESULT_(tn, __VA_ARGS__)
\
GMOCK_RESULT_(tn, __VA_ARGS__)
ct Method(
\
ct Method(
GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1) constness {
\
GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1) constness { \
GTEST_COMPILE_ASSERT_(
\
GTEST_COMPILE_ASSERT_(
(::std::tuple_size<
\
(::testing::tuple_size<
tn ::testing::internal::Function<
\
tn ::testing::internal::Function<
__VA_ARGS__>::ArgumentTuple>::value
\
__VA_ARGS__>::ArgumentTuple>::value == 1),
\
== 1),
\
this_method_does_not_take_1_argument);
\
this_method_does_not_take_1_argument); \
GMOCK_MOCKER_(1, constness, Method).SetOwnerAndName(this, #Method);
\
GMOCK_MOCKER_(1, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(1, constness,
Method)
\
return GMOCK_MOCKER_(1, constness, \
.Invoke(::
testing::internal
::forward<GMOCK_ARG_(tn, 1,
__VA_ARGS__)>(
\
Method)
.Invoke(::
std
::forward<GMOCK_ARG_(tn, 1, \
gmock_a1));
\
__VA_ARGS__)>(gmock_a1));
\
}
\
} \
::testing::MockSpec<__VA_ARGS__>
gmock_##Method(
\
::testing::MockSpec<__VA_ARGS__> \
GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1) constness {
\
gmock_##Method(
GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1) constness { \
GMOCK_MOCKER_(1, constness, Method).RegisterOwner(this);
\
GMOCK_MOCKER_(1, constness, Method).RegisterOwner(this); \
return GMOCK_MOCKER_(1, constness, Method).With(gmock_a1);
\
return GMOCK_MOCKER_(1, constness, Method).With(gmock_a1); \
}
\
} \
::testing::MockSpec<__VA_ARGS__> gmock_##Method(
\
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
const ::testing::internal::WithoutMatchers&,
\
const ::testing::internal::WithoutMatchers&, \
constness ::testing::internal::Function<__VA_ARGS__>*) const {
\
constness ::testing::internal::Function<__VA_ARGS__>*
) const { \
return ::testing::internal::AdjustConstness_##constness(this)
\
return ::testing::internal::AdjustConstness_##constness(this)
->
\
->
gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>());
\
gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>()); \
}
\
}
\
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(1, constness,
\
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(1, constness, \
Method)
Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD2_(tn, constness, ct, Method, ...) \
#define GMOCK_METHOD2_(tn, constness, ct, Method, ...) \
GMOCK_RESULT_(tn, __VA_ARGS__) \
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \
GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2) constness { \
__VA_ARGS__) gmock_a2) constness { \
GTEST_COMPILE_ASSERT_( \
GTEST_COMPILE_ASSERT_((::std::tuple_size< \
(::testing::tuple_size<tn ::testing::internal::Function< \
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
__VA_ARGS__>::ArgumentTuple>::value == 2), \
== 2), \
this_method_does_not_take_2_arguments); \
this_method_does_not_take_2_arguments); \
GMOCK_MOCKER_(2, constness, Method).SetOwnerAndName(this, #Method); \
GMOCK_MOCKER_(2, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(2, constness, Method) \
return GMOCK_MOCKER_(2, constness, \
.Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
Method).Invoke(::std::forward<GMOCK_ARG_(tn, 1, \
gmock_a1), \
__VA_ARGS__)>(gmock_a1), \
::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(gmock_a2)); \
gmock_a2)); \
} \
} \
::testing::MockSpec<__VA_ARGS__> \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2) constness { \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2) constness { \
GMOCK_MOCKER_(2, constness, Method).RegisterOwner(this); \
GMOCK_MOCKER_(2, constness, Method).RegisterOwner(this); \
return GMOCK_MOCKER_(2, constness, Method).With(gmock_a1, gmock_a2); \
return GMOCK_MOCKER_(2, constness, Method).With(gmock_a1, gmock_a2); \
} \
} \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
const ::testing::internal::WithoutMatchers&, \
const ::testing::internal::WithoutMatchers&, \
constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
constness ::testing::internal::Function<__VA_ARGS__>*) const { \
return ::testing::internal::AdjustConstness_##constness(this)-> \
return ::testing::internal::AdjustConstness_##constness(this) \
gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>()); \
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>()); \
} \
} \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(2, constness, \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(2, constness, \
Method)
Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD3_(tn, constness, ct, Method, ...) \
#define GMOCK_METHOD3_(tn, constness, ct, Method, ...) \
GMOCK_RESULT_(tn, __VA_ARGS__) \
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \
GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
__VA_ARGS__) gmock_a2, GMOCK_ARG_(tn, 3, \
GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3) constness { \
__VA_ARGS__) gmock_a3) constness { \
GTEST_COMPILE_ASSERT_( \
GTEST_COMPILE_ASSERT_((::std::tuple_size< \
(::testing::tuple_size<tn ::testing::internal::Function< \
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
__VA_ARGS__>::ArgumentTuple>::value == 3), \
== 3), \
this_method_does_not_take_3_arguments); \
this_method_does_not_take_3_arguments); \
GMOCK_MOCKER_(3, constness, Method).SetOwnerAndName(this, #Method); \
GMOCK_MOCKER_(3, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(3, constness, Method) \
return GMOCK_MOCKER_(3, constness, \
.Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
Method).Invoke(::std::forward<GMOCK_ARG_(tn, 1, \
gmock_a1), \
__VA_ARGS__)>(gmock_a1), \
::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(gmock_a2), \
gmock_a2), \
::std::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(gmock_a3)); \
::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
} \
gmock_a3)); \
::testing::MockSpec<__VA_ARGS__> \
} \
gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3) constness { \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
GMOCK_MOCKER_(3, constness, Method).RegisterOwner(this); \
GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3) constness { \
return GMOCK_MOCKER_(3, constness, Method).With(gmock_a1, gmock_a2, \
GMOCK_MOCKER_(3, constness, Method).RegisterOwner(this); \
gmock_a3); \
return GMOCK_MOCKER_(3, constness, Method) \
} \
.With(gmock_a1, gmock_a2, gmock_a3); \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
} \
const ::testing::internal::WithoutMatchers&, \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
const ::testing::internal::WithoutMatchers&, \
return ::testing::internal::AdjustConstness_##constness(this)-> \
constness ::testing::internal::Function<__VA_ARGS__>*) const { \
gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
return ::testing::internal::AdjustConstness_##constness(this) \
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>()); \
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
} \
::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>()); \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(3, constness, \
} \
Method)
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(3, constness, \
Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD4_(tn, constness, ct, Method, ...) \
#define GMOCK_METHOD4_(tn, constness, ct, Method, ...) \
GMOCK_RESULT_(tn, __VA_ARGS__) \
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \
GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
__VA_ARGS__) gmock_a2, GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
GTEST_COMPILE_ASSERT_((::std::tuple_size< \
GTEST_COMPILE_ASSERT_( \
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
(::testing::tuple_size<tn ::testing::internal::Function< \
== 4), \
__VA_ARGS__>::ArgumentTuple>::value == 4), \
this_method_does_not_take_4_arguments); \
this_method_does_not_take_4_arguments); \
GMOCK_MOCKER_(4, constness, Method).SetOwnerAndName(this, #Method); \
GMOCK_MOCKER_(4, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(4, constness, \
return GMOCK_MOCKER_(4, constness, Method) \
Method).Invoke(::std::forward<GMOCK_ARG_(tn, 1, \
.Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
__VA_ARGS__)>(gmock_a1), \
gmock_a1), \
::std::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(gmock_a2), \
::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(gmock_a3), \
gmock_a2), \
::std::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(gmock_a4)); \
::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
} \
gmock_a3), \
::testing::MockSpec<__VA_ARGS__> \
::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
gmock_a4)); \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
} \
GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
GMOCK_MOCKER_(4, constness, Method).RegisterOwner(this); \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
return GMOCK_MOCKER_(4, constness, Method).With(gmock_a1, gmock_a2, \
GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
gmock_a3, gmock_a4); \
GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4) constness { \
} \
GMOCK_MOCKER_(4, constness, Method).RegisterOwner(this); \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
return GMOCK_MOCKER_(4, constness, Method) \
const ::testing::internal::WithoutMatchers&, \
.With(gmock_a1, gmock_a2, gmock_a3, gmock_a4); \
constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
} \
return ::testing::internal::AdjustConstness_##constness(this)-> \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
const ::testing::internal::WithoutMatchers&, \
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
constness ::testing::internal::Function<__VA_ARGS__>*) const { \
::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
return ::testing::internal::AdjustConstness_##constness(this) \
::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>()); \
->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
} \
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(4, constness, \
::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
Method)
::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>()); \
} \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(4, constness, \
Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD5_(tn, constness, ct, Method, ...) \
#define GMOCK_METHOD5_(tn, constness, ct, Method, ...) \
GMOCK_RESULT_(tn, __VA_ARGS__) \
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \
GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
__VA_ARGS__) gmock_a2, GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(tn, 5, \
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
__VA_ARGS__) gmock_a5) constness { \
GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5) constness { \
GTEST_COMPILE_ASSERT_((::std::tuple_size< \
GTEST_COMPILE_ASSERT_( \
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
(::testing::tuple_size<tn ::testing::internal::Function< \
== 5), \
__VA_ARGS__>::ArgumentTuple>::value == 5), \
this_method_does_not_take_5_arguments); \
this_method_does_not_take_5_arguments); \
GMOCK_MOCKER_(5, constness, Method).SetOwnerAndName(this, #Method); \
GMOCK_MOCKER_(5, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(5, constness, \
return GMOCK_MOCKER_(5, constness, Method) \
Method).Invoke(::std::forward<GMOCK_ARG_(tn, 1, \
.Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
__VA_ARGS__)>(gmock_a1), \
gmock_a1), \
::std::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(gmock_a2), \
::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(gmock_a3), \
gmock_a2), \
::std::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(gmock_a4), \
::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(gmock_a5)); \
gmock_a3), \
} \
::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
::testing::MockSpec<__VA_ARGS__> \
gmock_a4), \
gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
gmock_a5)); \
GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
} \
GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5) constness { \
GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
GMOCK_MOCKER_(5, constness, Method).RegisterOwner(this); \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
return GMOCK_MOCKER_(5, constness, Method).With(gmock_a1, gmock_a2, \
GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
gmock_a3, gmock_a4, gmock_a5); \
GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
} \
GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5) constness { \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
GMOCK_MOCKER_(5, constness, Method).RegisterOwner(this); \
const ::testing::internal::WithoutMatchers&, \
return GMOCK_MOCKER_(5, constness, Method) \
constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
.With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5); \
return ::testing::internal::AdjustConstness_##constness(this)-> \
} \
gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
const ::testing::internal::WithoutMatchers&, \
::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
constness ::testing::internal::Function<__VA_ARGS__>*) const { \
::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
return ::testing::internal::AdjustConstness_##constness(this) \
::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>()); \
->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
} \
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(5, constness, \
::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
Method)
::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>()); \
} \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(5, constness, \
Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD6_(tn, constness, ct, Method, ...) \
#define GMOCK_METHOD6_(tn, constness, ct, Method, ...) \
GMOCK_RESULT_(tn, __VA_ARGS__) \
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \
GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
__VA_ARGS__) gmock_a2, GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(tn, 5, \
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
__VA_ARGS__) gmock_a5, GMOCK_ARG_(tn, 6, \
GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
__VA_ARGS__) gmock_a6) constness { \
GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6) constness { \
GTEST_COMPILE_ASSERT_((::std::tuple_size< \
GTEST_COMPILE_ASSERT_( \
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
(::testing::tuple_size<tn ::testing::internal::Function< \
== 6), \
__VA_ARGS__>::ArgumentTuple>::value == 6), \
this_method_does_not_take_6_arguments); \
this_method_does_not_take_6_arguments); \
GMOCK_MOCKER_(6, constness, Method).SetOwnerAndName(this, #Method); \
GMOCK_MOCKER_(6, constness, Method).SetOwnerAndName(this, #Method); \
return GMOCK_MOCKER_(6, constness, \
return GMOCK_MOCKER_(6, constness, Method) \
Method).Invoke(::std::forward<GMOCK_ARG_(tn, 1, \
.Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
__VA_ARGS__)>(gmock_a1), \
gmock_a1), \
::std::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(gmock_a2), \
::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(gmock_a3), \
gmock_a2), \
::std::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(gmock_a4), \
::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(gmock_a5), \
gmock_a3), \
::std::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(gmock_a6)); \
::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
} \
gmock_a4), \
::testing::MockSpec<__VA_ARGS__> \
::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
gmock_a5), \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
::testing::internal::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>( \
GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
gmock_a6)); \
GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
} \
GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6) constness { \
GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
GMOCK_MOCKER_(6, constness, Method).RegisterOwner(this); \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
return GMOCK_MOCKER_(6, constness, Method).With(gmock_a1, gmock_a2, \
GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
} \
GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6) constness { \
const ::testing::internal::WithoutMatchers&, \
GMOCK_MOCKER_(6, constness, Method).RegisterOwner(this); \
constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
return GMOCK_MOCKER_(6, constness, Method) \
return ::testing::internal::AdjustConstness_##constness(this)-> \
.With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5, gmock_a6); \
gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
} \
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
const ::testing::internal::WithoutMatchers&, \
::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
constness ::testing::internal::Function<__VA_ARGS__>*) const { \
::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
return ::testing::internal::AdjustConstness_##constness(this) \
::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>()); \
->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
} \
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(6, constness, \
::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
Method)
::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>()); \
} \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(6, constness, \
Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD7_(tn, constness, ct, Method, ...) \
#define GMOCK_METHOD7_(tn, constness, ct, Method, ...) \
GMOCK_RESULT_(tn, __VA_ARGS__) \
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \
GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
__VA_ARGS__) gmock_a2, GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(tn, 5, \
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
__VA_ARGS__) gmock_a5, GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
GTEST_COMPILE_ASSERT_((::std::tuple_size< \
GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
GTEST_COMPILE_ASSERT_( \
== 7), \
(::testing::tuple_size<tn ::testing::internal::Function< \
this_method_does_not_take_7_arguments); \
__VA_ARGS__>::ArgumentTuple>::value == 7), \
GMOCK_MOCKER_(7, constness, Method).SetOwnerAndName(this, #Method); \
this_method_does_not_take_7_arguments); \
return GMOCK_MOCKER_(7, constness, \
GMOCK_MOCKER_(7, constness, Method).SetOwnerAndName(this, #Method); \
Method).Invoke(::std::forward<GMOCK_ARG_(tn, 1, \
return GMOCK_MOCKER_(7, constness, Method) \
__VA_ARGS__)>(gmock_a1), \
.Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(gmock_a2), \
gmock_a1), \
::std::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(gmock_a3), \
::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(gmock_a4), \
gmock_a2), \
::std::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(gmock_a5), \
::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(gmock_a6), \
gmock_a3), \
::std::forward<GMOCK_ARG_(tn, 7, __VA_ARGS__)>(gmock_a7)); \
::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
} \
gmock_a4), \
::testing::MockSpec<__VA_ARGS__> \
::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
gmock_a5), \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
::testing::internal::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>( \
GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
gmock_a6), \
GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
::testing::internal::forward<GMOCK_ARG_(tn, 7, __VA_ARGS__)>( \
GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
gmock_a7)); \
GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
} \
GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
GMOCK_MOCKER_(7, constness, Method).RegisterOwner(this); \
GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
return GMOCK_MOCKER_(7, constness, Method).With(gmock_a1, gmock_a2, \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \
GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
} \
GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
const ::testing::internal::WithoutMatchers&, \
GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7) constness { \
return ::testing::internal::AdjustConstness_##constness(this)-> \
GMOCK_MOCKER_(7, constness, Method).RegisterOwner(this); \
gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
return GMOCK_MOCKER_(7, constness, Method) \
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
.With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5, gmock_a6, \
::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
gmock_a7); \
::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
} \
::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(), \
const ::testing::internal::WithoutMatchers&, \
::testing::A<GMOCK_ARG_(tn, 7, __VA_ARGS__)>()); \
constness ::testing::internal::Function<__VA_ARGS__>*) const { \
} \
return ::testing::internal::AdjustConstness_##constness(this) \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(7, constness, \
->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
Method)
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 7, __VA_ARGS__)>()); \
} \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(7, constness, \
Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD8_(tn, constness, ct, Method, ...) \
#define GMOCK_METHOD8_(tn, constness, ct, Method, ...) \
GMOCK_RESULT_(tn, __VA_ARGS__) \
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \
GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
__VA_ARGS__) gmock_a2, GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(tn, 5, \
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
__VA_ARGS__) gmock_a5, GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, GMOCK_ARG_(tn, 8, \
GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
__VA_ARGS__) gmock_a8) constness { \
GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
GTEST_COMPILE_ASSERT_((::std::tuple_size< \
GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8) constness { \
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
GTEST_COMPILE_ASSERT_( \
== 8), \
(::testing::tuple_size<tn ::testing::internal::Function< \
this_method_does_not_take_8_arguments); \
__VA_ARGS__>::ArgumentTuple>::value == 8), \
GMOCK_MOCKER_(8, constness, Method).SetOwnerAndName(this, #Method); \
this_method_does_not_take_8_arguments); \
return GMOCK_MOCKER_(8, constness, \
GMOCK_MOCKER_(8, constness, Method).SetOwnerAndName(this, #Method); \
Method).Invoke(::std::forward<GMOCK_ARG_(tn, 1, \
return GMOCK_MOCKER_(8, constness, Method) \
__VA_ARGS__)>(gmock_a1), \
.Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(gmock_a2), \
gmock_a1), \
::std::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(gmock_a3), \
::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(gmock_a4), \
gmock_a2), \
::std::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(gmock_a5), \
::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(gmock_a6), \
gmock_a3), \
::std::forward<GMOCK_ARG_(tn, 7, __VA_ARGS__)>(gmock_a7), \
::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 8, __VA_ARGS__)>(gmock_a8)); \
gmock_a4), \
} \
::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
::testing::MockSpec<__VA_ARGS__> \
gmock_a5), \
gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
::testing::internal::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>( \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
gmock_a6), \
GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
::testing::internal::forward<GMOCK_ARG_(tn, 7, __VA_ARGS__)>( \
GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
gmock_a7), \
GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
::testing::internal::forward<GMOCK_ARG_(tn, 8, __VA_ARGS__)>( \
GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
gmock_a8)); \
GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
} \
GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8) constness { \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
GMOCK_MOCKER_(8, constness, Method).RegisterOwner(this); \
GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
return GMOCK_MOCKER_(8, constness, Method).With(gmock_a1, gmock_a2, \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \
GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
} \
GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
const ::testing::internal::WithoutMatchers&, \
GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
return ::testing::internal::AdjustConstness_##constness(this)-> \
GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8) constness { \
gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
GMOCK_MOCKER_(8, constness, Method).RegisterOwner(this); \
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
return GMOCK_MOCKER_(8, constness, Method) \
::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
.With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5, gmock_a6, \
::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
gmock_a7, gmock_a8); \
::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
} \
::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(), \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
::testing::A<GMOCK_ARG_(tn, 7, __VA_ARGS__)>(), \
const ::testing::internal::WithoutMatchers&, \
::testing::A<GMOCK_ARG_(tn, 8, __VA_ARGS__)>()); \
constness ::testing::internal::Function<__VA_ARGS__>*) const { \
} \
return ::testing::internal::AdjustConstness_##constness(this) \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(8, constness, \
->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
Method)
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 7, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 8, __VA_ARGS__)>()); \
} \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(8, constness, \
Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD9_(tn, constness, ct, Method, ...) \
#define GMOCK_METHOD9_(tn, constness, ct, Method, ...) \
GMOCK_RESULT_(tn, __VA_ARGS__) \
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \
GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
__VA_ARGS__) gmock_a2, GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(tn, 5, \
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
__VA_ARGS__) gmock_a5, GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, GMOCK_ARG_(tn, 8, \
GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
__VA_ARGS__) gmock_a8, GMOCK_ARG_(tn, 9, \
GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
__VA_ARGS__) gmock_a9) constness { \
GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \
GTEST_COMPILE_ASSERT_((::std::tuple_size< \
GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9) constness { \
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
GTEST_COMPILE_ASSERT_( \
== 9), \
(::testing::tuple_size<tn ::testing::internal::Function< \
this_method_does_not_take_9_arguments); \
__VA_ARGS__>::ArgumentTuple>::value == 9), \
GMOCK_MOCKER_(9, constness, Method).SetOwnerAndName(this, #Method); \
this_method_does_not_take_9_arguments); \
return GMOCK_MOCKER_(9, constness, \
GMOCK_MOCKER_(9, constness, Method).SetOwnerAndName(this, #Method); \
Method).Invoke(::std::forward<GMOCK_ARG_(tn, 1, \
return GMOCK_MOCKER_(9, constness, Method) \
__VA_ARGS__)>(gmock_a1), \
.Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(gmock_a2), \
gmock_a1), \
::std::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(gmock_a3), \
::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(gmock_a4), \
gmock_a2), \
::std::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(gmock_a5), \
::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(gmock_a6), \
gmock_a3), \
::std::forward<GMOCK_ARG_(tn, 7, __VA_ARGS__)>(gmock_a7), \
::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 8, __VA_ARGS__)>(gmock_a8), \
gmock_a4), \
::std::forward<GMOCK_ARG_(tn, 9, __VA_ARGS__)>(gmock_a9)); \
::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
} \
gmock_a5), \
::testing::MockSpec<__VA_ARGS__> \
::testing::internal::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>( \
gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
gmock_a6), \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
::testing::internal::forward<GMOCK_ARG_(tn, 7, __VA_ARGS__)>( \
GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
gmock_a7), \
GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
::testing::internal::forward<GMOCK_ARG_(tn, 8, __VA_ARGS__)>( \
GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
gmock_a8), \
GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
::testing::internal::forward<GMOCK_ARG_(tn, 9, __VA_ARGS__)>( \
GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
gmock_a9)); \
GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \
} \
GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9) constness { \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
GMOCK_MOCKER_(9, constness, Method).RegisterOwner(this); \
GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
return GMOCK_MOCKER_(9, constness, Method).With(gmock_a1, gmock_a2, \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \
GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
gmock_a9); \
GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
} \
GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
const ::testing::internal::WithoutMatchers&, \
GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \
return ::testing::internal::AdjustConstness_##constness(this)-> \
GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9) constness { \
gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
GMOCK_MOCKER_(9, constness, Method).RegisterOwner(this); \
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
return GMOCK_MOCKER_(9, constness, Method) \
::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
.With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5, gmock_a6, \
::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
gmock_a7, gmock_a8, gmock_a9); \
::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
} \
::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(), \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
::testing::A<GMOCK_ARG_(tn, 7, __VA_ARGS__)>(), \
const ::testing::internal::WithoutMatchers&, \
::testing::A<GMOCK_ARG_(tn, 8, __VA_ARGS__)>(), \
constness ::testing::internal::Function<__VA_ARGS__>*) const { \
::testing::A<GMOCK_ARG_(tn, 9, __VA_ARGS__)>()); \
return ::testing::internal::AdjustConstness_##constness(this) \
} \
->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(9, constness, \
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
Method)
::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 7, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 8, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 9, __VA_ARGS__)>()); \
} \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(9, constness, \
Method)
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
#define GMOCK_METHOD10_(tn, constness, ct, Method, ...) \
#define GMOCK_METHOD10_(tn, constness, ct, Method, ...) \
GMOCK_RESULT_(tn, __VA_ARGS__) \
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
ct Method(GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \
GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, GMOCK_ARG_(tn, 2, \
GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \
__VA_ARGS__) gmock_a2, GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, GMOCK_ARG_(tn, 5, \
GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \
__VA_ARGS__) gmock_a5, GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \
GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, GMOCK_ARG_(tn, 8, \
GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \
__VA_ARGS__) gmock_a8, GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9, \
GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \
GMOCK_ARG_(tn, 10, __VA_ARGS__) gmock_a10) constness { \
GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \
GTEST_COMPILE_ASSERT_((::std::tuple_size< \
GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9, \
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \
GMOCK_ARG_(tn, 10, __VA_ARGS__) gmock_a10) constness { \
== 10), \
GTEST_COMPILE_ASSERT_( \
this_method_does_not_take_10_arguments); \
(::testing::tuple_size<tn ::testing::internal::Function< \
GMOCK_MOCKER_(10, constness, Method).SetOwnerAndName(this, #Method); \
__VA_ARGS__>::ArgumentTuple>::value == 10), \
return GMOCK_MOCKER_(10, constness, \
this_method_does_not_take_10_arguments); \
Method).Invoke(::std::forward<GMOCK_ARG_(tn, 1, \
GMOCK_MOCKER_(10, constness, Method).SetOwnerAndName(this, #Method); \
__VA_ARGS__)>(gmock_a1), \
return GMOCK_MOCKER_(10, constness, Method) \
::std::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(gmock_a2), \
.Invoke(::testing::internal::forward<GMOCK_ARG_(tn, 1, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(gmock_a3), \
gmock_a1), \
::std::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(gmock_a4), \
::testing::internal::forward<GMOCK_ARG_(tn, 2, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(gmock_a5), \
gmock_a2), \
::std::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(gmock_a6), \
::testing::internal::forward<GMOCK_ARG_(tn, 3, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 7, __VA_ARGS__)>(gmock_a7), \
gmock_a3), \
::std::forward<GMOCK_ARG_(tn, 8, __VA_ARGS__)>(gmock_a8), \
::testing::internal::forward<GMOCK_ARG_(tn, 4, __VA_ARGS__)>( \
::std::forward<GMOCK_ARG_(tn, 9, __VA_ARGS__)>(gmock_a9), \
gmock_a4), \
::std::forward<GMOCK_ARG_(tn, 10, __VA_ARGS__)>(gmock_a10)); \
::testing::internal::forward<GMOCK_ARG_(tn, 5, __VA_ARGS__)>( \
} \
gmock_a5), \
::testing::MockSpec<__VA_ARGS__> \
::testing::internal::forward<GMOCK_ARG_(tn, 6, __VA_ARGS__)>( \
gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
gmock_a6), \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
::testing::internal::forward<GMOCK_ARG_(tn, 7, __VA_ARGS__)>( \
GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
gmock_a7), \
GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
::testing::internal::forward<GMOCK_ARG_(tn, 8, __VA_ARGS__)>( \
GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
gmock_a8), \
GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
::testing::internal::forward<GMOCK_ARG_(tn, 9, __VA_ARGS__)>( \
GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
gmock_a9), \
GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \
::testing::internal::forward<GMOCK_ARG_(tn, 10, __VA_ARGS__)>( \
GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9, \
gmock_a10)); \
GMOCK_MATCHER_(tn, 10, \
} \
__VA_ARGS__) gmock_a10) constness { \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
GMOCK_MOCKER_(10, constness, Method).RegisterOwner(this); \
GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \
return GMOCK_MOCKER_(10, constness, Method).With(gmock_a1, gmock_a2, \
GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \
gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \
GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \
gmock_a10); \
GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \
} \
GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \
const ::testing::internal::WithoutMatchers&, \
GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \
constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \
return ::testing::internal::AdjustConstness_##constness(this)-> \
GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9, \
gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
GMOCK_MATCHER_(tn, 10, __VA_ARGS__) gmock_a10) constness { \
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
GMOCK_MOCKER_(10, constness, Method).RegisterOwner(this); \
::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
return GMOCK_MOCKER_(10, constness, Method) \
::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
.With(gmock_a1, gmock_a2, gmock_a3, gmock_a4, gmock_a5, gmock_a6, \
::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
gmock_a7, gmock_a8, gmock_a9, gmock_a10); \
::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(), \
} \
::testing::A<GMOCK_ARG_(tn, 7, __VA_ARGS__)>(), \
::testing::MockSpec<__VA_ARGS__> gmock_##Method( \
::testing::A<GMOCK_ARG_(tn, 8, __VA_ARGS__)>(), \
const ::testing::internal::WithoutMatchers&, \
::testing::A<GMOCK_ARG_(tn, 9, __VA_ARGS__)>(), \
constness ::testing::internal::Function<__VA_ARGS__>*) const { \
::testing::A<GMOCK_ARG_(tn, 10, __VA_ARGS__)>()); \
return ::testing::internal::AdjustConstness_##constness(this) \
} \
->gmock_##Method(::testing::A<GMOCK_ARG_(tn, 1, __VA_ARGS__)>(), \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(10, constness, \
::testing::A<GMOCK_ARG_(tn, 2, __VA_ARGS__)>(), \
Method)
::testing::A<GMOCK_ARG_(tn, 3, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 4, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 5, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 6, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 7, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 8, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 9, __VA_ARGS__)>(), \
::testing::A<GMOCK_ARG_(tn, 10, __VA_ARGS__)>()); \
} \
mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(10, constness, \
Method)
#define MOCK_METHOD0(m, ...) GMOCK_METHOD0_(, , , m, __VA_ARGS__)
#define MOCK_METHOD0(m, ...) GMOCK_METHOD0_(, , , m, __VA_ARGS__)
#define MOCK_METHOD1(m, ...) GMOCK_METHOD1_(, , , m, __VA_ARGS__)
#define MOCK_METHOD1(m, ...) GMOCK_METHOD1_(, , , m, __VA_ARGS__)
...
@@ -1098,291 +758,6 @@ using internal::FunctionMocker;
...
@@ -1098,291 +758,6 @@ using internal::FunctionMocker;
#define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \
#define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \
GMOCK_METHOD10_(typename, const, ct, m, __VA_ARGS__)
GMOCK_METHOD10_(typename, const, ct, m, __VA_ARGS__)
// A MockFunction<F> class has one mock method whose type is F. It is
// useful when you just want your test code to emit some messages and
// have Google Mock verify the right messages are sent (and perhaps at
// the right times). For example, if you are exercising code:
//
// Foo(1);
// Foo(2);
// Foo(3);
//
// and want to verify that Foo(1) and Foo(3) both invoke
// mock.Bar("a"), but Foo(2) doesn't invoke anything, you can write:
//
// TEST(FooTest, InvokesBarCorrectly) {
// MyMock mock;
// MockFunction<void(string check_point_name)> check;
// {
// InSequence s;
//
// EXPECT_CALL(mock, Bar("a"));
// EXPECT_CALL(check, Call("1"));
// EXPECT_CALL(check, Call("2"));
// EXPECT_CALL(mock, Bar("a"));
// }
// Foo(1);
// check.Call("1");
// Foo(2);
// check.Call("2");
// Foo(3);
// }
//
// The expectation spec says that the first Bar("a") must happen
// before check point "1", the second Bar("a") must happen after check
// point "2", and nothing should happen between the two check
// points. The explicit check points make it easy to tell which
// Bar("a") is called by which call to Foo().
//
// MockFunction<F> can also be used to exercise code that accepts
// std::function<F> callbacks. To do so, use AsStdFunction() method
// to create std::function proxy forwarding to original object's Call.
// Example:
//
// TEST(FooTest, RunsCallbackWithBarArgument) {
// MockFunction<int(string)> callback;
// EXPECT_CALL(callback, Call("bar")).WillOnce(Return(1));
// Foo(callback.AsStdFunction());
// }
template
<
typename
F
>
class
MockFunction
;
template
<
typename
R
>
class
MockFunction
<
R
()
>
{
public:
MockFunction
()
{}
MOCK_METHOD0_T
(
Call
,
R
());
#if GTEST_HAS_STD_FUNCTION_
::
std
::
function
<
R
()
>
AsStdFunction
()
{
return
[
this
]()
->
R
{
return
this
->
Call
();
};
}
#endif // GTEST_HAS_STD_FUNCTION_
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MockFunction
);
};
template
<
typename
R
,
typename
A0
>
class
MockFunction
<
R
(
A0
)
>
{
public:
MockFunction
()
{}
MOCK_METHOD1_T
(
Call
,
R
(
A0
));
#if GTEST_HAS_STD_FUNCTION_
::
std
::
function
<
R
(
A0
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
)
->
R
{
return
this
->
Call
(
::
std
::
forward
<
A0
>
(
a0
));
};
}
#endif // GTEST_HAS_STD_FUNCTION_
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MockFunction
);
};
template
<
typename
R
,
typename
A0
,
typename
A1
>
class
MockFunction
<
R
(
A0
,
A1
)
>
{
public:
MockFunction
()
{}
MOCK_METHOD2_T
(
Call
,
R
(
A0
,
A1
));
#if GTEST_HAS_STD_FUNCTION_
::
std
::
function
<
R
(
A0
,
A1
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
)
->
R
{
return
this
->
Call
(
::
std
::
forward
<
A0
>
(
a0
),
::
std
::
forward
<
A1
>
(
a1
));
};
}
#endif // GTEST_HAS_STD_FUNCTION_
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MockFunction
);
};
template
<
typename
R
,
typename
A0
,
typename
A1
,
typename
A2
>
class
MockFunction
<
R
(
A0
,
A1
,
A2
)
>
{
public:
MockFunction
()
{}
MOCK_METHOD3_T
(
Call
,
R
(
A0
,
A1
,
A2
));
#if GTEST_HAS_STD_FUNCTION_
::
std
::
function
<
R
(
A0
,
A1
,
A2
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
)
->
R
{
return
this
->
Call
(
::
std
::
forward
<
A0
>
(
a0
),
::
std
::
forward
<
A1
>
(
a1
),
::
std
::
forward
<
A2
>
(
a2
));
};
}
#endif // GTEST_HAS_STD_FUNCTION_
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MockFunction
);
};
template
<
typename
R
,
typename
A0
,
typename
A1
,
typename
A2
,
typename
A3
>
class
MockFunction
<
R
(
A0
,
A1
,
A2
,
A3
)
>
{
public:
MockFunction
()
{}
MOCK_METHOD4_T
(
Call
,
R
(
A0
,
A1
,
A2
,
A3
));
#if GTEST_HAS_STD_FUNCTION_
::
std
::
function
<
R
(
A0
,
A1
,
A2
,
A3
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
)
->
R
{
return
this
->
Call
(
::
std
::
forward
<
A0
>
(
a0
),
::
std
::
forward
<
A1
>
(
a1
),
::
std
::
forward
<
A2
>
(
a2
),
::
std
::
forward
<
A3
>
(
a3
));
};
}
#endif // GTEST_HAS_STD_FUNCTION_
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MockFunction
);
};
template
<
typename
R
,
typename
A0
,
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
>
class
MockFunction
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
)
>
{
public:
MockFunction
()
{}
MOCK_METHOD5_T
(
Call
,
R
(
A0
,
A1
,
A2
,
A3
,
A4
));
#if GTEST_HAS_STD_FUNCTION_
::
std
::
function
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
)
->
R
{
return
this
->
Call
(
::
std
::
forward
<
A0
>
(
a0
),
::
std
::
forward
<
A1
>
(
a1
),
::
std
::
forward
<
A2
>
(
a2
),
::
std
::
forward
<
A3
>
(
a3
),
::
std
::
forward
<
A4
>
(
a4
));
};
}
#endif // GTEST_HAS_STD_FUNCTION_
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MockFunction
);
};
template
<
typename
R
,
typename
A0
,
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
>
class
MockFunction
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
)
>
{
public:
MockFunction
()
{}
MOCK_METHOD6_T
(
Call
,
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
));
#if GTEST_HAS_STD_FUNCTION_
::
std
::
function
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
)
->
R
{
return
this
->
Call
(
::
std
::
forward
<
A0
>
(
a0
),
::
std
::
forward
<
A1
>
(
a1
),
::
std
::
forward
<
A2
>
(
a2
),
::
std
::
forward
<
A3
>
(
a3
),
::
std
::
forward
<
A4
>
(
a4
),
::
std
::
forward
<
A5
>
(
a5
));
};
}
#endif // GTEST_HAS_STD_FUNCTION_
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MockFunction
);
};
template
<
typename
R
,
typename
A0
,
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
>
class
MockFunction
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
)
>
{
public:
MockFunction
()
{}
MOCK_METHOD7_T
(
Call
,
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
));
#if GTEST_HAS_STD_FUNCTION_
::
std
::
function
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
,
A6
a6
)
->
R
{
return
this
->
Call
(
::
std
::
forward
<
A0
>
(
a0
),
::
std
::
forward
<
A1
>
(
a1
),
::
std
::
forward
<
A2
>
(
a2
),
::
std
::
forward
<
A3
>
(
a3
),
::
std
::
forward
<
A4
>
(
a4
),
::
std
::
forward
<
A5
>
(
a5
),
::
std
::
forward
<
A6
>
(
a6
));
};
}
#endif // GTEST_HAS_STD_FUNCTION_
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MockFunction
);
};
template
<
typename
R
,
typename
A0
,
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
>
class
MockFunction
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
)
>
{
public:
MockFunction
()
{}
MOCK_METHOD8_T
(
Call
,
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
));
#if GTEST_HAS_STD_FUNCTION_
::
std
::
function
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
,
A6
a6
,
A7
a7
)
->
R
{
return
this
->
Call
(
::
std
::
forward
<
A0
>
(
a0
),
::
std
::
forward
<
A1
>
(
a1
),
::
std
::
forward
<
A2
>
(
a2
),
::
std
::
forward
<
A3
>
(
a3
),
::
std
::
forward
<
A4
>
(
a4
),
::
std
::
forward
<
A5
>
(
a5
),
::
std
::
forward
<
A6
>
(
a6
),
::
std
::
forward
<
A7
>
(
a7
));
};
}
#endif // GTEST_HAS_STD_FUNCTION_
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MockFunction
);
};
template
<
typename
R
,
typename
A0
,
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
>
class
MockFunction
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
)
>
{
public:
MockFunction
()
{}
MOCK_METHOD9_T
(
Call
,
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
));
#if GTEST_HAS_STD_FUNCTION_
::
std
::
function
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
,
A6
a6
,
A7
a7
,
A8
a8
)
->
R
{
return
this
->
Call
(
::
std
::
forward
<
A0
>
(
a0
),
::
std
::
forward
<
A1
>
(
a1
),
::
std
::
forward
<
A2
>
(
a2
),
::
std
::
forward
<
A3
>
(
a3
),
::
std
::
forward
<
A4
>
(
a4
),
::
std
::
forward
<
A5
>
(
a5
),
::
std
::
forward
<
A6
>
(
a6
),
::
std
::
forward
<
A7
>
(
a7
),
::
std
::
forward
<
A8
>
(
a8
));
};
}
#endif // GTEST_HAS_STD_FUNCTION_
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MockFunction
);
};
template
<
typename
R
,
typename
A0
,
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
,
typename
A9
>
class
MockFunction
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
)
>
{
public:
MockFunction
()
{}
MOCK_METHOD10_T
(
Call
,
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
));
#if GTEST_HAS_STD_FUNCTION_
::
std
::
function
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
,
A6
a6
,
A7
a7
,
A8
a8
,
A9
a9
)
->
R
{
return
this
->
Call
(
::
std
::
forward
<
A0
>
(
a0
),
::
std
::
forward
<
A1
>
(
a1
),
::
std
::
forward
<
A2
>
(
a2
),
::
std
::
forward
<
A3
>
(
a3
),
::
std
::
forward
<
A4
>
(
a4
),
::
std
::
forward
<
A5
>
(
a5
),
::
std
::
forward
<
A6
>
(
a6
),
::
std
::
forward
<
A7
>
(
a7
),
::
std
::
forward
<
A8
>
(
a8
),
::
std
::
forward
<
A9
>
(
a9
));
};
}
#endif // GTEST_HAS_STD_FUNCTION_
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MockFunction
);
};
}
// namespace testing
}
// namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
googlemock/include/gmock/gmock-generated-function-mockers.h.pump
View file @
25905b9f
...
@@ -42,59 +42,16 @@ $var n = 10 $$ The maximum arity we support.
...
@@ -42,59 +42,16 @@ $var n = 10 $$ The maximum arity we support.
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
#include <functional>
#include <utility>
#include "gmock/gmock-spec-builders.h"
#include "gmock/gmock-spec-builders.h"
#include "gmock/internal/gmock-internal-utils.h"
#include "gmock/internal/gmock-internal-utils.h"
#if GTEST_HAS_STD_FUNCTION_
# include <functional>
#endif
namespace
testing
{
namespace
testing
{
namespace
internal
{
namespace
internal
{
template
<
typename
F
>
class
FunctionMockerBase
;
// Note: class FunctionMocker really belongs to the ::testing
// namespace. However if we define it in ::testing, MSVC will
// complain when classes in ::testing::internal declare it as a
// friend class template. To workaround this compiler bug, we define
// FunctionMocker in ::testing::internal and import it into ::testing.
template
<
typename
F
>
class
FunctionMocker
;
$
range
i
0.
.
n
$
range
i
0.
.
n
$
for
i
[[
$
range
j
1.
.
i
$
var
typename_As
=
[[
$
for
j
[[,
typename
A
$
j
]]]]
$
var
As
=
[[
$
for
j
,
[[
A
$
j
]]]]
$
var
as
=
[[
$
for
j
,
[[
internal
::
forward
<
A
$
j
>
(
a
$
j
)]]]]
$
var
Aas
=
[[
$
for
j
,
[[
A
$
j
a
$
j
]]]]
$
var
ms
=
[[
$
for
j
,
[[
m
$
j
]]]]
$
var
matchers
=
[[
$
for
j
,
[[
const
Matcher
<
A
$
j
>&
m
$
j
]]]]
template
<
typename
R
$
typename_As
>
class
FunctionMocker
<
R
(
$
As
)
>
:
public
internal
::
FunctionMockerBase
<
R
(
$
As
)
>
{
public:
typedef
R
F
(
$
As
);
typedef
typename
internal
::
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
MockSpec
<
F
>
With
(
$
matchers
)
{
return
MockSpec
<
F
>
(
this
,
::
testing
::
make_tuple
(
$
ms
));
}
R
Invoke
(
$
Aas
)
{
// Even though gcc and MSVC don't enforce it, 'this->' is required
// by the C++ standard [14.6.4] here, as the base class type is
// dependent on the template argument (and thus shouldn't be
// looked into when resolving InvokeWith).
return
this
->
InvokeWith
(
ArgumentTuple
(
$
as
));
}
};
]]
// Removes the given pointer; this is a helper for the expectation setter method
// Removes the given pointer; this is a helper for the expectation setter method
// for parameterless matchers.
// for parameterless matchers.
//
//
...
@@ -184,7 +141,7 @@ $for i [[
...
@@ -184,7 +141,7 @@ $for i [[
$
range
j
1.
.
i
$
range
j
1.
.
i
$
var
arg_as
=
[[
$
for
j
,
[[
GMOCK_ARG_
(
tn
,
$
j
,
__VA_ARGS__
)
gmock_a
$
j
]]]]
$
var
arg_as
=
[[
$
for
j
,
[[
GMOCK_ARG_
(
tn
,
$
j
,
__VA_ARGS__
)
gmock_a
$
j
]]]]
$
var
as
=
[[
$
for
j
,
\
$
var
as
=
[[
$
for
j
,
\
[[
::
testing
::
internal
::
forward
<
GMOCK_ARG_
(
tn
,
$
j
,
__VA_ARGS__
)
>
(
gmock_a
$
j
)]]]]
[[
::
std
::
forward
<
GMOCK_ARG_
(
tn
,
$
j
,
__VA_ARGS__
)
>
(
gmock_a
$
j
)]]]]
$
var
matcher_arg_as
=
[[
$
for
j
,
\
$
var
matcher_arg_as
=
[[
$
for
j
,
\
[[
GMOCK_MATCHER_
(
tn
,
$
j
,
__VA_ARGS__
)
gmock_a
$
j
]]]]
[[
GMOCK_MATCHER_
(
tn
,
$
j
,
__VA_ARGS__
)
gmock_a
$
j
]]]]
$
var
matcher_as
=
[[
$
for
j
,
[[
gmock_a
$
j
]]]]
$
var
matcher_as
=
[[
$
for
j
,
[[
gmock_a
$
j
]]]]
...
@@ -194,7 +151,7 @@ $var anything_matchers = [[$for j, \
...
@@ -194,7 +151,7 @@ $var anything_matchers = [[$for j, \
#define GMOCK_METHOD$i[[]]_(tn, constness, ct, Method, ...) \
#define GMOCK_METHOD$i[[]]_(tn, constness, ct, Method, ...) \
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
$arg_as) constness { \
$arg_as) constness { \
GTEST_COMPILE_ASSERT_((::
testing
::tuple_size< \
GTEST_COMPILE_ASSERT_((::
std
::tuple_size< \
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value == $i), \
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value == $i), \
this_method_does_not_take_$i[[]]_argument[[$if i != 1 [[s]]]]); \
this_method_does_not_take_$i[[]]_argument[[$if i != 1 [[s]]]]); \
GMOCK_MOCKER_($i, constness, Method).SetOwnerAndName(this, #Method); \
GMOCK_MOCKER_($i, constness, Method).SetOwnerAndName(this, #Method); \
...
@@ -267,82 +224,6 @@ $for i [[
...
@@ -267,82 +224,6 @@ $for i [[
]]
]]
// A MockFunction<F> class has one mock method whose type is F. It is
// useful when you just want your test code to emit some messages and
// have Google Mock verify the right messages are sent (and perhaps at
// the right times). For example, if you are exercising code:
//
// Foo(1);
// Foo(2);
// Foo(3);
//
// and want to verify that Foo(1) and Foo(3) both invoke
// mock.Bar("a"), but Foo(2) doesn't invoke anything, you can write:
//
// TEST(FooTest, InvokesBarCorrectly) {
// MyMock mock;
// MockFunction<void(string check_point_name)> check;
// {
// InSequence s;
//
// EXPECT_CALL(mock, Bar("a"));
// EXPECT_CALL(check, Call("1"));
// EXPECT_CALL(check, Call("2"));
// EXPECT_CALL(mock, Bar("a"));
// }
// Foo(1);
// check.Call("1");
// Foo(2);
// check.Call("2");
// Foo(3);
// }
//
// The expectation spec says that the first Bar("a") must happen
// before check point "1", the second Bar("a") must happen after check
// point "2", and nothing should happen between the two check
// points. The explicit check points make it easy to tell which
// Bar("a") is called by which call to Foo().
//
// MockFunction<F> can also be used to exercise code that accepts
// std::function<F> callbacks. To do so, use AsStdFunction() method
// to create std::function proxy forwarding to original object's Call.
// Example:
//
// TEST(FooTest, RunsCallbackWithBarArgument) {
// MockFunction<int(string)> callback;
// EXPECT_CALL(callback, Call("bar")).WillOnce(Return(1));
// Foo(callback.AsStdFunction());
// }
template
<
typename
F
>
class
MockFunction
;
$
for
i
[[
$
range
j
0.
.
i
-
1
$
var
ArgTypes
=
[[
$
for
j
,
[[
A
$
j
]]]]
$
var
ArgValues
=
[[
$
for
j
,
[[
::
std
::
forward
<
A
$
j
>
(
a
$
j
)]]]]
$
var
ArgDecls
=
[[
$
for
j
,
[[
A
$
j
a
$
j
]]]]
template
<
typename
R
$
for
j
[[,
typename
A
$
j
]]>
class
MockFunction
<
R
(
$
ArgTypes
)
>
{
public:
MockFunction
()
{}
MOCK_METHOD
$
i
[[]]
_T
(
Call
,
R
(
$
ArgTypes
));
#if GTEST_HAS_STD_FUNCTION_
::
std
::
function
<
R
(
$
ArgTypes
)
>
AsStdFunction
()
{
return
[
this
](
$
ArgDecls
)
->
R
{
return
this
->
Call
(
$
ArgValues
);
};
}
#endif // GTEST_HAS_STD_FUNCTION_
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MockFunction
);
};
]]
}
// namespace testing
}
// namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
googlemock/include/gmock/gmock-generated-matchers.h
View file @
25905b9f
...
@@ -43,515 +43,10 @@
...
@@ -43,515 +43,10 @@
#include <iterator>
#include <iterator>
#include <sstream>
#include <sstream>
#include <string>
#include <string>
#include <utility>
#include <vector>
#include <vector>
#include "gmock/gmock-matchers.h"
#include "gmock/gmock-matchers.h"
namespace
testing
{
namespace
internal
{
// The type of the i-th (0-based) field of Tuple.
#define GMOCK_FIELD_TYPE_(Tuple, i) \
typename ::testing::tuple_element<i, Tuple>::type
// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
// tuple of type Tuple. It has two members:
//
// type: a tuple type whose i-th field is the ki-th field of Tuple.
// GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
//
// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
//
// type is tuple<int, bool>, and
// GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
template
<
class
Tuple
,
int
k0
=
-
1
,
int
k1
=
-
1
,
int
k2
=
-
1
,
int
k3
=
-
1
,
int
k4
=
-
1
,
int
k5
=
-
1
,
int
k6
=
-
1
,
int
k7
=
-
1
,
int
k8
=
-
1
,
int
k9
=
-
1
>
class
TupleFields
;
// This generic version is used when there are 10 selectors.
template
<
class
Tuple
,
int
k0
,
int
k1
,
int
k2
,
int
k3
,
int
k4
,
int
k5
,
int
k6
,
int
k7
,
int
k8
,
int
k9
>
class
TupleFields
{
public:
typedef
::
testing
::
tuple
<
GMOCK_FIELD_TYPE_
(
Tuple
,
k0
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k1
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k2
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k3
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k4
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k5
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k6
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k7
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k8
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k9
)
>
type
;
static
type
GetSelectedFields
(
const
Tuple
&
t
)
{
return
type
(
get
<
k0
>
(
t
),
get
<
k1
>
(
t
),
get
<
k2
>
(
t
),
get
<
k3
>
(
t
),
get
<
k4
>
(
t
),
get
<
k5
>
(
t
),
get
<
k6
>
(
t
),
get
<
k7
>
(
t
),
get
<
k8
>
(
t
),
get
<
k9
>
(
t
));
}
};
// The following specialization is used for 0 ~ 9 selectors.
template
<
class
Tuple
>
class
TupleFields
<
Tuple
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
>
{
public:
typedef
::
testing
::
tuple
<>
type
;
static
type
GetSelectedFields
(
const
Tuple
&
/* t */
)
{
return
type
();
}
};
template
<
class
Tuple
,
int
k0
>
class
TupleFields
<
Tuple
,
k0
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
>
{
public:
typedef
::
testing
::
tuple
<
GMOCK_FIELD_TYPE_
(
Tuple
,
k0
)
>
type
;
static
type
GetSelectedFields
(
const
Tuple
&
t
)
{
return
type
(
get
<
k0
>
(
t
));
}
};
template
<
class
Tuple
,
int
k0
,
int
k1
>
class
TupleFields
<
Tuple
,
k0
,
k1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
>
{
public:
typedef
::
testing
::
tuple
<
GMOCK_FIELD_TYPE_
(
Tuple
,
k0
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k1
)
>
type
;
static
type
GetSelectedFields
(
const
Tuple
&
t
)
{
return
type
(
get
<
k0
>
(
t
),
get
<
k1
>
(
t
));
}
};
template
<
class
Tuple
,
int
k0
,
int
k1
,
int
k2
>
class
TupleFields
<
Tuple
,
k0
,
k1
,
k2
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
>
{
public:
typedef
::
testing
::
tuple
<
GMOCK_FIELD_TYPE_
(
Tuple
,
k0
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k1
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k2
)
>
type
;
static
type
GetSelectedFields
(
const
Tuple
&
t
)
{
return
type
(
get
<
k0
>
(
t
),
get
<
k1
>
(
t
),
get
<
k2
>
(
t
));
}
};
template
<
class
Tuple
,
int
k0
,
int
k1
,
int
k2
,
int
k3
>
class
TupleFields
<
Tuple
,
k0
,
k1
,
k2
,
k3
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
>
{
public:
typedef
::
testing
::
tuple
<
GMOCK_FIELD_TYPE_
(
Tuple
,
k0
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k1
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k2
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k3
)
>
type
;
static
type
GetSelectedFields
(
const
Tuple
&
t
)
{
return
type
(
get
<
k0
>
(
t
),
get
<
k1
>
(
t
),
get
<
k2
>
(
t
),
get
<
k3
>
(
t
));
}
};
template
<
class
Tuple
,
int
k0
,
int
k1
,
int
k2
,
int
k3
,
int
k4
>
class
TupleFields
<
Tuple
,
k0
,
k1
,
k2
,
k3
,
k4
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
>
{
public:
typedef
::
testing
::
tuple
<
GMOCK_FIELD_TYPE_
(
Tuple
,
k0
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k1
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k2
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k3
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k4
)
>
type
;
static
type
GetSelectedFields
(
const
Tuple
&
t
)
{
return
type
(
get
<
k0
>
(
t
),
get
<
k1
>
(
t
),
get
<
k2
>
(
t
),
get
<
k3
>
(
t
),
get
<
k4
>
(
t
));
}
};
template
<
class
Tuple
,
int
k0
,
int
k1
,
int
k2
,
int
k3
,
int
k4
,
int
k5
>
class
TupleFields
<
Tuple
,
k0
,
k1
,
k2
,
k3
,
k4
,
k5
,
-
1
,
-
1
,
-
1
,
-
1
>
{
public:
typedef
::
testing
::
tuple
<
GMOCK_FIELD_TYPE_
(
Tuple
,
k0
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k1
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k2
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k3
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k4
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k5
)
>
type
;
static
type
GetSelectedFields
(
const
Tuple
&
t
)
{
return
type
(
get
<
k0
>
(
t
),
get
<
k1
>
(
t
),
get
<
k2
>
(
t
),
get
<
k3
>
(
t
),
get
<
k4
>
(
t
),
get
<
k5
>
(
t
));
}
};
template
<
class
Tuple
,
int
k0
,
int
k1
,
int
k2
,
int
k3
,
int
k4
,
int
k5
,
int
k6
>
class
TupleFields
<
Tuple
,
k0
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
,
-
1
,
-
1
,
-
1
>
{
public:
typedef
::
testing
::
tuple
<
GMOCK_FIELD_TYPE_
(
Tuple
,
k0
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k1
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k2
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k3
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k4
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k5
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k6
)
>
type
;
static
type
GetSelectedFields
(
const
Tuple
&
t
)
{
return
type
(
get
<
k0
>
(
t
),
get
<
k1
>
(
t
),
get
<
k2
>
(
t
),
get
<
k3
>
(
t
),
get
<
k4
>
(
t
),
get
<
k5
>
(
t
),
get
<
k6
>
(
t
));
}
};
template
<
class
Tuple
,
int
k0
,
int
k1
,
int
k2
,
int
k3
,
int
k4
,
int
k5
,
int
k6
,
int
k7
>
class
TupleFields
<
Tuple
,
k0
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
,
k7
,
-
1
,
-
1
>
{
public:
typedef
::
testing
::
tuple
<
GMOCK_FIELD_TYPE_
(
Tuple
,
k0
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k1
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k2
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k3
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k4
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k5
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k6
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k7
)
>
type
;
static
type
GetSelectedFields
(
const
Tuple
&
t
)
{
return
type
(
get
<
k0
>
(
t
),
get
<
k1
>
(
t
),
get
<
k2
>
(
t
),
get
<
k3
>
(
t
),
get
<
k4
>
(
t
),
get
<
k5
>
(
t
),
get
<
k6
>
(
t
),
get
<
k7
>
(
t
));
}
};
template
<
class
Tuple
,
int
k0
,
int
k1
,
int
k2
,
int
k3
,
int
k4
,
int
k5
,
int
k6
,
int
k7
,
int
k8
>
class
TupleFields
<
Tuple
,
k0
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
,
k7
,
k8
,
-
1
>
{
public:
typedef
::
testing
::
tuple
<
GMOCK_FIELD_TYPE_
(
Tuple
,
k0
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k1
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k2
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k3
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k4
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k5
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k6
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k7
),
GMOCK_FIELD_TYPE_
(
Tuple
,
k8
)
>
type
;
static
type
GetSelectedFields
(
const
Tuple
&
t
)
{
return
type
(
get
<
k0
>
(
t
),
get
<
k1
>
(
t
),
get
<
k2
>
(
t
),
get
<
k3
>
(
t
),
get
<
k4
>
(
t
),
get
<
k5
>
(
t
),
get
<
k6
>
(
t
),
get
<
k7
>
(
t
),
get
<
k8
>
(
t
));
}
};
#undef GMOCK_FIELD_TYPE_
// Implements the Args() matcher.
template
<
class
ArgsTuple
,
int
k0
=
-
1
,
int
k1
=
-
1
,
int
k2
=
-
1
,
int
k3
=
-
1
,
int
k4
=
-
1
,
int
k5
=
-
1
,
int
k6
=
-
1
,
int
k7
=
-
1
,
int
k8
=
-
1
,
int
k9
=
-
1
>
class
ArgsMatcherImpl
:
public
MatcherInterface
<
ArgsTuple
>
{
public:
// ArgsTuple may have top-level const or reference modifiers.
typedef
GTEST_REMOVE_REFERENCE_AND_CONST_
(
ArgsTuple
)
RawArgsTuple
;
typedef
typename
internal
::
TupleFields
<
RawArgsTuple
,
k0
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
,
k7
,
k8
,
k9
>::
type
SelectedArgs
;
typedef
Matcher
<
const
SelectedArgs
&>
MonomorphicInnerMatcher
;
template
<
typename
InnerMatcher
>
explicit
ArgsMatcherImpl
(
const
InnerMatcher
&
inner_matcher
)
:
inner_matcher_
(
SafeMatcherCast
<
const
SelectedArgs
&>
(
inner_matcher
))
{}
virtual
bool
MatchAndExplain
(
ArgsTuple
args
,
MatchResultListener
*
listener
)
const
{
const
SelectedArgs
&
selected_args
=
GetSelectedArgs
(
args
);
if
(
!
listener
->
IsInterested
())
return
inner_matcher_
.
Matches
(
selected_args
);
PrintIndices
(
listener
->
stream
());
*
listener
<<
"are "
<<
PrintToString
(
selected_args
);
StringMatchResultListener
inner_listener
;
const
bool
match
=
inner_matcher_
.
MatchAndExplain
(
selected_args
,
&
inner_listener
);
PrintIfNotEmpty
(
inner_listener
.
str
(),
listener
->
stream
());
return
match
;
}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"are a tuple "
;
PrintIndices
(
os
);
inner_matcher_
.
DescribeTo
(
os
);
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"are a tuple "
;
PrintIndices
(
os
);
inner_matcher_
.
DescribeNegationTo
(
os
);
}
private:
static
SelectedArgs
GetSelectedArgs
(
ArgsTuple
args
)
{
return
TupleFields
<
RawArgsTuple
,
k0
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
,
k7
,
k8
,
k9
>::
GetSelectedFields
(
args
);
}
// Prints the indices of the selected fields.
static
void
PrintIndices
(
::
std
::
ostream
*
os
)
{
*
os
<<
"whose fields ("
;
const
int
indices
[
10
]
=
{
k0
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
,
k7
,
k8
,
k9
};
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
if
(
indices
[
i
]
<
0
)
break
;
if
(
i
>=
1
)
*
os
<<
", "
;
*
os
<<
"#"
<<
indices
[
i
];
}
*
os
<<
") "
;
}
const
MonomorphicInnerMatcher
inner_matcher_
;
GTEST_DISALLOW_ASSIGN_
(
ArgsMatcherImpl
);
};
template
<
class
InnerMatcher
,
int
k0
=
-
1
,
int
k1
=
-
1
,
int
k2
=
-
1
,
int
k3
=
-
1
,
int
k4
=
-
1
,
int
k5
=
-
1
,
int
k6
=
-
1
,
int
k7
=
-
1
,
int
k8
=
-
1
,
int
k9
=
-
1
>
class
ArgsMatcher
{
public:
explicit
ArgsMatcher
(
const
InnerMatcher
&
inner_matcher
)
:
inner_matcher_
(
inner_matcher
)
{}
template
<
typename
ArgsTuple
>
operator
Matcher
<
ArgsTuple
>
()
const
{
return
MakeMatcher
(
new
ArgsMatcherImpl
<
ArgsTuple
,
k0
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
,
k7
,
k8
,
k9
>
(
inner_matcher_
));
}
private:
const
InnerMatcher
inner_matcher_
;
GTEST_DISALLOW_ASSIGN_
(
ArgsMatcher
);
};
// A set of metafunctions for computing the result type of AnyOf.
// AnyOf(m1, ..., mN) returns
// AnyOfResultN<decltype(m1), ..., decltype(mN)>::type.
// Although AnyOf isn't defined for one argument, AnyOfResult1 is defined
// to simplify the implementation.
template
<
typename
M1
>
struct
AnyOfResult1
{
typedef
M1
type
;
};
template
<
typename
M1
,
typename
M2
>
struct
AnyOfResult2
{
typedef
EitherOfMatcher
<
typename
AnyOfResult1
<
M1
>::
type
,
typename
AnyOfResult1
<
M2
>::
type
>
type
;
};
template
<
typename
M1
,
typename
M2
,
typename
M3
>
struct
AnyOfResult3
{
typedef
EitherOfMatcher
<
typename
AnyOfResult1
<
M1
>::
type
,
typename
AnyOfResult2
<
M2
,
M3
>::
type
>
type
;
};
template
<
typename
M1
,
typename
M2
,
typename
M3
,
typename
M4
>
struct
AnyOfResult4
{
typedef
EitherOfMatcher
<
typename
AnyOfResult2
<
M1
,
M2
>::
type
,
typename
AnyOfResult2
<
M3
,
M4
>::
type
>
type
;
};
template
<
typename
M1
,
typename
M2
,
typename
M3
,
typename
M4
,
typename
M5
>
struct
AnyOfResult5
{
typedef
EitherOfMatcher
<
typename
AnyOfResult2
<
M1
,
M2
>::
type
,
typename
AnyOfResult3
<
M3
,
M4
,
M5
>::
type
>
type
;
};
template
<
typename
M1
,
typename
M2
,
typename
M3
,
typename
M4
,
typename
M5
,
typename
M6
>
struct
AnyOfResult6
{
typedef
EitherOfMatcher
<
typename
AnyOfResult3
<
M1
,
M2
,
M3
>::
type
,
typename
AnyOfResult3
<
M4
,
M5
,
M6
>::
type
>
type
;
};
template
<
typename
M1
,
typename
M2
,
typename
M3
,
typename
M4
,
typename
M5
,
typename
M6
,
typename
M7
>
struct
AnyOfResult7
{
typedef
EitherOfMatcher
<
typename
AnyOfResult3
<
M1
,
M2
,
M3
>::
type
,
typename
AnyOfResult4
<
M4
,
M5
,
M6
,
M7
>::
type
>
type
;
};
template
<
typename
M1
,
typename
M2
,
typename
M3
,
typename
M4
,
typename
M5
,
typename
M6
,
typename
M7
,
typename
M8
>
struct
AnyOfResult8
{
typedef
EitherOfMatcher
<
typename
AnyOfResult4
<
M1
,
M2
,
M3
,
M4
>::
type
,
typename
AnyOfResult4
<
M5
,
M6
,
M7
,
M8
>::
type
>
type
;
};
template
<
typename
M1
,
typename
M2
,
typename
M3
,
typename
M4
,
typename
M5
,
typename
M6
,
typename
M7
,
typename
M8
,
typename
M9
>
struct
AnyOfResult9
{
typedef
EitherOfMatcher
<
typename
AnyOfResult4
<
M1
,
M2
,
M3
,
M4
>::
type
,
typename
AnyOfResult5
<
M5
,
M6
,
M7
,
M8
,
M9
>::
type
>
type
;
};
template
<
typename
M1
,
typename
M2
,
typename
M3
,
typename
M4
,
typename
M5
,
typename
M6
,
typename
M7
,
typename
M8
,
typename
M9
,
typename
M10
>
struct
AnyOfResult10
{
typedef
EitherOfMatcher
<
typename
AnyOfResult5
<
M1
,
M2
,
M3
,
M4
,
M5
>::
type
,
typename
AnyOfResult5
<
M6
,
M7
,
M8
,
M9
,
M10
>::
type
>
type
;
};
}
// namespace internal
// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
// fields of it matches a_matcher. C++ doesn't support default
// arguments for function templates, so we have to overload it.
template
<
typename
InnerMatcher
>
inline
internal
::
ArgsMatcher
<
InnerMatcher
>
Args
(
const
InnerMatcher
&
matcher
)
{
return
internal
::
ArgsMatcher
<
InnerMatcher
>
(
matcher
);
}
template
<
int
k1
,
typename
InnerMatcher
>
inline
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
>
Args
(
const
InnerMatcher
&
matcher
)
{
return
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
>
(
matcher
);
}
template
<
int
k1
,
int
k2
,
typename
InnerMatcher
>
inline
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
>
Args
(
const
InnerMatcher
&
matcher
)
{
return
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
>
(
matcher
);
}
template
<
int
k1
,
int
k2
,
int
k3
,
typename
InnerMatcher
>
inline
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
,
k3
>
Args
(
const
InnerMatcher
&
matcher
)
{
return
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
,
k3
>
(
matcher
);
}
template
<
int
k1
,
int
k2
,
int
k3
,
int
k4
,
typename
InnerMatcher
>
inline
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
,
k3
,
k4
>
Args
(
const
InnerMatcher
&
matcher
)
{
return
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
,
k3
,
k4
>
(
matcher
);
}
template
<
int
k1
,
int
k2
,
int
k3
,
int
k4
,
int
k5
,
typename
InnerMatcher
>
inline
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
,
k3
,
k4
,
k5
>
Args
(
const
InnerMatcher
&
matcher
)
{
return
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
,
k3
,
k4
,
k5
>
(
matcher
);
}
template
<
int
k1
,
int
k2
,
int
k3
,
int
k4
,
int
k5
,
int
k6
,
typename
InnerMatcher
>
inline
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
>
Args
(
const
InnerMatcher
&
matcher
)
{
return
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
>
(
matcher
);
}
template
<
int
k1
,
int
k2
,
int
k3
,
int
k4
,
int
k5
,
int
k6
,
int
k7
,
typename
InnerMatcher
>
inline
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
,
k7
>
Args
(
const
InnerMatcher
&
matcher
)
{
return
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
,
k7
>
(
matcher
);
}
template
<
int
k1
,
int
k2
,
int
k3
,
int
k4
,
int
k5
,
int
k6
,
int
k7
,
int
k8
,
typename
InnerMatcher
>
inline
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
,
k7
,
k8
>
Args
(
const
InnerMatcher
&
matcher
)
{
return
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
,
k7
,
k8
>
(
matcher
);
}
template
<
int
k1
,
int
k2
,
int
k3
,
int
k4
,
int
k5
,
int
k6
,
int
k7
,
int
k8
,
int
k9
,
typename
InnerMatcher
>
inline
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
,
k7
,
k8
,
k9
>
Args
(
const
InnerMatcher
&
matcher
)
{
return
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
,
k7
,
k8
,
k9
>
(
matcher
);
}
template
<
int
k1
,
int
k2
,
int
k3
,
int
k4
,
int
k5
,
int
k6
,
int
k7
,
int
k8
,
int
k9
,
int
k10
,
typename
InnerMatcher
>
inline
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
,
k7
,
k8
,
k9
,
k10
>
Args
(
const
InnerMatcher
&
matcher
)
{
return
internal
::
ArgsMatcher
<
InnerMatcher
,
k1
,
k2
,
k3
,
k4
,
k5
,
k6
,
k7
,
k8
,
k9
,
k10
>
(
matcher
);
}
// AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
// sub-matchers. AnyOf is called fully qualified to prevent ADL from firing.
template
<
typename
M1
,
typename
M2
>
inline
typename
internal
::
AnyOfResult2
<
M1
,
M2
>::
type
AnyOf
(
M1
m1
,
M2
m2
)
{
return
typename
internal
::
AnyOfResult2
<
M1
,
M2
>::
type
(
m1
,
m2
);
}
template
<
typename
M1
,
typename
M2
,
typename
M3
>
inline
typename
internal
::
AnyOfResult3
<
M1
,
M2
,
M3
>::
type
AnyOf
(
M1
m1
,
M2
m2
,
M3
m3
)
{
return
typename
internal
::
AnyOfResult3
<
M1
,
M2
,
M3
>::
type
(
m1
,
::
testing
::
AnyOf
(
m2
,
m3
));
}
template
<
typename
M1
,
typename
M2
,
typename
M3
,
typename
M4
>
inline
typename
internal
::
AnyOfResult4
<
M1
,
M2
,
M3
,
M4
>::
type
AnyOf
(
M1
m1
,
M2
m2
,
M3
m3
,
M4
m4
)
{
return
typename
internal
::
AnyOfResult4
<
M1
,
M2
,
M3
,
M4
>::
type
(
::
testing
::
AnyOf
(
m1
,
m2
),
::
testing
::
AnyOf
(
m3
,
m4
));
}
template
<
typename
M1
,
typename
M2
,
typename
M3
,
typename
M4
,
typename
M5
>
inline
typename
internal
::
AnyOfResult5
<
M1
,
M2
,
M3
,
M4
,
M5
>::
type
AnyOf
(
M1
m1
,
M2
m2
,
M3
m3
,
M4
m4
,
M5
m5
)
{
return
typename
internal
::
AnyOfResult5
<
M1
,
M2
,
M3
,
M4
,
M5
>::
type
(
::
testing
::
AnyOf
(
m1
,
m2
),
::
testing
::
AnyOf
(
m3
,
m4
,
m5
));
}
template
<
typename
M1
,
typename
M2
,
typename
M3
,
typename
M4
,
typename
M5
,
typename
M6
>
inline
typename
internal
::
AnyOfResult6
<
M1
,
M2
,
M3
,
M4
,
M5
,
M6
>::
type
AnyOf
(
M1
m1
,
M2
m2
,
M3
m3
,
M4
m4
,
M5
m5
,
M6
m6
)
{
return
typename
internal
::
AnyOfResult6
<
M1
,
M2
,
M3
,
M4
,
M5
,
M6
>::
type
(
::
testing
::
AnyOf
(
m1
,
m2
,
m3
),
::
testing
::
AnyOf
(
m4
,
m5
,
m6
));
}
template
<
typename
M1
,
typename
M2
,
typename
M3
,
typename
M4
,
typename
M5
,
typename
M6
,
typename
M7
>
inline
typename
internal
::
AnyOfResult7
<
M1
,
M2
,
M3
,
M4
,
M5
,
M6
,
M7
>::
type
AnyOf
(
M1
m1
,
M2
m2
,
M3
m3
,
M4
m4
,
M5
m5
,
M6
m6
,
M7
m7
)
{
return
typename
internal
::
AnyOfResult7
<
M1
,
M2
,
M3
,
M4
,
M5
,
M6
,
M7
>::
type
(
::
testing
::
AnyOf
(
m1
,
m2
,
m3
),
::
testing
::
AnyOf
(
m4
,
m5
,
m6
,
m7
));
}
template
<
typename
M1
,
typename
M2
,
typename
M3
,
typename
M4
,
typename
M5
,
typename
M6
,
typename
M7
,
typename
M8
>
inline
typename
internal
::
AnyOfResult8
<
M1
,
M2
,
M3
,
M4
,
M5
,
M6
,
M7
,
M8
>::
type
AnyOf
(
M1
m1
,
M2
m2
,
M3
m3
,
M4
m4
,
M5
m5
,
M6
m6
,
M7
m7
,
M8
m8
)
{
return
typename
internal
::
AnyOfResult8
<
M1
,
M2
,
M3
,
M4
,
M5
,
M6
,
M7
,
M8
>::
type
(
::
testing
::
AnyOf
(
m1
,
m2
,
m3
,
m4
),
::
testing
::
AnyOf
(
m5
,
m6
,
m7
,
m8
));
}
template
<
typename
M1
,
typename
M2
,
typename
M3
,
typename
M4
,
typename
M5
,
typename
M6
,
typename
M7
,
typename
M8
,
typename
M9
>
inline
typename
internal
::
AnyOfResult9
<
M1
,
M2
,
M3
,
M4
,
M5
,
M6
,
M7
,
M8
,
M9
>::
type
AnyOf
(
M1
m1
,
M2
m2
,
M3
m3
,
M4
m4
,
M5
m5
,
M6
m6
,
M7
m7
,
M8
m8
,
M9
m9
)
{
return
typename
internal
::
AnyOfResult9
<
M1
,
M2
,
M3
,
M4
,
M5
,
M6
,
M7
,
M8
,
M9
>::
type
(
::
testing
::
AnyOf
(
m1
,
m2
,
m3
,
m4
),
::
testing
::
AnyOf
(
m5
,
m6
,
m7
,
m8
,
m9
));
}
template
<
typename
M1
,
typename
M2
,
typename
M3
,
typename
M4
,
typename
M5
,
typename
M6
,
typename
M7
,
typename
M8
,
typename
M9
,
typename
M10
>
inline
typename
internal
::
AnyOfResult10
<
M1
,
M2
,
M3
,
M4
,
M5
,
M6
,
M7
,
M8
,
M9
,
M10
>::
type
AnyOf
(
M1
m1
,
M2
m2
,
M3
m3
,
M4
m4
,
M5
m5
,
M6
m6
,
M7
m7
,
M8
m8
,
M9
m9
,
M10
m10
)
{
return
typename
internal
::
AnyOfResult10
<
M1
,
M2
,
M3
,
M4
,
M5
,
M6
,
M7
,
M8
,
M9
,
M10
>::
type
(
::
testing
::
AnyOf
(
m1
,
m2
,
m3
,
m4
,
m5
),
::
testing
::
AnyOf
(
m6
,
m7
,
m8
,
m9
,
m10
));
}
}
// namespace testing
// The MATCHER* family of macros can be used in a namespace scope to
// The MATCHER* family of macros can be used in a namespace scope to
// define custom matchers easily.
// define custom matchers easily.
//
//
...
@@ -795,7 +290,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -795,7 +290,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::
testing
::tuple<>()));\
::
std
::tuple<>()));\
}\
}\
};\
};\
template <typename arg_type>\
template <typename arg_type>\
...
@@ -825,7 +320,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -825,7 +320,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
GTEST_REFERENCE_TO_CONST_(arg_type)> {\
GTEST_REFERENCE_TO_CONST_(arg_type)> {\
public:\
public:\
explicit gmock_Impl(p0##_type gmock_p0)\
explicit gmock_Impl(p0##_type gmock_p0)\
: p0(::
testing::internal
::move(gmock_p0)) {}\
: p0(::
std
::move(gmock_p0)) {}\
virtual bool MatchAndExplain(\
virtual bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const;\
::testing::MatchResultListener* result_listener) const;\
...
@@ -845,7 +340,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -845,7 +340,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::
testing
::tuple<p0##_type>(p0)));\
::
std
::tuple<p0##_type>(p0)));\
}\
}\
};\
};\
template <typename arg_type>\
template <typename arg_type>\
...
@@ -853,8 +348,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -853,8 +348,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::Matcher<arg_type>(\
return ::testing::Matcher<arg_type>(\
new gmock_Impl<arg_type>(p0));\
new gmock_Impl<arg_type>(p0));\
}\
}\
explicit name##MatcherP(p0##_type gmock_p0) : \
explicit name##MatcherP(p0##_type gmock_p0) : p0(::std::move(gmock_p0)) {\
p0(::testing::internal::move(gmock_p0)) {\
}\
}\
p0##_type const p0;\
p0##_type const p0;\
private:\
private:\
...
@@ -879,8 +373,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -879,8 +373,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
GTEST_REFERENCE_TO_CONST_(arg_type)> {\
GTEST_REFERENCE_TO_CONST_(arg_type)> {\
public:\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
: p0(::testing::internal::move(gmock_p0)), \
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)) {}\
p1(::testing::internal::move(gmock_p1)) {}\
virtual bool MatchAndExplain(\
virtual bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const;\
::testing::MatchResultListener* result_listener) const;\
...
@@ -901,7 +394,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -901,7 +394,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::
testing
::tuple<p0##_type, p1##_type>(p0, p1)));\
::
std
::tuple<p0##_type, p1##_type>(p0, p1)));\
}\
}\
};\
};\
template <typename arg_type>\
template <typename arg_type>\
...
@@ -910,8 +403,8 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -910,8 +403,8 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
new gmock_Impl<arg_type>(p0, p1));\
new gmock_Impl<arg_type>(p0, p1));\
}\
}\
name##MatcherP2(p0##_type gmock_p0, \
name##MatcherP2(p0##_type gmock_p0, \
p1##_type gmock_p1) : p0(::
testing::internal
::move(gmock_p0)), \
p1##_type gmock_p1) : p0(::
std
::move(gmock_p0)), \
p1(::
testing::internal
::move(gmock_p1)) {\
p1(::
std
::move(gmock_p1)) {\
}\
}\
p0##_type const p0;\
p0##_type const p0;\
p1##_type const p1;\
p1##_type const p1;\
...
@@ -939,9 +432,8 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -939,9 +432,8 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
GTEST_REFERENCE_TO_CONST_(arg_type)> {\
GTEST_REFERENCE_TO_CONST_(arg_type)> {\
public:\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
: p0(::testing::internal::move(gmock_p0)), \
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
p1(::testing::internal::move(gmock_p1)), \
p2(::std::move(gmock_p2)) {}\
p2(::testing::internal::move(gmock_p2)) {}\
virtual bool MatchAndExplain(\
virtual bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const;\
::testing::MatchResultListener* result_listener) const;\
...
@@ -963,8 +455,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -963,8 +455,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
::std::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, p2)));\
p2)));\
}\
}\
};\
};\
template <typename arg_type>\
template <typename arg_type>\
...
@@ -973,9 +464,8 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -973,9 +464,8 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
new gmock_Impl<arg_type>(p0, p1, p2));\
new gmock_Impl<arg_type>(p0, p1, p2));\
}\
}\
name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \
name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2) : p0(::testing::internal::move(gmock_p0)), \
p2##_type gmock_p2) : p0(::std::move(gmock_p0)), \
p1(::testing::internal::move(gmock_p1)), \
p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)) {\
p2(::testing::internal::move(gmock_p2)) {\
}\
}\
p0##_type const p0;\
p0##_type const p0;\
p1##_type const p1;\
p1##_type const p1;\
...
@@ -1006,10 +496,8 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1006,10 +496,8 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
public:\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p3##_type gmock_p3)\
p3##_type gmock_p3)\
: p0(::testing::internal::move(gmock_p0)), \
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
p1(::testing::internal::move(gmock_p1)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)) {}\
p2(::testing::internal::move(gmock_p2)), \
p3(::testing::internal::move(gmock_p3)) {}\
virtual bool MatchAndExplain(\
virtual bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const;\
::testing::MatchResultListener* result_listener) const;\
...
@@ -1032,8 +520,8 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1032,8 +520,8 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::
testing
::tuple<p0##_type, p1##_type, p2##_type, \
::
std
::tuple<p0##_type, p1##_type, p2##_type,
p3##_type>(p0,
\
p3##_type>(p0,
p1, p2, p3)));\
p1, p2, p3)));\
}\
}\
};\
};\
template <typename arg_type>\
template <typename arg_type>\
...
@@ -1042,11 +530,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1042,11 +530,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
new gmock_Impl<arg_type>(p0, p1, p2, p3));\
new gmock_Impl<arg_type>(p0, p1, p2, p3));\
}\
}\
name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \
name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, \
p2##_type gmock_p2, p3##_type gmock_p3) : p0(::std::move(gmock_p0)), \
p3##_type gmock_p3) : p0(::testing::internal::move(gmock_p0)), \
p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
p1(::testing::internal::move(gmock_p1)), \
p3(::std::move(gmock_p3)) {\
p2(::testing::internal::move(gmock_p2)), \
p3(::testing::internal::move(gmock_p3)) {\
}\
}\
p0##_type const p0;\
p0##_type const p0;\
p1##_type const p1;\
p1##_type const p1;\
...
@@ -1082,11 +568,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1082,11 +568,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
public:\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p3##_type gmock_p3, p4##_type gmock_p4)\
p3##_type gmock_p3, p4##_type gmock_p4)\
: p0(::testing::internal::move(gmock_p0)), \
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
p1(::testing::internal::move(gmock_p1)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \
p2(::testing::internal::move(gmock_p2)), \
p4(::std::move(gmock_p4)) {}\
p3(::testing::internal::move(gmock_p3)), \
p4(::testing::internal::move(gmock_p4)) {}\
virtual bool MatchAndExplain(\
virtual bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const;\
::testing::MatchResultListener* result_listener) const;\
...
@@ -1110,7 +594,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1110,7 +594,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::
testing
::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
::
std
::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type>(p0, p1, p2, p3, p4)));\
p4##_type>(p0, p1, p2, p3, p4)));\
}\
}\
};\
};\
...
@@ -1121,11 +605,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1121,11 +605,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
}\
}\
name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \
name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, \
p2##_type gmock_p2, p3##_type gmock_p3, \
p4##_type gmock_p4) : p0(::testing::internal::move(gmock_p0)), \
p4##_type gmock_p4) : p0(::std::move(gmock_p0)), \
p1(::testing::internal::move(gmock_p1)), \
p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
p2(::testing::internal::move(gmock_p2)), \
p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)) {\
p3(::testing::internal::move(gmock_p3)), \
p4(::testing::internal::move(gmock_p4)) {\
}\
}\
p0##_type const p0;\
p0##_type const p0;\
p1##_type const p1;\
p1##_type const p1;\
...
@@ -1162,12 +644,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1162,12 +644,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
public:\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
gmock_Impl(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)\
: p0(::testing::internal::move(gmock_p0)), \
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
p1(::testing::internal::move(gmock_p1)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \
p2(::testing::internal::move(gmock_p2)), \
p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)) {}\
p3(::testing::internal::move(gmock_p3)), \
p4(::testing::internal::move(gmock_p4)), \
p5(::testing::internal::move(gmock_p5)) {}\
virtual bool MatchAndExplain(\
virtual bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const;\
::testing::MatchResultListener* result_listener) const;\
...
@@ -1192,7 +671,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1192,7 +671,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::
testing
::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
::
std
::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5)));\
p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5)));\
}\
}\
};\
};\
...
@@ -1203,12 +682,10 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1203,12 +682,10 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
}\
}\
name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \
name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5) : p0(::testing::internal::move(gmock_p0)), \
p5##_type gmock_p5) : p0(::std::move(gmock_p0)), \
p1(::testing::internal::move(gmock_p1)), \
p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
p2(::testing::internal::move(gmock_p2)), \
p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
p3(::testing::internal::move(gmock_p3)), \
p5(::std::move(gmock_p5)) {\
p4(::testing::internal::move(gmock_p4)), \
p5(::testing::internal::move(gmock_p5)) {\
}\
}\
p0##_type const p0;\
p0##_type const p0;\
p1##_type const p1;\
p1##_type const p1;\
...
@@ -1248,13 +725,10 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1248,13 +725,10 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
gmock_Impl(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)\
p6##_type gmock_p6)\
: p0(::testing::internal::move(gmock_p0)), \
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
p1(::testing::internal::move(gmock_p1)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \
p2(::testing::internal::move(gmock_p2)), \
p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)), \
p3(::testing::internal::move(gmock_p3)), \
p6(::std::move(gmock_p6)) {}\
p4(::testing::internal::move(gmock_p4)), \
p5(::testing::internal::move(gmock_p5)), \
p6(::testing::internal::move(gmock_p6)) {}\
virtual bool MatchAndExplain(\
virtual bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const;\
::testing::MatchResultListener* result_listener) const;\
...
@@ -1280,7 +754,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1280,7 +754,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::
testing
::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
::
std
::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
p6)));\
p6)));\
}\
}\
...
@@ -1292,14 +766,10 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1292,14 +766,10 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
}\
}\
name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \
name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5, \
p5##_type gmock_p5, p6##_type gmock_p6) : p0(::std::move(gmock_p0)), \
p6##_type gmock_p6) : p0(::testing::internal::move(gmock_p0)), \
p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
p1(::testing::internal::move(gmock_p1)), \
p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
p2(::testing::internal::move(gmock_p2)), \
p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)) {\
p3(::testing::internal::move(gmock_p3)), \
p4(::testing::internal::move(gmock_p4)), \
p5(::testing::internal::move(gmock_p5)), \
p6(::testing::internal::move(gmock_p6)) {\
}\
}\
p0##_type const p0;\
p0##_type const p0;\
p1##_type const p1;\
p1##_type const p1;\
...
@@ -1343,14 +813,10 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1343,14 +813,10 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
gmock_Impl(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)\
: p0(::testing::internal::move(gmock_p0)), \
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
p1(::testing::internal::move(gmock_p1)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \
p2(::testing::internal::move(gmock_p2)), \
p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)), \
p3(::testing::internal::move(gmock_p3)), \
p6(::std::move(gmock_p6)), p7(::std::move(gmock_p7)) {}\
p4(::testing::internal::move(gmock_p4)), \
p5(::testing::internal::move(gmock_p5)), \
p6(::testing::internal::move(gmock_p6)), \
p7(::testing::internal::move(gmock_p7)) {}\
virtual bool MatchAndExplain(\
virtual bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const;\
::testing::MatchResultListener* result_listener) const;\
...
@@ -1377,7 +843,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1377,7 +843,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::
testing
::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
::
std
::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
p3, p4, p5, p6, p7)));\
p3, p4, p5, p6, p7)));\
}\
}\
...
@@ -1390,14 +856,11 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1390,14 +856,11 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \
name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5, p6##_type gmock_p6, \
p5##_type gmock_p5, p6##_type gmock_p6, \
p7##_type gmock_p7) : p0(::testing::internal::move(gmock_p0)), \
p7##_type gmock_p7) : p0(::std::move(gmock_p0)), \
p1(::testing::internal::move(gmock_p1)), \
p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
p2(::testing::internal::move(gmock_p2)), \
p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
p3(::testing::internal::move(gmock_p3)), \
p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \
p4(::testing::internal::move(gmock_p4)), \
p7(::std::move(gmock_p7)) {\
p5(::testing::internal::move(gmock_p5)), \
p6(::testing::internal::move(gmock_p6)), \
p7(::testing::internal::move(gmock_p7)) {\
}\
}\
p0##_type const p0;\
p0##_type const p0;\
p1##_type const p1;\
p1##_type const p1;\
...
@@ -1444,15 +907,11 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1444,15 +907,11 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
gmock_Impl(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)\
: p0(::testing::internal::move(gmock_p0)), \
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
p1(::testing::internal::move(gmock_p1)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \
p2(::testing::internal::move(gmock_p2)), \
p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)), \
p3(::testing::internal::move(gmock_p3)), \
p6(::std::move(gmock_p6)), p7(::std::move(gmock_p7)), \
p4(::testing::internal::move(gmock_p4)), \
p8(::std::move(gmock_p8)) {}\
p5(::testing::internal::move(gmock_p5)), \
p6(::testing::internal::move(gmock_p6)), \
p7(::testing::internal::move(gmock_p7)), \
p8(::testing::internal::move(gmock_p8)) {}\
virtual bool MatchAndExplain(\
virtual bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const;\
::testing::MatchResultListener* result_listener) const;\
...
@@ -1480,7 +939,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1480,7 +939,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::
testing
::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
::
std
::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type, \
p4##_type, p5##_type, p6##_type, p7##_type, \
p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8)));\
p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8)));\
}\
}\
...
@@ -1493,15 +952,11 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1493,15 +952,11 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \
name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
p8##_type gmock_p8) : p0(::testing::internal::move(gmock_p0)), \
p8##_type gmock_p8) : p0(::std::move(gmock_p0)), \
p1(::testing::internal::move(gmock_p1)), \
p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
p2(::testing::internal::move(gmock_p2)), \
p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
p3(::testing::internal::move(gmock_p3)), \
p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \
p4(::testing::internal::move(gmock_p4)), \
p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8)) {\
p5(::testing::internal::move(gmock_p5)), \
p6(::testing::internal::move(gmock_p6)), \
p7(::testing::internal::move(gmock_p7)), \
p8(::testing::internal::move(gmock_p8)) {\
}\
}\
p0##_type const p0;\
p0##_type const p0;\
p1##_type const p1;\
p1##_type const p1;\
...
@@ -1552,16 +1007,11 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1552,16 +1007,11 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
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)\
p9##_type gmock_p9)\
: p0(::testing::internal::move(gmock_p0)), \
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
p1(::testing::internal::move(gmock_p1)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \
p2(::testing::internal::move(gmock_p2)), \
p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)), \
p3(::testing::internal::move(gmock_p3)), \
p6(::std::move(gmock_p6)), p7(::std::move(gmock_p7)), \
p4(::testing::internal::move(gmock_p4)), \
p8(::std::move(gmock_p8)), p9(::std::move(gmock_p9)) {}\
p5(::testing::internal::move(gmock_p5)), \
p6(::testing::internal::move(gmock_p6)), \
p7(::testing::internal::move(gmock_p7)), \
p8(::testing::internal::move(gmock_p8)), \
p9(::testing::internal::move(gmock_p9)) {}\
virtual bool MatchAndExplain(\
virtual bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const;\
::testing::MatchResultListener* result_listener) const;\
...
@@ -1590,7 +1040,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1590,7 +1040,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::
testing
::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
::
std
::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)));\
p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)));\
}\
}\
...
@@ -1603,17 +1053,12 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
...
@@ -1603,17 +1053,12 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \
name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \
p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \
p8##_type gmock_p8, \
p8##_type gmock_p8, p9##_type gmock_p9) : p0(::std::move(gmock_p0)), \
p9##_type gmock_p9) : p0(::testing::internal::move(gmock_p0)), \
p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
p1(::testing::internal::move(gmock_p1)), \
p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
p2(::testing::internal::move(gmock_p2)), \
p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \
p3(::testing::internal::move(gmock_p3)), \
p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8)), \
p4(::testing::internal::move(gmock_p4)), \
p9(::std::move(gmock_p9)) {\
p5(::testing::internal::move(gmock_p5)), \
p6(::testing::internal::move(gmock_p6)), \
p7(::testing::internal::move(gmock_p7)), \
p8(::testing::internal::move(gmock_p8)), \
p9(::testing::internal::move(gmock_p9)) {\
}\
}\
p0##_type const p0;\
p0##_type const p0;\
p1##_type const p1;\
p1##_type const p1;\
...
...
googlemock/include/gmock/gmock-generated-matchers.h.pump
View file @
25905b9f
...
@@ -45,221 +45,10 @@ $$ }} This line fixes auto-indentation of the following code in Emacs.
...
@@ -45,221 +45,10 @@ $$ }} This line fixes auto-indentation of the following code in Emacs.
#include <iterator>
#include <iterator>
#include <sstream>
#include <sstream>
#include <string>
#include <string>
#include <utility>
#include <vector>
#include <vector>
#include "gmock/gmock-matchers.h"
#include "gmock/gmock-matchers.h"
namespace
testing
{
namespace
internal
{
$
range
i
0.
.
n
-
1
// The type of the i-th (0-based) field of Tuple.
#define GMOCK_FIELD_TYPE_(Tuple, i) \
typename ::testing::tuple_element<i, Tuple>::type
// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
// tuple of type Tuple. It has two members:
//
// type: a tuple type whose i-th field is the ki-th field of Tuple.
// GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
//
// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
//
// type is tuple<int, bool>, and
// GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
template
<
class
Tuple
$
for
i
[[,
int
k
$
i
=
-
1
]]>
class
TupleFields
;
// This generic version is used when there are $n selectors.
template
<
class
Tuple
$
for
i
[[,
int
k
$
i
]]>
class
TupleFields
{
public:
typedef
::
testing
::
tuple
<
$
for
i
,
[[
GMOCK_FIELD_TYPE_
(
Tuple
,
k
$
i
)]]
>
type
;
static
type
GetSelectedFields
(
const
Tuple
&
t
)
{
return
type
(
$
for
i
,
[[
get
<
k
$
i
>
(
t
)]]);
}
};
// The following specialization is used for 0 ~ $(n-1) selectors.
$
for
i
[[
$$
}}
}
$
range
j
0.
.
i
-
1
$
range
k
0.
.
n
-
1
template
<
class
Tuple
$
for
j
[[,
int
k
$
j
]]>
class
TupleFields
<
Tuple
,
$
for
k
,
[[
$
if
k
<
i
[[
k
$
k
]]
$
else
[[
-
1
]]]]
>
{
public:
typedef
::
testing
::
tuple
<
$
for
j
,
[[
GMOCK_FIELD_TYPE_
(
Tuple
,
k
$
j
)]]
>
type
;
static
type
GetSelectedFields
(
const
Tuple
&
$
if
i
==
0
[[
/* t */
]]
$
else
[[
t
]])
{
return
type
(
$
for
j
,
[[
get
<
k
$
j
>
(
t
)]]);
}
};
]]
#undef GMOCK_FIELD_TYPE_
// Implements the Args() matcher.
$
var
ks
=
[[
$
for
i
,
[[
k
$
i
]]]]
template
<
class
ArgsTuple
$
for
i
[[,
int
k
$
i
=
-
1
]]>
class
ArgsMatcherImpl
:
public
MatcherInterface
<
ArgsTuple
>
{
public:
// ArgsTuple may have top-level const or reference modifiers.
typedef
GTEST_REMOVE_REFERENCE_AND_CONST_
(
ArgsTuple
)
RawArgsTuple
;
typedef
typename
internal
::
TupleFields
<
RawArgsTuple
,
$
ks
>::
type
SelectedArgs
;
typedef
Matcher
<
const
SelectedArgs
&>
MonomorphicInnerMatcher
;
template
<
typename
InnerMatcher
>
explicit
ArgsMatcherImpl
(
const
InnerMatcher
&
inner_matcher
)
:
inner_matcher_
(
SafeMatcherCast
<
const
SelectedArgs
&>
(
inner_matcher
))
{}
virtual
bool
MatchAndExplain
(
ArgsTuple
args
,
MatchResultListener
*
listener
)
const
{
const
SelectedArgs
&
selected_args
=
GetSelectedArgs
(
args
);
if
(
!
listener
->
IsInterested
())
return
inner_matcher_
.
Matches
(
selected_args
);
PrintIndices
(
listener
->
stream
());
*
listener
<<
"are "
<<
PrintToString
(
selected_args
);
StringMatchResultListener
inner_listener
;
const
bool
match
=
inner_matcher_
.
MatchAndExplain
(
selected_args
,
&
inner_listener
);
PrintIfNotEmpty
(
inner_listener
.
str
(),
listener
->
stream
());
return
match
;
}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"are a tuple "
;
PrintIndices
(
os
);
inner_matcher_
.
DescribeTo
(
os
);
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"are a tuple "
;
PrintIndices
(
os
);
inner_matcher_
.
DescribeNegationTo
(
os
);
}
private:
static
SelectedArgs
GetSelectedArgs
(
ArgsTuple
args
)
{
return
TupleFields
<
RawArgsTuple
,
$
ks
>::
GetSelectedFields
(
args
);
}
// Prints the indices of the selected fields.
static
void
PrintIndices
(
::
std
::
ostream
*
os
)
{
*
os
<<
"whose fields ("
;
const
int
indices
[
$
n
]
=
{
$
ks
};
for
(
int
i
=
0
;
i
<
$
n
;
i
++
)
{
if
(
indices
[
i
]
<
0
)
break
;
if
(
i
>=
1
)
*
os
<<
", "
;
*
os
<<
"#"
<<
indices
[
i
];
}
*
os
<<
") "
;
}
const
MonomorphicInnerMatcher
inner_matcher_
;
GTEST_DISALLOW_ASSIGN_
(
ArgsMatcherImpl
);
};
template
<
class
InnerMatcher
$
for
i
[[,
int
k
$
i
=
-
1
]]>
class
ArgsMatcher
{
public:
explicit
ArgsMatcher
(
const
InnerMatcher
&
inner_matcher
)
:
inner_matcher_
(
inner_matcher
)
{}
template
<
typename
ArgsTuple
>
operator
Matcher
<
ArgsTuple
>
()
const
{
return
MakeMatcher
(
new
ArgsMatcherImpl
<
ArgsTuple
,
$
ks
>
(
inner_matcher_
));
}
private:
const
InnerMatcher
inner_matcher_
;
GTEST_DISALLOW_ASSIGN_
(
ArgsMatcher
);
};
// A set of metafunctions for computing the result type of AnyOf.
// AnyOf(m1, ..., mN) returns
// AnyOfResultN<decltype(m1), ..., decltype(mN)>::type.
// Although AnyOf isn't defined for one argument, AnyOfResult1 is defined
// to simplify the implementation.
template
<
typename
M1
>
struct
AnyOfResult1
{
typedef
M1
type
;
};
$
range
i
1.
.
n
$
range
i
2.
.
n
$
for
i
[[
$
range
j
2.
.
i
$
var
m
=
i
/
2
$
range
k
1.
.
m
$
range
t
m
+
1.
.
i
template
<
typename
M1
$
for
j
[[,
typename
M
$
j
]]>
struct
AnyOfResult
$
i
{
typedef
EitherOfMatcher
<
typename
AnyOfResult
$
m
<
$
for
k
,
[[
M
$
k
]]
>::
type
,
typename
AnyOfResult
$
(
i
-
m
)
<
$
for
t
,
[[
M
$
t
]]
>::
type
>
type
;
};
]]
}
// namespace internal
// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
// fields of it matches a_matcher. C++ doesn't support default
// arguments for function templates, so we have to overload it.
$
range
i
0.
.
n
$
for
i
[[
$
range
j
1.
.
i
template
<
$
for
j
[[
int
k
$
j
,
]]
typename
InnerMatcher
>
inline
internal
::
ArgsMatcher
<
InnerMatcher
$
for
j
[[,
k
$
j
]]
>
Args
(
const
InnerMatcher
&
matcher
)
{
return
internal
::
ArgsMatcher
<
InnerMatcher
$
for
j
[[,
k
$
j
]]
>
(
matcher
);
}
]]
// AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
// sub-matchers. AnyOf is called fully qualified to prevent ADL from firing.
$
range
i
2.
.
n
$
for
i
[[
$
range
j
1.
.
i
$
var
m
=
i
/
2
$
range
k
1.
.
m
$
range
t
m
+
1.
.
i
template
<
$
for
j
,
[[
typename
M
$
j
]]>
inline
typename
internal
::
AnyOfResult
$
i
<
$
for
j
,
[[
M
$
j
]]
>::
type
AnyOf
(
$
for
j
,
[[
M
$
j
m
$
j
]])
{
return
typename
internal
::
AnyOfResult
$
i
<
$
for
j
,
[[
M
$
j
]]
>::
type
(
$
if
m
==
1
[[
m1
]]
$
else
[[
::
testing
::
AnyOf
(
$
for
k
,
[[
m
$
k
]])]],
$
if
m
+
1
==
i
[[
m
$
i
]]
$
else
[[
::
testing
::
AnyOf
(
$
for
t
,
[[
m
$
t
]])]]);
}
]]
}
// namespace testing
$$
}
// This Pump meta comment fixes auto-indentation in Emacs. It will not
$$
// show up in the generated code.
// The MATCHER* family of macros can be used in a namespace scope to
// The MATCHER* family of macros can be used in a namespace scope to
// define custom matchers easily.
// define custom matchers easily.
//
//
...
@@ -491,8 +280,8 @@ $var template = [[$if i==0 [[]] $else [[
...
@@ -491,8 +280,8 @@ $var template = [[$if i==0 [[]] $else [[
]]]]
]]]]
$
var
ctor_param_list
=
[[
$
for
j
,
[[
p
$
j
##
_type
gmock_p
$
j
]]]]
$
var
ctor_param_list
=
[[
$
for
j
,
[[
p
$
j
##
_type
gmock_p
$
j
]]]]
$
var
impl_ctor_param_list
=
[[
$
for
j
,
[[
p
$
j
##
_type
gmock_p
$
j
]]]]
$
var
impl_ctor_param_list
=
[[
$
for
j
,
[[
p
$
j
##
_type
gmock_p
$
j
]]]]
$
var
impl_inits
=
[[
$
if
i
==
0
[[]]
$
else
[[
:
$
for
j
,
[[
p
$
j
(
::
testing
::
internal
::
move
(
gmock_p
$
j
))]]]]]]
$
var
impl_inits
=
[[
$
if
i
==
0
[[]]
$
else
[[
:
$
for
j
,
[[
p
$
j
(
::
std
::
move
(
gmock_p
$
j
))]]]]]]
$
var
inits
=
[[
$
if
i
==
0
[[]]
$
else
[[
:
$
for
j
,
[[
p
$
j
(
::
testing
::
internal
::
move
(
gmock_p
$
j
))]]]]]]
$
var
inits
=
[[
$
if
i
==
0
[[]]
$
else
[[
:
$
for
j
,
[[
p
$
j
(
::
std
::
move
(
gmock_p
$
j
))]]]]]]
$
var
params
=
[[
$
for
j
,
[[
p
$
j
]]]]
$
var
params
=
[[
$
for
j
,
[[
p
$
j
]]]]
$
var
param_types
=
[[
$
if
i
==
0
[[]]
$
else
[[
<
$
for
j
,
[[
p
$
j
##
_type
]]>]]]]
$
var
param_types
=
[[
$
if
i
==
0
[[]]
$
else
[[
<
$
for
j
,
[[
p
$
j
##
_type
]]>]]]]
$
var
param_types_and_names
=
[[
$
for
j
,
[[
p
$
j
##
_type
p
$
j
]]]]
$
var
param_types_and_names
=
[[
$
for
j
,
[[
p
$
j
##
_type
p
$
j
]]]]
...
@@ -534,7 +323,7 @@ $var param_field_decls2 = [[$for j
...
@@ -534,7 +323,7 @@ $var param_field_decls2 = [[$for j
return
::
testing
::
internal
::
FormatMatcherDescription
(
\
return
::
testing
::
internal
::
FormatMatcherDescription
(
\
negation
,
#
name
,
\
negation
,
#
name
,
\
::
testing
::
internal
::
UniversalTersePrintTupleFieldsToStrings
(
\
::
testing
::
internal
::
UniversalTersePrintTupleFieldsToStrings
(
\
::
testing
::
tuple
<
$
for
j
,
[[
p
$
j
##
_type
]]
>
(
$
for
j
,
[[
p
$
j
]])));
\
::
std
::
tuple
<
$
for
j
,
[[
p
$
j
##
_type
]]
>
(
$
for
j
,
[[
p
$
j
]])));
\
}
\
}
\
};
\
};
\
template
<
typename
arg_type
>
\
template
<
typename
arg_type
>
\
...
...
googlemock/include/gmock/gmock-generated-nice-strict.h
deleted
100644 → 0
View file @
4665eee1
// This file was GENERATED by command:
// pump.py gmock-generated-nice-strict.h.pump
// DO NOT EDIT BY HAND!!!
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// 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.
// Implements class templates NiceMock, NaggyMock, and StrictMock.
//
// Given a mock class MockFoo that is created using Google Mock,
// NiceMock<MockFoo> is a subclass of MockFoo that allows
// uninteresting calls (i.e. calls to mock methods that have no
// EXPECT_CALL specs), NaggyMock<MockFoo> is a subclass of MockFoo
// that prints a warning when an uninteresting call occurs, and
// StrictMock<MockFoo> is a subclass of MockFoo that treats all
// uninteresting calls as errors.
//
// Currently a mock is naggy by default, so MockFoo and
// NaggyMock<MockFoo> behave like the same. However, we will soon
// switch the default behavior of mocks to be nice, as that in general
// leads to more maintainable tests. When that happens, MockFoo will
// stop behaving like NaggyMock<MockFoo> and start behaving like
// NiceMock<MockFoo>.
//
// NiceMock, NaggyMock, and StrictMock "inherit" the constructors of
// 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
// the MOCK_METHOD* family of macros DIRECTLY in the MockFoo class.
// If a mock method is defined in a base class of MockFoo, the "nice"
// or "strict" modifier may not affect it, depending on the compiler.
// 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_
#include "gmock/gmock-spec-builders.h"
#include "gmock/internal/gmock-port.h"
namespace
testing
{
template
<
class
MockClass
>
class
NiceMock
:
public
MockClass
{
public:
NiceMock
()
:
MockClass
()
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
#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
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
)...)
{
::
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
)
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
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
)
{
::
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
)
{
::
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
)
{
::
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
)
{
::
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
)
{
::
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
)
{
::
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
)
{
::
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
)
{
::
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
);
};
template
<
class
MockClass
>
class
NaggyMock
:
public
MockClass
{
public:
NaggyMock
()
:
MockClass
()
{
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
#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
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
)...)
{
::
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
)
{
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
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
)
{
::
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
)
{
::
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
)
{
::
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
)
{
::
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
)
{
::
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
)
{
::
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
)
{
::
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
)
{
::
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
);
};
template
<
class
MockClass
>
class
StrictMock
:
public
MockClass
{
public:
StrictMock
()
:
MockClass
()
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
#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
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
)...)
{
::
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
)
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
template
<
typename
A1
,
typename
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
)
{
::
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
)
{
::
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
)
{
::
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
)
{
::
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
)
{
::
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
)
{
::
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
)
{
::
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
)
{
::
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
);
};
// The following specializations catch some (relatively more common)
// user errors of nesting nice and strict mocks. They do NOT catch
// all possible errors.
// These specializations are declared but not defined, as NiceMock,
// NaggyMock, and StrictMock cannot be nested.
template
<
typename
MockClass
>
class
NiceMock
<
NiceMock
<
MockClass
>
>
;
template
<
typename
MockClass
>
class
NiceMock
<
NaggyMock
<
MockClass
>
>
;
template
<
typename
MockClass
>
class
NiceMock
<
StrictMock
<
MockClass
>
>
;
template
<
typename
MockClass
>
class
NaggyMock
<
NiceMock
<
MockClass
>
>
;
template
<
typename
MockClass
>
class
NaggyMock
<
NaggyMock
<
MockClass
>
>
;
template
<
typename
MockClass
>
class
NaggyMock
<
StrictMock
<
MockClass
>
>
;
template
<
typename
MockClass
>
class
StrictMock
<
NiceMock
<
MockClass
>
>
;
template
<
typename
MockClass
>
class
StrictMock
<
NaggyMock
<
MockClass
>
>
;
template
<
typename
MockClass
>
class
StrictMock
<
StrictMock
<
MockClass
>
>
;
}
// namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
googlemock/include/gmock/gmock-matchers.h
View file @
25905b9f
...
@@ -33,6 +33,9 @@
...
@@ -33,6 +33,9 @@
// This file implements some commonly used argument matchers. More
// This file implements some commonly used argument matchers. More
// matchers can be defined by the user implementing the
// matchers can be defined by the user implementing the
// MatcherInterface<T> interface if necessary.
// MatcherInterface<T> interface if necessary.
//
// See googletest/include/gtest/gtest-matchers.h for the definition of class
// Matcher, class MatcherInterface, and others.
// GOOGLETEST_CM0002 DO NOT DELETE
// GOOGLETEST_CM0002 DO NOT DELETE
...
@@ -41,20 +44,19 @@
...
@@ -41,20 +44,19 @@
#include <math.h>
#include <math.h>
#include <algorithm>
#include <algorithm>
#include <initializer_list>
#include <iterator>
#include <iterator>
#include <limits>
#include <limits>
#include <memory>
#include <ostream> // NOLINT
#include <ostream> // NOLINT
#include <sstream>
#include <sstream>
#include <string>
#include <string>
#include <type_traits>
#include <utility>
#include <utility>
#include <vector>
#include <vector>
#include "gtest/gtest.h"
#include "gmock/internal/gmock-internal-utils.h"
#include "gmock/internal/gmock-internal-utils.h"
#include "gmock/internal/gmock-port.h"
#include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h"
#if GTEST_HAS_STD_INITIALIZER_LIST_
# include <initializer_list> // NOLINT -- must be after gtest.h
#endif
GTEST_DISABLE_MSC_WARNINGS_PUSH_
(
GTEST_DISABLE_MSC_WARNINGS_PUSH_
(
4251
5046
/* class A needs to have dll-interface to be used by clients of
4251
5046
/* class A needs to have dll-interface to be used by clients of
...
@@ -75,144 +77,6 @@ namespace testing {
...
@@ -75,144 +77,6 @@ namespace testing {
// ownership management as Matcher objects can now be copied like
// ownership management as Matcher objects can now be copied like
// plain values.
// plain values.
// MatchResultListener is an abstract class. Its << operator can be
// used by a matcher to explain why a value matches or doesn't match.
//
// FIXME: add method
// bool InterestedInWhy(bool result) const;
// to indicate whether the listener is interested in why the match
// result is 'result'.
class
MatchResultListener
{
public:
// Creates a listener object with the given underlying ostream. The
// listener does not own the ostream, and does not dereference it
// in the constructor or destructor.
explicit
MatchResultListener
(
::
std
::
ostream
*
os
)
:
stream_
(
os
)
{}
virtual
~
MatchResultListener
()
=
0
;
// Makes this class abstract.
// Streams x to the underlying ostream; does nothing if the ostream
// is NULL.
template
<
typename
T
>
MatchResultListener
&
operator
<<
(
const
T
&
x
)
{
if
(
stream_
!=
nullptr
)
*
stream_
<<
x
;
return
*
this
;
}
// Returns the underlying ostream.
::
std
::
ostream
*
stream
()
{
return
stream_
;
}
// Returns true iff the listener is interested in an explanation of
// the match result. A matcher's MatchAndExplain() method can use
// this information to avoid generating the explanation when no one
// intends to hear it.
bool
IsInterested
()
const
{
return
stream_
!=
nullptr
;
}
private:
::
std
::
ostream
*
const
stream_
;
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MatchResultListener
);
};
inline
MatchResultListener
::~
MatchResultListener
()
{
}
// An instance of a subclass of this knows how to describe itself as a
// matcher.
class
MatcherDescriberInterface
{
public:
virtual
~
MatcherDescriberInterface
()
{}
// Describes this matcher to an ostream. The function should print
// a verb phrase that describes the property a value matching this
// matcher should have. The subject of the verb phrase is the value
// being matched. For example, the DescribeTo() method of the Gt(7)
// matcher prints "is greater than 7".
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
=
0
;
// Describes the negation of this matcher to an ostream. For
// example, if the description of this matcher is "is greater than
// 7", the negated description could be "is not greater than 7".
// You are not required to override this when implementing
// MatcherInterface, but it is highly advised so that your matcher
// can produce good error messages.
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"not ("
;
DescribeTo
(
os
);
*
os
<<
")"
;
}
};
// The implementation of a matcher.
template
<
typename
T
>
class
MatcherInterface
:
public
MatcherDescriberInterface
{
public:
// Returns true iff the matcher matches x; also explains the match
// result to 'listener' if necessary (see the next paragraph), in
// the form of a non-restrictive relative clause ("which ...",
// "whose ...", etc) that describes x. For example, the
// MatchAndExplain() method of the Pointee(...) matcher should
// generate an explanation like "which points to ...".
//
// Implementations of MatchAndExplain() should add an explanation of
// the match result *if and only if* they can provide additional
// information that's not already present (or not obvious) in the
// print-out of x and the matcher's description. Whether the match
// succeeds is not a factor in deciding whether an explanation is
// needed, as sometimes the caller needs to print a failure message
// when the match succeeds (e.g. when the matcher is used inside
// Not()).
//
// For example, a "has at least 10 elements" matcher should explain
// what the actual element count is, regardless of the match result,
// as it is useful information to the reader; on the other hand, an
// "is empty" matcher probably only needs to explain what the actual
// size is when the match fails, as it's redundant to say that the
// size is 0 when the value is already known to be empty.
//
// You should override this method when defining a new matcher.
//
// It's the responsibility of the caller (Google Mock) to guarantee
// that 'listener' is not NULL. This helps to simplify a matcher's
// implementation when it doesn't care about the performance, as it
// can talk to 'listener' without checking its validity first.
// However, in order to implement dummy listeners efficiently,
// listener->stream() may be NULL.
virtual
bool
MatchAndExplain
(
T
x
,
MatchResultListener
*
listener
)
const
=
0
;
// Inherits these methods from MatcherDescriberInterface:
// virtual void DescribeTo(::std::ostream* os) const = 0;
// virtual void DescribeNegationTo(::std::ostream* os) const;
};
namespace
internal
{
// Converts a MatcherInterface<T> to a MatcherInterface<const T&>.
template
<
typename
T
>
class
MatcherInterfaceAdapter
:
public
MatcherInterface
<
const
T
&>
{
public:
explicit
MatcherInterfaceAdapter
(
const
MatcherInterface
<
T
>*
impl
)
:
impl_
(
impl
)
{}
virtual
~
MatcherInterfaceAdapter
()
{
delete
impl_
;
}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
impl_
->
DescribeTo
(
os
);
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
impl_
->
DescribeNegationTo
(
os
);
}
virtual
bool
MatchAndExplain
(
const
T
&
x
,
MatchResultListener
*
listener
)
const
{
return
impl_
->
MatchAndExplain
(
x
,
listener
);
}
private:
const
MatcherInterface
<
T
>*
const
impl_
;
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MatcherInterfaceAdapter
);
};
}
// namespace internal
// A match result listener that stores the explanation in a string.
// A match result listener that stores the explanation in a string.
class
StringMatchResultListener
:
public
MatchResultListener
{
class
StringMatchResultListener
:
public
MatchResultListener
{
public:
public:
...
@@ -230,411 +94,6 @@ class StringMatchResultListener : public MatchResultListener {
...
@@ -230,411 +94,6 @@ class StringMatchResultListener : public MatchResultListener {
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
StringMatchResultListener
);
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
StringMatchResultListener
);
};
};
namespace
internal
{
struct
AnyEq
{
template
<
typename
A
,
typename
B
>
bool
operator
()(
const
A
&
a
,
const
B
&
b
)
const
{
return
a
==
b
;
}
};
struct
AnyNe
{
template
<
typename
A
,
typename
B
>
bool
operator
()(
const
A
&
a
,
const
B
&
b
)
const
{
return
a
!=
b
;
}
};
struct
AnyLt
{
template
<
typename
A
,
typename
B
>
bool
operator
()(
const
A
&
a
,
const
B
&
b
)
const
{
return
a
<
b
;
}
};
struct
AnyGt
{
template
<
typename
A
,
typename
B
>
bool
operator
()(
const
A
&
a
,
const
B
&
b
)
const
{
return
a
>
b
;
}
};
struct
AnyLe
{
template
<
typename
A
,
typename
B
>
bool
operator
()(
const
A
&
a
,
const
B
&
b
)
const
{
return
a
<=
b
;
}
};
struct
AnyGe
{
template
<
typename
A
,
typename
B
>
bool
operator
()(
const
A
&
a
,
const
B
&
b
)
const
{
return
a
>=
b
;
}
};
// A match result listener that ignores the explanation.
class
DummyMatchResultListener
:
public
MatchResultListener
{
public:
DummyMatchResultListener
()
:
MatchResultListener
(
nullptr
)
{}
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
DummyMatchResultListener
);
};
// A match result listener that forwards the explanation to a given
// ostream. The difference between this and MatchResultListener is
// that the former is concrete.
class
StreamMatchResultListener
:
public
MatchResultListener
{
public:
explicit
StreamMatchResultListener
(
::
std
::
ostream
*
os
)
:
MatchResultListener
(
os
)
{}
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
StreamMatchResultListener
);
};
// An internal class for implementing Matcher<T>, which will derive
// from it. We put functionalities common to all Matcher<T>
// specializations here to avoid code duplication.
template
<
typename
T
>
class
MatcherBase
{
public:
// Returns true iff the matcher matches x; also explains the match
// result to 'listener'.
bool
MatchAndExplain
(
GTEST_REFERENCE_TO_CONST_
(
T
)
x
,
MatchResultListener
*
listener
)
const
{
return
impl_
->
MatchAndExplain
(
x
,
listener
);
}
// Returns true iff this matcher matches x.
bool
Matches
(
GTEST_REFERENCE_TO_CONST_
(
T
)
x
)
const
{
DummyMatchResultListener
dummy
;
return
MatchAndExplain
(
x
,
&
dummy
);
}
// Describes this matcher to an ostream.
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
impl_
->
DescribeTo
(
os
);
}
// Describes the negation of this matcher to an ostream.
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
impl_
->
DescribeNegationTo
(
os
);
}
// Explains why x matches, or doesn't match, the matcher.
void
ExplainMatchResultTo
(
GTEST_REFERENCE_TO_CONST_
(
T
)
x
,
::
std
::
ostream
*
os
)
const
{
StreamMatchResultListener
listener
(
os
);
MatchAndExplain
(
x
,
&
listener
);
}
// Returns the describer for this matcher object; retains ownership
// of the describer, which is only guaranteed to be alive when
// this matcher object is alive.
const
MatcherDescriberInterface
*
GetDescriber
()
const
{
return
impl_
.
get
();
}
protected:
MatcherBase
()
{}
// Constructs a matcher from its implementation.
explicit
MatcherBase
(
const
MatcherInterface
<
GTEST_REFERENCE_TO_CONST_
(
T
)
>*
impl
)
:
impl_
(
impl
)
{}
template
<
typename
U
>
explicit
MatcherBase
(
const
MatcherInterface
<
U
>*
impl
,
typename
internal
::
EnableIf
<
!
internal
::
IsSame
<
U
,
GTEST_REFERENCE_TO_CONST_
(
U
)
>::
value
>::
type
*
=
nullptr
)
:
impl_
(
new
internal
::
MatcherInterfaceAdapter
<
U
>
(
impl
))
{}
virtual
~
MatcherBase
()
{}
private:
// shared_ptr (util/gtl/shared_ptr.h) and linked_ptr have similar
// interfaces. The former dynamically allocates a chunk of memory
// to hold the reference count, while the latter tracks all
// references using a circular linked list without allocating
// memory. It has been observed that linked_ptr performs better in
// typical scenarios. However, shared_ptr can out-perform
// linked_ptr when there are many more uses of the copy constructor
// than the default constructor.
//
// If performance becomes a problem, we should see if using
// shared_ptr helps.
::
testing
::
internal
::
linked_ptr
<
const
MatcherInterface
<
GTEST_REFERENCE_TO_CONST_
(
T
)
>
>
impl_
;
};
}
// namespace internal
// A Matcher<T> is a copyable and IMMUTABLE (except by assignment)
// object that can check whether a value of type T matches. The
// implementation of Matcher<T> is just a linked_ptr to const
// MatcherInterface<T>, so copying is fairly cheap. Don't inherit
// from Matcher!
template
<
typename
T
>
class
Matcher
:
public
internal
::
MatcherBase
<
T
>
{
public:
// Constructs a null matcher. Needed for storing Matcher objects in STL
// containers. A default-constructed matcher is not yet initialized. You
// cannot use it until a valid value has been assigned to it.
explicit
Matcher
()
{}
// NOLINT
// Constructs a matcher from its implementation.
explicit
Matcher
(
const
MatcherInterface
<
GTEST_REFERENCE_TO_CONST_
(
T
)
>*
impl
)
:
internal
::
MatcherBase
<
T
>
(
impl
)
{}
template
<
typename
U
>
explicit
Matcher
(
const
MatcherInterface
<
U
>*
impl
,
typename
internal
::
EnableIf
<
!
internal
::
IsSame
<
U
,
GTEST_REFERENCE_TO_CONST_
(
U
)
>::
value
>::
type
*
=
nullptr
)
:
internal
::
MatcherBase
<
T
>
(
impl
)
{}
// Implicit constructor here allows people to write
// EXPECT_CALL(foo, Bar(5)) instead of EXPECT_CALL(foo, Bar(Eq(5))) sometimes
Matcher
(
T
value
);
// NOLINT
};
// The following two specializations allow the user to write str
// instead of Eq(str) and "foo" instead of Eq("foo") when a std::string
// matcher is expected.
template
<>
class
GTEST_API_
Matcher
<
const
std
::
string
&>
:
public
internal
::
MatcherBase
<
const
std
::
string
&>
{
public:
Matcher
()
{}
explicit
Matcher
(
const
MatcherInterface
<
const
std
::
string
&>*
impl
)
:
internal
::
MatcherBase
<
const
std
::
string
&>
(
impl
)
{}
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a std::string object.
Matcher
(
const
std
::
string
&
s
);
// NOLINT
#if GTEST_HAS_GLOBAL_STRING
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a ::string object.
Matcher
(
const
::
string
&
s
);
// NOLINT
#endif // GTEST_HAS_GLOBAL_STRING
// Allows the user to write "foo" instead of Eq("foo") sometimes.
Matcher
(
const
char
*
s
);
// NOLINT
};
template
<>
class
GTEST_API_
Matcher
<
std
::
string
>
:
public
internal
::
MatcherBase
<
std
::
string
>
{
public:
Matcher
()
{}
explicit
Matcher
(
const
MatcherInterface
<
const
std
::
string
&>*
impl
)
:
internal
::
MatcherBase
<
std
::
string
>
(
impl
)
{}
explicit
Matcher
(
const
MatcherInterface
<
std
::
string
>*
impl
)
:
internal
::
MatcherBase
<
std
::
string
>
(
impl
)
{}
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a string object.
Matcher
(
const
std
::
string
&
s
);
// NOLINT
#if GTEST_HAS_GLOBAL_STRING
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a ::string object.
Matcher
(
const
::
string
&
s
);
// NOLINT
#endif // GTEST_HAS_GLOBAL_STRING
// Allows the user to write "foo" instead of Eq("foo") sometimes.
Matcher
(
const
char
*
s
);
// NOLINT
};
#if GTEST_HAS_GLOBAL_STRING
// The following two specializations allow the user to write str
// instead of Eq(str) and "foo" instead of Eq("foo") when a ::string
// matcher is expected.
template
<>
class
GTEST_API_
Matcher
<
const
::
string
&>
:
public
internal
::
MatcherBase
<
const
::
string
&>
{
public:
Matcher
()
{}
explicit
Matcher
(
const
MatcherInterface
<
const
::
string
&>*
impl
)
:
internal
::
MatcherBase
<
const
::
string
&>
(
impl
)
{}
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a std::string object.
Matcher
(
const
std
::
string
&
s
);
// NOLINT
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a ::string object.
Matcher
(
const
::
string
&
s
);
// NOLINT
// Allows the user to write "foo" instead of Eq("foo") sometimes.
Matcher
(
const
char
*
s
);
// NOLINT
};
template
<>
class
GTEST_API_
Matcher
<
::
string
>
:
public
internal
::
MatcherBase
<
::
string
>
{
public:
Matcher
()
{}
explicit
Matcher
(
const
MatcherInterface
<
const
::
string
&>*
impl
)
:
internal
::
MatcherBase
<
::
string
>
(
impl
)
{}
explicit
Matcher
(
const
MatcherInterface
<
::
string
>*
impl
)
:
internal
::
MatcherBase
<
::
string
>
(
impl
)
{}
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a std::string object.
Matcher
(
const
std
::
string
&
s
);
// NOLINT
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a ::string object.
Matcher
(
const
::
string
&
s
);
// NOLINT
// Allows the user to write "foo" instead of Eq("foo") sometimes.
Matcher
(
const
char
*
s
);
// NOLINT
};
#endif // GTEST_HAS_GLOBAL_STRING
#if GTEST_HAS_ABSL
// The following two specializations allow the user to write str
// instead of Eq(str) and "foo" instead of Eq("foo") when a absl::string_view
// matcher is expected.
template
<>
class
GTEST_API_
Matcher
<
const
absl
::
string_view
&>
:
public
internal
::
MatcherBase
<
const
absl
::
string_view
&>
{
public:
Matcher
()
{}
explicit
Matcher
(
const
MatcherInterface
<
const
absl
::
string_view
&>*
impl
)
:
internal
::
MatcherBase
<
const
absl
::
string_view
&>
(
impl
)
{}
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a std::string object.
Matcher
(
const
std
::
string
&
s
);
// NOLINT
#if GTEST_HAS_GLOBAL_STRING
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a ::string object.
Matcher
(
const
::
string
&
s
);
// NOLINT
#endif // GTEST_HAS_GLOBAL_STRING
// Allows the user to write "foo" instead of Eq("foo") sometimes.
Matcher
(
const
char
*
s
);
// NOLINT
// Allows the user to pass absl::string_views directly.
Matcher
(
absl
::
string_view
s
);
// NOLINT
};
template
<>
class
GTEST_API_
Matcher
<
absl
::
string_view
>
:
public
internal
::
MatcherBase
<
absl
::
string_view
>
{
public:
Matcher
()
{}
explicit
Matcher
(
const
MatcherInterface
<
const
absl
::
string_view
&>*
impl
)
:
internal
::
MatcherBase
<
absl
::
string_view
>
(
impl
)
{}
explicit
Matcher
(
const
MatcherInterface
<
absl
::
string_view
>*
impl
)
:
internal
::
MatcherBase
<
absl
::
string_view
>
(
impl
)
{}
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a std::string object.
Matcher
(
const
std
::
string
&
s
);
// NOLINT
#if GTEST_HAS_GLOBAL_STRING
// Allows the user to write str instead of Eq(str) sometimes, where
// str is a ::string object.
Matcher
(
const
::
string
&
s
);
// NOLINT
#endif // GTEST_HAS_GLOBAL_STRING
// Allows the user to write "foo" instead of Eq("foo") sometimes.
Matcher
(
const
char
*
s
);
// NOLINT
// Allows the user to pass absl::string_views directly.
Matcher
(
absl
::
string_view
s
);
// NOLINT
};
#endif // GTEST_HAS_ABSL
// Prints a matcher in a human-readable format.
template
<
typename
T
>
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Matcher
<
T
>&
matcher
)
{
matcher
.
DescribeTo
(
&
os
);
return
os
;
}
// The PolymorphicMatcher class template makes it easy to implement a
// polymorphic matcher (i.e. a matcher that can match values of more
// than one type, e.g. Eq(n) and NotNull()).
//
// To define a polymorphic matcher, a user should provide an Impl
// class that has a DescribeTo() method and a DescribeNegationTo()
// method, and define a member function (or member function template)
//
// bool MatchAndExplain(const Value& value,
// MatchResultListener* listener) const;
//
// See the definition of NotNull() for a complete example.
template
<
class
Impl
>
class
PolymorphicMatcher
{
public:
explicit
PolymorphicMatcher
(
const
Impl
&
an_impl
)
:
impl_
(
an_impl
)
{}
// Returns a mutable reference to the underlying matcher
// implementation object.
Impl
&
mutable_impl
()
{
return
impl_
;
}
// Returns an immutable reference to the underlying matcher
// implementation object.
const
Impl
&
impl
()
const
{
return
impl_
;
}
template
<
typename
T
>
operator
Matcher
<
T
>
()
const
{
return
Matcher
<
T
>
(
new
MonomorphicImpl
<
GTEST_REFERENCE_TO_CONST_
(
T
)
>
(
impl_
));
}
private:
template
<
typename
T
>
class
MonomorphicImpl
:
public
MatcherInterface
<
T
>
{
public:
explicit
MonomorphicImpl
(
const
Impl
&
impl
)
:
impl_
(
impl
)
{}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
impl_
.
DescribeTo
(
os
);
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
impl_
.
DescribeNegationTo
(
os
);
}
virtual
bool
MatchAndExplain
(
T
x
,
MatchResultListener
*
listener
)
const
{
return
impl_
.
MatchAndExplain
(
x
,
listener
);
}
private:
const
Impl
impl_
;
GTEST_DISALLOW_ASSIGN_
(
MonomorphicImpl
);
};
Impl
impl_
;
GTEST_DISALLOW_ASSIGN_
(
PolymorphicMatcher
);
};
// Creates a matcher from its implementation. This is easier to use
// than the Matcher<T> constructor as it doesn't require you to
// explicitly write the template argument, e.g.
//
// MakeMatcher(foo);
// vs
// Matcher<const string&>(foo);
template
<
typename
T
>
inline
Matcher
<
T
>
MakeMatcher
(
const
MatcherInterface
<
T
>*
impl
)
{
return
Matcher
<
T
>
(
impl
);
}
// Creates a polymorphic matcher from its implementation. This is
// easier to use than the PolymorphicMatcher<Impl> constructor as it
// doesn't require you to explicitly write the template argument, e.g.
//
// MakePolymorphicMatcher(foo);
// vs
// PolymorphicMatcher<TypeOfFoo>(foo);
template
<
class
Impl
>
inline
PolymorphicMatcher
<
Impl
>
MakePolymorphicMatcher
(
const
Impl
&
impl
)
{
return
PolymorphicMatcher
<
Impl
>
(
impl
);
}
// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION
// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION
// and MUST NOT BE USED IN USER CODE!!!
// and MUST NOT BE USED IN USER CODE!!!
namespace
internal
{
namespace
internal
{
...
@@ -731,8 +190,7 @@ class MatcherCastImpl<T, Matcher<U> > {
...
@@ -731,8 +190,7 @@ class MatcherCastImpl<T, Matcher<U> > {
:
source_matcher_
(
source_matcher
)
{}
:
source_matcher_
(
source_matcher
)
{}
// We delegate the matching logic to the source matcher.
// We delegate the matching logic to the source matcher.
virtual
bool
MatchAndExplain
(
T
x
,
MatchResultListener
*
listener
)
const
{
bool
MatchAndExplain
(
T
x
,
MatchResultListener
*
listener
)
const
override
{
#if GTEST_LANG_CXX11
using
FromType
=
typename
std
::
remove_cv
<
typename
std
::
remove_pointer
<
using
FromType
=
typename
std
::
remove_cv
<
typename
std
::
remove_pointer
<
typename
std
::
remove_reference
<
T
>::
type
>::
type
>::
type
;
typename
std
::
remove_reference
<
T
>::
type
>::
type
>::
type
;
using
ToType
=
typename
std
::
remove_cv
<
typename
std
::
remove_pointer
<
using
ToType
=
typename
std
::
remove_cv
<
typename
std
::
remove_pointer
<
...
@@ -746,16 +204,15 @@ class MatcherCastImpl<T, Matcher<U> > {
...
@@ -746,16 +204,15 @@ class MatcherCastImpl<T, Matcher<U> > {
std
::
is_same
<
FromType
,
ToType
>::
value
||
std
::
is_same
<
FromType
,
ToType
>::
value
||
!
std
::
is_base_of
<
FromType
,
ToType
>::
value
,
!
std
::
is_base_of
<
FromType
,
ToType
>::
value
,
"Can't implicitly convert from <base> to <derived>"
);
"Can't implicitly convert from <base> to <derived>"
);
#endif // GTEST_LANG_CXX11
return
source_matcher_
.
MatchAndExplain
(
static_cast
<
U
>
(
x
),
listener
);
return
source_matcher_
.
MatchAndExplain
(
static_cast
<
U
>
(
x
),
listener
);
}
}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
source_matcher_
.
DescribeTo
(
os
);
source_matcher_
.
DescribeTo
(
os
);
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
source_matcher_
.
DescribeNegationTo
(
os
);
source_matcher_
.
DescribeNegationTo
(
os
);
}
}
...
@@ -905,8 +362,8 @@ class TuplePrefix {
...
@@ -905,8 +362,8 @@ class TuplePrefix {
template
<
typename
MatcherTuple
,
typename
ValueTuple
>
template
<
typename
MatcherTuple
,
typename
ValueTuple
>
static
bool
Matches
(
const
MatcherTuple
&
matcher_tuple
,
static
bool
Matches
(
const
MatcherTuple
&
matcher_tuple
,
const
ValueTuple
&
value_tuple
)
{
const
ValueTuple
&
value_tuple
)
{
return
TuplePrefix
<
N
-
1
>::
Matches
(
matcher_tuple
,
value_tuple
)
return
TuplePrefix
<
N
-
1
>::
Matches
(
matcher_tuple
,
value_tuple
)
&&
&&
get
<
N
-
1
>
(
matcher_tuple
).
Matches
(
get
<
N
-
1
>
(
value_tuple
));
std
::
get
<
N
-
1
>
(
matcher_tuple
).
Matches
(
std
::
get
<
N
-
1
>
(
value_tuple
));
}
}
// TuplePrefix<N>::ExplainMatchFailuresTo(matchers, values, os)
// TuplePrefix<N>::ExplainMatchFailuresTo(matchers, values, os)
...
@@ -922,16 +379,16 @@ class TuplePrefix {
...
@@ -922,16 +379,16 @@ class TuplePrefix {
// Then describes the failure (if any) in the (N - 1)-th (0-based)
// Then describes the failure (if any) in the (N - 1)-th (0-based)
// field.
// field.
typename
tuple_element
<
N
-
1
,
MatcherTuple
>::
type
matcher
=
typename
std
::
tuple_element
<
N
-
1
,
MatcherTuple
>::
type
matcher
=
get
<
N
-
1
>
(
matchers
);
std
::
get
<
N
-
1
>
(
matchers
);
typedef
typename
tuple_element
<
N
-
1
,
ValueTuple
>::
type
Value
;
typedef
typename
std
::
tuple_element
<
N
-
1
,
ValueTuple
>::
type
Value
;
GTEST_REFERENCE_TO_CONST_
(
Value
)
value
=
get
<
N
-
1
>
(
values
);
const
Value
&
value
=
std
::
get
<
N
-
1
>
(
values
);
StringMatchResultListener
listener
;
StringMatchResultListener
listener
;
if
(
!
matcher
.
MatchAndExplain
(
value
,
&
listener
))
{
if
(
!
matcher
.
MatchAndExplain
(
value
,
&
listener
))
{
// FIXME: 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.
// as used in MOCK_METHOD*() when possible.
*
os
<<
" Expected arg #"
<<
N
-
1
<<
": "
;
*
os
<<
" Expected arg #"
<<
N
-
1
<<
": "
;
get
<
N
-
1
>
(
matchers
).
DescribeTo
(
os
);
std
::
get
<
N
-
1
>
(
matchers
).
DescribeTo
(
os
);
*
os
<<
"
\n
Actual: "
;
*
os
<<
"
\n
Actual: "
;
// We remove the reference in type Value to prevent the
// We remove the reference in type Value to prevent the
// universal printer from printing the address of value, which
// universal printer from printing the address of value, which
...
@@ -971,11 +428,11 @@ bool TupleMatches(const MatcherTuple& matcher_tuple,
...
@@ -971,11 +428,11 @@ bool TupleMatches(const MatcherTuple& matcher_tuple,
const
ValueTuple
&
value_tuple
)
{
const
ValueTuple
&
value_tuple
)
{
// Makes sure that matcher_tuple and value_tuple have the same
// Makes sure that matcher_tuple and value_tuple have the same
// number of fields.
// number of fields.
GTEST_COMPILE_ASSERT_
(
tuple_size
<
MatcherTuple
>::
value
==
GTEST_COMPILE_ASSERT_
(
std
::
tuple_size
<
MatcherTuple
>::
value
==
tuple_size
<
ValueTuple
>::
value
,
std
::
tuple_size
<
ValueTuple
>::
value
,
matcher_and_value_have_different_numbers_of_fields
);
matcher_and_value_have_different_numbers_of_fields
);
return
TuplePrefix
<
tuple_size
<
ValueTuple
>::
value
>::
return
TuplePrefix
<
std
::
tuple_size
<
ValueTuple
>::
value
>::
Matches
(
matcher_tuple
,
Matches
(
matcher_tuple
,
value_tuple
);
value_tuple
);
}
}
// Describes failures in matching matchers against values. If there
// Describes failures in matching matchers against values. If there
...
@@ -984,7 +441,7 @@ template <typename MatcherTuple, typename ValueTuple>
...
@@ -984,7 +441,7 @@ template <typename MatcherTuple, typename ValueTuple>
void
ExplainMatchFailureTupleTo
(
const
MatcherTuple
&
matchers
,
void
ExplainMatchFailureTupleTo
(
const
MatcherTuple
&
matchers
,
const
ValueTuple
&
values
,
const
ValueTuple
&
values
,
::
std
::
ostream
*
os
)
{
::
std
::
ostream
*
os
)
{
TuplePrefix
<
tuple_size
<
MatcherTuple
>::
value
>::
ExplainMatchFailuresTo
(
TuplePrefix
<
std
::
tuple_size
<
MatcherTuple
>::
value
>::
ExplainMatchFailuresTo
(
matchers
,
values
,
os
);
matchers
,
values
,
os
);
}
}
...
@@ -995,7 +452,7 @@ void ExplainMatchFailureTupleTo(const MatcherTuple& matchers,
...
@@ -995,7 +452,7 @@ void ExplainMatchFailureTupleTo(const MatcherTuple& matchers,
template
<
typename
Tuple
,
typename
Func
,
typename
OutIter
>
template
<
typename
Tuple
,
typename
Func
,
typename
OutIter
>
class
TransformTupleValuesHelper
{
class
TransformTupleValuesHelper
{
private:
private:
typedef
::
testing
::
tuple_size
<
Tuple
>
TupleSize
;
typedef
::
std
::
tuple_size
<
Tuple
>
TupleSize
;
public:
public:
// For each member of tuple 't', taken in order, evaluates '*out++ = f(t)'.
// For each member of tuple 't', taken in order, evaluates '*out++ = f(t)'.
...
@@ -1008,7 +465,7 @@ class TransformTupleValuesHelper {
...
@@ -1008,7 +465,7 @@ class TransformTupleValuesHelper {
template
<
typename
Tup
,
size_t
kRemainingSize
>
template
<
typename
Tup
,
size_t
kRemainingSize
>
struct
IterateOverTuple
{
struct
IterateOverTuple
{
OutIter
operator
()
(
Func
f
,
const
Tup
&
t
,
OutIter
out
)
const
{
OutIter
operator
()
(
Func
f
,
const
Tup
&
t
,
OutIter
out
)
const
{
*
out
++
=
f
(
::
testing
::
get
<
TupleSize
::
value
-
kRemainingSize
>
(
t
));
*
out
++
=
f
(
::
std
::
get
<
TupleSize
::
value
-
kRemainingSize
>
(
t
));
return
IterateOverTuple
<
Tup
,
kRemainingSize
-
1
>
()(
f
,
t
,
out
);
return
IterateOverTuple
<
Tup
,
kRemainingSize
-
1
>
()(
f
,
t
,
out
);
}
}
};
};
...
@@ -1030,14 +487,14 @@ OutIter TransformTupleValues(Func f, const Tuple& t, OutIter out) {
...
@@ -1030,14 +487,14 @@ OutIter TransformTupleValues(Func f, const Tuple& t, OutIter out) {
// Implements A<T>().
// Implements A<T>().
template
<
typename
T
>
template
<
typename
T
>
class
AnyMatcherImpl
:
public
MatcherInterface
<
GTEST_REFERENCE_TO_CONST_
(
T
)
>
{
class
AnyMatcherImpl
:
public
MatcherInterface
<
const
T
&
>
{
public:
public:
virtual
bool
MatchAndExplain
(
GTEST_REFERENCE_TO_CONST_
(
T
)
/* x */
,
bool
MatchAndExplain
(
const
T
&
/* x */
,
MatchResultListener
*
/* listener */
)
const
{
MatchResultListener
*
/* listener */
)
const
override
{
return
true
;
return
true
;
}
}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"is anything"
;
}
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"is anything"
;
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
// This is mostly for completeness' safe, as it's not very useful
// This is mostly for completeness' safe, as it's not very useful
// to write Not(A<bool>()). However we cannot completely rule out
// to write Not(A<bool>()). However we cannot completely rule out
// such a possibility, and it doesn't hurt to be prepared.
// such a possibility, and it doesn't hurt to be prepared.
...
@@ -1055,99 +512,6 @@ class AnythingMatcher {
...
@@ -1055,99 +512,6 @@ class AnythingMatcher {
operator
Matcher
<
T
>
()
const
{
return
A
<
T
>
();
}
operator
Matcher
<
T
>
()
const
{
return
A
<
T
>
();
}
};
};
// Implements a matcher that compares a given value with a
// pre-supplied value using one of the ==, <=, <, etc, operators. The
// two values being compared don't have to have the same type.
//
// The matcher defined here is polymorphic (for example, Eq(5) can be
// used to match an int, a short, a double, etc). Therefore we use
// a template type conversion operator in the implementation.
//
// The following template definition assumes that the Rhs parameter is
// a "bare" type (i.e. neither 'const T' nor 'T&').
template
<
typename
D
,
typename
Rhs
,
typename
Op
>
class
ComparisonBase
{
public:
explicit
ComparisonBase
(
const
Rhs
&
rhs
)
:
rhs_
(
rhs
)
{}
template
<
typename
Lhs
>
operator
Matcher
<
Lhs
>
()
const
{
return
MakeMatcher
(
new
Impl
<
Lhs
>
(
rhs_
));
}
private:
template
<
typename
Lhs
>
class
Impl
:
public
MatcherInterface
<
Lhs
>
{
public:
explicit
Impl
(
const
Rhs
&
rhs
)
:
rhs_
(
rhs
)
{}
virtual
bool
MatchAndExplain
(
Lhs
lhs
,
MatchResultListener
*
/* listener */
)
const
{
return
Op
()(
lhs
,
rhs_
);
}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
D
::
Desc
()
<<
" "
;
UniversalPrint
(
rhs_
,
os
);
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
D
::
NegatedDesc
()
<<
" "
;
UniversalPrint
(
rhs_
,
os
);
}
private:
Rhs
rhs_
;
GTEST_DISALLOW_ASSIGN_
(
Impl
);
};
Rhs
rhs_
;
GTEST_DISALLOW_ASSIGN_
(
ComparisonBase
);
};
template
<
typename
Rhs
>
class
EqMatcher
:
public
ComparisonBase
<
EqMatcher
<
Rhs
>
,
Rhs
,
AnyEq
>
{
public:
explicit
EqMatcher
(
const
Rhs
&
rhs
)
:
ComparisonBase
<
EqMatcher
<
Rhs
>
,
Rhs
,
AnyEq
>
(
rhs
)
{
}
static
const
char
*
Desc
()
{
return
"is equal to"
;
}
static
const
char
*
NegatedDesc
()
{
return
"isn't equal to"
;
}
};
template
<
typename
Rhs
>
class
NeMatcher
:
public
ComparisonBase
<
NeMatcher
<
Rhs
>
,
Rhs
,
AnyNe
>
{
public:
explicit
NeMatcher
(
const
Rhs
&
rhs
)
:
ComparisonBase
<
NeMatcher
<
Rhs
>
,
Rhs
,
AnyNe
>
(
rhs
)
{
}
static
const
char
*
Desc
()
{
return
"isn't equal to"
;
}
static
const
char
*
NegatedDesc
()
{
return
"is equal to"
;
}
};
template
<
typename
Rhs
>
class
LtMatcher
:
public
ComparisonBase
<
LtMatcher
<
Rhs
>
,
Rhs
,
AnyLt
>
{
public:
explicit
LtMatcher
(
const
Rhs
&
rhs
)
:
ComparisonBase
<
LtMatcher
<
Rhs
>
,
Rhs
,
AnyLt
>
(
rhs
)
{
}
static
const
char
*
Desc
()
{
return
"is <"
;
}
static
const
char
*
NegatedDesc
()
{
return
"isn't <"
;
}
};
template
<
typename
Rhs
>
class
GtMatcher
:
public
ComparisonBase
<
GtMatcher
<
Rhs
>
,
Rhs
,
AnyGt
>
{
public:
explicit
GtMatcher
(
const
Rhs
&
rhs
)
:
ComparisonBase
<
GtMatcher
<
Rhs
>
,
Rhs
,
AnyGt
>
(
rhs
)
{
}
static
const
char
*
Desc
()
{
return
"is >"
;
}
static
const
char
*
NegatedDesc
()
{
return
"isn't >"
;
}
};
template
<
typename
Rhs
>
class
LeMatcher
:
public
ComparisonBase
<
LeMatcher
<
Rhs
>
,
Rhs
,
AnyLe
>
{
public:
explicit
LeMatcher
(
const
Rhs
&
rhs
)
:
ComparisonBase
<
LeMatcher
<
Rhs
>
,
Rhs
,
AnyLe
>
(
rhs
)
{
}
static
const
char
*
Desc
()
{
return
"is <="
;
}
static
const
char
*
NegatedDesc
()
{
return
"isn't <="
;
}
};
template
<
typename
Rhs
>
class
GeMatcher
:
public
ComparisonBase
<
GeMatcher
<
Rhs
>
,
Rhs
,
AnyGe
>
{
public:
explicit
GeMatcher
(
const
Rhs
&
rhs
)
:
ComparisonBase
<
GeMatcher
<
Rhs
>
,
Rhs
,
AnyGe
>
(
rhs
)
{
}
static
const
char
*
Desc
()
{
return
"is >="
;
}
static
const
char
*
NegatedDesc
()
{
return
"isn't >="
;
}
};
// Implements the polymorphic IsNull() matcher, which matches any raw or smart
// Implements the polymorphic IsNull() matcher, which matches any raw or smart
// pointer that is NULL.
// pointer that is NULL.
class
IsNullMatcher
{
class
IsNullMatcher
{
...
@@ -1155,11 +519,7 @@ class IsNullMatcher {
...
@@ -1155,11 +519,7 @@ class IsNullMatcher {
template
<
typename
Pointer
>
template
<
typename
Pointer
>
bool
MatchAndExplain
(
const
Pointer
&
p
,
bool
MatchAndExplain
(
const
Pointer
&
p
,
MatchResultListener
*
/* listener */
)
const
{
MatchResultListener
*
/* listener */
)
const
{
#if GTEST_LANG_CXX11
return
p
==
nullptr
;
return
p
==
nullptr
;
#else // GTEST_LANG_CXX11
return
GetRawPointer
(
p
)
==
NULL
;
#endif // GTEST_LANG_CXX11
}
}
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"is NULL"
;
}
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"is NULL"
;
}
...
@@ -1175,11 +535,7 @@ class NotNullMatcher {
...
@@ -1175,11 +535,7 @@ class NotNullMatcher {
template
<
typename
Pointer
>
template
<
typename
Pointer
>
bool
MatchAndExplain
(
const
Pointer
&
p
,
bool
MatchAndExplain
(
const
Pointer
&
p
,
MatchResultListener
*
/* listener */
)
const
{
MatchResultListener
*
/* listener */
)
const
{
#if GTEST_LANG_CXX11
return
p
!=
nullptr
;
return
p
!=
nullptr
;
#else // GTEST_LANG_CXX11
return
GetRawPointer
(
p
)
!=
NULL
;
#endif // GTEST_LANG_CXX11
}
}
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"isn't NULL"
;
}
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"isn't NULL"
;
}
...
@@ -1235,18 +591,18 @@ class RefMatcher<T&> {
...
@@ -1235,18 +591,18 @@ class RefMatcher<T&> {
// MatchAndExplain() takes a Super& (as opposed to const Super&)
// MatchAndExplain() takes a Super& (as opposed to const Super&)
// in order to match the interface MatcherInterface<Super&>.
// in order to match the interface MatcherInterface<Super&>.
virtual
bool
MatchAndExplain
(
bool
MatchAndExplain
(
Super
&
x
,
Super
&
x
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
*
listener
<<
"which is located @"
<<
static_cast
<
const
void
*>
(
&
x
);
*
listener
<<
"which is located @"
<<
static_cast
<
const
void
*>
(
&
x
);
return
&
x
==
&
object_
;
return
&
x
==
&
object_
;
}
}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"references the variable "
;
*
os
<<
"references the variable "
;
UniversalPrinter
<
Super
&>::
Print
(
object_
,
os
);
UniversalPrinter
<
Super
&>::
Print
(
object_
,
os
);
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"does not reference the variable "
;
*
os
<<
"does not reference the variable "
;
UniversalPrinter
<
Super
&>::
Print
(
object_
,
os
);
UniversalPrinter
<
Super
&>::
Print
(
object_
,
os
);
}
}
...
@@ -1536,80 +892,24 @@ class EndsWithMatcher {
...
@@ -1536,80 +892,24 @@ class EndsWithMatcher {
GTEST_DISALLOW_ASSIGN_
(
EndsWithMatcher
);
GTEST_DISALLOW_ASSIGN_
(
EndsWithMatcher
);
};
};
// Implements polymorphic matchers MatchesRegex(regex) and
// ContainsRegex(regex), which can be used as a Matcher<T> as long as
// T can be converted to a string.
class
MatchesRegexMatcher
{
public:
MatchesRegexMatcher
(
const
RE
*
regex
,
bool
full_match
)
:
regex_
(
regex
),
full_match_
(
full_match
)
{}
#if GTEST_HAS_ABSL
bool
MatchAndExplain
(
const
absl
::
string_view
&
s
,
MatchResultListener
*
listener
)
const
{
return
MatchAndExplain
(
string
(
s
),
listener
);
}
#endif // GTEST_HAS_ABSL
// Accepts pointer types, particularly:
// const char*
// char*
// const wchar_t*
// wchar_t*
template
<
typename
CharType
>
bool
MatchAndExplain
(
CharType
*
s
,
MatchResultListener
*
listener
)
const
{
return
s
!=
nullptr
&&
MatchAndExplain
(
std
::
string
(
s
),
listener
);
}
// Matches anything that can convert to std::string.
//
// This is a template, not just a plain function with const std::string&,
// because absl::string_view has some interfering non-explicit constructors.
template
<
class
MatcheeStringType
>
bool
MatchAndExplain
(
const
MatcheeStringType
&
s
,
MatchResultListener
*
/* listener */
)
const
{
const
std
::
string
&
s2
(
s
);
return
full_match_
?
RE
:
:
FullMatch
(
s2
,
*
regex_
)
:
RE
::
PartialMatch
(
s2
,
*
regex_
);
}
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
(
full_match_
?
"matches"
:
"contains"
)
<<
" regular expression "
;
UniversalPrinter
<
std
::
string
>::
Print
(
regex_
->
pattern
(),
os
);
}
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"doesn't "
<<
(
full_match_
?
"match"
:
"contain"
)
<<
" regular expression "
;
UniversalPrinter
<
std
::
string
>::
Print
(
regex_
->
pattern
(),
os
);
}
private:
const
internal
::
linked_ptr
<
const
RE
>
regex_
;
const
bool
full_match_
;
GTEST_DISALLOW_ASSIGN_
(
MatchesRegexMatcher
);
};
// Implements a matcher that compares the two fields of a 2-tuple
// Implements a matcher that compares the two fields of a 2-tuple
// using one of the ==, <=, <, etc, operators. The two fields being
// using one of the ==, <=, <, etc, operators. The two fields being
// compared don't have to have the same type.
// compared don't have to have the same type.
//
//
// The matcher defined here is polymorphic (for example, Eq() can be
// The matcher defined here is polymorphic (for example, Eq() can be
// used to match a tuple<int, short>, a tuple<const long&, double>,
// used to match a
std::
tuple<int, short>, a
std::
tuple<const long&, double>,
// etc). Therefore we use a template type conversion operator in the
// etc). Therefore we use a template type conversion operator in the
// implementation.
// implementation.
template
<
typename
D
,
typename
Op
>
template
<
typename
D
,
typename
Op
>
class
PairMatchBase
{
class
PairMatchBase
{
public:
public:
template
<
typename
T1
,
typename
T2
>
template
<
typename
T1
,
typename
T2
>
operator
Matcher
<
::
testing
::
tuple
<
T1
,
T2
>
>
()
const
{
operator
Matcher
<::
std
::
tuple
<
T1
,
T2
>>
()
const
{
return
MakeMatcher
(
new
Impl
<
::
testing
::
tuple
<
T1
,
T2
>
>
);
return
MakeMatcher
(
new
Impl
<::
std
::
tuple
<
T1
,
T2
>>
);
}
}
template
<
typename
T1
,
typename
T2
>
template
<
typename
T1
,
typename
T2
>
operator
Matcher
<
const
::
testing
::
tuple
<
T1
,
T2
>&>
()
const
{
operator
Matcher
<
const
::
std
::
tuple
<
T1
,
T2
>&>
()
const
{
return
MakeMatcher
(
new
Impl
<
const
::
testing
::
tuple
<
T1
,
T2
>&>
);
return
MakeMatcher
(
new
Impl
<
const
::
std
::
tuple
<
T1
,
T2
>&>
);
}
}
private:
private:
...
@@ -1620,15 +920,14 @@ class PairMatchBase {
...
@@ -1620,15 +920,14 @@ class PairMatchBase {
template
<
typename
Tuple
>
template
<
typename
Tuple
>
class
Impl
:
public
MatcherInterface
<
Tuple
>
{
class
Impl
:
public
MatcherInterface
<
Tuple
>
{
public:
public:
virtual
bool
MatchAndExplain
(
bool
MatchAndExplain
(
Tuple
args
,
Tuple
args
,
MatchResultListener
*
/* listener */
)
const
override
{
MatchResultListener
*
/* listener */
)
const
{
return
Op
()(
::
std
::
get
<
0
>
(
args
),
::
std
::
get
<
1
>
(
args
));
return
Op
()(
::
testing
::
get
<
0
>
(
args
),
::
testing
::
get
<
1
>
(
args
));
}
}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"are "
<<
GetDesc
;
*
os
<<
"are "
<<
GetDesc
;
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"aren't "
<<
GetDesc
;
*
os
<<
"aren't "
<<
GetDesc
;
}
}
};
};
...
@@ -1664,21 +963,21 @@ class Ge2Matcher : public PairMatchBase<Ge2Matcher, AnyGe> {
...
@@ -1664,21 +963,21 @@ class Ge2Matcher : public PairMatchBase<Ge2Matcher, AnyGe> {
// will prevent different instantiations of NotMatcher from sharing
// will prevent different instantiations of NotMatcher from sharing
// the same NotMatcherImpl<T> class.
// the same NotMatcherImpl<T> class.
template
<
typename
T
>
template
<
typename
T
>
class
NotMatcherImpl
:
public
MatcherInterface
<
GTEST_REFERENCE_TO_CONST_
(
T
)
>
{
class
NotMatcherImpl
:
public
MatcherInterface
<
const
T
&
>
{
public:
public:
explicit
NotMatcherImpl
(
const
Matcher
<
T
>&
matcher
)
explicit
NotMatcherImpl
(
const
Matcher
<
T
>&
matcher
)
:
matcher_
(
matcher
)
{}
:
matcher_
(
matcher
)
{}
virtual
bool
MatchAndExplain
(
GTEST_REFERENCE_TO_CONST_
(
T
)
x
,
bool
MatchAndExplain
(
const
T
&
x
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
return
!
matcher_
.
MatchAndExplain
(
x
,
listener
);
return
!
matcher_
.
MatchAndExplain
(
x
,
listener
);
}
}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
matcher_
.
DescribeNegationTo
(
os
);
matcher_
.
DescribeNegationTo
(
os
);
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
matcher_
.
DescribeTo
(
os
);
matcher_
.
DescribeTo
(
os
);
}
}
...
@@ -1713,13 +1012,12 @@ class NotMatcher {
...
@@ -1713,13 +1012,12 @@ class NotMatcher {
// that will prevent different instantiations of BothOfMatcher from
// that will prevent different instantiations of BothOfMatcher from
// sharing the same BothOfMatcherImpl<T> class.
// sharing the same BothOfMatcherImpl<T> class.
template
<
typename
T
>
template
<
typename
T
>
class
AllOfMatcherImpl
class
AllOfMatcherImpl
:
public
MatcherInterface
<
const
T
&>
{
:
public
MatcherInterface
<
GTEST_REFERENCE_TO_CONST_
(
T
)
>
{
public:
public:
explicit
AllOfMatcherImpl
(
std
::
vector
<
Matcher
<
T
>
>
matchers
)
explicit
AllOfMatcherImpl
(
std
::
vector
<
Matcher
<
T
>
>
matchers
)
:
matchers_
(
internal
::
move
(
matchers
))
{}
:
matchers_
(
std
::
move
(
matchers
))
{}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"("
;
*
os
<<
"("
;
for
(
size_t
i
=
0
;
i
<
matchers_
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
matchers_
.
size
();
++
i
)
{
if
(
i
!=
0
)
*
os
<<
") and ("
;
if
(
i
!=
0
)
*
os
<<
") and ("
;
...
@@ -1728,7 +1026,7 @@ class AllOfMatcherImpl
...
@@ -1728,7 +1026,7 @@ class AllOfMatcherImpl
*
os
<<
")"
;
*
os
<<
")"
;
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"("
;
*
os
<<
"("
;
for
(
size_t
i
=
0
;
i
<
matchers_
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
matchers_
.
size
();
++
i
)
{
if
(
i
!=
0
)
*
os
<<
") or ("
;
if
(
i
!=
0
)
*
os
<<
") or ("
;
...
@@ -1737,8 +1035,8 @@ class AllOfMatcherImpl
...
@@ -1737,8 +1035,8 @@ class AllOfMatcherImpl
*
os
<<
")"
;
*
os
<<
")"
;
}
}
virtual
bool
MatchAndExplain
(
GTEST_REFERENCE_TO_CONST_
(
T
)
x
,
bool
MatchAndExplain
(
const
T
&
x
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
// If either matcher1_ or matcher2_ doesn't match x, we only need
// If either matcher1_ or matcher2_ doesn't match x, we only need
// to explain why one of them fails.
// to explain why one of them fails.
std
::
string
all_match_result
;
std
::
string
all_match_result
;
...
@@ -1791,7 +1089,7 @@ class VariadicMatcher {
...
@@ -1791,7 +1089,7 @@ class VariadicMatcher {
operator
Matcher
<
T
>
()
const
{
operator
Matcher
<
T
>
()
const
{
std
::
vector
<
Matcher
<
T
>
>
values
;
std
::
vector
<
Matcher
<
T
>
>
values
;
CreateVariadicMatcher
<
T
>
(
&
values
,
std
::
integral_constant
<
size_t
,
0
>
());
CreateVariadicMatcher
<
T
>
(
&
values
,
std
::
integral_constant
<
size_t
,
0
>
());
return
Matcher
<
T
>
(
new
CombiningMatcher
<
T
>
(
internal
::
move
(
values
)));
return
Matcher
<
T
>
(
new
CombiningMatcher
<
T
>
(
std
::
move
(
values
)));
}
}
private:
private:
...
@@ -1807,7 +1105,7 @@ class VariadicMatcher {
...
@@ -1807,7 +1105,7 @@ class VariadicMatcher {
std
::
vector
<
Matcher
<
T
>
>*
,
std
::
vector
<
Matcher
<
T
>
>*
,
std
::
integral_constant
<
size_t
,
sizeof
...(
Args
)
>
)
const
{}
std
::
integral_constant
<
size_t
,
sizeof
...(
Args
)
>
)
const
{}
tuple
<
Args
...
>
matchers_
;
std
::
tuple
<
Args
...
>
matchers_
;
GTEST_DISALLOW_ASSIGN_
(
VariadicMatcher
);
GTEST_DISALLOW_ASSIGN_
(
VariadicMatcher
);
};
};
...
@@ -1815,44 +1113,17 @@ class VariadicMatcher {
...
@@ -1815,44 +1113,17 @@ class VariadicMatcher {
template
<
typename
...
Args
>
template
<
typename
...
Args
>
using
AllOfMatcher
=
VariadicMatcher
<
AllOfMatcherImpl
,
Args
...
>
;
using
AllOfMatcher
=
VariadicMatcher
<
AllOfMatcherImpl
,
Args
...
>
;
// Used for implementing the AllOf(m_1, ..., m_n) matcher, which
// matches a value that matches all of the matchers m_1, ..., and m_n.
template
<
typename
Matcher1
,
typename
Matcher2
>
class
BothOfMatcher
{
public:
BothOfMatcher
(
Matcher1
matcher1
,
Matcher2
matcher2
)
:
matcher1_
(
matcher1
),
matcher2_
(
matcher2
)
{}
// This template type conversion operator allows a
// BothOfMatcher<Matcher1, Matcher2> object to match any type that
// both Matcher1 and Matcher2 can match.
template
<
typename
T
>
operator
Matcher
<
T
>
()
const
{
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:
Matcher1
matcher1_
;
Matcher2
matcher2_
;
GTEST_DISALLOW_ASSIGN_
(
BothOfMatcher
);
};
// Implements the AnyOf(m1, m2) matcher for a particular argument type
// Implements the AnyOf(m1, m2) matcher for a particular argument type
// T. We do not nest it inside the AnyOfMatcher class template, as
// T. We do not nest it inside the AnyOfMatcher class template, as
// that will prevent different instantiations of AnyOfMatcher from
// that will prevent different instantiations of AnyOfMatcher from
// sharing the same EitherOfMatcherImpl<T> class.
// sharing the same EitherOfMatcherImpl<T> class.
template
<
typename
T
>
template
<
typename
T
>
class
AnyOfMatcherImpl
class
AnyOfMatcherImpl
:
public
MatcherInterface
<
const
T
&>
{
:
public
MatcherInterface
<
GTEST_REFERENCE_TO_CONST_
(
T
)
>
{
public:
public:
explicit
AnyOfMatcherImpl
(
std
::
vector
<
Matcher
<
T
>
>
matchers
)
explicit
AnyOfMatcherImpl
(
std
::
vector
<
Matcher
<
T
>
>
matchers
)
:
matchers_
(
internal
::
move
(
matchers
))
{}
:
matchers_
(
std
::
move
(
matchers
))
{}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"("
;
*
os
<<
"("
;
for
(
size_t
i
=
0
;
i
<
matchers_
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
matchers_
.
size
();
++
i
)
{
if
(
i
!=
0
)
*
os
<<
") or ("
;
if
(
i
!=
0
)
*
os
<<
") or ("
;
...
@@ -1861,7 +1132,7 @@ class AnyOfMatcherImpl
...
@@ -1861,7 +1132,7 @@ class AnyOfMatcherImpl
*
os
<<
")"
;
*
os
<<
")"
;
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"("
;
*
os
<<
"("
;
for
(
size_t
i
=
0
;
i
<
matchers_
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
matchers_
.
size
();
++
i
)
{
if
(
i
!=
0
)
*
os
<<
") and ("
;
if
(
i
!=
0
)
*
os
<<
") and ("
;
...
@@ -1870,8 +1141,8 @@ class AnyOfMatcherImpl
...
@@ -1870,8 +1141,8 @@ class AnyOfMatcherImpl
*
os
<<
")"
;
*
os
<<
")"
;
}
}
virtual
bool
MatchAndExplain
(
GTEST_REFERENCE_TO_CONST_
(
T
)
x
,
bool
MatchAndExplain
(
const
T
&
x
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
std
::
string
no_match_result
;
std
::
string
no_match_result
;
// If either matcher1_ or matcher2_ matches x, we just need to
// If either matcher1_ or matcher2_ matches x, we just need to
...
@@ -1905,40 +1176,10 @@ class AnyOfMatcherImpl
...
@@ -1905,40 +1176,10 @@ class AnyOfMatcherImpl
GTEST_DISALLOW_ASSIGN_
(
AnyOfMatcherImpl
);
GTEST_DISALLOW_ASSIGN_
(
AnyOfMatcherImpl
);
};
};
#if GTEST_LANG_CXX11
// AnyOfMatcher is used for the variadic implementation of AnyOf(m_1, m_2, ...).
// AnyOfMatcher is used for the variadic implementation of AnyOf(m_1, m_2, ...).
template
<
typename
...
Args
>
template
<
typename
...
Args
>
using
AnyOfMatcher
=
VariadicMatcher
<
AnyOfMatcherImpl
,
Args
...
>
;
using
AnyOfMatcher
=
VariadicMatcher
<
AnyOfMatcherImpl
,
Args
...
>
;
#endif // GTEST_LANG_CXX11
// Used for implementing the AnyOf(m_1, ..., m_n) matcher, which
// matches a value that matches at least one of the matchers m_1, ...,
// and m_n.
template
<
typename
Matcher1
,
typename
Matcher2
>
class
EitherOfMatcher
{
public:
EitherOfMatcher
(
Matcher1
matcher1
,
Matcher2
matcher2
)
:
matcher1_
(
matcher1
),
matcher2_
(
matcher2
)
{}
// This template type conversion operator allows a
// EitherOfMatcher<Matcher1, Matcher2> object to match any type that
// both Matcher1 and Matcher2 can match.
template
<
typename
T
>
operator
Matcher
<
T
>
()
const
{
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:
Matcher1
matcher1_
;
Matcher2
matcher2_
;
GTEST_DISALLOW_ASSIGN_
(
EitherOfMatcher
);
};
// Used for implementing Truly(pred), which turns a predicate into a
// Used for implementing Truly(pred), which turns a predicate into a
// matcher.
// matcher.
template
<
typename
Predicate
>
template
<
typename
Predicate
>
...
@@ -2021,7 +1262,7 @@ class MatcherAsPredicate {
...
@@ -2021,7 +1262,7 @@ class MatcherAsPredicate {
template
<
typename
M
>
template
<
typename
M
>
class
PredicateFormatterFromMatcher
{
class
PredicateFormatterFromMatcher
{
public:
public:
explicit
PredicateFormatterFromMatcher
(
M
m
)
:
matcher_
(
internal
::
move
(
m
))
{}
explicit
PredicateFormatterFromMatcher
(
M
m
)
:
matcher_
(
std
::
move
(
m
))
{}
// This template () operator allows a PredicateFormatterFromMatcher
// This template () operator allows a PredicateFormatterFromMatcher
// object to act as a predicate-formatter suitable for using with
// object to act as a predicate-formatter suitable for using with
...
@@ -2040,14 +1281,24 @@ class PredicateFormatterFromMatcher {
...
@@ -2040,14 +1281,24 @@ class PredicateFormatterFromMatcher {
// We don't write MatcherCast<const T&> either, as that allows
// We don't write MatcherCast<const T&> either, as that allows
// potentially unsafe downcasting of the matcher argument.
// potentially unsafe downcasting of the matcher argument.
const
Matcher
<
const
T
&>
matcher
=
SafeMatcherCast
<
const
T
&>
(
matcher_
);
const
Matcher
<
const
T
&>
matcher
=
SafeMatcherCast
<
const
T
&>
(
matcher_
);
StringMatchResultListener
listener
;
if
(
MatchPrintAndExplain
(
x
,
matcher
,
&
listener
))
// The expected path here is that the matcher should match (i.e. that most
// tests pass) so optimize for this case.
if
(
matcher
.
Matches
(
x
))
{
return
AssertionSuccess
();
return
AssertionSuccess
();
}
::
std
::
stringstream
ss
;
::
std
::
stringstream
ss
;
ss
<<
"Value of: "
<<
value_text
<<
"
\n
"
ss
<<
"Value of: "
<<
value_text
<<
"
\n
"
<<
"Expected: "
;
<<
"Expected: "
;
matcher
.
DescribeTo
(
&
ss
);
matcher
.
DescribeTo
(
&
ss
);
// Rerun the matcher to "PrintAndExain" the failure.
StringMatchResultListener
listener
;
if
(
MatchPrintAndExplain
(
x
,
matcher
,
&
listener
))
{
ss
<<
"
\n
The matcher failed on the initial attempt; but passed when "
"rerun to generate the explanation."
;
}
ss
<<
"
\n
Actual: "
<<
listener
.
str
();
ss
<<
"
\n
Actual: "
<<
listener
.
str
();
return
AssertionFailure
()
<<
ss
.
str
();
return
AssertionFailure
()
<<
ss
.
str
();
}
}
...
@@ -2065,7 +1316,7 @@ class PredicateFormatterFromMatcher {
...
@@ -2065,7 +1316,7 @@ class PredicateFormatterFromMatcher {
template
<
typename
M
>
template
<
typename
M
>
inline
PredicateFormatterFromMatcher
<
M
>
inline
PredicateFormatterFromMatcher
<
M
>
MakePredicateFormatterFromMatcher
(
M
matcher
)
{
MakePredicateFormatterFromMatcher
(
M
matcher
)
{
return
PredicateFormatterFromMatcher
<
M
>
(
internal
::
move
(
matcher
));
return
PredicateFormatterFromMatcher
<
M
>
(
std
::
move
(
matcher
));
}
}
// Implements the polymorphic floating point equality matcher, which matches
// Implements the polymorphic floating point equality matcher, which matches
...
@@ -2106,8 +1357,8 @@ class FloatingEqMatcher {
...
@@ -2106,8 +1357,8 @@ class FloatingEqMatcher {
nan_eq_nan_
(
nan_eq_nan
),
nan_eq_nan_
(
nan_eq_nan
),
max_abs_error_
(
max_abs_error
)
{}
max_abs_error_
(
max_abs_error
)
{}
virtual
bool
MatchAndExplain
(
T
value
,
bool
MatchAndExplain
(
T
value
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
const
FloatingPoint
<
FloatType
>
actual
(
value
),
expected
(
expected_
);
const
FloatingPoint
<
FloatType
>
actual
(
value
),
expected
(
expected_
);
// Compares NaNs first, if nan_eq_nan_ is true.
// Compares NaNs first, if nan_eq_nan_ is true.
...
@@ -2141,7 +1392,7 @@ class FloatingEqMatcher {
...
@@ -2141,7 +1392,7 @@ class FloatingEqMatcher {
}
}
}
}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
// os->precision() returns the previously set precision, which we
// os->precision() returns the previously set precision, which we
// store to restore the ostream to its original configuration
// store to restore the ostream to its original configuration
// after outputting.
// after outputting.
...
@@ -2162,7 +1413,7 @@ class FloatingEqMatcher {
...
@@ -2162,7 +1413,7 @@ class FloatingEqMatcher {
os
->
precision
(
old_precision
);
os
->
precision
(
old_precision
);
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
// As before, get original precision.
// As before, get original precision.
const
::
std
::
streamsize
old_precision
=
os
->
precision
(
const
::
std
::
streamsize
old_precision
=
os
->
precision
(
::
std
::
numeric_limits
<
FloatType
>::
digits10
+
2
);
::
std
::
numeric_limits
<
FloatType
>::
digits10
+
2
);
...
@@ -2246,14 +1497,14 @@ class FloatingEq2Matcher {
...
@@ -2246,14 +1497,14 @@ class FloatingEq2Matcher {
}
}
template
<
typename
T1
,
typename
T2
>
template
<
typename
T1
,
typename
T2
>
operator
Matcher
<
::
testing
::
tuple
<
T1
,
T2
>
>
()
const
{
operator
Matcher
<::
std
::
tuple
<
T1
,
T2
>>
()
const
{
return
MakeMatcher
(
return
MakeMatcher
(
new
Impl
<
::
testing
::
tuple
<
T1
,
T2
>
>
(
max_abs_error_
,
nan_eq_nan_
));
new
Impl
<::
std
::
tuple
<
T1
,
T2
>>
(
max_abs_error_
,
nan_eq_nan_
));
}
}
template
<
typename
T1
,
typename
T2
>
template
<
typename
T1
,
typename
T2
>
operator
Matcher
<
const
::
testing
::
tuple
<
T1
,
T2
>&>
()
const
{
operator
Matcher
<
const
::
std
::
tuple
<
T1
,
T2
>&>
()
const
{
return
MakeMatcher
(
return
MakeMatcher
(
new
Impl
<
const
::
testing
::
tuple
<
T1
,
T2
>&>
(
max_abs_error_
,
nan_eq_nan_
));
new
Impl
<
const
::
std
::
tuple
<
T1
,
T2
>&>
(
max_abs_error_
,
nan_eq_nan_
));
}
}
private:
private:
...
@@ -2268,23 +1519,23 @@ class FloatingEq2Matcher {
...
@@ -2268,23 +1519,23 @@ class FloatingEq2Matcher {
max_abs_error_
(
max_abs_error
),
max_abs_error_
(
max_abs_error
),
nan_eq_nan_
(
nan_eq_nan
)
{}
nan_eq_nan_
(
nan_eq_nan
)
{}
virtual
bool
MatchAndExplain
(
Tuple
args
,
bool
MatchAndExplain
(
Tuple
args
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
if
(
max_abs_error_
==
-
1
)
{
if
(
max_abs_error_
==
-
1
)
{
FloatingEqMatcher
<
FloatType
>
fm
(
::
testing
::
get
<
0
>
(
args
),
nan_eq_nan_
);
FloatingEqMatcher
<
FloatType
>
fm
(
::
std
::
get
<
0
>
(
args
),
nan_eq_nan_
);
return
static_cast
<
Matcher
<
FloatType
>
>
(
fm
).
MatchAndExplain
(
return
static_cast
<
Matcher
<
FloatType
>>
(
fm
).
MatchAndExplain
(
::
testing
::
get
<
1
>
(
args
),
listener
);
::
std
::
get
<
1
>
(
args
),
listener
);
}
else
{
}
else
{
FloatingEqMatcher
<
FloatType
>
fm
(
::
testing
::
get
<
0
>
(
args
),
nan_eq_nan_
,
FloatingEqMatcher
<
FloatType
>
fm
(
::
std
::
get
<
0
>
(
args
),
nan_eq_nan_
,
max_abs_error_
);
max_abs_error_
);
return
static_cast
<
Matcher
<
FloatType
>
>
(
fm
).
MatchAndExplain
(
return
static_cast
<
Matcher
<
FloatType
>>
(
fm
).
MatchAndExplain
(
::
testing
::
get
<
1
>
(
args
),
listener
);
::
std
::
get
<
1
>
(
args
),
listener
);
}
}
}
}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"are "
<<
GetDesc
;
*
os
<<
"are "
<<
GetDesc
;
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"aren't "
<<
GetDesc
;
*
os
<<
"aren't "
<<
GetDesc
;
}
}
...
@@ -2318,8 +1569,7 @@ class PointeeMatcher {
...
@@ -2318,8 +1569,7 @@ class PointeeMatcher {
// enough for implementing the DescribeTo() method of Pointee().
// enough for implementing the DescribeTo() method of Pointee().
template
<
typename
Pointer
>
template
<
typename
Pointer
>
operator
Matcher
<
Pointer
>
()
const
{
operator
Matcher
<
Pointer
>
()
const
{
return
Matcher
<
Pointer
>
(
return
Matcher
<
Pointer
>
(
new
Impl
<
const
Pointer
&>
(
matcher_
));
new
Impl
<
GTEST_REFERENCE_TO_CONST_
(
Pointer
)
>
(
matcher_
));
}
}
private:
private:
...
@@ -2333,18 +1583,18 @@ class PointeeMatcher {
...
@@ -2333,18 +1583,18 @@ class PointeeMatcher {
explicit
Impl
(
const
InnerMatcher
&
matcher
)
explicit
Impl
(
const
InnerMatcher
&
matcher
)
:
matcher_
(
MatcherCast
<
const
Pointee
&>
(
matcher
))
{}
:
matcher_
(
MatcherCast
<
const
Pointee
&>
(
matcher
))
{}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"points to a value that "
;
*
os
<<
"points to a value that "
;
matcher_
.
DescribeTo
(
os
);
matcher_
.
DescribeTo
(
os
);
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"does not point to a value that "
;
*
os
<<
"does not point to a value that "
;
matcher_
.
DescribeTo
(
os
);
matcher_
.
DescribeTo
(
os
);
}
}
virtual
bool
MatchAndExplain
(
Pointer
pointer
,
bool
MatchAndExplain
(
Pointer
pointer
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
if
(
GetRawPointer
(
pointer
)
==
nullptr
)
return
false
;
if
(
GetRawPointer
(
pointer
)
==
nullptr
)
return
false
;
*
listener
<<
"which points to "
;
*
listener
<<
"which points to "
;
...
@@ -2509,11 +1759,7 @@ class FieldMatcher {
...
@@ -2509,11 +1759,7 @@ class FieldMatcher {
template
<
typename
Class
,
typename
PropertyType
,
typename
Property
>
template
<
typename
Class
,
typename
PropertyType
,
typename
Property
>
class
PropertyMatcher
{
class
PropertyMatcher
{
public:
public:
// The property may have a reference type, so 'const PropertyType&'
typedef
const
PropertyType
&
RefToConstProperty
;
// may cause double references and fail to compile. That's why we
// need GTEST_REFERENCE_TO_CONST, which works regardless of
// PropertyType being a reference or not.
typedef
GTEST_REFERENCE_TO_CONST_
(
PropertyType
)
RefToConstProperty
;
PropertyMatcher
(
Property
property
,
const
Matcher
<
RefToConstProperty
>&
matcher
)
PropertyMatcher
(
Property
property
,
const
Matcher
<
RefToConstProperty
>&
matcher
)
:
property_
(
property
),
:
property_
(
property
),
...
@@ -2553,15 +1799,8 @@ class PropertyMatcher {
...
@@ -2553,15 +1799,8 @@ class PropertyMatcher {
*
listener
<<
whose_property_
<<
"is "
;
*
listener
<<
whose_property_
<<
"is "
;
// Cannot pass the return value (for example, int) to MatchPrintAndExplain,
// Cannot pass the return value (for example, int) to MatchPrintAndExplain,
// which takes a non-const reference as argument.
// which takes a non-const reference as argument.
#if defined(_PREFAST_ ) && _MSC_VER == 1800
// Workaround bug in VC++ 2013's /analyze parser.
// https://connect.microsoft.com/VisualStudio/feedback/details/1106363/internal-compiler-error-with-analyze-due-to-failure-to-infer-move
posix
::
Abort
();
// To make sure it is never run.
return
false
;
#else
RefToConstProperty
result
=
(
obj
.
*
property_
)();
RefToConstProperty
result
=
(
obj
.
*
property_
)();
return
MatchPrintAndExplain
(
result
,
matcher_
,
listener
);
return
MatchPrintAndExplain
(
result
,
matcher_
,
listener
);
#endif
}
}
bool
MatchAndExplainImpl
(
true_type
/* is_pointer */
,
const
Class
*
p
,
bool
MatchAndExplainImpl
(
true_type
/* is_pointer */
,
const
Class
*
p
,
...
@@ -2593,14 +1832,8 @@ struct CallableTraits {
...
@@ -2593,14 +1832,8 @@ struct CallableTraits {
static
void
CheckIsValid
(
Functor
/* functor */
)
{}
static
void
CheckIsValid
(
Functor
/* functor */
)
{}
#if GTEST_LANG_CXX11
template
<
typename
T
>
template
<
typename
T
>
static
auto
Invoke
(
Functor
f
,
T
arg
)
->
decltype
(
f
(
arg
))
{
return
f
(
arg
);
}
static
auto
Invoke
(
Functor
f
,
T
arg
)
->
decltype
(
f
(
arg
))
{
return
f
(
arg
);
}
#else
typedef
typename
Functor
::
result_type
ResultType
;
template
<
typename
T
>
static
ResultType
Invoke
(
Functor
f
,
T
arg
)
{
return
f
(
arg
);
}
#endif
};
};
// Specialization for function pointers.
// Specialization for function pointers.
...
@@ -2625,7 +1858,7 @@ template <typename Callable, typename InnerMatcher>
...
@@ -2625,7 +1858,7 @@ template <typename Callable, typename InnerMatcher>
class
ResultOfMatcher
{
class
ResultOfMatcher
{
public:
public:
ResultOfMatcher
(
Callable
callable
,
InnerMatcher
matcher
)
ResultOfMatcher
(
Callable
callable
,
InnerMatcher
matcher
)
:
callable_
(
internal
::
move
(
callable
)),
matcher_
(
internal
::
move
(
matcher
))
{
:
callable_
(
std
::
move
(
callable
)),
matcher_
(
std
::
move
(
matcher
))
{
CallableTraits
<
Callable
>::
CheckIsValid
(
callable_
);
CallableTraits
<
Callable
>::
CheckIsValid
(
callable_
);
}
}
...
@@ -2639,29 +1872,25 @@ class ResultOfMatcher {
...
@@ -2639,29 +1872,25 @@ class ResultOfMatcher {
template
<
typename
T
>
template
<
typename
T
>
class
Impl
:
public
MatcherInterface
<
T
>
{
class
Impl
:
public
MatcherInterface
<
T
>
{
#if GTEST_LANG_CXX11
using
ResultType
=
decltype
(
CallableTraits
<
Callable
>::
template
Invoke
<
T
>
(
using
ResultType
=
decltype
(
CallableTraits
<
Callable
>::
template
Invoke
<
T
>
(
std
::
declval
<
CallableStorageType
>
(),
std
::
declval
<
T
>
()));
std
::
declval
<
CallableStorageType
>
(),
std
::
declval
<
T
>
()));
#else
typedef
typename
CallableTraits
<
Callable
>::
ResultType
ResultType
;
#endif
public:
public:
template
<
typename
M
>
template
<
typename
M
>
Impl
(
const
CallableStorageType
&
callable
,
const
M
&
matcher
)
Impl
(
const
CallableStorageType
&
callable
,
const
M
&
matcher
)
:
callable_
(
callable
),
matcher_
(
MatcherCast
<
ResultType
>
(
matcher
))
{}
:
callable_
(
callable
),
matcher_
(
MatcherCast
<
ResultType
>
(
matcher
))
{}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"is mapped by the given callable to a value that "
;
*
os
<<
"is mapped by the given callable to a value that "
;
matcher_
.
DescribeTo
(
os
);
matcher_
.
DescribeTo
(
os
);
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"is mapped by the given callable to a value that "
;
*
os
<<
"is mapped by the given callable to a value that "
;
matcher_
.
DescribeNegationTo
(
os
);
matcher_
.
DescribeNegationTo
(
os
);
}
}
virtual
bool
MatchAndExplain
(
T
obj
,
MatchResultListener
*
listener
)
const
{
bool
MatchAndExplain
(
T
obj
,
MatchResultListener
*
listener
)
const
override
{
*
listener
<<
"which is mapped by the given callable to "
;
*
listener
<<
"which is mapped by the given callable to "
;
// Cannot pass the return value directly to MatchPrintAndExplain, which
// Cannot pass the return value directly to MatchPrintAndExplain, which
// takes a non-const reference as argument.
// takes a non-const reference as argument.
...
@@ -2700,29 +1929,27 @@ class SizeIsMatcher {
...
@@ -2700,29 +1929,27 @@ class SizeIsMatcher {
template
<
typename
Container
>
template
<
typename
Container
>
operator
Matcher
<
Container
>
()
const
{
operator
Matcher
<
Container
>
()
const
{
return
Make
Matcher
(
new
Impl
<
Container
>
(
size_matcher_
));
return
Matcher
<
Container
>
(
new
Impl
<
const
Container
&
>
(
size_matcher_
));
}
}
template
<
typename
Container
>
template
<
typename
Container
>
class
Impl
:
public
MatcherInterface
<
Container
>
{
class
Impl
:
public
MatcherInterface
<
Container
>
{
public:
public:
typedef
internal
::
StlContainerView
<
using
SizeType
=
decltype
(
std
::
declval
<
Container
>
().
size
());
GTEST_REMOVE_REFERENCE_AND_CONST_
(
Container
)
>
ContainerView
;
typedef
typename
ContainerView
::
type
::
size_type
SizeType
;
explicit
Impl
(
const
SizeMatcher
&
size_matcher
)
explicit
Impl
(
const
SizeMatcher
&
size_matcher
)
:
size_matcher_
(
MatcherCast
<
SizeType
>
(
size_matcher
))
{}
:
size_matcher_
(
MatcherCast
<
SizeType
>
(
size_matcher
))
{}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"size "
;
*
os
<<
"size "
;
size_matcher_
.
DescribeTo
(
os
);
size_matcher_
.
DescribeTo
(
os
);
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"size "
;
*
os
<<
"size "
;
size_matcher_
.
DescribeNegationTo
(
os
);
size_matcher_
.
DescribeNegationTo
(
os
);
}
}
virtual
bool
MatchAndExplain
(
Container
container
,
bool
MatchAndExplain
(
Container
container
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
SizeType
size
=
container
.
size
();
SizeType
size
=
container
.
size
();
StringMatchResultListener
size_listener
;
StringMatchResultListener
size_listener
;
const
bool
result
=
size_matcher_
.
MatchAndExplain
(
size
,
&
size_listener
);
const
bool
result
=
size_matcher_
.
MatchAndExplain
(
size
,
&
size_listener
);
...
@@ -2752,7 +1979,7 @@ class BeginEndDistanceIsMatcher {
...
@@ -2752,7 +1979,7 @@ class BeginEndDistanceIsMatcher {
template
<
typename
Container
>
template
<
typename
Container
>
operator
Matcher
<
Container
>
()
const
{
operator
Matcher
<
Container
>
()
const
{
return
Make
Matcher
(
new
Impl
<
Container
>
(
distance_matcher_
));
return
Matcher
<
Container
>
(
new
Impl
<
const
Container
&
>
(
distance_matcher_
));
}
}
template
<
typename
Container
>
template
<
typename
Container
>
...
@@ -2766,24 +1993,20 @@ class BeginEndDistanceIsMatcher {
...
@@ -2766,24 +1993,20 @@ class BeginEndDistanceIsMatcher {
explicit
Impl
(
const
DistanceMatcher
&
distance_matcher
)
explicit
Impl
(
const
DistanceMatcher
&
distance_matcher
)
:
distance_matcher_
(
MatcherCast
<
DistanceType
>
(
distance_matcher
))
{}
:
distance_matcher_
(
MatcherCast
<
DistanceType
>
(
distance_matcher
))
{}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"distance between begin() and end() "
;
*
os
<<
"distance between begin() and end() "
;
distance_matcher_
.
DescribeTo
(
os
);
distance_matcher_
.
DescribeTo
(
os
);
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"distance between begin() and end() "
;
*
os
<<
"distance between begin() and end() "
;
distance_matcher_
.
DescribeNegationTo
(
os
);
distance_matcher_
.
DescribeNegationTo
(
os
);
}
}
virtual
bool
MatchAndExplain
(
Container
container
,
bool
MatchAndExplain
(
Container
container
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
#if GTEST_HAS_STD_BEGIN_AND_END_
using
std
::
begin
;
using
std
::
begin
;
using
std
::
end
;
using
std
::
end
;
DistanceType
distance
=
std
::
distance
(
begin
(
container
),
end
(
container
));
DistanceType
distance
=
std
::
distance
(
begin
(
container
),
end
(
container
));
#else
DistanceType
distance
=
std
::
distance
(
container
.
begin
(),
container
.
end
());
#endif
StringMatchResultListener
distance_listener
;
StringMatchResultListener
distance_listener
;
const
bool
result
=
const
bool
result
=
distance_matcher_
.
MatchAndExplain
(
distance
,
&
distance_listener
);
distance_matcher_
.
MatchAndExplain
(
distance
,
&
distance_listener
);
...
@@ -2932,18 +2155,18 @@ class WhenSortedByMatcher {
...
@@ -2932,18 +2155,18 @@ class WhenSortedByMatcher {
Impl
(
const
Comparator
&
comparator
,
const
ContainerMatcher
&
matcher
)
Impl
(
const
Comparator
&
comparator
,
const
ContainerMatcher
&
matcher
)
:
comparator_
(
comparator
),
matcher_
(
matcher
)
{}
:
comparator_
(
comparator
),
matcher_
(
matcher
)
{}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"(when sorted) "
;
*
os
<<
"(when sorted) "
;
matcher_
.
DescribeTo
(
os
);
matcher_
.
DescribeTo
(
os
);
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"(when sorted) "
;
*
os
<<
"(when sorted) "
;
matcher_
.
DescribeNegationTo
(
os
);
matcher_
.
DescribeNegationTo
(
os
);
}
}
virtual
bool
MatchAndExplain
(
LhsContainer
lhs
,
bool
MatchAndExplain
(
LhsContainer
lhs
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
LhsStlContainerReference
lhs_stl_container
=
LhsView
::
ConstReference
(
lhs
);
LhsStlContainerReference
lhs_stl_container
=
LhsView
::
ConstReference
(
lhs
);
::
std
::
vector
<
LhsValue
>
sorted_container
(
lhs_stl_container
.
begin
(),
::
std
::
vector
<
LhsValue
>
sorted_container
(
lhs_stl_container
.
begin
(),
lhs_stl_container
.
end
());
lhs_stl_container
.
end
());
...
@@ -2982,7 +2205,7 @@ class WhenSortedByMatcher {
...
@@ -2982,7 +2205,7 @@ class WhenSortedByMatcher {
};
};
// Implements Pointwise(tuple_matcher, rhs_container). tuple_matcher
// Implements Pointwise(tuple_matcher, rhs_container). tuple_matcher
// must be able to be safely cast to Matcher<tuple<const T1&, const
// must be able to be safely cast to Matcher<
std::
tuple<const T1&, const
// T2&> >, where T1 and T2 are the types of elements in the LHS
// T2&> >, where T1 and T2 are the types of elements in the LHS
// container and the RHS container respectively.
// container and the RHS container respectively.
template
<
typename
TupleMatcher
,
typename
RhsContainer
>
template
<
typename
TupleMatcher
,
typename
RhsContainer
>
...
@@ -3012,7 +2235,8 @@ class PointwiseMatcher {
...
@@ -3012,7 +2235,8 @@ class PointwiseMatcher {
!
IsHashTable
<
GTEST_REMOVE_REFERENCE_AND_CONST_
(
LhsContainer
)
>::
value
,
!
IsHashTable
<
GTEST_REMOVE_REFERENCE_AND_CONST_
(
LhsContainer
)
>::
value
,
use_UnorderedPointwise_with_hash_tables
);
use_UnorderedPointwise_with_hash_tables
);
return
MakeMatcher
(
new
Impl
<
LhsContainer
>
(
tuple_matcher_
,
rhs_
));
return
Matcher
<
LhsContainer
>
(
new
Impl
<
const
LhsContainer
&>
(
tuple_matcher_
,
rhs_
));
}
}
template
<
typename
LhsContainer
>
template
<
typename
LhsContainer
>
...
@@ -3027,21 +2251,21 @@ class PointwiseMatcher {
...
@@ -3027,21 +2251,21 @@ class PointwiseMatcher {
// reference, as they may be expensive to copy. We must use tuple
// reference, as they may be expensive to copy. We must use tuple
// instead of pair here, as a pair cannot hold references (C++ 98,
// instead of pair here, as a pair cannot hold references (C++ 98,
// 20.2.2 [lib.pairs]).
// 20.2.2 [lib.pairs]).
typedef
::
testing
::
tuple
<
const
LhsValue
&
,
const
RhsValue
&>
InnerMatcherArg
;
typedef
::
std
::
tuple
<
const
LhsValue
&
,
const
RhsValue
&>
InnerMatcherArg
;
Impl
(
const
TupleMatcher
&
tuple_matcher
,
const
RhsStlContainer
&
rhs
)
Impl
(
const
TupleMatcher
&
tuple_matcher
,
const
RhsStlContainer
&
rhs
)
// mono_tuple_matcher_ holds a monomorphic version of the tuple matcher.
// mono_tuple_matcher_ holds a monomorphic version of the tuple matcher.
:
mono_tuple_matcher_
(
SafeMatcherCast
<
InnerMatcherArg
>
(
tuple_matcher
)),
:
mono_tuple_matcher_
(
SafeMatcherCast
<
InnerMatcherArg
>
(
tuple_matcher
)),
rhs_
(
rhs
)
{}
rhs_
(
rhs
)
{}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"contains "
<<
rhs_
.
size
()
*
os
<<
"contains "
<<
rhs_
.
size
()
<<
" values, where each value and its corresponding value in "
;
<<
" values, where each value and its corresponding value in "
;
UniversalPrinter
<
RhsStlContainer
>::
Print
(
rhs_
,
os
);
UniversalPrinter
<
RhsStlContainer
>::
Print
(
rhs_
,
os
);
*
os
<<
" "
;
*
os
<<
" "
;
mono_tuple_matcher_
.
DescribeTo
(
os
);
mono_tuple_matcher_
.
DescribeTo
(
os
);
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"doesn't contain exactly "
<<
rhs_
.
size
()
*
os
<<
"doesn't contain exactly "
<<
rhs_
.
size
()
<<
" values, or contains a value x at some index i"
<<
" values, or contains a value x at some index i"
<<
" where x and the i-th value of "
;
<<
" where x and the i-th value of "
;
...
@@ -3050,8 +2274,8 @@ class PointwiseMatcher {
...
@@ -3050,8 +2274,8 @@ class PointwiseMatcher {
mono_tuple_matcher_
.
DescribeNegationTo
(
os
);
mono_tuple_matcher_
.
DescribeNegationTo
(
os
);
}
}
virtual
bool
MatchAndExplain
(
LhsContainer
lhs
,
bool
MatchAndExplain
(
LhsContainer
lhs
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
LhsStlContainerReference
lhs_stl_container
=
LhsView
::
ConstReference
(
lhs
);
LhsStlContainerReference
lhs_stl_container
=
LhsView
::
ConstReference
(
lhs
);
const
size_t
actual_size
=
lhs_stl_container
.
size
();
const
size_t
actual_size
=
lhs_stl_container
.
size
();
if
(
actual_size
!=
rhs_
.
size
())
{
if
(
actual_size
!=
rhs_
.
size
())
{
...
@@ -3158,18 +2382,18 @@ class ContainsMatcherImpl : public QuantifierMatcherImpl<Container> {
...
@@ -3158,18 +2382,18 @@ class ContainsMatcherImpl : public QuantifierMatcherImpl<Container> {
:
QuantifierMatcherImpl
<
Container
>
(
inner_matcher
)
{}
:
QuantifierMatcherImpl
<
Container
>
(
inner_matcher
)
{}
// Describes what this matcher does.
// Describes what this matcher does.
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"contains at least one element that "
;
*
os
<<
"contains at least one element that "
;
this
->
inner_matcher_
.
DescribeTo
(
os
);
this
->
inner_matcher_
.
DescribeTo
(
os
);
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"doesn't contain any element that "
;
*
os
<<
"doesn't contain any element that "
;
this
->
inner_matcher_
.
DescribeTo
(
os
);
this
->
inner_matcher_
.
DescribeTo
(
os
);
}
}
virtual
bool
MatchAndExplain
(
Container
container
,
bool
MatchAndExplain
(
Container
container
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
return
this
->
MatchAndExplainImpl
(
false
,
container
,
listener
);
return
this
->
MatchAndExplainImpl
(
false
,
container
,
listener
);
}
}
...
@@ -3187,18 +2411,18 @@ class EachMatcherImpl : public QuantifierMatcherImpl<Container> {
...
@@ -3187,18 +2411,18 @@ class EachMatcherImpl : public QuantifierMatcherImpl<Container> {
:
QuantifierMatcherImpl
<
Container
>
(
inner_matcher
)
{}
:
QuantifierMatcherImpl
<
Container
>
(
inner_matcher
)
{}
// Describes what this matcher does.
// Describes what this matcher does.
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"only contains elements that "
;
*
os
<<
"only contains elements that "
;
this
->
inner_matcher_
.
DescribeTo
(
os
);
this
->
inner_matcher_
.
DescribeTo
(
os
);
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"contains some element that "
;
*
os
<<
"contains some element that "
;
this
->
inner_matcher_
.
DescribeNegationTo
(
os
);
this
->
inner_matcher_
.
DescribeNegationTo
(
os
);
}
}
virtual
bool
MatchAndExplain
(
Container
container
,
bool
MatchAndExplain
(
Container
container
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
return
this
->
MatchAndExplainImpl
(
true
,
container
,
listener
);
return
this
->
MatchAndExplainImpl
(
true
,
container
,
listener
);
}
}
...
@@ -3214,7 +2438,8 @@ class ContainsMatcher {
...
@@ -3214,7 +2438,8 @@ class ContainsMatcher {
template
<
typename
Container
>
template
<
typename
Container
>
operator
Matcher
<
Container
>
()
const
{
operator
Matcher
<
Container
>
()
const
{
return
MakeMatcher
(
new
ContainsMatcherImpl
<
Container
>
(
inner_matcher_
));
return
Matcher
<
Container
>
(
new
ContainsMatcherImpl
<
const
Container
&>
(
inner_matcher_
));
}
}
private:
private:
...
@@ -3231,7 +2456,8 @@ class EachMatcher {
...
@@ -3231,7 +2456,8 @@ class EachMatcher {
template
<
typename
Container
>
template
<
typename
Container
>
operator
Matcher
<
Container
>
()
const
{
operator
Matcher
<
Container
>
()
const
{
return
MakeMatcher
(
new
EachMatcherImpl
<
Container
>
(
inner_matcher_
));
return
Matcher
<
Container
>
(
new
EachMatcherImpl
<
const
Container
&>
(
inner_matcher_
));
}
}
private:
private:
...
@@ -3244,7 +2470,6 @@ struct Rank1 {};
...
@@ -3244,7 +2470,6 @@ struct Rank1 {};
struct
Rank0
:
Rank1
{};
struct
Rank0
:
Rank1
{};
namespace
pair_getters
{
namespace
pair_getters
{
#if GTEST_LANG_CXX11
using
std
::
get
;
using
std
::
get
;
template
<
typename
T
>
template
<
typename
T
>
auto
First
(
T
&
x
,
Rank1
)
->
decltype
(
get
<
0
>
(
x
))
{
// NOLINT
auto
First
(
T
&
x
,
Rank1
)
->
decltype
(
get
<
0
>
(
x
))
{
// NOLINT
...
@@ -3263,25 +2488,6 @@ template <typename T>
...
@@ -3263,25 +2488,6 @@ template <typename T>
auto
Second
(
T
&
x
,
Rank0
)
->
decltype
((
x
.
second
))
{
// NOLINT
auto
Second
(
T
&
x
,
Rank0
)
->
decltype
((
x
.
second
))
{
// NOLINT
return
x
.
second
;
return
x
.
second
;
}
}
#else
template
<
typename
T
>
typename
T
::
first_type
&
First
(
T
&
x
,
Rank0
)
{
// NOLINT
return
x
.
first
;
}
template
<
typename
T
>
const
typename
T
::
first_type
&
First
(
const
T
&
x
,
Rank0
)
{
return
x
.
first
;
}
template
<
typename
T
>
typename
T
::
second_type
&
Second
(
T
&
x
,
Rank0
)
{
// NOLINT
return
x
.
second
;
}
template
<
typename
T
>
const
typename
T
::
second_type
&
Second
(
const
T
&
x
,
Rank0
)
{
return
x
.
second
;
}
#endif // GTEST_LANG_CXX11
}
// namespace pair_getters
}
// namespace pair_getters
// Implements Key(inner_matcher) for the given argument pair type.
// Implements Key(inner_matcher) for the given argument pair type.
...
@@ -3301,8 +2507,8 @@ class KeyMatcherImpl : public MatcherInterface<PairType> {
...
@@ -3301,8 +2507,8 @@ class KeyMatcherImpl : public MatcherInterface<PairType> {
}
}
// Returns true iff 'key_value.first' (the key) matches the inner matcher.
// Returns true iff 'key_value.first' (the key) matches the inner matcher.
virtual
bool
MatchAndExplain
(
PairType
key_value
,
bool
MatchAndExplain
(
PairType
key_value
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
StringMatchResultListener
inner_listener
;
StringMatchResultListener
inner_listener
;
const
bool
match
=
inner_matcher_
.
MatchAndExplain
(
const
bool
match
=
inner_matcher_
.
MatchAndExplain
(
pair_getters
::
First
(
key_value
,
Rank0
()),
&
inner_listener
);
pair_getters
::
First
(
key_value
,
Rank0
()),
&
inner_listener
);
...
@@ -3314,13 +2520,13 @@ class KeyMatcherImpl : public MatcherInterface<PairType> {
...
@@ -3314,13 +2520,13 @@ class KeyMatcherImpl : public MatcherInterface<PairType> {
}
}
// Describes what this matcher does.
// Describes what this matcher does.
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"has a key that "
;
*
os
<<
"has a key that "
;
inner_matcher_
.
DescribeTo
(
os
);
inner_matcher_
.
DescribeTo
(
os
);
}
}
// Describes what the negation of this matcher does.
// Describes what the negation of this matcher does.
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"doesn't have a key that "
;
*
os
<<
"doesn't have a key that "
;
inner_matcher_
.
DescribeTo
(
os
);
inner_matcher_
.
DescribeTo
(
os
);
}
}
...
@@ -3366,7 +2572,7 @@ class PairMatcherImpl : public MatcherInterface<PairType> {
...
@@ -3366,7 +2572,7 @@ class PairMatcherImpl : public MatcherInterface<PairType> {
}
}
// Describes what this matcher does.
// Describes what this matcher does.
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"has a first field that "
;
*
os
<<
"has a first field that "
;
first_matcher_
.
DescribeTo
(
os
);
first_matcher_
.
DescribeTo
(
os
);
*
os
<<
", and has a second field that "
;
*
os
<<
", and has a second field that "
;
...
@@ -3374,7 +2580,7 @@ class PairMatcherImpl : public MatcherInterface<PairType> {
...
@@ -3374,7 +2580,7 @@ class PairMatcherImpl : public MatcherInterface<PairType> {
}
}
// Describes what the negation of this matcher does.
// Describes what the negation of this matcher does.
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"has a first field that "
;
*
os
<<
"has a first field that "
;
first_matcher_
.
DescribeNegationTo
(
os
);
first_matcher_
.
DescribeNegationTo
(
os
);
*
os
<<
", or has a second field that "
;
*
os
<<
", or has a second field that "
;
...
@@ -3383,8 +2589,8 @@ class PairMatcherImpl : public MatcherInterface<PairType> {
...
@@ -3383,8 +2589,8 @@ class PairMatcherImpl : public MatcherInterface<PairType> {
// Returns true iff 'a_pair.first' matches first_matcher and 'a_pair.second'
// Returns true iff 'a_pair.first' matches first_matcher and 'a_pair.second'
// matches second_matcher.
// matches second_matcher.
virtual
bool
MatchAndExplain
(
PairType
a_pair
,
bool
MatchAndExplain
(
PairType
a_pair
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
if
(
!
listener
->
IsInterested
())
{
if
(
!
listener
->
IsInterested
())
{
// If the listener is not interested, we don't need to construct the
// If the listener is not interested, we don't need to construct the
// explanation.
// explanation.
...
@@ -3476,7 +2682,7 @@ class ElementsAreMatcherImpl : public MatcherInterface<Container> {
...
@@ -3476,7 +2682,7 @@ class ElementsAreMatcherImpl : public MatcherInterface<Container> {
}
}
// Describes what this matcher does.
// Describes what this matcher does.
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
if
(
count
()
==
0
)
{
if
(
count
()
==
0
)
{
*
os
<<
"is empty"
;
*
os
<<
"is empty"
;
}
else
if
(
count
()
==
1
)
{
}
else
if
(
count
()
==
1
)
{
...
@@ -3495,7 +2701,7 @@ class ElementsAreMatcherImpl : public MatcherInterface<Container> {
...
@@ -3495,7 +2701,7 @@ class ElementsAreMatcherImpl : public MatcherInterface<Container> {
}
}
// Describes what the negation of this matcher does.
// Describes what the negation of this matcher does.
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
if
(
count
()
==
0
)
{
if
(
count
()
==
0
)
{
*
os
<<
"isn't empty"
;
*
os
<<
"isn't empty"
;
return
;
return
;
...
@@ -3511,8 +2717,8 @@ class ElementsAreMatcherImpl : public MatcherInterface<Container> {
...
@@ -3511,8 +2717,8 @@ class ElementsAreMatcherImpl : public MatcherInterface<Container> {
}
}
}
}
virtual
bool
MatchAndExplain
(
Container
container
,
bool
MatchAndExplain
(
Container
container
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
// To work with stream-like "containers", we must only walk
// To work with stream-like "containers", we must only walk
// through the elements in one pass.
// through the elements in one pass.
...
@@ -3732,17 +2938,17 @@ class UnorderedElementsAreMatcherImpl
...
@@ -3732,17 +2938,17 @@ class UnorderedElementsAreMatcherImpl
}
}
// Describes what this matcher does.
// Describes what this matcher does.
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
return
UnorderedElementsAreMatcherImplBase
::
DescribeToImpl
(
os
);
return
UnorderedElementsAreMatcherImplBase
::
DescribeToImpl
(
os
);
}
}
// Describes what the negation of this matcher does.
// Describes what the negation of this matcher does.
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
return
UnorderedElementsAreMatcherImplBase
::
DescribeNegationToImpl
(
os
);
return
UnorderedElementsAreMatcherImplBase
::
DescribeNegationToImpl
(
os
);
}
}
virtual
bool
MatchAndExplain
(
Container
container
,
bool
MatchAndExplain
(
Container
container
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
StlContainerReference
stl_container
=
View
::
ConstReference
(
container
);
StlContainerReference
stl_container
=
View
::
ConstReference
(
container
);
::
std
::
vector
<
std
::
string
>
element_printouts
;
::
std
::
vector
<
std
::
string
>
element_printouts
;
MatchMatrix
matrix
=
MatchMatrix
matrix
=
...
@@ -3826,11 +3032,13 @@ class UnorderedElementsAreMatcher {
...
@@ -3826,11 +3032,13 @@ class UnorderedElementsAreMatcher {
typedef
typename
View
::
value_type
Element
;
typedef
typename
View
::
value_type
Element
;
typedef
::
std
::
vector
<
Matcher
<
const
Element
&>
>
MatcherVec
;
typedef
::
std
::
vector
<
Matcher
<
const
Element
&>
>
MatcherVec
;
MatcherVec
matchers
;
MatcherVec
matchers
;
matchers
.
reserve
(
::
testing
::
tuple_size
<
MatcherTuple
>::
value
);
matchers
.
reserve
(
::
std
::
tuple_size
<
MatcherTuple
>::
value
);
TransformTupleValues
(
CastAndAppendTransform
<
const
Element
&>
(),
matchers_
,
TransformTupleValues
(
CastAndAppendTransform
<
const
Element
&>
(),
matchers_
,
::
std
::
back_inserter
(
matchers
));
::
std
::
back_inserter
(
matchers
));
return
MakeMatcher
(
new
UnorderedElementsAreMatcherImpl
<
Container
>
(
return
Matcher
<
Container
>
(
UnorderedMatcherRequire
::
ExactMatch
,
matchers
.
begin
(),
matchers
.
end
()));
new
UnorderedElementsAreMatcherImpl
<
const
Container
&>
(
UnorderedMatcherRequire
::
ExactMatch
,
matchers
.
begin
(),
matchers
.
end
()));
}
}
private:
private:
...
@@ -3848,7 +3056,7 @@ class ElementsAreMatcher {
...
@@ -3848,7 +3056,7 @@ class ElementsAreMatcher {
operator
Matcher
<
Container
>
()
const
{
operator
Matcher
<
Container
>
()
const
{
GTEST_COMPILE_ASSERT_
(
GTEST_COMPILE_ASSERT_
(
!
IsHashTable
<
GTEST_REMOVE_REFERENCE_AND_CONST_
(
Container
)
>::
value
||
!
IsHashTable
<
GTEST_REMOVE_REFERENCE_AND_CONST_
(
Container
)
>::
value
||
::
testing
::
tuple_size
<
MatcherTuple
>::
value
<
2
,
::
std
::
tuple_size
<
MatcherTuple
>::
value
<
2
,
use_UnorderedElementsAre_with_hash_tables
);
use_UnorderedElementsAre_with_hash_tables
);
typedef
GTEST_REMOVE_REFERENCE_AND_CONST_
(
Container
)
RawContainer
;
typedef
GTEST_REMOVE_REFERENCE_AND_CONST_
(
Container
)
RawContainer
;
...
@@ -3856,11 +3064,11 @@ class ElementsAreMatcher {
...
@@ -3856,11 +3064,11 @@ class ElementsAreMatcher {
typedef
typename
View
::
value_type
Element
;
typedef
typename
View
::
value_type
Element
;
typedef
::
std
::
vector
<
Matcher
<
const
Element
&>
>
MatcherVec
;
typedef
::
std
::
vector
<
Matcher
<
const
Element
&>
>
MatcherVec
;
MatcherVec
matchers
;
MatcherVec
matchers
;
matchers
.
reserve
(
::
testing
::
tuple_size
<
MatcherTuple
>::
value
);
matchers
.
reserve
(
::
std
::
tuple_size
<
MatcherTuple
>::
value
);
TransformTupleValues
(
CastAndAppendTransform
<
const
Element
&>
(),
matchers_
,
TransformTupleValues
(
CastAndAppendTransform
<
const
Element
&>
(),
matchers_
,
::
std
::
back_inserter
(
matchers
));
::
std
::
back_inserter
(
matchers
));
return
Make
Matcher
(
new
ElementsAreMatcherImpl
<
Container
>
(
return
Matcher
<
Container
>
(
new
ElementsAreMatcherImpl
<
const
Container
&
>
(
matchers
.
begin
(),
matchers
.
end
()));
matchers
.
begin
(),
matchers
.
end
()));
}
}
private:
private:
...
@@ -3879,8 +3087,9 @@ class UnorderedElementsAreArrayMatcher {
...
@@ -3879,8 +3087,9 @@ class UnorderedElementsAreArrayMatcher {
template
<
typename
Container
>
template
<
typename
Container
>
operator
Matcher
<
Container
>
()
const
{
operator
Matcher
<
Container
>
()
const
{
return
MakeMatcher
(
new
UnorderedElementsAreMatcherImpl
<
Container
>
(
return
Matcher
<
Container
>
(
match_flags_
,
matchers_
.
begin
(),
matchers_
.
end
()));
new
UnorderedElementsAreMatcherImpl
<
const
Container
&>
(
match_flags_
,
matchers_
.
begin
(),
matchers_
.
end
()));
}
}
private:
private:
...
@@ -3903,7 +3112,7 @@ class ElementsAreArrayMatcher {
...
@@ -3903,7 +3112,7 @@ class ElementsAreArrayMatcher {
!
IsHashTable
<
GTEST_REMOVE_REFERENCE_AND_CONST_
(
Container
)
>::
value
,
!
IsHashTable
<
GTEST_REMOVE_REFERENCE_AND_CONST_
(
Container
)
>::
value
,
use_UnorderedElementsAreArray_with_hash_tables
);
use_UnorderedElementsAreArray_with_hash_tables
);
return
Make
Matcher
(
new
ElementsAreMatcherImpl
<
Container
>
(
return
Matcher
<
Container
>
(
new
ElementsAreMatcherImpl
<
const
Container
&
>
(
matchers_
.
begin
(),
matchers_
.
end
()));
matchers_
.
begin
(),
matchers_
.
end
()));
}
}
...
@@ -3949,20 +3158,20 @@ class BoundSecondMatcher {
...
@@ -3949,20 +3158,20 @@ class BoundSecondMatcher {
template
<
typename
T
>
template
<
typename
T
>
class
Impl
:
public
MatcherInterface
<
T
>
{
class
Impl
:
public
MatcherInterface
<
T
>
{
public:
public:
typedef
::
testing
::
tuple
<
T
,
Second
>
ArgTuple
;
typedef
::
std
::
tuple
<
T
,
Second
>
ArgTuple
;
Impl
(
const
Tuple2Matcher
&
tm
,
const
Second
&
second
)
Impl
(
const
Tuple2Matcher
&
tm
,
const
Second
&
second
)
:
mono_tuple2_matcher_
(
SafeMatcherCast
<
const
ArgTuple
&>
(
tm
)),
:
mono_tuple2_matcher_
(
SafeMatcherCast
<
const
ArgTuple
&>
(
tm
)),
second_value_
(
second
)
{}
second_value_
(
second
)
{}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"and "
;
*
os
<<
"and "
;
UniversalPrint
(
second_value_
,
os
);
UniversalPrint
(
second_value_
,
os
);
*
os
<<
" "
;
*
os
<<
" "
;
mono_tuple2_matcher_
.
DescribeTo
(
os
);
mono_tuple2_matcher_
.
DescribeTo
(
os
);
}
}
virtual
bool
MatchAndExplain
(
T
x
,
MatchResultListener
*
listener
)
const
{
bool
MatchAndExplain
(
T
x
,
MatchResultListener
*
listener
)
const
override
{
return
mono_tuple2_matcher_
.
MatchAndExplain
(
ArgTuple
(
x
,
second_value_
),
return
mono_tuple2_matcher_
.
MatchAndExplain
(
ArgTuple
(
x
,
second_value_
),
listener
);
listener
);
}
}
...
@@ -4017,18 +3226,18 @@ class OptionalMatcher {
...
@@ -4017,18 +3226,18 @@ class OptionalMatcher {
explicit
Impl
(
const
ValueMatcher
&
value_matcher
)
explicit
Impl
(
const
ValueMatcher
&
value_matcher
)
:
value_matcher_
(
MatcherCast
<
ValueType
>
(
value_matcher
))
{}
:
value_matcher_
(
MatcherCast
<
ValueType
>
(
value_matcher
))
{}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"value "
;
*
os
<<
"value "
;
value_matcher_
.
DescribeTo
(
os
);
value_matcher_
.
DescribeTo
(
os
);
}
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"value "
;
*
os
<<
"value "
;
value_matcher_
.
DescribeNegationTo
(
os
);
value_matcher_
.
DescribeNegationTo
(
os
);
}
}
virtual
bool
MatchAndExplain
(
Optional
optional
,
bool
MatchAndExplain
(
Optional
optional
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
override
{
if
(
!
optional
)
{
if
(
!
optional
)
{
*
listener
<<
"which is not engaged"
;
*
listener
<<
"which is not engaged"
;
return
false
;
return
false
;
...
@@ -4064,11 +3273,12 @@ template <typename T>
...
@@ -4064,11 +3273,12 @@ template <typename T>
class
VariantMatcher
{
class
VariantMatcher
{
public:
public:
explicit
VariantMatcher
(
::
testing
::
Matcher
<
const
T
&>
matcher
)
explicit
VariantMatcher
(
::
testing
::
Matcher
<
const
T
&>
matcher
)
:
matcher_
(
internal
::
move
(
matcher
))
{}
:
matcher_
(
std
::
move
(
matcher
))
{}
template
<
typename
Variant
>
template
<
typename
Variant
>
bool
MatchAndExplain
(
const
Variant
&
value
,
bool
MatchAndExplain
(
const
Variant
&
value
,
::
testing
::
MatchResultListener
*
listener
)
const
{
::
testing
::
MatchResultListener
*
listener
)
const
{
using
std
::
get
;
if
(
!
listener
->
IsInterested
())
{
if
(
!
listener
->
IsInterested
())
{
return
holds_alternative
<
T
>
(
value
)
&&
matcher_
.
Matches
(
get
<
T
>
(
value
));
return
holds_alternative
<
T
>
(
value
)
&&
matcher_
.
Matches
(
get
<
T
>
(
value
));
}
}
...
@@ -4173,6 +3383,80 @@ class AnyCastMatcher {
...
@@ -4173,6 +3383,80 @@ class AnyCastMatcher {
};
};
}
// namespace any_cast_matcher
}
// namespace any_cast_matcher
// Implements the Args() matcher.
template
<
class
ArgsTuple
,
size_t
...
k
>
class
ArgsMatcherImpl
:
public
MatcherInterface
<
ArgsTuple
>
{
public:
using
RawArgsTuple
=
typename
std
::
decay
<
ArgsTuple
>::
type
;
using
SelectedArgs
=
std
::
tuple
<
typename
std
::
tuple_element
<
k
,
RawArgsTuple
>::
type
...
>
;
using
MonomorphicInnerMatcher
=
Matcher
<
const
SelectedArgs
&>
;
template
<
typename
InnerMatcher
>
explicit
ArgsMatcherImpl
(
const
InnerMatcher
&
inner_matcher
)
:
inner_matcher_
(
SafeMatcherCast
<
const
SelectedArgs
&>
(
inner_matcher
))
{}
bool
MatchAndExplain
(
ArgsTuple
args
,
MatchResultListener
*
listener
)
const
override
{
// Workaround spurious C4100 on MSVC<=15.7 when k is empty.
(
void
)
args
;
const
SelectedArgs
&
selected_args
=
std
::
forward_as_tuple
(
std
::
get
<
k
>
(
args
)...);
if
(
!
listener
->
IsInterested
())
return
inner_matcher_
.
Matches
(
selected_args
);
PrintIndices
(
listener
->
stream
());
*
listener
<<
"are "
<<
PrintToString
(
selected_args
);
StringMatchResultListener
inner_listener
;
const
bool
match
=
inner_matcher_
.
MatchAndExplain
(
selected_args
,
&
inner_listener
);
PrintIfNotEmpty
(
inner_listener
.
str
(),
listener
->
stream
());
return
match
;
}
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"are a tuple "
;
PrintIndices
(
os
);
inner_matcher_
.
DescribeTo
(
os
);
}
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"are a tuple "
;
PrintIndices
(
os
);
inner_matcher_
.
DescribeNegationTo
(
os
);
}
private:
// Prints the indices of the selected fields.
static
void
PrintIndices
(
::
std
::
ostream
*
os
)
{
*
os
<<
"whose fields ("
;
const
char
*
sep
=
""
;
// Workaround spurious C4189 on MSVC<=15.7 when k is empty.
(
void
)
sep
;
const
char
*
dummy
[]
=
{
""
,
(
*
os
<<
sep
<<
"#"
<<
k
,
sep
=
", "
)...};
(
void
)
dummy
;
*
os
<<
") "
;
}
MonomorphicInnerMatcher
inner_matcher_
;
};
template
<
class
InnerMatcher
,
size_t
...
k
>
class
ArgsMatcher
{
public:
explicit
ArgsMatcher
(
InnerMatcher
inner_matcher
)
:
inner_matcher_
(
std
::
move
(
inner_matcher
))
{}
template
<
typename
ArgsTuple
>
operator
Matcher
<
ArgsTuple
>
()
const
{
// NOLINT
return
MakeMatcher
(
new
ArgsMatcherImpl
<
ArgsTuple
,
k
...
>
(
inner_matcher_
));
}
private:
InnerMatcher
inner_matcher_
;
};
}
// namespace internal
}
// namespace internal
// ElementsAreArray(iterator_first, iterator_last)
// ElementsAreArray(iterator_first, iterator_last)
...
@@ -4216,13 +3500,11 @@ ElementsAreArray(const Container& container) {
...
@@ -4216,13 +3500,11 @@ ElementsAreArray(const Container& container) {
return
ElementsAreArray
(
container
.
begin
(),
container
.
end
());
return
ElementsAreArray
(
container
.
begin
(),
container
.
end
());
}
}
#if GTEST_HAS_STD_INITIALIZER_LIST_
template
<
typename
T
>
template
<
typename
T
>
inline
internal
::
ElementsAreArrayMatcher
<
T
>
inline
internal
::
ElementsAreArrayMatcher
<
T
>
ElementsAreArray
(
::
std
::
initializer_list
<
T
>
xs
)
{
ElementsAreArray
(
::
std
::
initializer_list
<
T
>
xs
)
{
return
ElementsAreArray
(
xs
.
begin
(),
xs
.
end
());
return
ElementsAreArray
(
xs
.
begin
(),
xs
.
end
());
}
}
#endif
// UnorderedElementsAreArray(iterator_first, iterator_last)
// UnorderedElementsAreArray(iterator_first, iterator_last)
// UnorderedElementsAreArray(pointer, count)
// UnorderedElementsAreArray(pointer, count)
...
@@ -4265,13 +3547,11 @@ UnorderedElementsAreArray(const Container& container) {
...
@@ -4265,13 +3547,11 @@ UnorderedElementsAreArray(const Container& container) {
return
UnorderedElementsAreArray
(
container
.
begin
(),
container
.
end
());
return
UnorderedElementsAreArray
(
container
.
begin
(),
container
.
end
());
}
}
#if GTEST_HAS_STD_INITIALIZER_LIST_
template
<
typename
T
>
template
<
typename
T
>
inline
internal
::
UnorderedElementsAreArrayMatcher
<
T
>
inline
internal
::
UnorderedElementsAreArrayMatcher
<
T
>
UnorderedElementsAreArray
(
::
std
::
initializer_list
<
T
>
xs
)
{
UnorderedElementsAreArray
(
::
std
::
initializer_list
<
T
>
xs
)
{
return
UnorderedElementsAreArray
(
xs
.
begin
(),
xs
.
end
());
return
UnorderedElementsAreArray
(
xs
.
begin
(),
xs
.
end
());
}
}
#endif
// _ is a matcher that matches anything of any type.
// _ is a matcher that matches anything of any type.
//
//
...
@@ -4293,17 +3573,6 @@ inline Matcher<T> A() {
...
@@ -4293,17 +3573,6 @@ inline Matcher<T> A() {
template
<
typename
T
>
template
<
typename
T
>
inline
Matcher
<
T
>
An
()
{
return
A
<
T
>
();
}
inline
Matcher
<
T
>
An
()
{
return
A
<
T
>
();
}
// Creates a polymorphic matcher that matches anything equal to x.
// Note: if the parameter of Eq() were declared as const T&, Eq("foo")
// wouldn't compile.
template
<
typename
T
>
inline
internal
::
EqMatcher
<
T
>
Eq
(
T
x
)
{
return
internal
::
EqMatcher
<
T
>
(
x
);
}
// Constructs a Matcher<T> from a 'value' of type T. The constructed
// matcher matches any value that's equal to 'value'.
template
<
typename
T
>
Matcher
<
T
>::
Matcher
(
T
value
)
{
*
this
=
Eq
(
value
);
}
template
<
typename
T
,
typename
M
>
template
<
typename
T
,
typename
M
>
Matcher
<
T
>
internal
::
MatcherCastImpl
<
T
,
M
>::
CastImpl
(
Matcher
<
T
>
internal
::
MatcherCastImpl
<
T
,
M
>::
CastImpl
(
const
M
&
value
,
const
M
&
value
,
...
@@ -4312,51 +3581,6 @@ Matcher<T> internal::MatcherCastImpl<T, M>::CastImpl(
...
@@ -4312,51 +3581,6 @@ Matcher<T> internal::MatcherCastImpl<T, M>::CastImpl(
return
Eq
(
value
);
return
Eq
(
value
);
}
}
// Creates a monomorphic matcher that matches anything with type Lhs
// and equal to rhs. A user may need to use this instead of Eq(...)
// in order to resolve an overloading ambiguity.
//
// TypedEq<T>(x) is just a convenient short-hand for Matcher<T>(Eq(x))
// or Matcher<T>(x), but more readable than the latter.
//
// We could define similar monomorphic matchers for other comparison
// operations (e.g. TypedLt, TypedGe, and etc), but decided not to do
// it yet as those are used much less than Eq() in practice. A user
// can always write Matcher<T>(Lt(5)) to be explicit about the type,
// for example.
template
<
typename
Lhs
,
typename
Rhs
>
inline
Matcher
<
Lhs
>
TypedEq
(
const
Rhs
&
rhs
)
{
return
Eq
(
rhs
);
}
// Creates a polymorphic matcher that matches anything >= x.
template
<
typename
Rhs
>
inline
internal
::
GeMatcher
<
Rhs
>
Ge
(
Rhs
x
)
{
return
internal
::
GeMatcher
<
Rhs
>
(
x
);
}
// Creates a polymorphic matcher that matches anything > x.
template
<
typename
Rhs
>
inline
internal
::
GtMatcher
<
Rhs
>
Gt
(
Rhs
x
)
{
return
internal
::
GtMatcher
<
Rhs
>
(
x
);
}
// Creates a polymorphic matcher that matches anything <= x.
template
<
typename
Rhs
>
inline
internal
::
LeMatcher
<
Rhs
>
Le
(
Rhs
x
)
{
return
internal
::
LeMatcher
<
Rhs
>
(
x
);
}
// Creates a polymorphic matcher that matches anything < x.
template
<
typename
Rhs
>
inline
internal
::
LtMatcher
<
Rhs
>
Lt
(
Rhs
x
)
{
return
internal
::
LtMatcher
<
Rhs
>
(
x
);
}
// Creates a polymorphic matcher that matches anything != x.
template
<
typename
Rhs
>
inline
internal
::
NeMatcher
<
Rhs
>
Ne
(
Rhs
x
)
{
return
internal
::
NeMatcher
<
Rhs
>
(
x
);
}
// Creates a polymorphic matcher that matches any NULL pointer.
// Creates a polymorphic matcher that matches any NULL pointer.
inline
PolymorphicMatcher
<
internal
::
IsNullMatcher
>
IsNull
()
{
inline
PolymorphicMatcher
<
internal
::
IsNullMatcher
>
IsNull
()
{
return
MakePolymorphicMatcher
(
internal
::
IsNullMatcher
());
return
MakePolymorphicMatcher
(
internal
::
IsNullMatcher
());
...
@@ -4494,8 +3718,7 @@ Property(PropertyType (Class::*property)() const,
...
@@ -4494,8 +3718,7 @@ Property(PropertyType (Class::*property)() const,
return
MakePolymorphicMatcher
(
return
MakePolymorphicMatcher
(
internal
::
PropertyMatcher
<
Class
,
PropertyType
,
internal
::
PropertyMatcher
<
Class
,
PropertyType
,
PropertyType
(
Class
::*
)()
const
>
(
PropertyType
(
Class
::*
)()
const
>
(
property
,
property
,
MatcherCast
<
const
PropertyType
&>
(
matcher
)));
MatcherCast
<
GTEST_REFERENCE_TO_CONST_
(
PropertyType
)
>
(
matcher
)));
// The call to MatcherCast() is required for supporting inner
// The call to MatcherCast() is required for supporting inner
// matchers of compatible types. For example, it allows
// matchers of compatible types. For example, it allows
// Property(&Foo::bar, m)
// Property(&Foo::bar, m)
...
@@ -4513,11 +3736,9 @@ Property(const std::string& property_name,
...
@@ -4513,11 +3736,9 @@ Property(const std::string& property_name,
return
MakePolymorphicMatcher
(
return
MakePolymorphicMatcher
(
internal
::
PropertyMatcher
<
Class
,
PropertyType
,
internal
::
PropertyMatcher
<
Class
,
PropertyType
,
PropertyType
(
Class
::*
)()
const
>
(
PropertyType
(
Class
::*
)()
const
>
(
property_name
,
property
,
property_name
,
property
,
MatcherCast
<
const
PropertyType
&>
(
matcher
)));
MatcherCast
<
GTEST_REFERENCE_TO_CONST_
(
PropertyType
)
>
(
matcher
)));
}
}
#if GTEST_LANG_CXX11
// The same as above but for reference-qualified member functions.
// The same as above but for reference-qualified member functions.
template
<
typename
Class
,
typename
PropertyType
,
typename
PropertyMatcher
>
template
<
typename
Class
,
typename
PropertyType
,
typename
PropertyMatcher
>
inline
PolymorphicMatcher
<
internal
::
PropertyMatcher
<
inline
PolymorphicMatcher
<
internal
::
PropertyMatcher
<
...
@@ -4526,9 +3747,8 @@ Property(PropertyType (Class::*property)() const &,
...
@@ -4526,9 +3747,8 @@ Property(PropertyType (Class::*property)() const &,
const
PropertyMatcher
&
matcher
)
{
const
PropertyMatcher
&
matcher
)
{
return
MakePolymorphicMatcher
(
return
MakePolymorphicMatcher
(
internal
::
PropertyMatcher
<
Class
,
PropertyType
,
internal
::
PropertyMatcher
<
Class
,
PropertyType
,
PropertyType
(
Class
::*
)()
const
&>
(
PropertyType
(
Class
::*
)()
const
&>
(
property
,
property
,
MatcherCast
<
const
PropertyType
&>
(
matcher
)));
MatcherCast
<
GTEST_REFERENCE_TO_CONST_
(
PropertyType
)
>
(
matcher
)));
}
}
// Three-argument form for reference-qualified member functions.
// Three-argument form for reference-qualified member functions.
...
@@ -4540,11 +3760,9 @@ Property(const std::string& property_name,
...
@@ -4540,11 +3760,9 @@ Property(const std::string& property_name,
const
PropertyMatcher
&
matcher
)
{
const
PropertyMatcher
&
matcher
)
{
return
MakePolymorphicMatcher
(
return
MakePolymorphicMatcher
(
internal
::
PropertyMatcher
<
Class
,
PropertyType
,
internal
::
PropertyMatcher
<
Class
,
PropertyType
,
PropertyType
(
Class
::*
)()
const
&>
(
PropertyType
(
Class
::*
)()
const
&>
(
property_name
,
property
,
property_name
,
property
,
MatcherCast
<
const
PropertyType
&>
(
matcher
)));
MatcherCast
<
GTEST_REFERENCE_TO_CONST_
(
PropertyType
)
>
(
matcher
)));
}
}
#endif
// Creates a matcher that matches an object iff the result of applying
// Creates a matcher that matches an object iff the result of applying
// a callable to x matches 'matcher'.
// a callable to x matches 'matcher'.
...
@@ -4559,7 +3777,7 @@ template <typename Callable, typename InnerMatcher>
...
@@ -4559,7 +3777,7 @@ template <typename Callable, typename InnerMatcher>
internal
::
ResultOfMatcher
<
Callable
,
InnerMatcher
>
ResultOf
(
internal
::
ResultOfMatcher
<
Callable
,
InnerMatcher
>
ResultOf
(
Callable
callable
,
InnerMatcher
matcher
)
{
Callable
callable
,
InnerMatcher
matcher
)
{
return
internal
::
ResultOfMatcher
<
Callable
,
InnerMatcher
>
(
return
internal
::
ResultOfMatcher
<
Callable
,
InnerMatcher
>
(
internal
::
move
(
callable
),
internal
::
move
(
matcher
));
std
::
move
(
callable
),
std
::
move
(
matcher
));
}
}
// String matchers.
// String matchers.
...
@@ -4613,28 +3831,6 @@ inline PolymorphicMatcher<internal::EndsWithMatcher<std::string> > EndsWith(
...
@@ -4613,28 +3831,6 @@ inline PolymorphicMatcher<internal::EndsWithMatcher<std::string> > EndsWith(
return
MakePolymorphicMatcher
(
internal
::
EndsWithMatcher
<
std
::
string
>
(
suffix
));
return
MakePolymorphicMatcher
(
internal
::
EndsWithMatcher
<
std
::
string
>
(
suffix
));
}
}
// Matches a string that fully matches regular expression 'regex'.
// The matcher takes ownership of 'regex'.
inline
PolymorphicMatcher
<
internal
::
MatchesRegexMatcher
>
MatchesRegex
(
const
internal
::
RE
*
regex
)
{
return
MakePolymorphicMatcher
(
internal
::
MatchesRegexMatcher
(
regex
,
true
));
}
inline
PolymorphicMatcher
<
internal
::
MatchesRegexMatcher
>
MatchesRegex
(
const
std
::
string
&
regex
)
{
return
MatchesRegex
(
new
internal
::
RE
(
regex
));
}
// Matches a string that contains regular expression 'regex'.
// The matcher takes ownership of 'regex'.
inline
PolymorphicMatcher
<
internal
::
MatchesRegexMatcher
>
ContainsRegex
(
const
internal
::
RE
*
regex
)
{
return
MakePolymorphicMatcher
(
internal
::
MatchesRegexMatcher
(
regex
,
false
));
}
inline
PolymorphicMatcher
<
internal
::
MatchesRegexMatcher
>
ContainsRegex
(
const
std
::
string
&
regex
)
{
return
ContainsRegex
(
new
internal
::
RE
(
regex
));
}
#if GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING
#if GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING
// Wide string matchers.
// Wide string matchers.
...
@@ -4843,7 +4039,7 @@ WhenSorted(const ContainerMatcher& container_matcher) {
...
@@ -4843,7 +4039,7 @@ WhenSorted(const ContainerMatcher& container_matcher) {
// Matches an STL-style container or a native array that contains the
// Matches an STL-style container or a native array that contains the
// same number of elements as in rhs, where its i-th element and rhs's
// same number of elements as in rhs, where its i-th element and rhs's
// i-th element (as a pair) satisfy the given pair matcher, for all i.
// i-th element (as a pair) satisfy the given pair matcher, for all i.
// TupleMatcher must be able to be safely cast to Matcher<tuple<const
// TupleMatcher must be able to be safely cast to Matcher<
std::
tuple<const
// T1&, const T2&> >, where T1 and T2 are the types of elements in the
// T1&, const T2&> >, where T1 and T2 are the types of elements in the
// LHS container and the RHS container respectively.
// LHS container and the RHS container respectively.
template
<
typename
TupleMatcher
,
typename
Container
>
template
<
typename
TupleMatcher
,
typename
Container
>
...
@@ -4858,7 +4054,6 @@ Pointwise(const TupleMatcher& tuple_matcher, const Container& rhs) {
...
@@ -4858,7 +4054,6 @@ Pointwise(const TupleMatcher& tuple_matcher, const Container& rhs) {
tuple_matcher
,
rhs
);
tuple_matcher
,
rhs
);
}
}
#if GTEST_HAS_STD_INITIALIZER_LIST_
// Supports the Pointwise(m, {a, b, c}) syntax.
// Supports the Pointwise(m, {a, b, c}) syntax.
template
<
typename
TupleMatcher
,
typename
T
>
template
<
typename
TupleMatcher
,
typename
T
>
...
@@ -4867,14 +4062,13 @@ inline internal::PointwiseMatcher<TupleMatcher, std::vector<T> > Pointwise(
...
@@ -4867,14 +4062,13 @@ inline internal::PointwiseMatcher<TupleMatcher, std::vector<T> > Pointwise(
return
Pointwise
(
tuple_matcher
,
std
::
vector
<
T
>
(
rhs
));
return
Pointwise
(
tuple_matcher
,
std
::
vector
<
T
>
(
rhs
));
}
}
#endif // GTEST_HAS_STD_INITIALIZER_LIST_
// UnorderedPointwise(pair_matcher, rhs) matches an STL-style
// UnorderedPointwise(pair_matcher, rhs) matches an STL-style
// container or a native array that contains the same number of
// container or a native array that contains the same number of
// elements as in rhs, where in some permutation of the container, its
// elements as in rhs, where in some permutation of the container, its
// i-th element and rhs's i-th element (as a pair) satisfy the given
// i-th element and rhs's i-th element (as a pair) satisfy the given
// pair matcher, for all i. Tuple2Matcher must be able to be safely
// pair matcher, for all i. Tuple2Matcher must be able to be safely
// cast to Matcher<tuple<const T1&, const T2&> >, where T1 and T2 are
// cast to Matcher<
std::
tuple<const T1&, const T2&> >, where T1 and T2 are
// the types of elements in the LHS container and the RHS container
// the types of elements in the LHS container and the RHS container
// respectively.
// respectively.
//
//
...
@@ -4912,7 +4106,6 @@ UnorderedPointwise(const Tuple2Matcher& tuple2_matcher,
...
@@ -4912,7 +4106,6 @@ UnorderedPointwise(const Tuple2Matcher& tuple2_matcher,
return
UnorderedElementsAreArray
(
matchers
);
return
UnorderedElementsAreArray
(
matchers
);
}
}
#if GTEST_HAS_STD_INITIALIZER_LIST_
// Supports the UnorderedPointwise(m, {a, b, c}) syntax.
// Supports the UnorderedPointwise(m, {a, b, c}) syntax.
template
<
typename
Tuple2Matcher
,
typename
T
>
template
<
typename
Tuple2Matcher
,
typename
T
>
...
@@ -4923,7 +4116,6 @@ UnorderedPointwise(const Tuple2Matcher& tuple2_matcher,
...
@@ -4923,7 +4116,6 @@ UnorderedPointwise(const Tuple2Matcher& tuple2_matcher,
return
UnorderedPointwise
(
tuple2_matcher
,
std
::
vector
<
T
>
(
rhs
));
return
UnorderedPointwise
(
tuple2_matcher
,
std
::
vector
<
T
>
(
rhs
));
}
}
#endif // GTEST_HAS_STD_INITIALIZER_LIST_
// Matches an STL-style container or a native array that contains at
// Matches an STL-style container or a native array that contains at
// least one element matching the given value or matcher.
// least one element matching the given value or matcher.
...
@@ -5003,13 +4195,11 @@ IsSupersetOf(const Container& container) {
...
@@ -5003,13 +4195,11 @@ IsSupersetOf(const Container& container) {
return
IsSupersetOf
(
container
.
begin
(),
container
.
end
());
return
IsSupersetOf
(
container
.
begin
(),
container
.
end
());
}
}
#if GTEST_HAS_STD_INITIALIZER_LIST_
template
<
typename
T
>
template
<
typename
T
>
inline
internal
::
UnorderedElementsAreArrayMatcher
<
T
>
IsSupersetOf
(
inline
internal
::
UnorderedElementsAreArrayMatcher
<
T
>
IsSupersetOf
(
::
std
::
initializer_list
<
T
>
xs
)
{
::
std
::
initializer_list
<
T
>
xs
)
{
return
IsSupersetOf
(
xs
.
begin
(),
xs
.
end
());
return
IsSupersetOf
(
xs
.
begin
(),
xs
.
end
());
}
}
#endif
// IsSubsetOf(iterator_first, iterator_last)
// IsSubsetOf(iterator_first, iterator_last)
// IsSubsetOf(pointer, count)
// IsSubsetOf(pointer, count)
...
@@ -5062,13 +4252,11 @@ IsSubsetOf(const Container& container) {
...
@@ -5062,13 +4252,11 @@ IsSubsetOf(const Container& container) {
return
IsSubsetOf
(
container
.
begin
(),
container
.
end
());
return
IsSubsetOf
(
container
.
begin
(),
container
.
end
());
}
}
#if GTEST_HAS_STD_INITIALIZER_LIST_
template
<
typename
T
>
template
<
typename
T
>
inline
internal
::
UnorderedElementsAreArrayMatcher
<
T
>
IsSubsetOf
(
inline
internal
::
UnorderedElementsAreArrayMatcher
<
T
>
IsSubsetOf
(
::
std
::
initializer_list
<
T
>
xs
)
{
::
std
::
initializer_list
<
T
>
xs
)
{
return
IsSubsetOf
(
xs
.
begin
(),
xs
.
end
());
return
IsSubsetOf
(
xs
.
begin
(),
xs
.
end
());
}
}
#endif
// Matches an STL-style container or a native array that contains only
// Matches an STL-style container or a native array that contains only
// elements matching the given value or matcher.
// elements matching the given value or matcher.
...
@@ -5166,20 +4354,21 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) {
...
@@ -5166,20 +4354,21 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) {
}
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
internal
::
ElementsAreMatcher
<
tuple
<
typename
std
::
decay
<
const
Args
&>::
type
...
>>
internal
::
ElementsAreMatcher
<
std
::
tuple
<
typename
std
::
decay
<
const
Args
&>::
type
...
>>
ElementsAre
(
const
Args
&
...
matchers
)
{
ElementsAre
(
const
Args
&
...
matchers
)
{
return
internal
::
ElementsAreMatcher
<
return
internal
::
ElementsAreMatcher
<
tuple
<
typename
std
::
decay
<
const
Args
&>::
type
...
>>
(
std
::
tuple
<
typename
std
::
decay
<
const
Args
&>::
type
...
>>
(
make_tuple
(
matchers
...));
std
::
make_tuple
(
matchers
...));
}
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
internal
::
UnorderedElementsAreMatcher
<
internal
::
UnorderedElementsAreMatcher
<
tuple
<
typename
std
::
decay
<
const
Args
&>::
type
...
>>
std
::
tuple
<
typename
std
::
decay
<
const
Args
&>::
type
...
>>
UnorderedElementsAre
(
const
Args
&
...
matchers
)
{
UnorderedElementsAre
(
const
Args
&
...
matchers
)
{
return
internal
::
UnorderedElementsAreMatcher
<
return
internal
::
UnorderedElementsAreMatcher
<
tuple
<
typename
std
::
decay
<
const
Args
&>::
type
...
>>
(
std
::
tuple
<
typename
std
::
decay
<
const
Args
&>::
type
...
>>
(
make_tuple
(
matchers
...));
std
::
make_tuple
(
matchers
...));
}
}
// Define variadic matcher versions.
// Define variadic matcher versions.
...
@@ -5197,6 +4386,16 @@ internal::AnyOfMatcher<typename std::decay<const Args&>::type...> AnyOf(
...
@@ -5197,6 +4386,16 @@ internal::AnyOfMatcher<typename std::decay<const Args&>::type...> AnyOf(
matchers
...);
matchers
...);
}
}
// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
// fields of it matches a_matcher. C++ doesn't support default
// arguments for function templates, so we have to overload it.
template
<
size_t
...
k
,
typename
InnerMatcher
>
internal
::
ArgsMatcher
<
typename
std
::
decay
<
InnerMatcher
>::
type
,
k
...
>
Args
(
InnerMatcher
&&
matcher
)
{
return
internal
::
ArgsMatcher
<
typename
std
::
decay
<
InnerMatcher
>::
type
,
k
...
>
(
std
::
forward
<
InnerMatcher
>
(
matcher
));
}
// AllArgs(m) is a synonym of m. This is useful in
// AllArgs(m) is a synonym of m. This is useful in
//
//
// EXPECT_CALL(foo, Bar(_, _)).With(AllArgs(Eq()));
// EXPECT_CALL(foo, Bar(_, _)).With(AllArgs(Eq()));
...
...
googlemock/include/gmock/gmock-more-actions.h
View file @
25905b9f
...
@@ -127,27 +127,6 @@ PolymorphicAction<internal::InvokeMethodAction<Class, MethodPtr> > Invoke(
...
@@ -127,27 +127,6 @@ PolymorphicAction<internal::InvokeMethodAction<Class, MethodPtr> > Invoke(
internal
::
InvokeMethodAction
<
Class
,
MethodPtr
>
(
obj_ptr
,
method_ptr
));
internal
::
InvokeMethodAction
<
Class
,
MethodPtr
>
(
obj_ptr
,
method_ptr
));
}
}
// WithoutArgs(inner_action) can be used in a mock function with a
// non-empty argument list to perform inner_action, which takes no
// argument. In other words, it adapts an action accepting no
// argument to one that accepts (and ignores) arguments.
template
<
typename
InnerAction
>
inline
internal
::
WithArgsAction
<
InnerAction
>
WithoutArgs
(
const
InnerAction
&
action
)
{
return
internal
::
WithArgsAction
<
InnerAction
>
(
action
);
}
// WithArg<k>(an_action) creates an action that passes the k-th
// (0-based) argument of the mock function to an_action and performs
// it. It adapts an action accepting one argument to one that accepts
// multiple arguments. For convenience, we also provide
// WithArgs<k>(an_action) (defined below) as a synonym.
template
<
int
k
,
typename
InnerAction
>
inline
internal
::
WithArgsAction
<
InnerAction
,
k
>
WithArg
(
const
InnerAction
&
action
)
{
return
internal
::
WithArgsAction
<
InnerAction
,
k
>
(
action
);
}
// The ACTION*() macros trigger warning C4100 (unreferenced formal
// The ACTION*() macros trigger warning C4100 (unreferenced formal
// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
// the macro definition, as the warnings are generated when the macro
// the macro definition, as the warnings are generated when the macro
...
@@ -162,7 +141,7 @@ WithArg(const InnerAction& action) {
...
@@ -162,7 +141,7 @@ WithArg(const InnerAction& action) {
ACTION_TEMPLATE
(
ReturnArg
,
ACTION_TEMPLATE
(
ReturnArg
,
HAS_1_TEMPLATE_PARAMS
(
int
,
k
),
HAS_1_TEMPLATE_PARAMS
(
int
,
k
),
AND_0_VALUE_PARAMS
())
{
AND_0_VALUE_PARAMS
())
{
return
::
testing
::
get
<
k
>
(
args
);
return
::
std
::
get
<
k
>
(
args
);
}
}
// Action SaveArg<k>(pointer) saves the k-th (0-based) argument of the
// Action SaveArg<k>(pointer) saves the k-th (0-based) argument of the
...
@@ -170,7 +149,7 @@ ACTION_TEMPLATE(ReturnArg,
...
@@ -170,7 +149,7 @@ ACTION_TEMPLATE(ReturnArg,
ACTION_TEMPLATE
(
SaveArg
,
ACTION_TEMPLATE
(
SaveArg
,
HAS_1_TEMPLATE_PARAMS
(
int
,
k
),
HAS_1_TEMPLATE_PARAMS
(
int
,
k
),
AND_1_VALUE_PARAMS
(
pointer
))
{
AND_1_VALUE_PARAMS
(
pointer
))
{
*
pointer
=
::
testing
::
get
<
k
>
(
args
);
*
pointer
=
::
std
::
get
<
k
>
(
args
);
}
}
// Action SaveArgPointee<k>(pointer) saves the value pointed to
// Action SaveArgPointee<k>(pointer) saves the value pointed to
...
@@ -178,7 +157,7 @@ ACTION_TEMPLATE(SaveArg,
...
@@ -178,7 +157,7 @@ ACTION_TEMPLATE(SaveArg,
ACTION_TEMPLATE
(
SaveArgPointee
,
ACTION_TEMPLATE
(
SaveArgPointee
,
HAS_1_TEMPLATE_PARAMS
(
int
,
k
),
HAS_1_TEMPLATE_PARAMS
(
int
,
k
),
AND_1_VALUE_PARAMS
(
pointer
))
{
AND_1_VALUE_PARAMS
(
pointer
))
{
*
pointer
=
*::
testing
::
get
<
k
>
(
args
);
*
pointer
=
*::
std
::
get
<
k
>
(
args
);
}
}
// Action SetArgReferee<k>(value) assigns 'value' to the variable
// Action SetArgReferee<k>(value) assigns 'value' to the variable
...
@@ -186,13 +165,13 @@ ACTION_TEMPLATE(SaveArgPointee,
...
@@ -186,13 +165,13 @@ ACTION_TEMPLATE(SaveArgPointee,
ACTION_TEMPLATE
(
SetArgReferee
,
ACTION_TEMPLATE
(
SetArgReferee
,
HAS_1_TEMPLATE_PARAMS
(
int
,
k
),
HAS_1_TEMPLATE_PARAMS
(
int
,
k
),
AND_1_VALUE_PARAMS
(
value
))
{
AND_1_VALUE_PARAMS
(
value
))
{
typedef
typename
::
testing
::
tuple_element
<
k
,
args_type
>::
type
argk_type
;
typedef
typename
::
std
::
tuple_element
<
k
,
args_type
>::
type
argk_type
;
// Ensures that argument #k is a reference. If you get a compiler
// Ensures that argument #k is a reference. If you get a compiler
// error on the next line, you are using SetArgReferee<k>(value) in
// error on the next line, you are using SetArgReferee<k>(value) in
// a mock function whose k-th (0-based) argument is not a reference.
// a mock function whose k-th (0-based) argument is not a reference.
GTEST_COMPILE_ASSERT_
(
internal
::
is_reference
<
argk_type
>::
value
,
GTEST_COMPILE_ASSERT_
(
internal
::
is_reference
<
argk_type
>::
value
,
SetArgReferee_must_be_used_with_a_reference_argument
);
SetArgReferee_must_be_used_with_a_reference_argument
);
::
testing
::
get
<
k
>
(
args
)
=
value
;
::
std
::
get
<
k
>
(
args
)
=
value
;
}
}
// Action SetArrayArgument<k>(first, last) copies the elements in
// Action SetArrayArgument<k>(first, last) copies the elements in
...
@@ -205,9 +184,9 @@ ACTION_TEMPLATE(SetArrayArgument,
...
@@ -205,9 +184,9 @@ ACTION_TEMPLATE(SetArrayArgument,
AND_2_VALUE_PARAMS
(
first
,
last
))
{
AND_2_VALUE_PARAMS
(
first
,
last
))
{
// Visual Studio deprecates ::std::copy, so we use our own copy in that case.
// Visual Studio deprecates ::std::copy, so we use our own copy in that case.
#ifdef _MSC_VER
#ifdef _MSC_VER
internal
::
CopyElements
(
first
,
last
,
::
testing
::
get
<
k
>
(
args
));
internal
::
CopyElements
(
first
,
last
,
::
std
::
get
<
k
>
(
args
));
#else
#else
::
std
::
copy
(
first
,
last
,
::
testing
::
get
<
k
>
(
args
));
::
std
::
copy
(
first
,
last
,
::
std
::
get
<
k
>
(
args
));
#endif
#endif
}
}
...
@@ -216,7 +195,7 @@ ACTION_TEMPLATE(SetArrayArgument,
...
@@ -216,7 +195,7 @@ ACTION_TEMPLATE(SetArrayArgument,
ACTION_TEMPLATE
(
DeleteArg
,
ACTION_TEMPLATE
(
DeleteArg
,
HAS_1_TEMPLATE_PARAMS
(
int
,
k
),
HAS_1_TEMPLATE_PARAMS
(
int
,
k
),
AND_0_VALUE_PARAMS
())
{
AND_0_VALUE_PARAMS
())
{
delete
::
testing
::
get
<
k
>
(
args
);
delete
::
std
::
get
<
k
>
(
args
);
}
}
// This action returns the value pointed to by 'pointer'.
// This action returns the value pointed to by 'pointer'.
...
...
googlemock/include/gmock/gmock-
generated-
nice-strict.h
.pump
→
googlemock/include/gmock/gmock-nice-strict.h
View file @
25905b9f
$$
-*-
mode
:
c
++
;
-*-
$$
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.
// Copyright 2008, Google Inc.
// All rights reserved.
// All rights reserved.
//
//
...
@@ -65,34 +60,60 @@ $var n = 10 $$ The maximum arity we support.
...
@@ -65,34 +60,60 @@ $var n = 10 $$ The maximum arity we support.
// GOOGLETEST_CM0002 DO NOT DELETE
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_
GENERATED_
NICE_STRICT_H_
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_
GENERATED_
NICE_STRICT_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_
#include "gmock/gmock-spec-builders.h"
#include "gmock/gmock-spec-builders.h"
#include "gmock/internal/gmock-port.h"
#include "gmock/internal/gmock-port.h"
namespace
testing
{
namespace
testing
{
$
range
kind
0..2
template
<
class
MockClass
>
$
for
kind
[[
class
NiceMock
:
public
MockClass
{
public:
NiceMock
()
:
MockClass
()
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
$
var
clazz
=
[[
$
if
kind
==
0
[[
NiceMock
]]
// Ideally, we would inherit base class's constructors through a using
$
elif
kind
==
1
[[
NaggyMock
]]
// declaration, which would preserve their visibility. However, many existing
$
else
[[
StrictMock
]]]]
// tests rely on the fact that current implementation reexports protected
// constructors as public. These tests would need to be cleaned up first.
$
var
method
=
[[
$
if
kind
==
0
[[
AllowUninterestingCalls
]]
// Single argument constructor is special-cased so that it can be
$
elif
kind
==
1
[[
WarnUninterestingCalls
]]
// made explicit.
$
else
[[
FailUninterestingCalls
]]]]
template
<
typename
A
>
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
)...)
{
::
testing
::
Mock
::
AllowUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
~
NiceMock
()
{
// NOLINT
::
testing
::
Mock
::
UnregisterCallReaction
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
NiceMock
);
};
template
<
class
MockClass
>
template
<
class
MockClass
>
class
$
clazz
:
public
MockClass
{
class
NaggyMock
:
public
MockClass
{
public:
public:
$
clazz
()
:
MockClass
()
{
NaggyMock
()
:
MockClass
()
{
::
testing
::
Mock
::
$
method
(
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
}
#if GTEST_LANG_CXX11
// Ideally, we would inherit base class's constructors through a using
// Ideally, we would inherit base class's constructors through a using
// declaration, which would preserve their visibility. However, many existing
// declaration, which would preserve their visibility. However, many existing
// tests rely on the fact that current implementation reexports protected
// tests rely on the fact that current implementation reexports protected
...
@@ -101,51 +122,66 @@ class $clazz : public MockClass {
...
@@ -101,51 +122,66 @@ class $clazz : public MockClass {
// Single argument constructor is special-cased so that it can be
// Single argument constructor is special-cased so that it can be
// made explicit.
// made explicit.
template
<
typename
A
>
template
<
typename
A
>
explicit
$
clazz
(
A
&&
arg
)
:
MockClass
(
std
::
forward
<
A
>
(
arg
))
{
explicit
NaggyMock
(
A
&&
arg
)
:
MockClass
(
std
::
forward
<
A
>
(
arg
))
{
::
testing
::
Mock
::
$
method
(
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
}
template
<
typename
A1
,
typename
A2
,
typename
...
An
>
template
<
typename
A1
,
typename
A2
,
typename
...
An
>
$
clazz
(
A1
&&
arg1
,
A2
&&
arg2
,
An
&&
...
args
)
NaggyMock
(
A1
&&
arg1
,
A2
&&
arg2
,
An
&&
...
args
)
:
MockClass
(
std
::
forward
<
A1
>
(
arg1
),
std
::
forward
<
A2
>
(
arg2
),
:
MockClass
(
std
::
forward
<
A1
>
(
arg1
),
std
::
forward
<
A2
>
(
arg2
),
std
::
forward
<
An
>
(
args
)...)
{
std
::
forward
<
An
>
(
args
)...)
{
::
testing
::
Mock
::
$
method
(
::
testing
::
Mock
::
WarnUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
}
#else
// C++98 doesn't have variadic templates, so we have to define one
~
NaggyMock
()
{
// NOLINT
// for each arity.
::
testing
::
Mock
::
UnregisterCallReaction
(
template
<
typename
A1
>
explicit
$
clazz
(
const
A1
&
a1
)
:
MockClass
(
a1
)
{
::
testing
::
Mock
::
$
method
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
}
$
range
i
2.
.
n
private:
$
for
i
[[
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
NaggyMock
);
$
range
j
1.
.
i
};
template
<
$
for
j
,
[[
typename
A
$
j
]]>
$
clazz
(
$
for
j
,
[[
const
A
$
j
&
a
$
j
]])
:
MockClass
(
$
for
j
,
[[
a
$
j
]])
{
template
<
class
MockClass
>
::
testing
::
Mock
::
$
method
(
class
StrictMock
:
public
MockClass
{
public:
StrictMock
()
:
MockClass
()
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
}
// 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
StrictMock
(
A
&&
arg
)
:
MockClass
(
std
::
forward
<
A
>
(
arg
))
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
]]
template
<
typename
A1
,
typename
A2
,
typename
...
An
>
#endif // GTEST_LANG_CXX11
StrictMock
(
A1
&&
arg1
,
A2
&&
arg2
,
An
&&
...
args
)
:
MockClass
(
std
::
forward
<
A1
>
(
arg1
),
std
::
forward
<
A2
>
(
arg2
),
std
::
forward
<
An
>
(
args
)...)
{
::
testing
::
Mock
::
FailUninterestingCalls
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
~
$
clazz
()
{
~
StrictMock
()
{
// NOLINT
::
testing
::
Mock
::
UnregisterCallReaction
(
::
testing
::
Mock
::
UnregisterCallReaction
(
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
internal
::
ImplicitCast_
<
MockClass
*>
(
this
));
}
}
private:
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
$
clazz
);
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
StrictMock
);
};
};
]]
// The following specializations catch some (relatively more common)
// The following specializations catch some (relatively more common)
// user errors of nesting nice and strict mocks. They do NOT catch
// user errors of nesting nice and strict mocks. They do NOT catch
// all possible errors.
// all possible errors.
...
@@ -176,4 +212,4 @@ class StrictMock<StrictMock<MockClass> >;
...
@@ -176,4 +212,4 @@ class StrictMock<StrictMock<MockClass> >;
}
// namespace testing
}
// namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_
GENERATED_
NICE_STRICT_H_
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_NICE_STRICT_H_
googlemock/include/gmock/gmock-spec-builders.h
View file @
25905b9f
...
@@ -62,9 +62,11 @@
...
@@ -62,9 +62,11 @@
#define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
#define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
#include <map>
#include <map>
#include <memory>
#include <set>
#include <set>
#include <sstream>
#include <sstream>
#include <string>
#include <string>
#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"
...
@@ -104,9 +106,6 @@ template <typename F> class TypedExpectation;
...
@@ -104,9 +106,6 @@ 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
;
// Base class for function mockers.
template
<
typename
F
>
class
FunctionMockerBase
;
// Protects the mock object registry (in class Mock), all function
// Protects the mock object registry (in class Mock), all function
// mockers, and all expectations.
// mockers, and all expectations.
//
//
...
@@ -123,9 +122,9 @@ GTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_gmock_mutex);
...
@@ -123,9 +122,9 @@ GTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_gmock_mutex);
// Untyped base class for ActionResultHolder<R>.
// Untyped base class for ActionResultHolder<R>.
class
UntypedActionResultHolderBase
;
class
UntypedActionResultHolderBase
;
// Abstract base class of FunctionMocker
Base
. This is the
// Abstract base class of FunctionMocker. This is the
// type-agnostic part of the function mocker interface. Its pure
// type-agnostic part of the function mocker interface. Its pure
// virtual methods are implemented by FunctionMocker
Base
.
// virtual methods are implemented by FunctionMocker.
class
GTEST_API_
UntypedFunctionMockerBase
{
class
GTEST_API_
UntypedFunctionMockerBase
{
public:
public:
UntypedFunctionMockerBase
();
UntypedFunctionMockerBase
();
...
@@ -218,8 +217,7 @@ class GTEST_API_ UntypedFunctionMockerBase {
...
@@ -218,8 +217,7 @@ class GTEST_API_ UntypedFunctionMockerBase {
protected:
protected:
typedef
std
::
vector
<
const
void
*>
UntypedOnCallSpecs
;
typedef
std
::
vector
<
const
void
*>
UntypedOnCallSpecs
;
typedef
std
::
vector
<
internal
::
linked_ptr
<
ExpectationBase
>
>
using
UntypedExpectations
=
std
::
vector
<
std
::
shared_ptr
<
ExpectationBase
>>
;
UntypedExpectations
;
// Returns an Expectation object that references and co-owns exp,
// Returns an Expectation object that references and co-owns exp,
// which must be an expectation on this mock function.
// which must be an expectation on this mock function.
...
@@ -398,13 +396,23 @@ class GTEST_API_ Mock {
...
@@ -398,13 +396,23 @@ class GTEST_API_ Mock {
static
bool
VerifyAndClear
(
void
*
mock_obj
)
static
bool
VerifyAndClear
(
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
);
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
);
// Returns whether the mock was created as a naggy mock (default)
static
bool
IsNaggy
(
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
);
// Returns whether the mock was created as a nice mock
static
bool
IsNice
(
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
);
// Returns whether the mock was created as a strict mock
static
bool
IsStrict
(
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
);
private:
private:
friend
class
internal
::
UntypedFunctionMockerBase
;
friend
class
internal
::
UntypedFunctionMockerBase
;
// Needed for a function mocker to register itself (so that we know
// Needed for a function mocker to register itself (so that we know
// how to clear a mock object).
// how to clear a mock object).
template
<
typename
F
>
template
<
typename
F
>
friend
class
internal
::
FunctionMocker
Base
;
friend
class
internal
::
FunctionMocker
;
template
<
typename
M
>
template
<
typename
M
>
friend
class
NiceMock
;
friend
class
NiceMock
;
...
@@ -467,7 +475,7 @@ class GTEST_API_ Mock {
...
@@ -467,7 +475,7 @@ class GTEST_API_ Mock {
// 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
// been unregistered. This is called only in the destructor of
// been unregistered. This is called only in the destructor of
// FunctionMocker
Base
.
// FunctionMocker.
static
void
UnregisterLocked
(
internal
::
UntypedFunctionMockerBase
*
mocker
)
static
void
UnregisterLocked
(
internal
::
UntypedFunctionMockerBase
*
mocker
)
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
internal
::
g_gmock_mutex
);
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
internal
::
g_gmock_mutex
);
};
// class Mock
};
// class Mock
...
@@ -487,12 +495,7 @@ class GTEST_API_ Mock {
...
@@ -487,12 +495,7 @@ class GTEST_API_ Mock {
// - Constness is shallow: a const Expectation object itself cannot
// - Constness is shallow: a const Expectation object itself cannot
// be modified, but the mutable methods of the ExpectationBase
// be modified, but the mutable methods of the ExpectationBase
// object it references can be called via expectation_base().
// object it references can be called via expectation_base().
// - The constructors and destructor are defined out-of-line because
// the Symbian WINSCW compiler wants to otherwise instantiate them
// when it sees this class definition, at which point it doesn't have
// ExpectationBase available yet, leading to incorrect destruction
// in the linked_ptr (or compilation errors if using a checking
// linked_ptr).
class
GTEST_API_
Expectation
{
class
GTEST_API_
Expectation
{
public:
public:
// Constructs a null object that doesn't reference any expectation.
// Constructs a null object that doesn't reference any expectation.
...
@@ -528,7 +531,7 @@ class GTEST_API_ Expectation {
...
@@ -528,7 +531,7 @@ class GTEST_API_ Expectation {
friend
class
::
testing
::
internal
::
UntypedFunctionMockerBase
;
friend
class
::
testing
::
internal
::
UntypedFunctionMockerBase
;
template
<
typename
F
>
template
<
typename
F
>
friend
class
::
testing
::
internal
::
FunctionMocker
Base
;
friend
class
::
testing
::
internal
::
FunctionMocker
;
template
<
typename
F
>
template
<
typename
F
>
friend
class
::
testing
::
internal
::
TypedExpectation
;
friend
class
::
testing
::
internal
::
TypedExpectation
;
...
@@ -544,16 +547,15 @@ class GTEST_API_ Expectation {
...
@@ -544,16 +547,15 @@ class GTEST_API_ Expectation {
typedef
::
std
::
set
<
Expectation
,
Less
>
Set
;
typedef
::
std
::
set
<
Expectation
,
Less
>
Set
;
Expectation
(
Expectation
(
const
internal
::
link
ed_ptr
<
internal
::
ExpectationBase
>&
expectation_base
);
const
std
::
shar
ed_ptr
<
internal
::
ExpectationBase
>&
expectation_base
);
// Returns the expectation this object references.
// Returns the expectation this object references.
const
internal
::
linked_ptr
<
internal
::
ExpectationBase
>&
const
std
::
shared_ptr
<
internal
::
ExpectationBase
>&
expectation_base
()
const
{
expectation_base
()
const
{
return
expectation_base_
;
return
expectation_base_
;
}
}
// A
link
ed_ptr that co-owns the expectation this handle references.
// A
shar
ed_ptr that co-owns the expectation this handle references.
internal
::
link
ed_ptr
<
internal
::
ExpectationBase
>
expectation_base_
;
std
::
shar
ed_ptr
<
internal
::
ExpectationBase
>
expectation_base_
;
};
};
// A set of expectation handles. Useful in the .After() clause of
// A set of expectation handles. Useful in the .After() clause of
...
@@ -635,11 +637,8 @@ class GTEST_API_ Sequence {
...
@@ -635,11 +637,8 @@ class GTEST_API_ Sequence {
void
AddExpectation
(
const
Expectation
&
expectation
)
const
;
void
AddExpectation
(
const
Expectation
&
expectation
)
const
;
private:
private:
// The last expectation in this sequence. We use a linked_ptr here
// The last expectation in this sequence.
// because Sequence objects are copyable and we want the copies to
std
::
shared_ptr
<
Expectation
>
last_expectation_
;
// be aliases. The linked_ptr allows the copies to co-own and share
// the same Expectation object.
internal
::
linked_ptr
<
Expectation
>
last_expectation_
;
};
// class Sequence
};
// class Sequence
// An object of this type causes all EXPECT_CALL() statements
// An object of this type causes all EXPECT_CALL() statements
...
@@ -862,7 +861,7 @@ class GTEST_API_ ExpectationBase {
...
@@ -862,7 +861,7 @@ class GTEST_API_ ExpectationBase {
Cardinality
cardinality_
;
// The cardinality of the expectation.
Cardinality
cardinality_
;
// The cardinality of the expectation.
// The immediate pre-requisites (i.e. expectations that must be
// The immediate pre-requisites (i.e. expectations that must be
// satisfied before this expectation can be matched) of this
// satisfied before this expectation can be matched) of this
// expectation. We use
link
ed_ptr in the set because we want an
// expectation. We use
std::shar
ed_ptr in the set because we want an
// Expectation object to be co-owned by its FunctionMocker and its
// Expectation object to be co-owned by its FunctionMocker and its
// successors. This allows multiple mock objects to be deleted at
// successors. This allows multiple mock objects to be deleted at
// different times.
// different times.
...
@@ -891,7 +890,7 @@ class TypedExpectation : public ExpectationBase {
...
@@ -891,7 +890,7 @@ class TypedExpectation : public ExpectationBase {
typedef
typename
Function
<
F
>::
ArgumentMatcherTuple
ArgumentMatcherTuple
;
typedef
typename
Function
<
F
>::
ArgumentMatcherTuple
ArgumentMatcherTuple
;
typedef
typename
Function
<
F
>::
Result
Result
;
typedef
typename
Function
<
F
>::
Result
Result
;
TypedExpectation
(
FunctionMocker
Base
<
F
>*
owner
,
const
char
*
a_file
,
int
a_line
,
TypedExpectation
(
FunctionMocker
<
F
>*
owner
,
const
char
*
a_file
,
int
a_line
,
const
std
::
string
&
a_source_text
,
const
std
::
string
&
a_source_text
,
const
ArgumentMatcherTuple
&
m
)
const
ArgumentMatcherTuple
&
m
)
:
ExpectationBase
(
a_file
,
a_line
,
a_source_text
),
:
ExpectationBase
(
a_file
,
a_line
,
a_source_text
),
...
@@ -904,7 +903,7 @@ class TypedExpectation : public ExpectationBase {
...
@@ -904,7 +903,7 @@ class TypedExpectation : public ExpectationBase {
extra_matcher_
(
A
<
const
ArgumentTuple
&>
()),
extra_matcher_
(
A
<
const
ArgumentTuple
&>
()),
repeated_action_
(
DoDefault
())
{}
repeated_action_
(
DoDefault
())
{}
virtual
~
TypedExpectation
()
{
~
TypedExpectation
()
override
{
// Check the validity of the action count if it hasn't been done
// Check the validity of the action count if it hasn't been done
// yet (for example, if the expectation was never used).
// yet (for example, if the expectation was never used).
CheckActionCountIfNotDone
();
CheckActionCountIfNotDone
();
...
@@ -1070,7 +1069,7 @@ class TypedExpectation : public ExpectationBase {
...
@@ -1070,7 +1069,7 @@ class TypedExpectation : public ExpectationBase {
// If this mock method has an extra matcher (i.e. .With(matcher)),
// If this mock method has an extra matcher (i.e. .With(matcher)),
// describes it to the ostream.
// describes it to the ostream.
virtual
void
MaybeDescribeExtraMatcherTo
(
::
std
::
ostream
*
os
)
{
void
MaybeDescribeExtraMatcherTo
(
::
std
::
ostream
*
os
)
override
{
if
(
extra_matcher_specified_
)
{
if
(
extra_matcher_specified_
)
{
*
os
<<
" Expected args: "
;
*
os
<<
" Expected args: "
;
extra_matcher_
.
DescribeTo
(
os
);
extra_matcher_
.
DescribeTo
(
os
);
...
@@ -1080,13 +1079,11 @@ class TypedExpectation : public ExpectationBase {
...
@@ -1080,13 +1079,11 @@ class TypedExpectation : public ExpectationBase {
private:
private:
template
<
typename
Function
>
template
<
typename
Function
>
friend
class
FunctionMocker
Base
;
friend
class
FunctionMocker
;
// Returns an Expectation object that references and co-owns this
// Returns an Expectation object that references and co-owns this
// expectation.
// expectation.
virtual
Expectation
GetHandle
()
{
Expectation
GetHandle
()
override
{
return
owner_
->
GetHandleOf
(
this
);
}
return
owner_
->
GetHandleOf
(
this
);
}
// The following methods will be called only after the EXPECT_CALL()
// The following methods will be called only after the EXPECT_CALL()
// statement finishes and when the current thread holds
// statement finishes and when the current thread holds
...
@@ -1159,10 +1156,9 @@ class TypedExpectation : public ExpectationBase {
...
@@ -1159,10 +1156,9 @@ class TypedExpectation : public ExpectationBase {
}
}
// Returns the action that should be taken for the current invocation.
// Returns the action that should be taken for the current invocation.
const
Action
<
F
>&
GetCurrentAction
(
const
Action
<
F
>&
GetCurrentAction
(
const
FunctionMocker
<
F
>*
mocker
,
const
FunctionMockerBase
<
F
>*
mocker
,
const
ArgumentTuple
&
args
)
const
const
ArgumentTuple
&
args
)
const
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
g_gmock_mutex
.
AssertHeld
();
g_gmock_mutex
.
AssertHeld
();
const
int
count
=
call_count
();
const
int
count
=
call_count
();
Assert
(
count
>=
1
,
__FILE__
,
__LINE__
,
Assert
(
count
>=
1
,
__FILE__
,
__LINE__
,
...
@@ -1184,9 +1180,10 @@ class TypedExpectation : public ExpectationBase {
...
@@ -1184,9 +1180,10 @@ class TypedExpectation : public ExpectationBase {
Log
(
kWarning
,
ss
.
str
(),
1
);
Log
(
kWarning
,
ss
.
str
(),
1
);
}
}
return
count
<=
action_count
?
return
count
<=
action_count
*
static_cast
<
const
Action
<
F
>*>
(
untyped_actions_
[
count
-
1
])
:
?
*
static_cast
<
const
Action
<
F
>*>
(
repeated_action
();
untyped_actions_
[
static_cast
<
size_t
>
(
count
-
1
)])
:
repeated_action
();
}
}
// Given the arguments of a mock function call, if the call will
// Given the arguments of a mock function call, if the call will
...
@@ -1196,12 +1193,11 @@ class TypedExpectation : public ExpectationBase {
...
@@ -1196,12 +1193,11 @@ class TypedExpectation : public ExpectationBase {
// Mock does it to 'why'. This method is not const as it calls
// Mock does it to 'why'. This method is not const as it calls
// IncrementCallCount(). A return value of NULL means the default
// IncrementCallCount(). A return value of NULL means the default
// action.
// action.
const
Action
<
F
>*
GetActionForArguments
(
const
Action
<
F
>*
GetActionForArguments
(
const
FunctionMocker
<
F
>*
mocker
,
const
FunctionMockerBase
<
F
>*
mocker
,
const
ArgumentTuple
&
args
,
const
ArgumentTuple
&
args
,
::
std
::
ostream
*
what
,
::
std
::
ostream
*
what
,
::
std
::
ostream
*
why
)
::
std
::
ostream
*
why
)
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
g_gmock_mutex
.
AssertHeld
();
g_gmock_mutex
.
AssertHeld
();
if
(
IsSaturated
())
{
if
(
IsSaturated
())
{
// We have an excessive call.
// We have an excessive call.
...
@@ -1230,7 +1226,7 @@ class TypedExpectation : public ExpectationBase {
...
@@ -1230,7 +1226,7 @@ class TypedExpectation : public ExpectationBase {
// All the fields below won't change once the EXPECT_CALL()
// All the fields below won't change once the EXPECT_CALL()
// statement finishes.
// statement finishes.
FunctionMocker
Base
<
F
>*
const
owner_
;
FunctionMocker
<
F
>*
const
owner_
;
ArgumentMatcherTuple
matchers_
;
ArgumentMatcherTuple
matchers_
;
Matcher
<
const
ArgumentTuple
&>
extra_matcher_
;
Matcher
<
const
ArgumentTuple
&>
extra_matcher_
;
Action
<
F
>
repeated_action_
;
Action
<
F
>
repeated_action_
;
...
@@ -1262,7 +1258,7 @@ class MockSpec {
...
@@ -1262,7 +1258,7 @@ class MockSpec {
// 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.
MockSpec
(
internal
::
FunctionMocker
Base
<
F
>*
function_mocker
,
MockSpec
(
internal
::
FunctionMocker
<
F
>*
function_mocker
,
const
ArgumentMatcherTuple
&
matchers
)
const
ArgumentMatcherTuple
&
matchers
)
:
function_mocker_
(
function_mocker
),
matchers_
(
matchers
)
{}
:
function_mocker_
(
function_mocker
),
matchers_
(
matchers
)
{}
...
@@ -1298,7 +1294,7 @@ class MockSpec {
...
@@ -1298,7 +1294,7 @@ class MockSpec {
friend
class
internal
::
FunctionMocker
;
friend
class
internal
::
FunctionMocker
;
// The function mocker that owns this spec.
// The function mocker that owns this spec.
internal
::
FunctionMocker
Base
<
F
>*
const
function_mocker_
;
internal
::
FunctionMocker
<
F
>*
const
function_mocker_
;
// The argument matchers specified in the spec.
// The argument matchers specified in the spec.
ArgumentMatcherTuple
matchers_
;
ArgumentMatcherTuple
matchers_
;
...
@@ -1319,13 +1315,13 @@ class ReferenceOrValueWrapper {
...
@@ -1319,13 +1315,13 @@ 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_
(
::
testing
::
internal
::
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
// the same object is unspecified.
// the same object is unspecified.
T
Unwrap
()
{
return
::
testing
::
internal
::
move
(
value_
);
}
T
Unwrap
()
{
return
std
::
move
(
value_
);
}
// Provides nondestructive access to the underlying value/reference.
// Provides nondestructive access to the underlying value/reference.
// Always returns a const reference (more precisely,
// Always returns a const reference (more precisely,
...
@@ -1389,7 +1385,7 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
...
@@ -1389,7 +1385,7 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
}
}
// Prints the held value as an action's result to os.
// Prints the held value as an action's result to os.
virtual
void
PrintAsActionResult
(
::
std
::
ostream
*
os
)
const
{
void
PrintAsActionResult
(
::
std
::
ostream
*
os
)
const
override
{
*
os
<<
"
\n
Returns: "
;
*
os
<<
"
\n
Returns: "
;
// T may be a reference type, so we don't use UniversalPrint().
// T may be a reference type, so we don't use UniversalPrint().
UniversalPrinter
<
T
>::
Print
(
result_
.
Peek
(),
os
);
UniversalPrinter
<
T
>::
Print
(
result_
.
Peek
(),
os
);
...
@@ -1399,28 +1395,27 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
...
@@ -1399,28 +1395,27 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
// result in a new-ed ActionResultHolder.
// result in a new-ed ActionResultHolder.
template
<
typename
F
>
template
<
typename
F
>
static
ActionResultHolder
*
PerformDefaultAction
(
static
ActionResultHolder
*
PerformDefaultAction
(
const
FunctionMocker
Base
<
F
>*
func_mocker
,
const
FunctionMocker
<
F
>*
func_mocker
,
typename
RvalueRef
<
typename
Function
<
F
>::
ArgumentTuple
>::
type
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
(
func_mocker
->
PerformDefaultAction
(
internal
::
move
(
args
),
call_description
)));
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
// ActionResultHolder.
// ActionResultHolder.
template
<
typename
F
>
template
<
typename
F
>
static
ActionResultHolder
*
PerformAction
(
static
ActionResultHolder
*
PerformAction
(
const
Action
<
F
>&
action
,
const
Action
<
F
>&
action
,
typename
Function
<
F
>::
ArgumentTuple
&&
args
)
{
typename
RvalueRef
<
typename
Function
<
F
>::
ArgumentTuple
>::
type
args
)
{
return
new
ActionResultHolder
(
return
new
ActionResultHolder
(
Wrapper
(
action
.
Perform
(
internal
::
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_
(
::
testing
::
internal
::
move
(
result
))
{
:
result_
(
std
::
move
(
result
))
{
}
}
Wrapper
result_
;
Wrapper
result_
;
...
@@ -1434,16 +1429,16 @@ class ActionResultHolder<void> : public UntypedActionResultHolderBase {
...
@@ -1434,16 +1429,16 @@ class ActionResultHolder<void> : public UntypedActionResultHolderBase {
public:
public:
void
Unwrap
()
{
}
void
Unwrap
()
{
}
virtual
void
PrintAsActionResult
(
::
std
::
ostream
*
/* os */
)
const
{}
void
PrintAsActionResult
(
::
std
::
ostream
*
/* os */
)
const
override
{}
// Performs the given mock function's default action and returns ownership
// Performs the given mock function's default action and returns ownership
// of an empty ActionResultHolder*.
// of an empty ActionResultHolder*.
template
<
typename
F
>
template
<
typename
F
>
static
ActionResultHolder
*
PerformDefaultAction
(
static
ActionResultHolder
*
PerformDefaultAction
(
const
FunctionMocker
Base
<
F
>*
func_mocker
,
const
FunctionMocker
<
F
>*
func_mocker
,
typename
RvalueRef
<
typename
Function
<
F
>::
ArgumentTuple
>::
type
args
,
typename
Function
<
F
>::
ArgumentTuple
&&
args
,
const
std
::
string
&
call_description
)
{
const
std
::
string
&
call_description
)
{
func_mocker
->
PerformDefaultAction
(
internal
::
move
(
args
),
call_description
);
func_mocker
->
PerformDefaultAction
(
std
::
move
(
args
),
call_description
);
return
new
ActionResultHolder
;
return
new
ActionResultHolder
;
}
}
...
@@ -1451,9 +1446,8 @@ class ActionResultHolder<void> : public UntypedActionResultHolderBase {
...
@@ -1451,9 +1446,8 @@ class ActionResultHolder<void> : public UntypedActionResultHolderBase {
// ActionResultHolder*.
// ActionResultHolder*.
template
<
typename
F
>
template
<
typename
F
>
static
ActionResultHolder
*
PerformAction
(
static
ActionResultHolder
*
PerformAction
(
const
Action
<
F
>&
action
,
const
Action
<
F
>&
action
,
typename
Function
<
F
>::
ArgumentTuple
&&
args
)
{
typename
RvalueRef
<
typename
Function
<
F
>::
ArgumentTuple
>::
type
args
)
{
action
.
Perform
(
std
::
move
(
args
));
action
.
Perform
(
internal
::
move
(
args
));
return
new
ActionResultHolder
;
return
new
ActionResultHolder
;
}
}
...
@@ -1462,23 +1456,39 @@ class ActionResultHolder<void> : public UntypedActionResultHolderBase {
...
@@ -1462,23 +1456,39 @@ class ActionResultHolder<void> : public UntypedActionResultHolderBase {
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
ActionResultHolder
);
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
ActionResultHolder
);
};
};
// The base of the function mocker class for the given function type.
// We put the methods in this class instead of its child to avoid code
// bloat.
template
<
typename
F
>
template
<
typename
F
>
class
FunctionMockerBase
:
public
UntypedFunctionMockerBase
{
class
FunctionMocker
;
template
<
typename
R
,
typename
...
Args
>
class
FunctionMocker
<
R
(
Args
...)
>
:
public
UntypedFunctionMockerBase
{
using
F
=
R
(
Args
...);
public:
public:
typedef
typename
Function
<
F
>::
Result
Result
;
using
Result
=
R
;
typedef
typename
Function
<
F
>::
ArgumentTuple
ArgumentTuple
;
using
ArgumentTuple
=
std
::
tuple
<
Args
...
>
;
typedef
typename
Function
<
F
>::
ArgumentMatcherTuple
ArgumentMatcherTuple
;
using
ArgumentMatcherTuple
=
std
::
tuple
<
Matcher
<
Args
>
...
>
;
FunctionMockerBase
()
{}
FunctionMocker
()
{}
// There is no generally useful and implementable semantics of
// copying a mock object, so copying a mock is usually a user error.
// Thus we disallow copying function mockers. If the user really
// wants to copy a mock object, they should implement their own copy
// operation, for example:
//
// class MockFoo : public Foo {
// public:
// // Defines a copy constructor explicitly.
// MockFoo(const MockFoo& src) {}
// ...
// };
FunctionMocker
(
const
FunctionMocker
&
)
=
delete
;
FunctionMocker
&
operator
=
(
const
FunctionMocker
&
)
=
delete
;
// The destructor verifies that all expectations on this mock
// The destructor verifies that all expectations on this mock
// function have been satisfied. If not, it will report Google Test
// function have been satisfied. If not, it will report Google Test
// non-fatal failures for the violations.
// non-fatal failures for the violations.
virtual
~
FunctionMockerBase
()
~
FunctionMocker
()
override
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
)
{
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
)
{
MutexLock
l
(
&
g_gmock_mutex
);
MutexLock
l
(
&
g_gmock_mutex
);
VerifyAndClearExpectationsLocked
();
VerifyAndClearExpectationsLocked
();
Mock
::
UnregisterLocked
(
this
);
Mock
::
UnregisterLocked
(
this
);
...
@@ -1508,13 +1518,12 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1508,13 +1518,12 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// mutable state of this object, and thus can be called concurrently
// mutable state of this object, and thus can be called concurrently
// without locking.
// without locking.
// L = *
// L = *
Result
PerformDefaultAction
(
Result
PerformDefaultAction
(
ArgumentTuple
&&
args
,
typename
RvalueRef
<
typename
Function
<
F
>::
ArgumentTuple
>::
type
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
(
internal
::
move
(
args
));
return
spec
->
GetAction
().
Perform
(
std
::
move
(
args
));
}
}
const
std
::
string
message
=
const
std
::
string
message
=
call_description
+
call_description
+
...
@@ -1535,11 +1544,11 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1535,11 +1544,11 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// the error message to describe the call in the case the default
// the error message to describe the call in the case the default
// action fails. The caller is responsible for deleting the result.
// action fails. The caller is responsible for deleting the result.
// L = *
// L = *
virtual
UntypedActionResultHolderBase
*
UntypedPerformDefaultAction
(
UntypedActionResultHolderBase
*
UntypedPerformDefaultAction
(
void
*
untyped_args
,
// must point to an ArgumentTuple
void
*
untyped_args
,
// must point to an ArgumentTuple
const
std
::
string
&
call_description
)
const
{
const
std
::
string
&
call_description
)
const
override
{
ArgumentTuple
*
args
=
static_cast
<
ArgumentTuple
*>
(
untyped_args
);
ArgumentTuple
*
args
=
static_cast
<
ArgumentTuple
*>
(
untyped_args
);
return
ResultHolder
::
PerformDefaultAction
(
this
,
internal
::
move
(
*
args
),
return
ResultHolder
::
PerformDefaultAction
(
this
,
std
::
move
(
*
args
),
call_description
);
call_description
);
}
}
...
@@ -1547,18 +1556,18 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1547,18 +1556,18 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// the action's result. The caller is responsible for deleting the
// the action's result. The caller is responsible for deleting the
// result.
// result.
// L = *
// L = *
virtual
UntypedActionResultHolderBase
*
UntypedPerformAction
(
UntypedActionResultHolderBase
*
UntypedPerformAction
(
const
void
*
untyped_action
,
void
*
untyped_args
)
const
{
const
void
*
untyped_action
,
void
*
untyped_args
)
const
override
{
// Make a copy of the action before performing it, in case the
// Make a copy of the action before performing it, in case the
// action deletes the mock object (and thus deletes itself).
// action deletes the mock object (and thus deletes itself).
const
Action
<
F
>
action
=
*
static_cast
<
const
Action
<
F
>*>
(
untyped_action
);
const
Action
<
F
>
action
=
*
static_cast
<
const
Action
<
F
>*>
(
untyped_action
);
ArgumentTuple
*
args
=
static_cast
<
ArgumentTuple
*>
(
untyped_args
);
ArgumentTuple
*
args
=
static_cast
<
ArgumentTuple
*>
(
untyped_args
);
return
ResultHolder
::
PerformAction
(
action
,
internal
::
move
(
*
args
));
return
ResultHolder
::
PerformAction
(
action
,
std
::
move
(
*
args
));
}
}
// Implements UntypedFunctionMockerBase::ClearDefaultActionsLocked():
// Implements UntypedFunctionMockerBase::ClearDefaultActionsLocked():
// clears the ON_CALL()s set on this mock function.
// clears the ON_CALL()s set on this mock function.
virtual
void
ClearDefaultActionsLocked
()
void
ClearDefaultActionsLocked
()
override
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
GTEST_EXCLUSIVE_LOCK_REQUIRED_
(
g_gmock_mutex
)
{
g_gmock_mutex
.
AssertHeld
();
g_gmock_mutex
.
AssertHeld
();
...
@@ -1584,26 +1593,26 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1584,26 +1593,26 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
g_gmock_mutex
.
Lock
();
g_gmock_mutex
.
Lock
();
}
}
protected:
template
<
typename
Function
>
friend
class
MockSpec
;
typedef
ActionResultHolder
<
Result
>
ResultHolder
;
// 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
// threads concurrently.
// threads concurrently.
Result
InvokeWith
(
Result
Invoke
(
Args
...
args
)
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
)
{
typename
RvalueRef
<
typename
Function
<
F
>::
ArgumentTuple
>::
type
args
)
ArgumentTuple
tuple
(
std
::
forward
<
Args
>
(
args
)...);
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
)
{
std
::
unique_ptr
<
ResultHolder
>
holder
(
DownCast_
<
ResultHolder
*>
(
// const_cast is required since in C++98 we still pass ArgumentTuple around
this
->
UntypedInvokeWith
(
static_cast
<
void
*>
(
&
tuple
))));
// by const& instead of rvalue reference.
void
*
untyped_args
=
const_cast
<
void
*>
(
static_cast
<
const
void
*>
(
&
args
));
scoped_ptr
<
ResultHolder
>
holder
(
DownCast_
<
ResultHolder
*>
(
this
->
UntypedInvokeWith
(
untyped_args
)));
return
holder
->
Unwrap
();
return
holder
->
Unwrap
();
}
}
MockSpec
<
F
>
With
(
Matcher
<
Args
>
...
m
)
{
return
MockSpec
<
F
>
(
this
,
::
std
::
make_tuple
(
std
::
move
(
m
)...));
}
protected:
template
<
typename
Function
>
friend
class
MockSpec
;
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
,
...
@@ -1623,7 +1632,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1623,7 +1632,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
Mock
::
RegisterUseByOnCallOrExpectCall
(
MockObject
(),
file
,
line
);
Mock
::
RegisterUseByOnCallOrExpectCall
(
MockObject
(),
file
,
line
);
TypedExpectation
<
F
>*
const
expectation
=
TypedExpectation
<
F
>*
const
expectation
=
new
TypedExpectation
<
F
>
(
this
,
file
,
line
,
source_text
,
m
);
new
TypedExpectation
<
F
>
(
this
,
file
,
line
,
source_text
,
m
);
const
link
ed_ptr
<
ExpectationBase
>
untyped_expectation
(
expectation
);
const
std
::
shar
ed_ptr
<
ExpectationBase
>
untyped_expectation
(
expectation
);
// See the definition of untyped_expectations_ for why access to
// See the definition of untyped_expectations_ for why access to
// it is unprotected here.
// it is unprotected here.
untyped_expectations_
.
push_back
(
untyped_expectation
);
untyped_expectations_
.
push_back
(
untyped_expectation
);
...
@@ -1662,10 +1671,9 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1662,10 +1671,9 @@ class FunctionMockerBase : public 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
(
void
UntypedDescribeUninterestingCall
(
const
void
*
untyped_args
,
const
void
*
untyped_args
,
::
std
::
ostream
*
os
)
const
override
::
std
::
ostream
*
os
)
const
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
)
{
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
)
{
const
ArgumentTuple
&
args
=
const
ArgumentTuple
&
args
=
*
static_cast
<
const
ArgumentTuple
*>
(
untyped_args
);
*
static_cast
<
const
ArgumentTuple
*>
(
untyped_args
);
*
os
<<
"Uninteresting mock function call - "
;
*
os
<<
"Uninteresting mock function call - "
;
...
@@ -1690,11 +1698,10 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1690,11 +1698,10 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// section. The reason is that we have no control on what the
// section. The reason is that we have no control on what the
// action does (it can invoke an arbitrary user function or even a
// action does (it can invoke an arbitrary user function or even a
// mock function) and excessive locking could cause a dead lock.
// mock function) and excessive locking could cause a dead lock.
virtual
const
ExpectationBase
*
UntypedFindMatchingExpectation
(
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
)
override
::
std
::
ostream
*
what
,
::
std
::
ostream
*
why
)
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
)
{
GTEST_LOCK_EXCLUDED_
(
g_gmock_mutex
)
{
const
ArgumentTuple
&
args
=
const
ArgumentTuple
&
args
=
*
static_cast
<
const
ArgumentTuple
*>
(
untyped_args
);
*
static_cast
<
const
ArgumentTuple
*>
(
untyped_args
);
MutexLock
l
(
&
g_gmock_mutex
);
MutexLock
l
(
&
g_gmock_mutex
);
...
@@ -1716,8 +1723,8 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1716,8 +1723,8 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
}
}
// Prints the given function arguments to the ostream.
// Prints the given function arguments to the ostream.
virtual
void
UntypedPrintArgs
(
const
void
*
untyped_args
,
void
UntypedPrintArgs
(
const
void
*
untyped_args
,
::
std
::
ostream
*
os
)
const
{
::
std
::
ostream
*
os
)
const
override
{
const
ArgumentTuple
&
args
=
const
ArgumentTuple
&
args
=
*
static_cast
<
const
ArgumentTuple
*>
(
untyped_args
);
*
static_cast
<
const
ArgumentTuple
*>
(
untyped_args
);
UniversalPrint
(
args
,
os
);
UniversalPrint
(
args
,
os
);
...
@@ -1762,12 +1769,12 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1762,12 +1769,12 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
::
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
in
t
count
=
static_cast
<
int
>
(
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
(
in
t
i
=
0
;
i
<
count
;
i
++
)
{
for
(
size_
t
i
=
0
;
i
<
count
;
i
++
)
{
TypedExpectation
<
F
>*
const
expectation
=
TypedExpectation
<
F
>*
const
expectation
=
static_cast
<
TypedExpectation
<
F
>*>
(
untyped_expectations_
[
i
].
get
());
static_cast
<
TypedExpectation
<
F
>*>
(
untyped_expectations_
[
i
].
get
());
*
why
<<
"
\n
"
;
*
why
<<
"
\n
"
;
...
@@ -1780,36 +1787,98 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
...
@@ -1780,36 +1787,98 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
expectation
->
DescribeCallCountTo
(
why
);
expectation
->
DescribeCallCountTo
(
why
);
}
}
}
}
};
// class FunctionMocker
// There is no generally useful and implementable semantics of
// copying a mock object, so copying a mock is usually a user error.
// Thus we disallow copying function mockers. If the user really
// wants to copy a mock object, they should implement their own copy
// operation, for example:
//
// class MockFoo : public Foo {
// public:
// // Defines a copy constructor explicitly.
// MockFoo(const MockFoo& src) {}
// ...
// };
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
FunctionMockerBase
);
};
// class FunctionMockerBase
GTEST_DISABLE_MSC_WARNINGS_POP_
()
// 4355
GTEST_DISABLE_MSC_WARNINGS_POP_
()
// 4355
// Implements methods of FunctionMockerBase.
// Verifies that all expectations on this mock function have been
// satisfied. Reports one or more Google Test non-fatal failures and
// returns false if not.
// Reports an uninteresting call (whose description is in msg) in the
// Reports an uninteresting call (whose description is in msg) in the
// manner specified by 'reaction'.
// manner specified by 'reaction'.
void
ReportUninterestingCall
(
CallReaction
reaction
,
const
std
::
string
&
msg
);
void
ReportUninterestingCall
(
CallReaction
reaction
,
const
std
::
string
&
msg
);
}
// namespace internal
}
// namespace internal
// A MockFunction<F> class has one mock method whose type is F. It is
// useful when you just want your test code to emit some messages and
// have Google Mock verify the right messages are sent (and perhaps at
// the right times). For example, if you are exercising code:
//
// Foo(1);
// Foo(2);
// Foo(3);
//
// and want to verify that Foo(1) and Foo(3) both invoke
// mock.Bar("a"), but Foo(2) doesn't invoke anything, you can write:
//
// TEST(FooTest, InvokesBarCorrectly) {
// MyMock mock;
// MockFunction<void(string check_point_name)> check;
// {
// InSequence s;
//
// EXPECT_CALL(mock, Bar("a"));
// EXPECT_CALL(check, Call("1"));
// EXPECT_CALL(check, Call("2"));
// EXPECT_CALL(mock, Bar("a"));
// }
// Foo(1);
// check.Call("1");
// Foo(2);
// check.Call("2");
// Foo(3);
// }
//
// The expectation spec says that the first Bar("a") must happen
// before check point "1", the second Bar("a") must happen after check
// point "2", and nothing should happen between the two check
// points. The explicit check points make it easy to tell which
// Bar("a") is called by which call to Foo().
//
// MockFunction<F> can also be used to exercise code that accepts
// std::function<F> callbacks. To do so, use AsStdFunction() method
// to create std::function proxy forwarding to original object's Call.
// Example:
//
// TEST(FooTest, RunsCallbackWithBarArgument) {
// MockFunction<int(string)> callback;
// EXPECT_CALL(callback, Call("bar")).WillOnce(Return(1));
// Foo(callback.AsStdFunction());
// }
template
<
typename
F
>
class
MockFunction
;
template
<
typename
R
,
typename
...
Args
>
class
MockFunction
<
R
(
Args
...)
>
{
public:
MockFunction
()
{}
MockFunction
(
const
MockFunction
&
)
=
delete
;
MockFunction
&
operator
=
(
const
MockFunction
&
)
=
delete
;
std
::
function
<
R
(
Args
...)
>
AsStdFunction
()
{
return
[
this
](
Args
...
args
)
->
R
{
return
this
->
Call
(
std
::
forward
<
Args
>
(
args
)...);
};
}
// Implementation detail: the expansion of the MOCK_METHOD macro.
R
Call
(
Args
...
args
)
{
mock_
.
SetOwnerAndName
(
this
,
"Call"
);
return
mock_
.
Invoke
(
std
::
forward
<
Args
>
(
args
)...);
}
internal
::
MockSpec
<
R
(
Args
...)
>
gmock_Call
(
Matcher
<
Args
>
...
m
)
{
mock_
.
RegisterOwner
(
this
);
return
mock_
.
With
(
std
::
move
(
m
)...);
}
internal
::
MockSpec
<
R
(
Args
...)
>
gmock_Call
(
const
internal
::
WithoutMatchers
&
,
R
(
*
)(
Args
...))
{
return
this
->
gmock_Call
(
::
testing
::
A
<
Args
>
()...);
}
private:
mutable
internal
::
FunctionMocker
<
R
(
Args
...)
>
mock_
;
};
// The style guide prohibits "using" statements in a namespace scope
// The style guide prohibits "using" statements in a namespace scope
// inside a header file. However, the MockSpec class template is
// inside a header file. However, the MockSpec class template is
// meant to be defined in the ::testing namespace. The following line
// meant to be defined in the ::testing namespace. The following line
...
@@ -1905,8 +1974,9 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
...
@@ -1905,8 +1974,9 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
// second argument is an internal type derived from the method signature. The
// second argument is an internal type derived from the method signature. The
// failure to disambiguate two overloads of this method in the ON_CALL statement
// failure to disambiguate two overloads of this method in the ON_CALL statement
// is how we block callers from setting expectations on overloaded methods.
// is how we block callers from setting expectations on overloaded methods.
#define GMOCK_ON_CALL_IMPL_(mock_expr, Setter, call) \
#define GMOCK_ON_CALL_IMPL_(mock_expr, Setter, call) \
((mock_expr).gmock_##call)(::testing::internal::GetWithoutMatchers(), NULL) \
((mock_expr).gmock_##call)(::testing::internal::GetWithoutMatchers(), \
nullptr) \
.Setter(__FILE__, __LINE__, #mock_expr, #call)
.Setter(__FILE__, __LINE__, #mock_expr, #call)
#define ON_CALL(obj, call) \
#define ON_CALL(obj, call) \
...
...
googlemock/include/gmock/gmock.h
View file @
25905b9f
...
@@ -58,13 +58,14 @@
...
@@ -58,13 +58,14 @@
#include "gmock/gmock-actions.h"
#include "gmock/gmock-actions.h"
#include "gmock/gmock-cardinalities.h"
#include "gmock/gmock-cardinalities.h"
#include "gmock/gmock-function-mocker.h"
#include "gmock/gmock-generated-actions.h"
#include "gmock/gmock-generated-actions.h"
#include "gmock/gmock-generated-function-mockers.h"
#include "gmock/gmock-generated-function-mockers.h"
#include "gmock/gmock-generated-matchers.h"
#include "gmock/gmock-generated-matchers.h"
#include "gmock/gmock-generated-nice-strict.h"
#include "gmock/gmock-matchers.h"
#include "gmock/gmock-matchers.h"
#include "gmock/gmock-more-actions.h"
#include "gmock/gmock-more-actions.h"
#include "gmock/gmock-more-matchers.h"
#include "gmock/gmock-more-matchers.h"
#include "gmock/gmock-nice-strict.h"
#include "gmock/internal/gmock-internal-utils.h"
#include "gmock/internal/gmock-internal-utils.h"
namespace
testing
{
namespace
testing
{
...
...
googlemock/include/gmock/internal/gmock-generated-internal-utils.h
View file @
25905b9f
...
@@ -70,79 +70,71 @@ template <typename Tuple>
...
@@ -70,79 +70,71 @@ template <typename Tuple>
struct
MatcherTuple
;
struct
MatcherTuple
;
template
<
>
template
<
>
struct
MatcherTuple
<
::
testing
::
tuple
<>
>
{
struct
MatcherTuple
<
::
std
::
tuple
<>
>
{
typedef
::
testing
::
tuple
<
>
type
;
typedef
::
std
::
tuple
<
>
type
;
};
};
template
<
typename
A1
>
template
<
typename
A1
>
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
>
>
{
struct
MatcherTuple
<
::
std
::
tuple
<
A1
>
>
{
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
>
type
;
typedef
::
std
::
tuple
<
Matcher
<
A1
>
>
type
;
};
};
template
<
typename
A1
,
typename
A2
>
template
<
typename
A1
,
typename
A2
>
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
>
>
{
struct
MatcherTuple
<
::
std
::
tuple
<
A1
,
A2
>
>
{
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
>
type
;
typedef
::
std
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
>
type
;
};
};
template
<
typename
A1
,
typename
A2
,
typename
A3
>
template
<
typename
A1
,
typename
A2
,
typename
A3
>
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
>
>
{
struct
MatcherTuple
<
::
std
::
tuple
<
A1
,
A2
,
A3
>
>
{
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
>
type
;
typedef
::
std
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
>
type
;
};
};
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
>
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
>
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
>
>
{
struct
MatcherTuple
<
::
std
::
tuple
<
A1
,
A2
,
A3
,
A4
>
>
{
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
>
typedef
::
std
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
type
;
Matcher
<
A4
>
>
type
;
};
};
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
>
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
>
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
>
>
{
struct
MatcherTuple
<
::
std
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
>
>
{
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
typedef
::
std
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
Matcher
<
A5
>
>
Matcher
<
A5
>
>
type
;
type
;
};
};
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
>
typename
A6
>
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
>
>
{
struct
MatcherTuple
<
::
std
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
>
>
{
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
typedef
::
std
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
Matcher
<
A5
>
,
Matcher
<
A6
>
>
Matcher
<
A5
>
,
Matcher
<
A6
>
>
type
;
type
;
};
};
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
>
typename
A6
,
typename
A7
>
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
>
>
{
struct
MatcherTuple
<
::
std
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
>
>
{
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
typedef
::
std
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
Matcher
<
A5
>
,
Matcher
<
A6
>
,
Matcher
<
A7
>
>
Matcher
<
A5
>
,
Matcher
<
A6
>
,
Matcher
<
A7
>
>
type
;
type
;
};
};
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
>
typename
A6
,
typename
A7
,
typename
A8
>
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
>
>
{
struct
MatcherTuple
<
::
std
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
>
>
{
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
typedef
::
std
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
Matcher
<
A5
>
,
Matcher
<
A6
>
,
Matcher
<
A7
>
,
Matcher
<
A8
>
>
Matcher
<
A5
>
,
Matcher
<
A6
>
,
Matcher
<
A7
>
,
Matcher
<
A8
>
>
type
;
type
;
};
};
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
,
typename
A9
>
typename
A6
,
typename
A7
,
typename
A8
,
typename
A9
>
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
>
>
{
struct
MatcherTuple
<
::
std
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
>
>
{
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
typedef
::
std
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
Matcher
<
A5
>
,
Matcher
<
A6
>
,
Matcher
<
A7
>
,
Matcher
<
A8
>
,
Matcher
<
A5
>
,
Matcher
<
A6
>
,
Matcher
<
A7
>
,
Matcher
<
A8
>
,
Matcher
<
A9
>
>
type
;
Matcher
<
A9
>
>
type
;
};
};
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
template
<
typename
A1
,
typename
A2
,
typename
A3
,
typename
A4
,
typename
A5
,
typename
A6
,
typename
A7
,
typename
A8
,
typename
A9
,
typename
A10
>
typename
A6
,
typename
A7
,
typename
A8
,
typename
A9
,
typename
A10
>
struct
MatcherTuple
<
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
struct
MatcherTuple
<
::
std
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
A10
>
>
{
A10
>
>
{
typedef
::
std
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
typedef
::
testing
::
tuple
<
Matcher
<
A1
>
,
Matcher
<
A2
>
,
Matcher
<
A3
>
,
Matcher
<
A4
>
,
Matcher
<
A5
>
,
Matcher
<
A6
>
,
Matcher
<
A7
>
,
Matcher
<
A8
>
,
Matcher
<
A9
>
,
Matcher
<
A5
>
,
Matcher
<
A6
>
,
Matcher
<
A7
>
,
Matcher
<
A8
>
,
Matcher
<
A10
>
>
type
;
Matcher
<
A9
>
,
Matcher
<
A10
>
>
type
;
};
};
// Template struct Function<F>, where F must be a function type, contains
// Template struct Function<F>, where F must be a function type, contains
...
@@ -164,7 +156,7 @@ struct Function;
...
@@ -164,7 +156,7 @@ struct Function;
template
<
typename
R
>
template
<
typename
R
>
struct
Function
<
R
()
>
{
struct
Function
<
R
()
>
{
typedef
R
Result
;
typedef
R
Result
;
typedef
::
testing
::
tuple
<>
ArgumentTuple
;
typedef
::
std
::
tuple
<>
ArgumentTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
void
MakeResultVoid
();
typedef
void
MakeResultVoid
();
typedef
IgnoredValue
MakeResultIgnoredValue
();
typedef
IgnoredValue
MakeResultIgnoredValue
();
...
@@ -174,7 +166,7 @@ template <typename R, typename A1>
...
@@ -174,7 +166,7 @@ template <typename R, typename A1>
struct
Function
<
R
(
A1
)
>
struct
Function
<
R
(
A1
)
>
:
Function
<
R
()
>
{
:
Function
<
R
()
>
{
typedef
A1
Argument1
;
typedef
A1
Argument1
;
typedef
::
testing
::
tuple
<
A1
>
ArgumentTuple
;
typedef
::
std
::
tuple
<
A1
>
ArgumentTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
void
MakeResultVoid
(
A1
);
typedef
void
MakeResultVoid
(
A1
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
);
...
@@ -184,7 +176,7 @@ template <typename R, typename A1, typename A2>
...
@@ -184,7 +176,7 @@ template <typename R, typename A1, typename A2>
struct
Function
<
R
(
A1
,
A2
)
>
struct
Function
<
R
(
A1
,
A2
)
>
:
Function
<
R
(
A1
)
>
{
:
Function
<
R
(
A1
)
>
{
typedef
A2
Argument2
;
typedef
A2
Argument2
;
typedef
::
testing
::
tuple
<
A1
,
A2
>
ArgumentTuple
;
typedef
::
std
::
tuple
<
A1
,
A2
>
ArgumentTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
void
MakeResultVoid
(
A1
,
A2
);
typedef
void
MakeResultVoid
(
A1
,
A2
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
);
...
@@ -194,7 +186,7 @@ template <typename R, typename A1, typename A2, typename A3>
...
@@ -194,7 +186,7 @@ template <typename R, typename A1, typename A2, typename A3>
struct
Function
<
R
(
A1
,
A2
,
A3
)
>
struct
Function
<
R
(
A1
,
A2
,
A3
)
>
:
Function
<
R
(
A1
,
A2
)
>
{
:
Function
<
R
(
A1
,
A2
)
>
{
typedef
A3
Argument3
;
typedef
A3
Argument3
;
typedef
::
testing
::
tuple
<
A1
,
A2
,
A3
>
ArgumentTuple
;
typedef
::
std
::
tuple
<
A1
,
A2
,
A3
>
ArgumentTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
void
MakeResultVoid
(
A1
,
A2
,
A3
);
typedef
void
MakeResultVoid
(
A1
,
A2
,
A3
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
,
A3
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
,
A3
);
...
@@ -204,7 +196,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4>
...
@@ -204,7 +196,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4>
struct
Function
<
R
(
A1
,
A2
,
A3
,
A4
)
>
struct
Function
<
R
(
A1
,
A2
,
A3
,
A4
)
>
:
Function
<
R
(
A1
,
A2
,
A3
)
>
{
:
Function
<
R
(
A1
,
A2
,
A3
)
>
{
typedef
A4
Argument4
;
typedef
A4
Argument4
;
typedef
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
>
ArgumentTuple
;
typedef
::
std
::
tuple
<
A1
,
A2
,
A3
,
A4
>
ArgumentTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
void
MakeResultVoid
(
A1
,
A2
,
A3
,
A4
);
typedef
void
MakeResultVoid
(
A1
,
A2
,
A3
,
A4
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
,
A3
,
A4
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
,
A3
,
A4
);
...
@@ -215,7 +207,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
...
@@ -215,7 +207,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
struct
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
)
>
struct
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
)
>
:
Function
<
R
(
A1
,
A2
,
A3
,
A4
)
>
{
:
Function
<
R
(
A1
,
A2
,
A3
,
A4
)
>
{
typedef
A5
Argument5
;
typedef
A5
Argument5
;
typedef
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
>
ArgumentTuple
;
typedef
::
std
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
>
ArgumentTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
void
MakeResultVoid
(
A1
,
A2
,
A3
,
A4
,
A5
);
typedef
void
MakeResultVoid
(
A1
,
A2
,
A3
,
A4
,
A5
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
,
A3
,
A4
,
A5
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
,
A3
,
A4
,
A5
);
...
@@ -226,7 +218,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
...
@@ -226,7 +218,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
struct
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
)
>
struct
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
)
>
:
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
)
>
{
:
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
)
>
{
typedef
A6
Argument6
;
typedef
A6
Argument6
;
typedef
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
>
ArgumentTuple
;
typedef
::
std
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
>
ArgumentTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
void
MakeResultVoid
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
);
typedef
void
MakeResultVoid
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
);
...
@@ -237,7 +229,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
...
@@ -237,7 +229,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
struct
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
)
>
struct
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
)
>
:
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
)
>
{
:
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
)
>
{
typedef
A7
Argument7
;
typedef
A7
Argument7
;
typedef
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
>
ArgumentTuple
;
typedef
::
std
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
>
ArgumentTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
void
MakeResultVoid
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
);
typedef
void
MakeResultVoid
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
);
...
@@ -248,7 +240,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
...
@@ -248,7 +240,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
struct
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
)
>
struct
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
)
>
:
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
)
>
{
:
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
)
>
{
typedef
A8
Argument8
;
typedef
A8
Argument8
;
typedef
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
>
ArgumentTuple
;
typedef
::
std
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
>
ArgumentTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
void
MakeResultVoid
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
);
typedef
void
MakeResultVoid
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
);
...
@@ -259,7 +251,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
...
@@ -259,7 +251,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
struct
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
)
>
struct
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
)
>
:
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
)
>
{
:
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
)
>
{
typedef
A9
Argument9
;
typedef
A9
Argument9
;
typedef
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
>
ArgumentTuple
;
typedef
::
std
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
>
ArgumentTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
void
MakeResultVoid
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
);
typedef
void
MakeResultVoid
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
...
@@ -272,8 +264,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
...
@@ -272,8 +264,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
struct
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
A10
)
>
struct
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
A10
)
>
:
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
)
>
{
:
Function
<
R
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
)
>
{
typedef
A10
Argument10
;
typedef
A10
Argument10
;
typedef
::
testing
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
typedef
::
std
::
tuple
<
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
A10
>
ArgumentTuple
;
A10
>
ArgumentTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
void
MakeResultVoid
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
A10
);
typedef
void
MakeResultVoid
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
A10
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
typedef
IgnoredValue
MakeResultIgnoredValue
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
...
...
googlemock/include/gmock/internal/gmock-generated-internal-utils.h.pump
View file @
25905b9f
...
@@ -78,8 +78,8 @@ $var typename_As = [[$for j, [[typename A$j]]]]
...
@@ -78,8 +78,8 @@ $var typename_As = [[$for j, [[typename A$j]]]]
$
var
As
=
[[
$
for
j
,
[[
A
$
j
]]]]
$
var
As
=
[[
$
for
j
,
[[
A
$
j
]]]]
$
var
matcher_As
=
[[
$
for
j
,
[[
Matcher
<
A
$
j
>
]]]]
$
var
matcher_As
=
[[
$
for
j
,
[[
Matcher
<
A
$
j
>
]]]]
template
<
$
typename_As
>
template
<
$
typename_As
>
struct
MatcherTuple
<
::
testing
::
tuple
<
$
As
>
>
{
struct
MatcherTuple
<
::
std
::
tuple
<
$
As
>
>
{
typedef
::
testing
::
tuple
<
$
matcher_As
>
type
;
typedef
::
std
::
tuple
<
$
matcher_As
>
type
;
};
};
...
@@ -103,7 +103,7 @@ struct Function;
...
@@ -103,7 +103,7 @@ struct Function;
template
<
typename
R
>
template
<
typename
R
>
struct
Function
<
R
()
>
{
struct
Function
<
R
()
>
{
typedef
R
Result
;
typedef
R
Result
;
typedef
::
testing
::
tuple
<>
ArgumentTuple
;
typedef
::
std
::
tuple
<>
ArgumentTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
void
MakeResultVoid
();
typedef
void
MakeResultVoid
();
typedef
IgnoredValue
MakeResultIgnoredValue
();
typedef
IgnoredValue
MakeResultIgnoredValue
();
...
@@ -122,7 +122,7 @@ template <typename R$typename_As>
...
@@ -122,7 +122,7 @@ template <typename R$typename_As>
struct
Function
<
R
(
$
As
)
>
struct
Function
<
R
(
$
As
)
>
:
Function
<
R
(
$
prev_As
)
>
{
:
Function
<
R
(
$
prev_As
)
>
{
typedef
A
$
i
Argument
$
i
;
typedef
A
$
i
Argument
$
i
;
typedef
::
testing
::
tuple
<
$
As
>
ArgumentTuple
;
typedef
::
std
::
tuple
<
$
As
>
ArgumentTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
typename
MatcherTuple
<
ArgumentTuple
>::
type
ArgumentMatcherTuple
;
typedef
void
MakeResultVoid
(
$
As
);
typedef
void
MakeResultVoid
(
$
As
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
$
As
);
typedef
IgnoredValue
MakeResultIgnoredValue
(
$
As
);
...
...
googlemock/include/gmock/internal/gmock-internal-utils.h
View file @
25905b9f
...
@@ -92,15 +92,6 @@ inline const typename Pointer::element_type* GetRawPointer(const Pointer& p) {
...
@@ -92,15 +92,6 @@ inline const typename Pointer::element_type* GetRawPointer(const Pointer& p) {
template
<
typename
Element
>
template
<
typename
Element
>
inline
Element
*
GetRawPointer
(
Element
*
p
)
{
return
p
;
}
inline
Element
*
GetRawPointer
(
Element
*
p
)
{
return
p
;
}
// This comparator allows linked_ptr to be stored in sets.
template
<
typename
T
>
struct
LinkedPtrLessThan
{
bool
operator
()(
const
::
testing
::
internal
::
linked_ptr
<
T
>&
lhs
,
const
::
testing
::
internal
::
linked_ptr
<
T
>&
rhs
)
const
{
return
lhs
.
get
()
<
rhs
.
get
();
}
};
// Symbian compilation can be done with wchar_t being either a native
// Symbian compilation can be done with wchar_t being either a native
// type or a typedef. Using Google Mock with OpenC without wchar_t
// type or a typedef. Using Google Mock with OpenC without wchar_t
// should require the definition of _STLP_NO_WCHAR_T.
// should require the definition of _STLP_NO_WCHAR_T.
...
@@ -493,7 +484,7 @@ class StlContainerView<Element[N]> {
...
@@ -493,7 +484,7 @@ class StlContainerView<Element[N]> {
// This specialization is used when RawContainer is a native array
// This specialization is used when RawContainer is a native array
// represented as a (pointer, size) tuple.
// represented as a (pointer, size) tuple.
template
<
typename
ElementPointer
,
typename
Size
>
template
<
typename
ElementPointer
,
typename
Size
>
class
StlContainerView
<
::
testing
::
tuple
<
ElementPointer
,
Size
>
>
{
class
StlContainerView
<
::
std
::
tuple
<
ElementPointer
,
Size
>
>
{
public:
public:
typedef
GTEST_REMOVE_CONST_
(
typedef
GTEST_REMOVE_CONST_
(
typename
internal
::
PointeeOf
<
ElementPointer
>::
type
)
RawElement
;
typename
internal
::
PointeeOf
<
ElementPointer
>::
type
)
RawElement
;
...
@@ -501,11 +492,12 @@ class StlContainerView< ::testing::tuple<ElementPointer, Size> > {
...
@@ -501,11 +492,12 @@ class StlContainerView< ::testing::tuple<ElementPointer, Size> > {
typedef
const
type
const_reference
;
typedef
const
type
const_reference
;
static
const_reference
ConstReference
(
static
const_reference
ConstReference
(
const
::
testing
::
tuple
<
ElementPointer
,
Size
>&
array
)
{
const
::
std
::
tuple
<
ElementPointer
,
Size
>&
array
)
{
return
type
(
get
<
0
>
(
array
),
get
<
1
>
(
array
),
RelationToSourceReference
());
return
type
(
std
::
get
<
0
>
(
array
),
std
::
get
<
1
>
(
array
),
RelationToSourceReference
());
}
}
static
type
Copy
(
const
::
testing
::
tuple
<
ElementPointer
,
Size
>&
array
)
{
static
type
Copy
(
const
::
std
::
tuple
<
ElementPointer
,
Size
>&
array
)
{
return
type
(
get
<
0
>
(
array
),
get
<
1
>
(
array
),
RelationToSourceCopy
());
return
type
(
std
::
get
<
0
>
(
array
),
std
::
get
<
1
>
(
array
),
RelationToSourceCopy
());
}
}
};
};
...
@@ -536,7 +528,6 @@ struct BooleanConstant {};
...
@@ -536,7 +528,6 @@ struct BooleanConstant {};
// reduce code size.
// reduce code size.
GTEST_API_
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.
// Helper types for Apply() below.
template
<
size_t
...
Is
>
struct
int_pack
{
typedef
int_pack
type
;
};
template
<
size_t
...
Is
>
struct
int_pack
{
typedef
int_pack
type
;
};
...
@@ -562,7 +553,6 @@ auto Apply(F&& f, Tuple&& args)
...
@@ -562,7 +553,6 @@ auto Apply(F&& f, Tuple&& args)
return
ApplyImpl
(
std
::
forward
<
F
>
(
f
),
std
::
forward
<
Tuple
>
(
args
),
return
ApplyImpl
(
std
::
forward
<
F
>
(
f
),
std
::
forward
<
Tuple
>
(
args
),
make_int_pack
<
std
::
tuple_size
<
Tuple
>::
value
>
());
make_int_pack
<
std
::
tuple_size
<
Tuple
>::
value
>
());
}
}
#endif
#ifdef _MSC_VER
#ifdef _MSC_VER
...
...
googlemock/include/gmock/internal/gmock-port.h
View file @
25905b9f
...
@@ -52,14 +52,13 @@
...
@@ -52,14 +52,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-linked_ptr.h"
#include "gtest/internal/gtest-port.h"
#include "gtest/internal/gtest-port.h"
#include "gmock/internal/custom/gmock-port.h"
#include "gmock/internal/custom/gmock-port.h"
// For MS Visual C++, check the compiler version. At least VS 20
03
is
// For MS Visual C++, check the compiler version. At least VS 20
15
is
// required to compile Google Mock.
// required to compile Google Mock.
#if defined(_MSC_VER) && _MSC_VER < 1
31
0
#if defined(_MSC_VER) && _MSC_VER < 1
90
0
# error "At least Visual C++ 20
03 (7.1
) is required to compile Google Mock."
# error "At least Visual C++ 20
15 (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
...
...
googlemock/include/gmock/internal/gmock-pp.h
0 → 100644
View file @
25905b9f
#ifndef THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_PP_H_
#define THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_PP_H_
#undef GMOCK_PP_INTERNAL_USE_MSVC
#if defined(__clang__)
#define GMOCK_PP_INTERNAL_USE_MSVC 0
#elif defined(_MSC_VER)
// TODO(iserna): Also verify tradional versus comformant preprocessor.
static_assert
(
_MSC_VER
>=
1900
,
"MSVC version not supported. There is support for MSVC 14.0 and above."
);
#define GMOCK_PP_INTERNAL_USE_MSVC 1
#else
#define GMOCK_PP_INTERNAL_USE_MSVC 0
#endif
// Expands and concatenates the arguments. Constructed macros reevaluate.
#define GMOCK_PP_CAT(_1, _2) GMOCK_PP_INTERNAL_CAT(_1, _2)
// Expands and stringifies the only argument.
#define GMOCK_PP_STRINGIZE(...) GMOCK_PP_INTERNAL_STRINGIZE(__VA_ARGS__)
// Returns empty. Given a variadic number of arguments.
#define GMOCK_PP_EMPTY(...)
// Returns a comma. Given a variadic number of arguments.
#define GMOCK_PP_COMMA(...) ,
// Returns the only argument.
#define GMOCK_PP_IDENTITY(_1) _1
// MSVC preprocessor collapses __VA_ARGS__ in a single argument, we use a
// CAT-like directive to force correct evaluation. Each macro has its own.
#if GMOCK_PP_INTERNAL_USE_MSVC
// Evaluates to the number of arguments after expansion.
//
// #define PAIR x, y
//
// GMOCK_PP_NARG() => 1
// GMOCK_PP_NARG(x) => 1
// GMOCK_PP_NARG(x, y) => 2
// GMOCK_PP_NARG(PAIR) => 2
//
// Requires: the number of arguments after expansion is at most 15.
#define GMOCK_PP_NARG(...) \
GMOCK_PP_INTERNAL_NARG_CAT( \
GMOCK_PP_INTERNAL_INTERNAL_16TH(__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, \
8, 7, 6, 5, 4, 3, 2, 1), )
// Returns 1 if the expansion of arguments has an unprotected comma. Otherwise
// returns 0. Requires no more than 15 unprotected commas.
#define GMOCK_PP_HAS_COMMA(...) \
GMOCK_PP_INTERNAL_HAS_COMMA_CAT( \
GMOCK_PP_INTERNAL_INTERNAL_16TH(__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
1, 1, 1, 1, 1, 0), )
// Returns the first argument.
#define GMOCK_PP_HEAD(...) \
GMOCK_PP_INTERNAL_HEAD_CAT(GMOCK_PP_INTERNAL_HEAD(__VA_ARGS__), )
// Returns the tail. A variadic list of all arguments minus the first. Requires
// at least one argument.
#define GMOCK_PP_TAIL(...) \
GMOCK_PP_INTERNAL_TAIL_CAT(GMOCK_PP_INTERNAL_TAIL(__VA_ARGS__), )
// Calls CAT(_Macro, NARG(__VA_ARGS__))(__VA_ARGS__)
#define GMOCK_PP_VARIADIC_CALL(_Macro, ...) \
GMOCK_PP_INTERNAL_VARIADIC_CALL_CAT( \
GMOCK_PP_CAT(_Macro, GMOCK_PP_NARG(__VA_ARGS__))(__VA_ARGS__), )
#else // GMOCK_PP_INTERNAL_USE_MSVC
#define GMOCK_PP_NARG(...) \
GMOCK_PP_INTERNAL_INTERNAL_16TH(__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, \
7, 6, 5, 4, 3, 2, 1)
#define GMOCK_PP_HAS_COMMA(...) \
GMOCK_PP_INTERNAL_INTERNAL_16TH(__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
1, 1, 1, 1, 0)
#define GMOCK_PP_HEAD(...) GMOCK_PP_INTERNAL_HEAD(__VA_ARGS__)
#define GMOCK_PP_TAIL(...) GMOCK_PP_INTERNAL_TAIL(__VA_ARGS__)
#define GMOCK_PP_VARIADIC_CALL(_Macro, ...) \
GMOCK_PP_CAT(_Macro, GMOCK_PP_NARG(__VA_ARGS__))(__VA_ARGS__)
#endif // GMOCK_PP_INTERNAL_USE_MSVC
// If the arguments after expansion have no tokens, evaluates to `1`. Otherwise
// evaluates to `0`.
//
// Requires: * the number of arguments after expansion is at most 15.
// * If the argument is a macro, it must be able to be called with one
// argument.
//
// Implementation details:
//
// There is one case when it generates a compile error: if the argument is macro
// that cannot be called with one argument.
//
// #define M(a, b) // it doesn't matter what it expands to
//
// // Expected: expands to `0`.
// // Actual: compile error.
// GMOCK_PP_IS_EMPTY(M)
//
// There are 4 cases tested:
//
// * __VA_ARGS__ possible expansion has no unparen'd commas. Expected 0.
// * __VA_ARGS__ possible expansion is not enclosed in parenthesis. Expected 0.
// * __VA_ARGS__ possible expansion is not a macro that ()-evaluates to a comma.
// Expected 0
// * __VA_ARGS__ is empty, or has unparen'd commas, or is enclosed in
// parenthesis, or is a macro that ()-evaluates to comma. Expected 1.
//
// We trigger detection on '0001', i.e. on empty.
#define GMOCK_PP_IS_EMPTY(...) \
GMOCK_PP_INTERNAL_IS_EMPTY(GMOCK_PP_HAS_COMMA(__VA_ARGS__), \
GMOCK_PP_HAS_COMMA(GMOCK_PP_COMMA __VA_ARGS__), \
GMOCK_PP_HAS_COMMA(__VA_ARGS__()), \
GMOCK_PP_HAS_COMMA(GMOCK_PP_COMMA __VA_ARGS__()))
// Evaluates to _Then if _Cond is 1 and _Else if _Cond is 0.
#define GMOCK_PP_IF(_Cond, _Then, _Else) \
GMOCK_PP_CAT(GMOCK_PP_INTERNAL_IF_, _Cond)(_Then, _Else)
// Evaluates to the number of arguments after expansion. Identifies 'empty' as
// 0.
//
// #define PAIR x, y
//
// GMOCK_PP_NARG0() => 0
// GMOCK_PP_NARG0(x) => 1
// GMOCK_PP_NARG0(x, y) => 2
// GMOCK_PP_NARG0(PAIR) => 2
//
// Requires: * the number of arguments after expansion is at most 15.
// * If the argument is a macro, it must be able to be called with one
// argument.
#define GMOCK_PP_NARG0(...) \
GMOCK_PP_IF(GMOCK_PP_IS_EMPTY(__VA_ARGS__), 0, GMOCK_PP_NARG(__VA_ARGS__))
// Expands to 1 if the first argument starts with something in parentheses,
// otherwise to 0.
#define GMOCK_PP_IS_BEGIN_PARENS(...) \
GMOCK_PP_INTERNAL_ALTERNATE_HEAD( \
GMOCK_PP_CAT(GMOCK_PP_INTERNAL_IBP_IS_VARIADIC_R_, \
GMOCK_PP_INTERNAL_IBP_IS_VARIADIC_C __VA_ARGS__))
// Expands to 1 is there is only one argument and it is enclosed in parentheses.
#define GMOCK_PP_IS_ENCLOSED_PARENS(...) \
GMOCK_PP_IF(GMOCK_PP_IS_BEGIN_PARENS(__VA_ARGS__), \
GMOCK_PP_IS_EMPTY(GMOCK_PP_EMPTY __VA_ARGS__), 0)
// Remove the parens, requires GMOCK_PP_IS_ENCLOSED_PARENS(args) => 1.
#define GMOCK_PP_REMOVE_PARENS(...) GMOCK_PP_INTERNAL_REMOVE_PARENS __VA_ARGS__
// Expands to _Macro(0, _Data, e1) _Macro(1, _Data, e2) ... _Macro(K -1, _Data,
// eK) as many of GMOCK_INTERNAL_NARG0 _Tuple.
// Requires: * |_Macro| can be called with 3 arguments.
// * |_Tuple| expansion has no more than 15 elements.
#define GMOCK_PP_FOR_EACH(_Macro, _Data, _Tuple) \
GMOCK_PP_CAT(GMOCK_PP_INTERNAL_FOR_EACH_IMPL_, GMOCK_PP_NARG0 _Tuple) \
(0, _Macro, _Data, _Tuple)
// Expands to _Macro(0, _Data, ) _Macro(1, _Data, ) ... _Macro(K - 1, _Data, )
// Empty if _K = 0.
// Requires: * |_Macro| can be called with 3 arguments.
// * |_K| literal between 0 and 15
#define GMOCK_PP_REPEAT(_Macro, _Data, _N) \
GMOCK_PP_CAT(GMOCK_PP_INTERNAL_FOR_EACH_IMPL_, _N) \
(0, _Macro, _Data, GMOCK_PP_INTENRAL_EMPTY_TUPLE)
// Increments the argument, requires the argument to be between 0 and 15.
#define GMOCK_PP_INC(_i) GMOCK_PP_CAT(GMOCK_PP_INTERNAL_INC_, _i)
// Returns comma if _i != 0. Requires _i to be between 0 and 15.
#define GMOCK_PP_COMMA_IF(_i) GMOCK_PP_CAT(GMOCK_PP_INTERNAL_COMMA_IF_, _i)
// Internal details follow. Do not use any of these symbols outside of this
// file or we will break your code.
#define GMOCK_PP_INTENRAL_EMPTY_TUPLE (, , , , , , , , , , , , , , , )
#define GMOCK_PP_INTERNAL_CAT(_1, _2) _1##_2
#define GMOCK_PP_INTERNAL_STRINGIZE(...) #__VA_ARGS__
#define GMOCK_PP_INTERNAL_INTERNAL_16TH(_1, _2, _3, _4, _5, _6, _7, _8, _9, \
_10, _11, _12, _13, _14, _15, _16, \
...) \
_16
#define GMOCK_PP_INTERNAL_CAT_5(_1, _2, _3, _4, _5) _1##_2##_3##_4##_5
#define GMOCK_PP_INTERNAL_IS_EMPTY(_1, _2, _3, _4) \
GMOCK_PP_HAS_COMMA(GMOCK_PP_INTERNAL_CAT_5(GMOCK_PP_INTERNAL_IS_EMPTY_CASE_, \
_1, _2, _3, _4))
#define GMOCK_PP_INTERNAL_IS_EMPTY_CASE_0001 ,
#define GMOCK_PP_INTERNAL_IF_1(_Then, _Else) _Then
#define GMOCK_PP_INTERNAL_IF_0(_Then, _Else) _Else
#define GMOCK_PP_INTERNAL_HEAD(_1, ...) _1
#define GMOCK_PP_INTERNAL_TAIL(_1, ...) __VA_ARGS__
#if GMOCK_PP_INTERNAL_USE_MSVC
#define GMOCK_PP_INTERNAL_NARG_CAT(_1, _2) GMOCK_PP_INTERNAL_NARG_CAT_I(_1, _2)
#define GMOCK_PP_INTERNAL_HEAD_CAT(_1, _2) GMOCK_PP_INTERNAL_HEAD_CAT_I(_1, _2)
#define GMOCK_PP_INTERNAL_HAS_COMMA_CAT(_1, _2) \
GMOCK_PP_INTERNAL_HAS_COMMA_CAT_I(_1, _2)
#define GMOCK_PP_INTERNAL_TAIL_CAT(_1, _2) GMOCK_PP_INTERNAL_TAIL_CAT_I(_1, _2)
#define GMOCK_PP_INTERNAL_VARIADIC_CALL_CAT(_1, _2) \
GMOCK_PP_INTERNAL_VARIADIC_CALL_CAT_I(_1, _2)
#define GMOCK_PP_INTERNAL_NARG_CAT_I(_1, _2) _1##_2
#define GMOCK_PP_INTERNAL_HEAD_CAT_I(_1, _2) _1##_2
#define GMOCK_PP_INTERNAL_HAS_COMMA_CAT_I(_1, _2) _1##_2
#define GMOCK_PP_INTERNAL_TAIL_CAT_I(_1, _2) _1##_2
#define GMOCK_PP_INTERNAL_VARIADIC_CALL_CAT_I(_1, _2) _1##_2
#define GMOCK_PP_INTERNAL_ALTERNATE_HEAD(...) \
GMOCK_PP_INTERNAL_ALTERNATE_HEAD_CAT(GMOCK_PP_HEAD(__VA_ARGS__), )
#define GMOCK_PP_INTERNAL_ALTERNATE_HEAD_CAT(_1, _2) \
GMOCK_PP_INTERNAL_ALTERNATE_HEAD_CAT_I(_1, _2)
#define GMOCK_PP_INTERNAL_ALTERNATE_HEAD_CAT_I(_1, _2) _1##_2
#else // GMOCK_PP_INTERNAL_USE_MSVC
#define GMOCK_PP_INTERNAL_ALTERNATE_HEAD(...) GMOCK_PP_HEAD(__VA_ARGS__)
#endif // GMOCK_PP_INTERNAL_USE_MSVC
#define GMOCK_PP_INTERNAL_IBP_IS_VARIADIC_C(...) 1 _
#define GMOCK_PP_INTERNAL_IBP_IS_VARIADIC_R_1 1,
#define GMOCK_PP_INTERNAL_IBP_IS_VARIADIC_R_GMOCK_PP_INTERNAL_IBP_IS_VARIADIC_C \
0,
#define GMOCK_PP_INTERNAL_REMOVE_PARENS(...) __VA_ARGS__
#define GMOCK_PP_INTERNAL_INC_0 1
#define GMOCK_PP_INTERNAL_INC_1 2
#define GMOCK_PP_INTERNAL_INC_2 3
#define GMOCK_PP_INTERNAL_INC_3 4
#define GMOCK_PP_INTERNAL_INC_4 5
#define GMOCK_PP_INTERNAL_INC_5 6
#define GMOCK_PP_INTERNAL_INC_6 7
#define GMOCK_PP_INTERNAL_INC_7 8
#define GMOCK_PP_INTERNAL_INC_8 9
#define GMOCK_PP_INTERNAL_INC_9 10
#define GMOCK_PP_INTERNAL_INC_10 11
#define GMOCK_PP_INTERNAL_INC_11 12
#define GMOCK_PP_INTERNAL_INC_12 13
#define GMOCK_PP_INTERNAL_INC_13 14
#define GMOCK_PP_INTERNAL_INC_14 15
#define GMOCK_PP_INTERNAL_INC_15 16
#define GMOCK_PP_INTERNAL_COMMA_IF_0
#define GMOCK_PP_INTERNAL_COMMA_IF_1 ,
#define GMOCK_PP_INTERNAL_COMMA_IF_2 ,
#define GMOCK_PP_INTERNAL_COMMA_IF_3 ,
#define GMOCK_PP_INTERNAL_COMMA_IF_4 ,
#define GMOCK_PP_INTERNAL_COMMA_IF_5 ,
#define GMOCK_PP_INTERNAL_COMMA_IF_6 ,
#define GMOCK_PP_INTERNAL_COMMA_IF_7 ,
#define GMOCK_PP_INTERNAL_COMMA_IF_8 ,
#define GMOCK_PP_INTERNAL_COMMA_IF_9 ,
#define GMOCK_PP_INTERNAL_COMMA_IF_10 ,
#define GMOCK_PP_INTERNAL_COMMA_IF_11 ,
#define GMOCK_PP_INTERNAL_COMMA_IF_12 ,
#define GMOCK_PP_INTERNAL_COMMA_IF_13 ,
#define GMOCK_PP_INTERNAL_COMMA_IF_14 ,
#define GMOCK_PP_INTERNAL_COMMA_IF_15 ,
#define GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, _element) \
_Macro(_i, _Data, _element)
#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_0(_i, _Macro, _Data, _Tuple)
#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_1(_i, _Macro, _Data, _Tuple) \
GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple)
#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_2(_i, _Macro, _Data, _Tuple) \
GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \
GMOCK_PP_INTERNAL_FOR_EACH_IMPL_1(GMOCK_PP_INC(_i), _Macro, _Data, \
(GMOCK_PP_TAIL _Tuple))
#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_3(_i, _Macro, _Data, _Tuple) \
GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \
GMOCK_PP_INTERNAL_FOR_EACH_IMPL_2(GMOCK_PP_INC(_i), _Macro, _Data, \
(GMOCK_PP_TAIL _Tuple))
#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_4(_i, _Macro, _Data, _Tuple) \
GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \
GMOCK_PP_INTERNAL_FOR_EACH_IMPL_3(GMOCK_PP_INC(_i), _Macro, _Data, \
(GMOCK_PP_TAIL _Tuple))
#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_5(_i, _Macro, _Data, _Tuple) \
GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \
GMOCK_PP_INTERNAL_FOR_EACH_IMPL_4(GMOCK_PP_INC(_i), _Macro, _Data, \
(GMOCK_PP_TAIL _Tuple))
#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_6(_i, _Macro, _Data, _Tuple) \
GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \
GMOCK_PP_INTERNAL_FOR_EACH_IMPL_5(GMOCK_PP_INC(_i), _Macro, _Data, \
(GMOCK_PP_TAIL _Tuple))
#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_7(_i, _Macro, _Data, _Tuple) \
GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \
GMOCK_PP_INTERNAL_FOR_EACH_IMPL_6(GMOCK_PP_INC(_i), _Macro, _Data, \
(GMOCK_PP_TAIL _Tuple))
#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_8(_i, _Macro, _Data, _Tuple) \
GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \
GMOCK_PP_INTERNAL_FOR_EACH_IMPL_7(GMOCK_PP_INC(_i), _Macro, _Data, \
(GMOCK_PP_TAIL _Tuple))
#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_9(_i, _Macro, _Data, _Tuple) \
GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \
GMOCK_PP_INTERNAL_FOR_EACH_IMPL_8(GMOCK_PP_INC(_i), _Macro, _Data, \
(GMOCK_PP_TAIL _Tuple))
#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_10(_i, _Macro, _Data, _Tuple) \
GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \
GMOCK_PP_INTERNAL_FOR_EACH_IMPL_9(GMOCK_PP_INC(_i), _Macro, _Data, \
(GMOCK_PP_TAIL _Tuple))
#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_11(_i, _Macro, _Data, _Tuple) \
GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \
GMOCK_PP_INTERNAL_FOR_EACH_IMPL_10(GMOCK_PP_INC(_i), _Macro, _Data, \
(GMOCK_PP_TAIL _Tuple))
#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_12(_i, _Macro, _Data, _Tuple) \
GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \
GMOCK_PP_INTERNAL_FOR_EACH_IMPL_11(GMOCK_PP_INC(_i), _Macro, _Data, \
(GMOCK_PP_TAIL _Tuple))
#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_13(_i, _Macro, _Data, _Tuple) \
GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \
GMOCK_PP_INTERNAL_FOR_EACH_IMPL_12(GMOCK_PP_INC(_i), _Macro, _Data, \
(GMOCK_PP_TAIL _Tuple))
#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_14(_i, _Macro, _Data, _Tuple) \
GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \
GMOCK_PP_INTERNAL_FOR_EACH_IMPL_13(GMOCK_PP_INC(_i), _Macro, _Data, \
(GMOCK_PP_TAIL _Tuple))
#define GMOCK_PP_INTERNAL_FOR_EACH_IMPL_15(_i, _Macro, _Data, _Tuple) \
GMOCK_PP_INTERNAL_CALL_MACRO(_Macro, _i, _Data, GMOCK_PP_HEAD _Tuple) \
GMOCK_PP_INTERNAL_FOR_EACH_IMPL_14(GMOCK_PP_INC(_i), _Macro, _Data, \
(GMOCK_PP_TAIL _Tuple))
#endif // THIRD_PARTY_GOOGLETEST_GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PP_H_
googlemock/src/gmock-cardinalities.cc
View file @
25905b9f
...
@@ -70,18 +70,18 @@ class BetweenCardinalityImpl : public CardinalityInterface {
...
@@ -70,18 +70,18 @@ class BetweenCardinalityImpl : public CardinalityInterface {
// Conservative estimate on the lower/upper bound of the number of
// Conservative estimate on the lower/upper bound of the number of
// calls allowed.
// calls allowed.
virtual
int
ConservativeLowerBound
()
const
{
return
min_
;
}
int
ConservativeLowerBound
()
const
override
{
return
min_
;
}
virtual
int
ConservativeUpperBound
()
const
{
return
max_
;
}
int
ConservativeUpperBound
()
const
override
{
return
max_
;
}
virtual
bool
IsSatisfiedByCallCount
(
int
call_count
)
const
{
bool
IsSatisfiedByCallCount
(
int
call_count
)
const
override
{
return
min_
<=
call_count
&&
call_count
<=
max_
;
return
min_
<=
call_count
&&
call_count
<=
max_
;
}
}
virtual
bool
IsSaturatedByCallCount
(
int
call_count
)
const
{
bool
IsSaturatedByCallCount
(
int
call_count
)
const
override
{
return
call_count
>=
max_
;
return
call_count
>=
max_
;
}
}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
;
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
override
;
private:
private:
const
int
min_
;
const
int
min_
;
...
...
googlemock/src/gmock-internal-utils.cc
View file @
25905b9f
...
@@ -93,8 +93,8 @@ GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name) {
...
@@ -93,8 +93,8 @@ GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name) {
// use Google Mock with a testing framework other than Google Test.
// use Google Mock with a testing framework other than Google Test.
class
GoogleTestFailureReporter
:
public
FailureReporterInterface
{
class
GoogleTestFailureReporter
:
public
FailureReporterInterface
{
public:
public:
virtual
void
ReportFailure
(
FailureType
type
,
const
char
*
file
,
int
line
,
void
ReportFailure
(
FailureType
type
,
const
char
*
file
,
int
line
,
const
std
::
string
&
message
)
{
const
std
::
string
&
message
)
override
{
AssertHelper
(
type
==
kFatal
?
AssertHelper
(
type
==
kFatal
?
TestPartResult
::
kFatalFailure
:
TestPartResult
::
kFatalFailure
:
TestPartResult
::
kNonFatalFailure
,
TestPartResult
::
kNonFatalFailure
,
...
...
googlemock/src/gmock-matchers.cc
View file @
25905b9f
...
@@ -42,116 +42,6 @@
...
@@ -42,116 +42,6 @@
#include <string>
#include <string>
namespace
testing
{
namespace
testing
{
// Constructs a matcher that matches a const std::string& whose value is
// equal to s.
Matcher
<
const
std
::
string
&>::
Matcher
(
const
std
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
#if GTEST_HAS_GLOBAL_STRING
// Constructs a matcher that matches a const std::string& whose value is
// equal to s.
Matcher
<
const
std
::
string
&>::
Matcher
(
const
::
string
&
s
)
{
*
this
=
Eq
(
static_cast
<
std
::
string
>
(
s
));
}
#endif // GTEST_HAS_GLOBAL_STRING
// Constructs a matcher that matches a const std::string& whose value is
// equal to s.
Matcher
<
const
std
::
string
&>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
std
::
string
(
s
));
}
// Constructs a matcher that matches a std::string whose value is equal to
// s.
Matcher
<
std
::
string
>::
Matcher
(
const
std
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
#if GTEST_HAS_GLOBAL_STRING
// Constructs a matcher that matches a std::string whose value is equal to
// s.
Matcher
<
std
::
string
>::
Matcher
(
const
::
string
&
s
)
{
*
this
=
Eq
(
static_cast
<
std
::
string
>
(
s
));
}
#endif // GTEST_HAS_GLOBAL_STRING
// Constructs a matcher that matches a std::string whose value is equal to
// s.
Matcher
<
std
::
string
>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
std
::
string
(
s
));
}
#if GTEST_HAS_GLOBAL_STRING
// Constructs a matcher that matches a const ::string& whose value is
// equal to s.
Matcher
<
const
::
string
&>::
Matcher
(
const
std
::
string
&
s
)
{
*
this
=
Eq
(
static_cast
<::
string
>
(
s
));
}
// Constructs a matcher that matches a const ::string& whose value is
// equal to s.
Matcher
<
const
::
string
&>::
Matcher
(
const
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
// Constructs a matcher that matches a const ::string& whose value is
// equal to s.
Matcher
<
const
::
string
&>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
::
string
(
s
));
}
// Constructs a matcher that matches a ::string whose value is equal to s.
Matcher
<::
string
>::
Matcher
(
const
std
::
string
&
s
)
{
*
this
=
Eq
(
static_cast
<::
string
>
(
s
));
}
// Constructs a matcher that matches a ::string whose value is equal to s.
Matcher
<::
string
>::
Matcher
(
const
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
// Constructs a matcher that matches a string whose value is equal to s.
Matcher
<::
string
>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
::
string
(
s
));
}
#endif // GTEST_HAS_GLOBAL_STRING
#if GTEST_HAS_ABSL
// Constructs a matcher that matches a const absl::string_view& whose value is
// equal to s.
Matcher
<
const
absl
::
string_view
&>::
Matcher
(
const
std
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
#if GTEST_HAS_GLOBAL_STRING
// Constructs a matcher that matches a const absl::string_view& whose value is
// equal to s.
Matcher
<
const
absl
::
string_view
&>::
Matcher
(
const
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
#endif // GTEST_HAS_GLOBAL_STRING
// Constructs a matcher that matches a const absl::string_view& whose value is
// equal to s.
Matcher
<
const
absl
::
string_view
&>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
std
::
string
(
s
));
}
// Constructs a matcher that matches a const absl::string_view& whose value is
// equal to s.
Matcher
<
const
absl
::
string_view
&>::
Matcher
(
absl
::
string_view
s
)
{
*
this
=
Eq
(
std
::
string
(
s
));
}
// Constructs a matcher that matches a absl::string_view whose value is equal to
// s.
Matcher
<
absl
::
string_view
>::
Matcher
(
const
std
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
#if GTEST_HAS_GLOBAL_STRING
// Constructs a matcher that matches a absl::string_view whose value is equal to
// s.
Matcher
<
absl
::
string_view
>::
Matcher
(
const
::
string
&
s
)
{
*
this
=
Eq
(
s
);
}
#endif // GTEST_HAS_GLOBAL_STRING
// Constructs a matcher that matches a absl::string_view whose value is equal to
// s.
Matcher
<
absl
::
string_view
>::
Matcher
(
const
char
*
s
)
{
*
this
=
Eq
(
std
::
string
(
s
));
}
// Constructs a matcher that matches a absl::string_view whose value is equal to
// s.
Matcher
<
absl
::
string_view
>::
Matcher
(
absl
::
string_view
s
)
{
*
this
=
Eq
(
std
::
string
(
s
));
}
#endif // GTEST_HAS_ABSL
namespace
internal
{
namespace
internal
{
// Returns the description for a matcher defined using the MATCHER*()
// Returns the description for a matcher defined using the MATCHER*()
...
...
googlemock/src/gmock-spec-builders.cc
View file @
25905b9f
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
#include <stdlib.h>
#include <stdlib.h>
#include <iostream> // NOLINT
#include <iostream> // NOLINT
#include <map>
#include <map>
#include <memory>
#include <set>
#include <set>
#include <string>
#include <string>
#include <vector>
#include <vector>
...
@@ -49,9 +50,9 @@
...
@@ -49,9 +50,9 @@
#endif
#endif
// Silence C4800 (C4800: 'int *const ': forcing value
// Silence C4800 (C4800: 'int *const ': forcing value
// to bool 'true' or 'false') for MSVC
14,
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
...
@@ -757,6 +758,19 @@ bool Mock::VerifyAndClearExpectationsLocked(void* mock_obj)
...
@@ -757,6 +758,19 @@ bool Mock::VerifyAndClearExpectationsLocked(void* mock_obj)
return
expectations_met
;
return
expectations_met
;
}
}
bool
Mock
::
IsNaggy
(
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
)
{
return
Mock
::
GetReactionOnUninterestingCalls
(
mock_obj
)
==
internal
::
kWarn
;
}
bool
Mock
::
IsNice
(
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
)
{
return
Mock
::
GetReactionOnUninterestingCalls
(
mock_obj
)
==
internal
::
kAllow
;
}
bool
Mock
::
IsStrict
(
void
*
mock_obj
)
GTEST_LOCK_EXCLUDED_
(
internal
::
g_gmock_mutex
)
{
return
Mock
::
GetReactionOnUninterestingCalls
(
mock_obj
)
==
internal
::
kFail
;
}
// Registers a mock object and a mock method it owns.
// Registers a mock object and a mock method it owns.
void
Mock
::
Register
(
const
void
*
mock_obj
,
void
Mock
::
Register
(
const
void
*
mock_obj
,
internal
::
UntypedFunctionMockerBase
*
mocker
)
internal
::
UntypedFunctionMockerBase
*
mocker
)
...
@@ -835,7 +849,7 @@ void Mock::ClearDefaultActionsLocked(void* mock_obj)
...
@@ -835,7 +849,7 @@ void Mock::ClearDefaultActionsLocked(void* mock_obj)
Expectation
::
Expectation
()
{}
Expectation
::
Expectation
()
{}
Expectation
::
Expectation
(
Expectation
::
Expectation
(
const
internal
::
link
ed_ptr
<
internal
::
ExpectationBase
>&
an_expectation_base
)
const
std
::
shar
ed_ptr
<
internal
::
ExpectationBase
>&
an_expectation_base
)
:
expectation_base_
(
an_expectation_base
)
{}
:
expectation_base_
(
an_expectation_base
)
{}
Expectation
::~
Expectation
()
{}
Expectation
::~
Expectation
()
{}
...
@@ -853,7 +867,7 @@ void Sequence::AddExpectation(const Expectation& expectation) const {
...
@@ -853,7 +867,7 @@ void Sequence::AddExpectation(const Expectation& expectation) const {
// Creates the implicit sequence if there isn't one.
// Creates the implicit sequence if there isn't one.
InSequence
::
InSequence
()
{
InSequence
::
InSequence
()
{
if
(
internal
::
g_gmock_implicit_sequence
.
get
()
==
NULL
)
{
if
(
internal
::
g_gmock_implicit_sequence
.
get
()
==
nullptr
)
{
internal
::
g_gmock_implicit_sequence
.
set
(
new
Sequence
);
internal
::
g_gmock_implicit_sequence
.
set
(
new
Sequence
);
sequence_created_
=
true
;
sequence_created_
=
true
;
}
else
{
}
else
{
...
@@ -866,14 +880,14 @@ InSequence::InSequence() {
...
@@ -866,14 +880,14 @@ InSequence::InSequence() {
InSequence
::~
InSequence
()
{
InSequence
::~
InSequence
()
{
if
(
sequence_created_
)
{
if
(
sequence_created_
)
{
delete
internal
::
g_gmock_implicit_sequence
.
get
();
delete
internal
::
g_gmock_implicit_sequence
.
get
();
internal
::
g_gmock_implicit_sequence
.
set
(
NULL
);
internal
::
g_gmock_implicit_sequence
.
set
(
nullptr
);
}
}
}
}
}
// namespace testing
}
// namespace testing
#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_main.cc
View file @
25905b9f
...
@@ -32,6 +32,22 @@
...
@@ -32,6 +32,22 @@
#include "gmock/gmock.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#ifdef ARDUINO
void
setup
()
{
// Since Arduino doesn't have a command line, fake out the argc/argv arguments
int
argc
=
1
;
const
auto
arg0
=
"PlatformIO"
;
char
*
argv0
=
const_cast
<
char
*>
(
arg0
);
char
**
argv
=
&
argv0
;
// Since Google Mock depends on Google Test, InitGoogleMock() is
// also responsible for initializing Google Test. Therefore there's
// no need for calling testing::InitGoogleTest() separately.
testing
::
InitGoogleMock
(
&
argc
,
argv
);
}
void
loop
()
{
RUN_ALL_TESTS
();
}
#else
// MS C++ compiler/linker has a bug on Windows (not on Windows CE), which
// MS C++ compiler/linker has a bug on Windows (not on Windows CE), which
// causes a link error when _tmain is defined in a static library and UNICODE
// causes a link error when _tmain is defined in a static library and UNICODE
// is enabled. For this reason instead of _tmain, main function is used on
// is enabled. For this reason instead of _tmain, main function is used on
...
@@ -52,3 +68,4 @@ GTEST_API_ int main(int argc, char** argv) {
...
@@ -52,3 +68,4 @@ GTEST_API_ int main(int argc, char** argv) {
testing
::
InitGoogleMock
(
&
argc
,
argv
);
testing
::
InitGoogleMock
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
return
RUN_ALL_TESTS
();
}
}
#endif
Prev
1
2
3
4
5
6
…
8
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