Commit Graph

62 Commits

Author SHA1 Message Date
Aaron Jacobs
0498660ea5 Support move-only and &&-qualified actions in DoAll.
This is necessary for generic support of these actions, since `DoAll` is a
frequently-used action wrapper.

PiperOrigin-RevId: 444561964
Change-Id: I02edb55e35ab4207fbd71e371255a319c8253136
2022-04-26 08:05:34 -07:00
Derek Mauro
bf66935e07 Remove the legacy internal GTEST_DISALLOW_* macros
PiperOrigin-RevId: 443715444
Change-Id: I3ffd54b63d2728ae4a668ee7875c8c3c8188087c
2022-04-22 11:26:03 -07:00
Aaron Jacobs
80600e56cc Document two surprises in DoAllAction::NonFinalType.
PiperOrigin-RevId: 441589196
Change-Id: Ic3e483ca70d72261046bad464d817f9dfd4bec65
2022-04-13 15:04:29 -07:00
Abseil Team
a1cc8c5519 Add support for move-only and &&-qualified actions in WillOnce.
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
2022-04-08 18:40:07 -07:00
Abseil Team
b007c54f29 Running clang-format over all of GoogleTest
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
2022-03-15 13:42:11 -07:00
slowy07
2f3e2e39cc fix: typo codespelling comment 2021-07-24 17:38:47 +07:00
John Bampton
050b517518 chore: fix spelling 2021-04-15 11:53:53 +10:00
durandal
a0669e070a Googletest export
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
2020-05-28 19:53:43 -04:00
Abseil Team
63713e1ce4 Googletest export
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
2020-05-28 19:53:26 -04:00
Gennadiy Rozental
ef25d27d46 Merge pull request #2815 from Quuxplusone:simple
PiperOrigin-RevId: 308625388
2020-05-01 17:11:43 -04:00
Abseil Team
955552518b Googletest export
Rewrite ReturnNew action without using pump.

PiperOrigin-RevId: 308219616
2020-05-01 17:11:34 -04:00
Arthur O'Dwyer
766ac2e1a4 Remove all uses of GTEST_DISALLOW_{MOVE_,}ASSIGN_.
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.
2020-04-23 22:22:07 -04: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
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
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
Piotr Nycz
208c2f6b60 variable names corrected (followed google coding style)
Issue 2527
2019-10-25 16:14:18 +02:00
Piotr Nycz
5ff72f5295 Apply 80chars limit
Issue 2527
2019-10-25 10:29:15 +02:00
Piotr Nycz
d072682119 Tests simplified and names corrected (POD->scalar)
Issue 2527
2019-10-24 10:22:09 +02: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
Piotr Nycz
37590da6c0 Added more tests to verify: ReturnRef not accept temporary
Issue 2471
2019-10-23 10:12:48 +02:00
Piotr Nycz
19a3bbce51 Added tests verifying that temporaries are accepted by ReturnRef
Issue no 2527
2019-10-22 18:41:35 +02:00
Abseil Team
d44b137fd1 Googletest export
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
2019-08-15 17:34:34 -04:00
Abseil Team
d982543131 Googletest export
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
2019-04-01 15:05:10 -04:00
Abseil Team
0adeadd283 Googletest export
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
2019-01-17 14:41:08 -05:00
Abseil Team
097407fd3c Googletest export
Deduplicate testing::ReferenceWrapper with std::reference_wrapper.
Minor cleanups in matchers_test.

PiperOrigin-RevId: 229022872
2019-01-14 17:01:56 -05:00
misterg
14c2fba734 Googletest export
Internal Change

PiperOrigin-RevId: 227575279
2019-01-02 16:51:40 -05:00
Abseil Team
f8b1c1af17 Googletest export
Remove the #ifs for old, unsupported and buggy compilers:
* old versions of GCC & MSVC
* Symbian

PiperOrigin-RevId: 227116941
2019-01-02 16:51:33 -05:00
Abseil Team
e26a3fa13c Googletest export
Unifdef c++11-related macros from googletest now that it requires C++11.

PiperOrigin-RevId: 225905601
2018-12-20 14:09:31 -05:00
Abseil Team
26743363be Googletest export
Applied fixes for ClangTidy modernize-use-override and modernize-use-using.

PiperOrigin-RevId: 223800219
2018-12-03 12:54:11 -05:00
misterg
a3013cceff Googletest export
Fix broken OSS build

PiperOrigin-RevId: 222244158
2018-11-20 13:30:32 -05:00
Abseil Team
64368e0584 Googletest export
Remove redundant Base/Derived types.

PiperOrigin-RevId: 222243634
2018-11-20 13:30:16 -05:00
Abseil Team
aac18185eb Googletest export
Upgrade WithArgs family of actions to C++11.

PiperOrigin-RevId: 221671690
2018-11-20 13:29:12 -05:00
Robin Lindén
826656b25f
Remove workarounds for unsupported MSVC versions 2018-11-10 15:20:26 +01:00
Abseil Team
7d3b73c85a Unconditionally use std::tuple.
Remove all mention of TR1 tuple and our own implementation of tuple.

PiperOrigin-RevId: 216395043
2018-10-09 16:25:58 -04:00
Abseil Team
4bb49ed640 Apply clang-tidy modernize-use-nullptr to googletest.
Now that googletest has moved to C++11, it should no longer
use NULL or 0 for the null pointer. This patch converts all
such usages to nullptr using clang-tidy.

This prevents LLVM from issuing -Wzero-as-null-pointer-constant
warnings.

PiperOrigin-RevId: 215814400
2018-10-05 12:54:14 -04:00
Gennadiy Civil
265efde9a5 Comments changes, no functionality changes. 2018-08-14 15:04:11 -04:00
Gennadiy Civil
a3c0dd0f4d Comments changes, no functionality changes 2018-08-14 14:04:07 -04:00
Gennadiy Civil
b78c3b8e00 small cleanup, np functional changes 2018-08-07 10:38:41 -04:00
Gennadiy Civil
24edf4e3bf automatic code sync mgt, comment only 2018-08-06 15:40:21 -04:00
Gennadiy Civil
8d07cfd053 Code sync, mostly formatting and removing outdates 2018-07-18 11:30:36 -04:00
Gennadiy Civil
9fba103156 merging, testing, this should be it 2018-04-16 10:42:08 -04:00
Gennadiy Civil
1c6e68cf6c merging 2018-04-16 10:34:07 -04:00
Gennadiy Civil
26c10dc7e6 merging 2018-04-16 10:16:48 -04:00
Gennadiy Civil
d84eb86df5 more pizza 2018-04-13 16:04:34 -04:00
Gennadiy Civil
f45728a5ac more OSX pizzas 2018-04-13 15:48:57 -04:00
Gennadiy Civil
b74a1af00f osx pizzas 2018-04-13 11:49:37 -04:00
Gennadiy Civil
f9bd6180de merging gmock actions test 2018-04-13 11:02:55 -04:00
Gennadiy Civil
0bfa823785 merging, gmock actions test 2018-04-13 11:02:25 -04:00
Gennadiy Civil
39c58da187 merge 2018-04-10 16:10:34 -04:00
Gennadiy Civil
e1071eb949 RE-Doing the merge, this time with gcc on mac in the PR so I can catch errors before merging the PR 2018-04-10 15:57:16 -04:00