Commit Graph

4149 Commits

Author SHA1 Message Date
Abseil Team
2a02723b76 Fix example of DescribeMatcher to properly support negation.
PiperOrigin-RevId: 446259163
Change-Id: I3ad5f405f44fc233f5cf5a18a274a9104b5c4ab8
2022-05-03 12:18:27 -07:00
Abseil Team
0027cf4703 Use TEST_TMPDIR on MacOS as well if available.
Currently MacOS falls back to generic /tmp, but
for all intents and purposes it should behave like
other Unixes using the TEST_TMPDIR environment variable
if available (this environment variable is set in bazel,
which sets up a unique temp directory for the test
process).

While at it, remove an incorrect #endif comment, that
looks like a leftover from some older implementation.

PiperOrigin-RevId: 446108391
Change-Id: I118eacf6e86a41d26cb81a130f7c54cccc0c5665
2022-05-02 21:57:01 -07:00
Aaron Jacobs
42ca3da579 gmock-actions: remove a no-longer-necessary friend declaration.
PiperOrigin-RevId: 445940487
Change-Id: I26952a72327db0d308bbe57ca4d1d91a0d7defc8
2022-05-02 08:37:49 -07:00
Aaron Jacobs
5176726123 gmock-actions: support ByMove in a specialization of ReturnAction.
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
2022-05-02 08:30:07 -07:00
Ayush Joshi
fae793c101 Fix typo in the test name of NormalizeTest
Signed-off-by: Ayush Joshi <ayush854032@gmail.com>
2022-04-30 20:59:00 +05:30
Abseil Team
8ded48c37b Rewrite "Testing a Certain Property of an Object" as "Defining a Custom Matcher Class", and fix the code examples.
PiperOrigin-RevId: 445252626
Change-Id: I9f038cb669d3da6743606343c2341fc59725d722
2022-04-28 14:41:49 -07:00
Aaron Jacobs
830fb56728 gmock-actions: improve comments and tests for the implicit cast in Return.
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
2022-04-27 08:49:18 -07:00
Aaron Jacobs
c144d78f82 Support move-only and &&-qualified actions in WithArgs.
PiperOrigin-RevId: 444671005
Change-Id: I7df5f038caf17afb60d4fb35434ff0b656d4c954
2022-04-26 14:39:37 -07:00
Derek Mauro
e33c2b24ca Use RE2 for the regex implementation when building with Bazel and using Abseil
bazel build --define=absl=1 ...

A dependency on RE2 is now required when building GoogleTest with Abseil.
Using RE2 will provide a consistent cross-platform regex experience.

Users will need to add the com_googlesource_code_re2, bazel_skylib,
and platforms repository to their WORKSPACE files. See our WORKSPACE
file in the root directory of this project for an example of how to
add the dependencies.

Please note that the com_googlesource_code_re2 dependency must use a
commit from the `abseil` branch of the project:
https://github.com/google/re2/tree/abseil

PiperOrigin-RevId: 444650118
Change-Id: I45c55b26684c0c50d721a05b81c5f8a0c092400f
2022-04-26 13:27:20 -07:00
Abseil Team
238e4745c6 Generalize gmock-matchers_test to handle is_gtest_matcher-style matchers, too.
PiperOrigin-RevId: 444586594
Change-Id: I0de9b40b3773e3047a492f050266967ea935ae3e
2022-04-26 09:49:03 -07:00
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
Copybara-Service
b53547bf01 Merge pull request #3797 from glandium:issue3514
PiperOrigin-RevId: 444444700
Change-Id: I8ac5cc96cc6eb9d583fa7e3fb304ef3dcaa95b5b
2022-04-25 20:29:56 -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
Derek Mauro
b85864c647 Eliminate the legacy GTEST_COMPILE_ASSERT_ macro
PiperOrigin-RevId: 443462203
Change-Id: I0c43f981663a7531ff5da4d4be01fb3d6762273d
2022-04-21 13:23:32 -07:00
Mike Hommey
d5ad28dbe1 Always initialize fields in MatcherBase constructors
This fixes -Wuninitialized warnings with GCC.

Fixes #3514.
2022-04-20 10:42:11 +09:00
Copybara-Service
8ccdb9d56d Merge pull request #3791 from MR-A0101:patch-1
PiperOrigin-RevId: 442609985
Change-Id: I4239171ef8a671ef6d548ba94e02104c5f0ecd36
2022-04-18 12:57: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
733f875989 Replace infinite recursion call (intentionally invoking undefined behavior to indicate unreachability) with explicit unreachability marker.
PiperOrigin-RevId: 441474979
Change-Id: I1fcbb437026631212fec954c663482bb7e1cf819
2022-04-13 07:28:00 -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
MR-A
f079775276
Removing commas.
Readme Update!
2022-04-06 23:03:06 +05:30
Derek Mauro
5f467ec04d Clarify what live-at-head actually means
PiperOrigin-RevId: 439835271
Change-Id: I40765e607a96dfc3f0679450938daf25163c48a4
2022-04-06 07:39:26 -07:00
Abseil Team
c9044ba3dd Trying to make it more clear: this is probably not about mock classes, but about mocked classes
PiperOrigin-RevId: 439427291
Change-Id: I3cac035e732fb3fe4f9c314657932a55269e0416
2022-04-04 15:30:50 -07:00
Abseil Team
137f67e91f gmock: improve SFINAE for actions involving arguments.
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
2022-04-04 14:38:58 -07:00
Abseil Team
3ffa237f0e Use ResultOf()'s result_description when explaining match result.
PiperOrigin-RevId: 439389646
Change-Id: Ie34adcdd2b24378e85962efac53b7bb89ed93803
2022-04-04 12:56:24 -07:00
Derek Mauro
25dcdc7e8b Use the Abseil flags library when Abseil is present
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
2022-04-04 07:39:03 -07:00
Alecto Irene Perez
7da4a4114a
Fix quickstart-cmake documentation
Signed-off-by: Alecto Irene Perez <perez.cs@pm.me>
2022-03-26 21:52:05 -06:00
Abseil Team
af29db7ec2 Address deprecation warning surfaced by Github presubmit tests
PiperOrigin-RevId: 436839469
Change-Id: I2bb90dce524c16bcc31569bb98772dcc62d08fbf
2022-03-23 15:08:26 -07:00
Mattias Ellert
073293463e Split gmock-matchers_test into 4 smaller test #3653
The one large test does not link in limited memory environments

Closes #3653

PiperOrigin-RevId: 436753193
Change-Id: Idd59b6509994fc642147b88279ee791cd1d7bdd0
2022-03-23 09:08:04 -07:00
Copybara-Service
0affd45b62 Merge pull request #3779 from messerb5467:promote-inclusive-behavior
PiperOrigin-RevId: 436579789
Change-Id: I19faae341027efba83f1c2b3839636fc95780fc7
2022-03-22 14:59:23 -07:00
Abseil Team
5d6f38c1e2 Only print disabled test banner if the test matches gtest_filter
Currently, the "[ DISABLED ]" banner is printed for every test in a suite.
When iterating on a single test gtest_filter this is very noisy.

PiperOrigin-RevId: 436489088
Change-Id: If337087a7a0986b073fabf2b0a55d26485eb5c37
2022-03-22 09:07:51 -07:00
Abseil Team
1754febbaa Clarify public access on gmock examples.
PiperOrigin-RevId: 436268062
Change-Id: I3161b36121f78acf920d66fe121b2f1d5e5707b9
2022-03-21 11:57:05 -07:00
Brad Messer
9e71237221
Merge branch 'main' into promote-inclusive-behavior 2022-03-18 12:32:39 -04:00
Brad Messer
794da715d4 Remove sanity as it is offensive to neurodiverse individuals. 2022-03-18 12:19:38 -04: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
Copybara-Service
8a422b8398 Merge pull request #3774 from sobczyk:main
PiperOrigin-RevId: 434738675
Change-Id: I7c8de4004bac6b750674d19e3e79c0695a42652e
2022-03-15 06:55:30 -07:00
Dino Radakovic
ae5e06dd35 Remove references to deleted script gen_gtest_pred_impl.py
PiperOrigin-RevId: 434464892
Change-Id: Iaa2277f26d0049b3d792e87f64679774a28205c6
2022-03-14 08:00:38 -07:00
Abseil Team
ae1b7ad430 Mark ACTION_Pn()-generated functions as must-use-result, adding 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
2022-03-08 06:42:11 -08:00
Szymon Sobik
3c5320bf6f Add myself to contributors 2022-03-08 01:21:16 +01:00
Szymon Sobik
132059ba0c Adjust documentation regarding xml and json source file location otput. 2022-03-08 01:16:36 +01:00
Szymon Sobik
5c1b42a58d Adjust xml and json unit tests to test for source file and line location. 2022-03-08 01:15:20 +01:00
Szymon Sobik
ee5e3043ce Add support for testing of xml and json output of source file and line location 2022-03-08 01:14:21 +01:00
Szymon Sobik
f7621f0191 Output source file path and line number in xml and json files.
It outputs the location of testcase only.
Standalone EXPECT will have no location.
2022-03-08 01:12:35 +01:00
Derek Mauro
c9461a9b55 Update GCC/Clang Linux tests to use Bazel 5.0.0
PiperOrigin-RevId: 429400664
Change-Id: I6454cf52cb2fc616a96663823de997591b63dfae
2022-02-17 14:19:07 -08:00
Abseil Team
ea55f1f52c Address conversion warning by explicitly casting to size_t
Closes #3762

PiperOrigin-RevId: 428593750
Change-Id: Ifac216568fbc7d999adb71996ec6a1bbe3b97412
2022-02-14 13:28:28 -08:00
Abseil Team
0e402173c9 Add a 3-arg overload for ResultOf() matcher that takes a description string for better error messages.
PiperOrigin-RevId: 427598749
Change-Id: I8c7a5d7b2dde017641534f1c7eed8dd56c33e845
2022-02-09 16:20:06 -08:00
Copybara-Service
06519cedc3 Merge pull request #3751 from noiseless:gtest-help-test-OpenBSD
PiperOrigin-RevId: 427207981
Change-Id: Ib93f8f61bf568d4651f9148fbc522288308c0d71
2022-02-08 09:11:25 -08:00
Copybara-Service
504eb98953 Merge pull request #3746 from IYP-Programer-Yeah:use-constant-time-lookup-for-exact-match
PiperOrigin-RevId: 427179775
Change-Id: I9928be2421d559acf0e0f03643ce0b856b63f737
2022-02-08 06:51:54 -08:00
Copybara-Service
43efa0a4ef Merge pull request #3617 from Bagira80:fix_3616
PiperOrigin-RevId: 426976022
Change-Id: Ib9f49cf84775a50cbc806d331349e61a1060b498
2022-02-07 11:51:52 -08:00
Hossein Ghahramanzadeh
d6841c040d Apply requested changes by using std::inserter with move. 2022-02-05 17:43:21 +01:00
Andrew Krasavin
631f4f9947 Fix gtest-help-test failure on OpenBSD 2022-02-05 03:44:54 +03:00