summaryrefslogtreecommitdiffstats
path: root/googlemock/include
Commit message (Collapse)AuthorAgeFilesLines
...
* gmock-spec-builders: add support for non-moveable types.Aaron Jacobs2022-05-271-189/+103
| | | | | | | | | Do this by ripping out the "untyped perform action" machinery, which isn't necessary: we can simply template the entry point on the result type, and use RAII to avoid the need to special case void. This makes it easier to understand the code and harder to introduce type-related undefined behavior, to boot. PiperOrigin-RevId: 451493451 Change-Id: I225305f83164752ca92f2916721972eafba33168
* gmock-actions: properly support non-moveable results in `is_callable_r`.Aaron Jacobs2022-05-271-3/+50
| | | | | | | | | | | | | | | 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-spec-builders: move a method to the header.Aaron Jacobs2022-05-261-3/+134
| | | | | | | | In order to make the diff more readable in an upcoming commit that requires the method to be templated on the action's result type. PiperOrigin-RevId: 451157029 Change-Id: I57beb7544efccd0459efb3a1f039ea45cd7c7602
* gmock-actions: add support for move-only values to Return.Aaron Jacobs2022-05-131-11/+45
| | | | | | | | `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-32/+15
| | | | | | | | 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-76/+158
| | | | | | | | | | 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-7/+7
| | | | | | | | 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
* Fix example of DescribeMatcher to properly support negation.Abseil Team2022-05-031-1/+2
| | | | | PiperOrigin-RevId: 446259163 Change-Id: I3ad5f405f44fc233f5cf5a18a274a9104b5c4ab8
* gmock-actions: remove a no-longer-necessary friend declaration.Aaron Jacobs2022-05-021-6/+0
| | | | | PiperOrigin-RevId: 445940487 Change-Id: I26952a72327db0d308bbe57ca4d1d91a0d7defc8
* gmock-actions: support ByMove in a specialization of ReturnAction.Aaron Jacobs2022-05-021-25/+34
| | | | | | | | | | | | | Rather than branching on whether the return type is ByMoveWrapper within ReturnAction itself, hoist the distinction to outside. This allows the main class template to be modified without worrying about this special case, which means we can stop using a shared pointer to the value (introduced as a linked_ptr in commit 3d1c78b2bf to support ByMove) in this commit and simplify the class template further in a future commit with the eventual aim of directly supporting move-only result types. PiperOrigin-RevId: 445938943 Change-Id: I7bc71ea301d5e493ac6ecbe57d62738a48a2721a
* gmock-actions: improve comments and tests for the implicit cast in Return.Aaron Jacobs2022-04-271-7/+8
| | | | | | | | | | 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-7/+50
| | | | | PiperOrigin-RevId: 444671005 Change-Id: I7df5f038caf17afb60d4fb35434ff0b656d4c954
* Support move-only and &&-qualified actions in DoAll.Aaron Jacobs2022-04-262-251/+381
| | | | | | | | 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-224-13/+27
| | | | | PiperOrigin-RevId: 443715444 Change-Id: I3ffd54b63d2728ae4a668ee7875c8c3c8188087c
* Eliminate the legacy GTEST_COMPILE_ASSERT_ macroDerek Mauro2022-04-212-26/+23
| | | | | PiperOrigin-RevId: 443462203 Change-Id: I0c43f981663a7531ff5da4d4be01fb3d6762273d
* Document two surprises in `DoAllAction::NonFinalType`.Aaron Jacobs2022-04-131-0/+45
| | | | | PiperOrigin-RevId: 441589196 Change-Id: Ic3e483ca70d72261046bad464d817f9dfd4bec65
* Replace infinite recursion call (intentionally invoking undefined behavior ↵Abseil Team2022-04-131-3/+6
| | | | | | | to indicate unreachability) with explicit unreachability marker. PiperOrigin-RevId: 441474979 Change-Id: I1fcbb437026631212fec954c663482bb7e1cf819
* Add support for move-only and &&-qualified actions in WillOnce.Abseil Team2022-04-092-6/+271
| | | | | | | | | | | | 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
* gmock: improve SFINAE for actions involving arguments.Abseil Team2022-04-042-2/+4
| | | | | | | | Avoid instantiating functions like std::get<index> for an out of range index when doing SFINAE on the invocability of the action itself. PiperOrigin-RevId: 439415110 Change-Id: Ifc20285a6d526c34830870cd1910c2b2b92e1e81
* Use ResultOf()'s result_description when explaining match result.Abseil Team2022-04-041-1/+5
| | | | | PiperOrigin-RevId: 439389646 Change-Id: Ie34adcdd2b24378e85962efac53b7bb89ed93803
* Use the Abseil flags library when Abseil is presentDerek Mauro2022-04-041-20/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | When built with `--define=absl=1` under Bazel, GoogleTest flags use ABSL_FLAG instead of GoogleTest's own implementation. There are some minor behavior differences in this mode. The most notable difference is that unrecognized flags result in a flag parsing error, and are not returned to the user though a modified argc/argv, unless they appear after the positional argument delimiter ("--"). For example, to pass a non-Abseil flag, you would have to do ./mytest --gtest_color=false -- --myflag=myvalue The documentation at https://abseil.io/docs/cpp/guides/flags may be helpful in understanding the behavior. There are some other minor differences. For example, passing --help results in the program returning 1 instead of 0. https://github.com/google/googletest/issues/3646 PiperOrigin-RevId: 439312700 Change-Id: Id696a25f50f24a5b1785c45ca8fa59794f86fd5c
* Running clang-format over all of GoogleTestAbseil Team2022-03-158-506/+576
| | | | | | | | | | | | | | | | 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
* Mark ACTION_Pn()-generated functions as must-use-result, adding ↵Abseil Team2022-03-081-0/+3
| | | | | | | | | | | | | non-compilation tests. This catches when a client creates an action and discards it, thinking that the action has actually been applied to something. This will help people who make the mistake of defining, for example, both `void Use(Foo*, Bar)` and `ACTION_P(Use, bar) { Use(arg, bar); }` for later application to a Foo. With such an overload, a client may then write `Use(bar);`, selecting the Action<> overload and being confused why nothing happens. This also catches when a client defines their own action in terms of an ACTION_P()-generated one, invokes the Action<>'s builder, and then fails to invoke the resulting action, thinking it's operating on the outer action's parameters. PiperOrigin-RevId: 433197479 Change-Id: I98e4389150d01a5e753230113016d9fc38b1d260
* Add a 3-arg overload for ResultOf() matcher that takes a description string ↵Abseil Team2022-02-101-6/+37
| | | | | | | for better error messages. PiperOrigin-RevId: 427598749 Change-Id: I8c7a5d7b2dde017641534f1c7eed8dd56c33e845
* Change `ReturnArg` to use perfect forwarding of arguments (#3733)Dino Radakovic2022-01-261-3/+3
| | | | | PiperOrigin-RevId: 424355706 Change-Id: I618e5574b4b2c56a343905c20d8cc6d2a70cbcd1
* Consistently apply IWYU pragmas across googletest and googlemock headersAbseil Team2022-01-1814-11/+42
| | | | | PiperOrigin-RevId: 422559250 Change-Id: I9f630f2186724950e5e9fbd7093d5264e8bf0a71
* Merge pull request #3725 from bsilver8192:remove-another-disallow-assignCopybara-Service2022-01-111-189/+162
|\ | | | | | | | | PiperOrigin-RevId: 421044680 Change-Id: If585089811f1b67eab6f339125c27174ee5bc290
| * Remove another GTEST_DISALLOW_ASSIGN_ that crept inrefs/pull/3725/headBrian2022-01-061-2/+0
|/ | | | | | They were all removed in #2815, but it looks like this one got added from a Google export which missed the update. See #2815 for reasons why removing this is desirable.
* Include the param names in the generated description of the MATCHER_P matchers.Abseil Team2021-12-272-15/+27
| | | | | PiperOrigin-RevId: 418497526 Change-Id: Ie53c3c0810c10a32cbcb941e3ca1ee8fb1ddd9f9
* Support std::reference_wapper as a smart pointer type in gmockAbseil Team2021-12-031-0/+7
| | | | | PiperOrigin-RevId: 413963503 Change-Id: I33440780bf087698f4e4325399227405885430b3
* Merge pull request #3581 from cclauss:codespelldinord2021-10-052-2/+2
|\ | | | | | | PiperOrigin-RevId: 400792845
| * Fix remaining typos discovered by codespellrefs/pull/3581/headChristian Clauss2021-09-242-2/+2
| |
* | Googletest exportAbseil Team2021-09-281-1/+2
|/ | | | | | | | Ensure `.what()` is printed in `ThrowsMessage(...)` to address https://github.com/google/googletest/issues/3582 Closes #3582 PiperOrigin-RevId: 399462851
* Merge pull request #3195 from Inujel:fix-3194dinord2021-09-231-10/+7
|\ | | | | | | PiperOrigin-RevId: 398271948
| * Using auto instead of container::const_iteratorrefs/pull/3195/headJulien JEMINE2020-12-291-10/+7
| |
* | Internal changeAbseil Team2021-09-231-6/+6
| | | | | | | | PiperOrigin-RevId: 397651677
* | Googletest exportAbseil Team2021-09-153-13/+33
| | | | | | | | | | | | Introduce GMOCK_FLAG_GET and GMOCK_FLAG_SET macros. PiperOrigin-RevId: 396649214
* | Merge pull request #3504 from duianto:patch-1Derek Mauro2021-08-131-1/+1
|\ \ | | | | | | | | | PiperOrigin-RevId: 390486428
| * | Typo, double "the"refs/pull/3504/headduianto2021-07-291-1/+1
| | |
* | | Googletest exportAbseil Team2021-08-131-43/+77
| | | | | | | | | | | | | | | | | | Identify bad specs of the type (const something, ...). PiperOrigin-RevId: 390346843
* | | Googletest exportAbseil Team2021-08-042-0/+49
|/ / | | | | | | | | | | Introduce a new matcher for unescaping Base-64 strings to gmock. PiperOrigin-RevId: 388471904
* | fix: typo codespelling commentrefs/pull/3499/headslowy072021-07-242-2/+2
| |
* | Googletest exportAbseil Team2021-07-2214-28/+0
| | | | | | | | | | | | Delete GOOGLETEST_CM.* tags from C++ code. PiperOrigin-RevId: 386268534
* | Googletest exportAbseil Team2021-07-091-0/+1
| | | | | | | | | | | | Suppress a clang-tidy warning in the MATCHER(name, description) macro. PiperOrigin-RevId: 383587271
* | Googletest exportAbseil Team2021-07-071-0/+36
| | | | | | | | | | | | | | | | Add `Conditional` wrapper to gtest This follows an initial proposal for an 'EqIff` matcher. `Conditional` was considered more precise as an EqIff() matcher may suffer from `Iff` not being universally understood. PiperOrigin-RevId: 383407665
* | Googletest exportAbseil Team2021-06-301-6/+122
| | | | | | | | | | | | Implement 'Contains(e).Times(n)' matcher modifier which allows to test for arbitrary occurrences including absence with Times(0). PiperOrigin-RevId: 382210276
* | Merge pull request #3429 from 1KoT1:masterCJ Johnson2021-06-171-8/+8
|\ \ | | | | | | | | | PiperOrigin-RevId: 379625931
| * | feat: make a matcher ElementsAreArray applicable for std rangesrefs/pull/3429/headVasilii Pochkaenko2021-06-151-2/+2
| | |
* | | Googletest exportAbseil Team2021-05-131-6/+8
| | | | | | | | | | | | | | | | | | Support templating MockFunction over function objects besides std::function. PiperOrigin-RevId: 373586967
* | | chore: fix spellingrefs/pull/3364/headJohn Bampton2021-04-151-1/+1
| | |