summaryrefslogtreecommitdiffstats
path: root/googlemock/test/gmock-actions_test.cc
Commit message (Collapse)AuthorAgeFilesLines
* Use GTEST_INTERNAL_CPLUSPLUS_LANG instead of __cplusplusDino Radakovic2023-04-281-1/+3
| | | | | | | | Some versions of MSVC provide incorrect values for the latter and rely on _MSVC_LANG instead. Fixes #4226. PiperOrigin-RevId: 527919195 Change-Id: Ifcca4612074f5ebc5337094426866a187f79f90a
* Use '=default' to define trivial constructor/destructorsrefs/pull/4221/headTom Hughes2023-04-211-1/+1
| | | | | | | https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-equals-default.html PiperOrigin-RevId: 526079054 Change-Id: Ia4db21e3e5f58b90de05d52fd94b291ed06d785d
* Add missing std includesTom Hughes2023-04-201-0/+3
| | | | | PiperOrigin-RevId: 525850646 Change-Id: I64387f5b933beb79cd05636dca81b7a75213383e
* Introduce std::make_unique and bool literals where possibleAbseil Team2023-03-201-9/+5
| | | | | PiperOrigin-RevId: 517910526 Change-Id: I398704f4b2ca0a55c86a06ca8b47d34c8670ddd7
* Use "#ifdef GTEST_OS_..." instead of "#if GTEST_OS_..."Tom Hughes2023-03-061-1/+1
| | | | | | | This is compatible with compiling with "-Wundef" (#3267). PiperOrigin-RevId: 513943378 Change-Id: I47cf5fabbb77be061c4483a0adc54511af6b191c
* Use GTEST_DISABLE_MSC_WARNINGS macros to disable warningsTom Hughes2023-01-301-13/+14
| | | | | | | | | Prior to this change we had a mixture of pragmas and GTEST_DISABLE_MSC_WARNINGS; this change consolidates all instances to use the macros. PiperOrigin-RevId: 505786926 Change-Id: I2be8f6304387393995081af42ed32c2ad1bba5a7
* Fix formatting of C++ filesTom Hughes2023-01-241-2/+2
| | | | | PiperOrigin-RevId: 504325204 Change-Id: Iaa1d6d0ab1dccaaeef26f9cb109d530835499240
* Fix -Wshadow warningsTom Hughes2023-01-121-2/+2
| | | | | | | | | | | | | | | | | | | | ../googlemock/test/gmock-actions_test.cc:687:36: warning: declaration of ‘v’ shadows a member of ‘testing::{anonymous}::ReturnTest_SupportsReferenceLikeReturnType_Test::TestBody()::Result’ [-Wshadow] 687 | Result(const std::vector<int>& v) : v(&v) {} // NOLINT | ~~~~~~~~~~~~~~~~~~~~~~~~^ ../googlemock/test/gmock-actions_test.cc:686:29: note: shadowed declaration is here 686 | const std::vector<int>* v; | ^ ../googlemock/test/gmock-actions_test.cc: In constructor ‘testing::{anonymous}::ReturnTest_PrefersConversionOperator_Test::TestBody()::Out::Out(int)’: ../googlemock/test/gmock-actions_test.cc:720:28: warning: declaration of ‘x’ shadows a member of ‘testing::{anonymous}::ReturnTest_PrefersConversionOperator_Test::TestBody()::Out’ [-Wshadow] 720 | explicit Out(const int x) : x(x) {} | ~~~~~~~~~~^ ../googlemock/test/gmock-actions_test.cc:718:9: note: shadowed declaration is here 718 | int x; | ^ PiperOrigin-RevId: 501580618 Change-Id: I584710fbbe440ec724f88746e51f3be5653c32d5
* fix: some typos in commentyutotnh2022-07-011-2/+2
|
* gmock-actions: properly support non-moveable results in `is_callable_r`.Aaron Jacobs2022-05-271-1/+29
| | | | | | | | | | | | | | | Previously this excluded callables that return non-moveable types. This is the same as the [libc++ std::is_invocable_r bug](https://github.com/llvm/llvm-project/issues/55346) fixed by [this commit](https://github.com/llvm/llvm-project/commit/c3a24882903d): it's wrong to use std::is_convertible for checking the return type, since (despite its name) that doesn't check the standard-defined notion of "implicitly convertible". Instead we must base the check on whether the source type can be used as an argument to a function that accepts the destination type. PiperOrigin-RevId: 451341205 Change-Id: I2530051312a0361ea7a2ce26993ae973c9242089
* gmock-actions: add support for move-only values to Return.Aaron Jacobs2022-05-131-18/+38
| | | | | | | | `Return(x)` can now be used directly with `WillOnce` (the only place it makes sense in the type system), without using `ByMove`. PiperOrigin-RevId: 448380066 Change-Id: Ia71cc60ccbc3b99720662731a2d309735a5ce7c8
* gmock-actions: provide a const reference when converting in ReturnAction.Aaron Jacobs2022-05-121-15/+52
| | | | | | | | It doesn't make semantic sense for the conversion to modify the input, and the fact that it's allowed to do so appears to have just been a historical accident. PiperOrigin-RevId: 448135555 Change-Id: Id10f17af38cf3947ee25fe10654d97527173ebfc
* gmock-actions: simplify Return and add better documentation.Aaron Jacobs2022-05-111-17/+28
| | | | | | | | | | Better document requirements, API decisions, and historical accidents. Make an implicit conversion easier and in a more appropriate place, and ease the burden of some assertions in the conversion operator. Stop using the legacy ActionInterface style for defining the action. PiperOrigin-RevId: 447894892 Change-Id: I179e23ec2abdd9bf05c204ab18dbb492f1372e8e
* gmock-actions: make OnceAction public.Aaron Jacobs2022-05-111-1/+1
| | | | | | | | So that it can be referenced in conversion operators for actions that need to know the concrete return type. PiperOrigin-RevId: 447889344 Change-Id: I643d3298bc8effd08741282a956c221f9d67d378
* gmock-actions: improve comments and tests for the implicit cast in Return.Aaron Jacobs2022-04-271-0/+31
| | | | | | | | | | Commit a070cbd91c added an implicit cast to this path but didn't leave a very clear explanation for why it was desirable, a clear example, or even test coverage. Add a better comment and a test that fails when the implicit cast is removed. PiperOrigin-RevId: 444871311 Change-Id: I127982fa8d5bce9b6d1b68177c12dc0709449164
* Support move-only and &&-qualified actions in WithArgs.Aaron Jacobs2022-04-261-2/+23
| | | | | PiperOrigin-RevId: 444671005 Change-Id: I7df5f038caf17afb60d4fb35434ff0b656d4c954
* Support move-only and &&-qualified actions in DoAll.Aaron Jacobs2022-04-261-7/+99
| | | | | | | | This is necessary for generic support of these actions, since `DoAll` is a frequently-used action wrapper. PiperOrigin-RevId: 444561964 Change-Id: I02edb55e35ab4207fbd71e371255a319c8253136
* Remove the legacy internal GTEST_DISALLOW_* macrosDerek Mauro2022-04-221-1/+2
| | | | | PiperOrigin-RevId: 443715444 Change-Id: I3ffd54b63d2728ae4a668ee7875c8c3c8188087c
* Document two surprises in `DoAllAction::NonFinalType`.Aaron Jacobs2022-04-131-0/+83
| | | | | PiperOrigin-RevId: 441589196 Change-Id: Ic3e483ca70d72261046bad464d817f9dfd4bec65
* Add support for move-only and &&-qualified actions in WillOnce.Abseil Team2022-04-091-28/+310
| | | | | | | | | | | | This provides a type-safe way for an action to express that it wants to be called only once, or to capture move-only objects. It is a generalization of the type system-evading hack in ByMove, with the improvement that it works for _any_ action (including user-defined ones), and correctly expresses that the action can only be used with WillOnce. I'll make existing actions benefit in a future commit. PiperOrigin-RevId: 440496139 Change-Id: I4145d191cca5655995ef41360bb126c123cb41d3
* Running clang-format over all of GoogleTestAbseil Team2022-03-151-95/+73
| | | | | | | | | | | | | | | | A few tests are examining code locations and looking af the resulting line numbers to verify that GoogleTest shows those to users correctly. Some of those locations change when clang-format is run. For those locations, I've wrapped portions in: // clang-format off ... // clang-format on There may be other locations that are currently not tickled by running clang-format. PiperOrigin-RevId: 434844712 Change-Id: I3a9f0a6f39eff741c576b6de389bef9b1d11139d
* fix: typo codespelling commentrefs/pull/3499/headslowy072021-07-241-1/+1
|
* chore: fix spellingrefs/pull/3364/headJohn Bampton2021-04-151-1/+1
|
* Googletest exportdurandal2020-05-281-3/+5
| | | | | | Silence MSVC C4100 (unused formal parameter) to fix breakage from recently added testcase. This warning is silenced in many files throughout googletest, but was not needed here until this testcase was added. PiperOrigin-RevId: 312121200
* Googletest exportAbseil Team2020-05-281-0/+20
| | | | | | | | Fix the ACTION* macros to allow for more than 10 arguments in the action. Only the first 10 will be passed as individual arguments as `argN`, but the rest can be accessed from the `args` tuple. PiperOrigin-RevId: 311542098
* Merge pull request #2815 from Quuxplusone:simpleGennadiy Rozental2020-05-011-2/+0
|\ | | | | | | PiperOrigin-RevId: 308625388
| * Remove all uses of GTEST_DISALLOW_{MOVE_,}ASSIGN_.Arthur O'Dwyer2020-04-241-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | None of these are strictly needed for correctness. A large number of them (maybe all of them?) trigger `-Wdeprecated` warnings on Clang trunk as soon as you try to use the implicitly defaulted (but deprecated) copy constructor of a class that has deleted its copy assignment operator. By declaring a deleted copy assignment operator, the old code also caused the move constructor and move assignment operator to be non-declared. This means that the old code never got move semantics -- "move-construction" would simply call the defaulted (but deprecated) copy constructor instead. With the new code, "move-construction" calls the defaulted move constructor, which I believe is what we want to happen. So this is a runtime performance optimization. Unfortunately we can't yet physically remove the definitions of these macros from gtest-port.h, because they are being used by other code internally at Google (according to zhangxy988). But no new uses should be added going forward.
* | Googletest exportAbseil Team2020-05-011-27/+72
|/ | | | | | Rewrite ReturnNew action without using pump. PiperOrigin-RevId: 308219616
* Googletest exportAbseil Team2020-02-281-2/+13
| | | | | | | | 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
* Googletest exportAbseil Team2019-11-221-6/+6
| | | | | | | | | | | | | 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
* Merge pull request #2527 from ↵vslashg2019-10-291-0/+36
|\ | | | | | | | | | | PiotrNycz:gmock_prevent_return_ref_to_store_temporaries_2 PiperOrigin-RevId: 277061341
| * variable names corrected (followed google coding style)refs/pull/2527/headPiotr Nycz2019-10-251-14/+14
| | | | | | | | Issue 2527
| * Apply 80chars limitPiotr Nycz2019-10-251-1/+2
| | | | | | | | Issue 2527
| * Tests simplified and names corrected (POD->scalar)Piotr Nycz2019-10-241-49/+18
| | | | | | | | Issue 2527
| * Added more tests to verify: ReturnRef not accept temporaryPiotr Nycz2019-10-231-15/+57
| | | | | | | | Issue 2471
| * Added tests verifying that temporaries are accepted by ReturnRefPiotr Nycz2019-10-221-0/+24
| | | | | | | | Issue no 2527
* | Googletest exportAbseil Team2019-10-231-0/+26
|/ | | | | | 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
* Googletest exportAbseil Team2019-08-151-8/+0
| | | | | | | | | | | | | Remove legacy support for signed wchar_t and unsigned wchar_t. Clang now errors out on these types as well by default. Rather than making the condition for these types even more complicated, just remove the tests covering these types since they don't seem to justify the maintenance burden. We can reasonably expect these types to work in compilers that support them without needing specific tests for them since they are treated as standard integral types. PiperOrigin-RevId: 263577673
* Googletest exportAbseil Team2019-04-011-8/+0
| | | | | | | | Remove support for "global" ::string and ::wstring types. This support existed for legacy codebases that existed from before namespaces where a thing. It is no longer necessary. PiperOrigin-RevId: 241335738
* Googletest exportAbseil Team2019-01-171-1/+2
| | | | | | | | | Refactor the `Invoke` and `InvokeWithoutArgs` actions: - Replace pump'd classes and functions with templates. - Make the polymorphic actions be polymorphic functors instead. - Fix Invoke(Callback*) to work with subclasses of the callbacks, instead of trying to diagnose that in gmock_doctor. PiperOrigin-RevId: 229604112
* Googletest exportAbseil Team2019-01-141-5/+3
| | | | | | | Deduplicate testing::ReferenceWrapper with std::reference_wrapper. Minor cleanups in matchers_test. PiperOrigin-RevId: 229022872
* Googletest exportmisterg2019-01-021-4/+0
| | | | | | Internal Change PiperOrigin-RevId: 227575279
* Googletest exportAbseil Team2019-01-021-10/+0
| | | | | | | | Remove the #ifs for old, unsupported and buggy compilers: * old versions of GCC & MSVC * Symbian PiperOrigin-RevId: 227116941
* Googletest exportAbseil Team2018-12-201-12/+0
| | | | | | Unifdef c++11-related macros from googletest now that it requires C++11. PiperOrigin-RevId: 225905601
* Googletest exportAbseil Team2018-12-031-5/+5
| | | | | | Applied fixes for ClangTidy modernize-use-override and modernize-use-using. PiperOrigin-RevId: 223800219
* Googletest exportmisterg2018-11-201-2/+2
| | | | | | Fix broken OSS build PiperOrigin-RevId: 222244158
* Googletest exportAbseil Team2018-11-201-2/+0
| | | | | | Remove redundant Base/Derived types. PiperOrigin-RevId: 222243634
* Googletest exportAbseil Team2018-11-201-0/+118
| | | | | | Upgrade WithArgs family of actions to C++11. PiperOrigin-RevId: 221671690
* Remove workarounds for unsupported MSVC versionsRobin Lindén2018-11-101-2/+2
|
* Unconditionally use std::tuple.Abseil Team2018-10-091-91/+91
| | | | | | Remove all mention of TR1 tuple and our own implementation of tuple. PiperOrigin-RevId: 216395043