Commit Graph

353 Commits

Author SHA1 Message Date
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
3ffa237f0e Use ResultOf()'s result_description when explaining match result.
PiperOrigin-RevId: 439389646
Change-Id: Ie34adcdd2b24378e85962efac53b7bb89ed93803
2022-04-04 12:56:24 -07: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
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
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
Dino Radakovic
0b7798b2fb Change ReturnArg to use perfect forwarding of arguments (#3733)
PiperOrigin-RevId: 424355706
Change-Id: I618e5574b4b2c56a343905c20d8cc6d2a70cbcd1
2022-01-26 08:40:27 -08:00
Abseil Team
6b74da4757 Include the param names in the generated description of the MATCHER_P matchers.
PiperOrigin-RevId: 418497526
Change-Id: Ie53c3c0810c10a32cbcb941e3ca1ee8fb1ddd9f9
2021-12-27 08:05:24 -08:00
Derek Mauro
c58f562fa2 Makes the Python imports consistently use full paths from the repository root,
unifying the behavior between Bazel and CMake

This fixes one of the CI failures on Windows

PiperOrigin-RevId: 417872531
Change-Id: I156989323b7e6d4a4420f4f9691b078829db933d
2021-12-22 13:01:24 -08:00
Abseil Team
d61d4d8e64 Support std::reference_wapper as a smart pointer type in gmock
PiperOrigin-RevId: 413963503
Change-Id: I33440780bf087698f4e4325399227405885430b3
2021-12-03 10:14:13 -08:00
Taylor Cramer
1a3e2a265f Clarify "Times() after X" error message
The previous error message could be misinterpreted to mean that `Times` could not be
used in combination with `WillRepeatedly`, when in fact the call to `Times` just needs to happen *first*.

PiperOrigin-RevId: 410070405
Change-Id: I747d34a4334cf2e56d589dcad3a08a8f322d77c8
2021-11-15 13:48:12 -08:00
Abseil Team
1b18723e87 Fix typo in gmock-matchers_test.cc: CanDescribeNegationOfExpectingOneElment => CanDescribeNegationOfExpectingOneElement
PiperOrigin-RevId: 409484263
Change-Id: I7448d6f04a9868602e0bc8dec40ea3eb63d3e387
2021-11-12 13:09:59 -08:00
Raul Tambre
5d1e4af673 Replace use of deprecated std::iterator
This was deprecated by P0174 in C++17.
2021-11-05 13:01:19 +02:00
Abseil Team
b3062166a1 Googletest export
Internal change

PiperOrigin-RevId: 405710296
2021-11-03 13:45:46 -04:00
dinord
075810f7a2 Merge pull request #3581 from cclauss:codespell
PiperOrigin-RevId: 400792845
2021-10-05 10:59:42 -04:00
Abseil Team
ab36804e42 Googletest export
Ensure `.what()` is printed in `ThrowsMessage(...)` to address https://github.com/google/googletest/issues/3582

Closes #3582

PiperOrigin-RevId: 399462851
2021-09-28 16:33:40 -04:00
Christian Clauss
ee1be03b43 Fix remaining typos discovered by codespell 2021-09-24 08:09:32 +02:00
Vertexwahn
277e0a0168 Remove bazelbuild/rules_cc dependency 2021-09-17 10:04:26 +02:00
Abseil Team
6202251f09 Googletest export
Introduce GMOCK_FLAG_GET and GMOCK_FLAG_SET macros.

PiperOrigin-RevId: 396649214
2021-09-15 13:33:42 -04:00
Abseil Team
652ec31f9f Googletest export
Introduce a new matcher for unescaping Base-64 strings to gmock.

PiperOrigin-RevId: 388471904
2021-08-04 13:54:39 -04:00
slowy07
2f3e2e39cc fix: typo codespelling comment 2021-07-24 17:38:47 +07:00
Abseil Team
8306020a3e Googletest export
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
2021-07-07 14:34:28 -04:00
Abseil Team
977cffc442 Googletest export
Introduce GTEST_FLAG_GET and GTEST_FLAG_SET macros.

PiperOrigin-RevId: 382808313
2021-07-07 14:34:19 -04:00
Abseil Team
4ec4cd23f4 Googletest export
Implement 'Contains(e).Times(n)' matcher modifier which allows to test for arbitrary occurrences including absence with Times(0).

PiperOrigin-RevId: 382210276
2021-06-30 13:33:57 -04:00
Manuel Binna
4281d2149c Don't link pthread on QNX
On QNX, pthread is part of libc [1]. There's no separate pthread library
to link.

[1] https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.lib_ref/topic/p/pthread_create.html
2021-06-26 13:26:20 +02:00
dmauro
8ceecc27c7 Googletest export
Updates Linux docker image to use Bazel 4.1.0 and GCC 11.1
Updates Bazel dependencies
Removes the last usage of the deprecated and removed Python2

PiperOrigin-RevId: 375759184
2021-06-02 17:54:36 -04:00
Abseil Team
662fe38e44 Googletest export
Support templating MockFunction over function objects besides std::function.

PiperOrigin-RevId: 373586967
2021-05-13 15:08:57 -04:00
John Bampton
050b517518 chore: fix spelling 2021-04-15 11:53:53 +10:00
Abseil Team
e7e591764b Googletest export
Format WORKSPACE and googlemock/test/BUILD.bazel using buildifier

PiperOrigin-RevId: 360913861
2021-03-04 12:07:39 -05:00
Abseil Team
5893778716 Googletest export
Update stale links to `gmock_cook_book.md`.

I'm a new googletest user and found these links broken when reading the documentation.

PiperOrigin-RevId: 357786392
2021-02-18 13:27:00 -05:00
Abseil Team
0a3a3a845e Googletest export
Make include guards conform with https://google.github.io/styleguide/cppguide.html#The__define_Guard, attempt #2

PiperOrigin-RevId: 357056902
2021-02-18 13:26:24 -05:00
Abseil Team
d4144d4ee2 Googletest export
Revert include guard fix

PiperOrigin-RevId: 356588893
2021-02-11 12:49:24 -05:00
Abseil Team
36b7792047 Googletest export
Make include guards conform with https://google.github.io/styleguide/cppguide.html#The__define_Guard

PiperOrigin-RevId: 355882793
2021-02-11 12:48:43 -05:00
Abseil Team
d114398800 Googletest export
Remove uses of GTEST_HAS_TYPED_TEST_P and GTEST_HAS_TYPED_TEST.

PiperOrigin-RevId: 353935996
2021-02-05 10:39:30 -08:00
ofats
59dea67b81 Googletest export
Remove scripts for code generating together with related files.

PiperOrigin-RevId: 352805926
2021-01-26 15:43:04 -05:00
Abseil Team
14098f2015 Googletest export
Merge CONTRIBUTORS, delete LICENSEs in googletest/ and googlemock/

PiperOrigin-RevId: 352558822
2021-01-26 15:42:13 -05:00
Abseil Team
c13c27a513 Googletest export
Change Matcher<T> to allow binding an implementation by value directly:
 - Drop the requirement of MatcherInterface. Doing manual type erasure avoid
   extra layers in many cases.
 - Avoid the adaptor for `MatcherInterface<T>` and `MatcherInterface<const T&>` mismatch.
 - Use a small object optimization when possible. This makes things like
   `_` and `Eq(1)` really cheap and do not require memory allocations.
 - Migrate some matchers to the new model to speed them up and to test the new framework. More matchers to come in future changes.

PiperOrigin-RevId: 350580998
2021-01-13 20:59:20 -05:00
Abseil Team
ca4b7c9ff4 Googletest export
Give each of Naggy/Nice/StrictMock a base class whose constructor runs before
the mocked class's constructor, and a destructor that runs after the mocked
class's destructor, so that any mock methods run in either the constructor or
destructor use the same strictness as other calls.

PiperOrigin-RevId: 348511612
2020-12-22 12:15:41 -05:00
dmauro
4f6fa70870 Googletest export
Internal Change

PiperOrigin-RevId: 347631521
2020-12-22 12:15:22 -05:00
dmauro
fb4b3b6b9a Googletest export
Fix a missing Bazel build dependency

PiperOrigin-RevId: 346783462
2020-12-10 17:56:26 -05:00
Abseil Team
e5644f5f12 Googletest export
Introduce a new `Address` matcher to gmock.

PiperOrigin-RevId: 346344591
2020-12-08 19:15:35 -05:00
Abseil Team
a02a591605 Googletest export
Add a `Pointer` matcher as an analog to `Pointee`.

Similar to `Pointee`, `Pointer` works with either raw or smart pointers and
allows creating a matcher like Pointer(Eq(foo)) for smart pointers.

PiperOrigin-RevId: 346164768
2020-12-07 18:04:12 -05:00
Abseil Team
93748a9466 Googletest export
Disable a gmock matcher test under MSVC 2015 (version 14) and earlier.  It interacts badly with Windows structured exceptions in a way we do not have the resources to investigate.  This test passes under MSVC 2017 and SEH.

PiperOrigin-RevId: 345496734
2020-12-03 15:42:58 -05:00
Abseil Team
0c400f67fc Googletest export
GMock: Make Truly explain when it fails

I just wrote a test that had a matcher of the form
  Optional(AllOf(
    SomeMatcher,
    SomeOtherMatcher,
    Truly(SomePredicate)))

The predicate failed, the other two matchers succeeded, and I got a hard-to-interpret message saying that the value in the optional "didn't match". Didn't match what?

This change improves situations like that slightly by having Truly explain to its result listener when it fails. When there are multiple Trulys in an AllOf, there will be some ambiguity, but it will at least provide more information than right now.

PiperOrigin-RevId: 341105141
2020-11-09 15:43:24 -05:00
Abseil Team
d89b363021 Googletest export
Add support for ref qualifiers in MOCK_METHOD.

PiperOrigin-RevId: 341047839
2020-11-06 13:23:55 -05:00
Abseil Team
a462188865 Googletest export
Add ::testing::FieldsAre matcher for objects that support get<> and structured bindings.
PiperOrigin-RevId: 337165285
2020-10-14 18:27:07 -04:00
Abseil Team
df6b75949b Googletest export
Replace uses of ACTION_TEMPLATE and ACTION_P with manually written functors.
The latter provide better error diagnostics.
This fixes https://github.com/google/googletest/issues/2729.

PiperOrigin-RevId: 328573022
2020-08-26 21:23:05 -04:00