Commit Graph

252 Commits

Author SHA1 Message Date
Xiaoyi Zhang
67cc66080d Merge pull request #2350 from adambadura:MockFunctionFromStdFunction
PiperOrigin-RevId: 302677275
2020-03-24 17:32:16 -04:00
Adam Badura
53740ebc21 Add support for std::function in MockFunction (#2277) 2020-03-18 01:11:30 +01:00
Abseil Team
909b1ccfca Googletest export
Relax the implementation of MatcherCast to allow conversion of `Matcher<T>` to
`Matcher<const T&>`. They have the same match signature.

PiperOrigin-RevId: 297115843
2020-02-28 16:41:01 -05:00
Abseil Team
fd538161f4 Googletest export
Allow construction of an Action from a callable of zero args

Action already allows construction from a callable with the same args as the mocked function, without needing to wrap the callable in Invoke. However, if you don't care about the arguments to the mocked function you need to either accept all of them or wrap your callable in InvokeWithoutArgs. This change makes both of those unnecessary, since it allows you to pass a no-args callable to Action directly.

PiperOrigin-RevId: 296117034
2020-02-28 16:40:53 -05:00
Abseil Team
6f5fd0d719 Googletest export
Add gmock Matcher<std::string_view> specialization.

PiperOrigin-RevId: 294443240
2020-02-11 15:50:26 -05:00
Abseil Team
41b5f149ab Googletest export
Get rid of gmock-generated-matchers.h and gmock-generated-matchers.h.pump.

Stop using pump for MATCHER* macroses generation.

PiperOrigin-RevId: 293878808
2020-02-07 18:20:45 -05:00
durandal
2d6d7a01c9 Googletest export
Tag the function generated by MATCHER with GTEST_ATTRIBUTE_UNUSED_ to fix CI builds of gmock-matchers_test.cc vs. -Wunused-function.

See https://github.com/google/googletest/pull/2697 for breakage.

PiperOrigin-RevId: 293669752
2020-02-07 13:35:36 -05:00
Abseil Team
fbf67a70d0 Googletest export
Get rid of gmock-generated-function-mockers.h and
gmock-generated-function-mockers.h.pump.

Stop using pump for GMOCK_METHOD* macroses generation.

PiperOrigin-RevId: 293454519
2020-02-07 13:35:27 -05:00
Abseil Team
d02e277275 Googletest export
Pass method's parameters count to internal GMOCK_METHOD* macro.

This will help removing copypaste in every GMOCK_METHOD* macro in future.

PiperOrigin-RevId: 292932554
2020-02-07 13:35:10 -05:00
Abseil Team
4f6609129a Googletest export
Fix std::move to std::forward where appropriate to support reference types.

PiperOrigin-RevId: 292923058
2020-02-07 13:35:00 -05:00
Abseil Team
572e261b60 Googletest export
Fix use of reserved names.
Minimize code duplication needed for explict-vs-nonexplicit constructor.

PiperOrigin-RevId: 292555014
2020-02-07 13:34:42 -05:00
Abseil Team
38f6608e87 Googletest export
Add includes for type_traits and utility to gmock-function-mocker.h: macros in the file require these headers.

PiperOrigin-RevId: 291782497
2020-02-07 13:34:26 -05:00
Abseil Team
d6ce39edf6 Googletest export
Create implementation macroses for matchers to move variadic parameters to the
end of parameters list.

To save backward compatibility, old macroses will be still taking `description`
parameter as the last one. But they will use INTERNAL macro that takes
`description` as the second parameter.

PiperOrigin-RevId: 291724469
2020-02-07 13:34:18 -05:00
Abseil Team
87061810f4 Googletest export
Move part of functionality of Matcher* class to the base one. Reduce copypaste.

Make constructor and conversion operator of Matcher* class independent of pump.

PiperOrigin-RevId: 291405510
2020-02-07 13:34:03 -05:00
Abseil Team
22397f28ef Googletest export
Add missing explicit keyword for gmock_Impl constructor.

When switching to using GMOCK_PP in ACTION* macroses `explicit` keyword was
missed in gmock_Impl constructor causing ClangTidy warnings in ACTION_P macro.

PiperOrigin-RevId: 291159975
2020-02-07 13:33:47 -05:00
Abseil Team
d01e356e15 Googletest export
Allow copying of the string in MatchAndExplain.

Otherwise, conversions from std::string_view to std::string will fail as being
explicit

PiperOrigin-RevId: 290301103
2020-01-21 16:26:33 -05:00
Abseil Team
5336106b66 Googletest export
Use GMOCK_PP to create GMOCK_INTERNAL_ACTION macro.

Create GMOCK_INTERNAL_ACTION macro that generates ACTION_P* macroses using
GMOCK_PP.

PiperOrigin-RevId: 289815906
2020-01-16 13:56:12 -05:00
Abseil Team
7a8591e6e4 Googletest export
Use GMOCK_PP to generate args boilerplate.

Move common args describing part to separate macroses that uses GMOCK_PP to
generate sequences.

PiperOrigin-RevId: 289655624
2020-01-16 13:55:54 -05:00
Abseil Team
c901f67ddf Googletest export
Move part of functionality of Action* class to the base one. Reduce copypaste.

Make constructor and conversion operator of Action* class independent of pump.

PiperOrigin-RevId: 288907005
2020-01-09 18:25:24 -05:00
Abseil Team
4b9c1691c4 Googletest export
Use C++11 variadic templates for Invoke in gmock-generated-actions.h.

Replace InvokeArgumentAdl with Invoke that uses C++11 variadic templates.

PiperOrigin-RevId: 288449236
2020-01-09 18:25:08 -05:00
Abseil Team
306f3754a7 Googletest export
Explicitly default copy constructor in BoundSecondMatcher

Since C++11, implicit defaulting of copy constructors is deprecated for types
with user-defined copy assignment operators, so we should explicitly default the
copy constructor of BoundSecondMatcher.

PiperOrigin-RevId: 287587847
2020-01-02 16:49:38 -05:00
Abseil Team
d0a521255e Googletest export
Use C++11 variadic templates for InvokeArgumentAdl in gmock-generated-actions.h.

Make InvokeArgumentAdl use variadic templates to generate its overloads instead
of using pump.py syntax.

PiperOrigin-RevId: 286267615
2020-01-02 16:48:42 -05:00
Abseil Team
6f1a8ffde9 Googletest export
Use C++11 variadic templates for InvokeArgumentAdl in gmock-generated-actions.h.

Make InvokeArgumentAdl use variadic templates to generate its overloads instead
of using pump.py syntax.

PiperOrigin-RevId: 286148805
2020-01-02 16:48:34 -05:00
Abseil Team
d8eeb9760a Googletest export
Use C++11 variadic templates for ActionHelper in gmock-generated-actions.h.

Make ActionHelper use variadic templates to generate Perform static member function specializations instead of using pump.py syntax.

PiperOrigin-RevId: 284988441
2019-12-13 12:57:53 -05:00
Matt Calabrese
88ba008c23 Merge pull request #2595 from kuzkry:remove-workaround_msvc-warning-4355
PiperOrigin-RevId: 284234675
2019-12-13 12:57:35 -05:00
Mark Barolak
1d563578c8 Merge pull request #2594 from kuzkry:remove-workaround_msvc-unneeded-const-dropping
PiperOrigin-RevId: 283979494
2019-12-05 14:41:50 -05:00
Gennadiy Rozental
b155875f32 Merge pull request #2583 from ChristophStrehle:master
PiperOrigin-RevId: 282817206
2019-11-27 16:20:38 -05:00
Gennadiy Rozental
db13ff1f0b Merge pull request #2597 from kuzkry:remove-workaround_Nokia-Sybian-SafeMatcherCastImpl
PiperOrigin-RevId: 282581402
2019-11-26 15:47:21 -05:00
Abseil Team
717ce7feb8 Googletest export
Use standard C++11 integer types in gtest-port.h.

Remove testing::internal::{Int,Uint}{32,64} in favor of types
guaranteed to be in <cstdint> since C++11.

Tests for built-in integer type coverage are switched from
{Int,Uint}64 to [unsigned] long long, which is guaranteed by
C++11 to exist and be at least 64-bit wide.

PiperOrigin-RevId: 281565263
2019-11-22 16:33:15 -05:00
Krystian Kuzniarek
bbbc5d8a4b remove Nokia's Symbian compiler workaround: SafeMatcherCastImpl 2019-11-22 17:25:34 +01:00
Krystian Kuzniarek
e0c80b0a6e consistency fix for SafeMatcherCastImpl member functions 2019-11-22 17:25:34 +01:00
Krystian Kuzniarek
6748df1eab remove MSVC workaround: cease const dropping 2019-11-22 17:17:41 +01:00
Krystian Kuzniarek
ecefcbd4aa remove MSVC workaround: warning 4355 2019-11-22 17:15:23 +01:00
Christoph Strehle
6a9d6d5c28 Fix compile break for Microsoft Visual Studio 2017 v141
This is a workaround, for those who have to compile with v141 build tools,
for a bug in msvc that the compiler can't compile the WithArgsAction.

see the following link for more details:
https://developercommunityapi.westus.cloudapp.azure.com/content/problem/420339/googlemocks-withargs-doesnt-compile-with-permissiv.html
2019-11-21 14:58:09 +01:00
Abseil Team
50cfbb726b Googletest export
Update stale comments to point to proper location.

PiperOrigin-RevId: 281157036
2019-11-19 11:25:59 -05:00
Krystian Kuzniarek
f658561ef2 fix a typo 2019-11-02 01:18:21 +01:00
vslashg
057ee5063d Merge pull request #2533 from thejcannon:noexcept_spec
PiperOrigin-RevId: 277924721
2019-11-01 16:02:05 -04:00
Abseil Team
2db3df9c4f Googletest export
Change variable name to match comment.

PiperOrigin-RevId: 277713621
2019-10-31 15:11:41 -04:00
Abseil Team
e2fc3a9c9c Googletest export
Tolerate std::string's explicit copy construction from std::string_view.

PiperOrigin-RevId: 277583394
2019-10-31 15:11:31 -04:00
Abseil Team
755f853c6b Googletest export
Avoid temporary matcher instances.
They are unnecessary and can be relatively more expensive than the rest of the
algorithm.

PiperOrigin-RevId: 277084853
2019-10-29 16:51:31 -04:00
vslashg
b5fb5ba05c Merge pull request #2527 from PiotrNycz:gmock_prevent_return_ref_to_store_temporaries_2
PiperOrigin-RevId: 277061341
2019-10-29 16:51:12 -04:00
Abseil Team
37f3227831 Googletest export
Add a matcher `testing::ReturnRoundRobin` which, on each call, returns the next element in the sequence, restarting at the beginning once it has reached the end.

PiperOrigin-RevId: 276312136
2019-10-23 15:54:45 -04:00
Joshua Cannon
676d0444bf Revert "Merge pull request #2498 from thejcannon:noexcept_spec"
This reverts commit ba513d2c95, reversing
changes made to a3ca5b9e0b.
2019-10-23 14:46:46 -05:00
vslashg
8bab7883a6 Merge pull request #2514 from thejcannon:msvc_macro_issue
PiperOrigin-RevId: 276134684
2019-10-23 13:35:26 -04:00
Piotr Nycz
b11fb80e9e Prevent using ReturnRef on reference to temporary
Fixed issue: 2471
2019-10-22 15:58:00 +02:00
Abseil Team
611a321a6e Googletest export
Remove bool_constant in favor of std::integral_constant<bool, ...>;
The one non-trivial use of bool_constant has been changed to have significantly
fewer template specializations.

PiperOrigin-RevId: 275842490
2019-10-22 09:38:12 -04:00
Abseil Team
011c4e23d5 Googletest export
Rolling forward IsNan() matcher with fixes in test for -Wconversion issues. Use
std::nanf and std::nanl where appropriate.
PiperOrigin-RevId: 275523003
2019-10-22 09:37:46 -04:00
misterg
f966ed1581 Googletest export
Added IsNan matcher

PiperOrigin-RevId: 275473218
2019-10-18 11:34:08 -04:00
Abseil Team
1f9edcd969 Googletest export
Addressing https://github.com/google/googletest/issues/2502

Add MOCK_METHOD support for returning function pointers.

PiperOrigin-RevId: 275323671
2019-10-18 11:33:59 -04:00
Abseil Team
bbe4b7363b Googletest export
Added IsNan matcher

PiperOrigin-RevId: 275278634
2019-10-17 13:08:00 -04:00