Commit Graph

318 Commits

Author SHA1 Message Date
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
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
CJ Johnson
7153098229 Merge pull request #3429 from 1KoT1:master
PiperOrigin-RevId: 379625931
2021-06-17 12:52:27 -04:00
Vasilii Pochkaenko
5ef9f63a72 feat: make a matcher ElementsAreArray applicable for std ranges 2021-06-15 16:42:40 +07: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
c3fc92f0b7 Googletest export
Update docs to point to the github.io pages.

PiperOrigin-RevId: 367711335
2021-04-12 20:14:19 -07:00
Austin Sullivan
9c047902ac
Update nicestrictnaggy gmock cook_book links
An incorrect link is output to the user when these conditions are met.
2021-03-17 10:33:19 -04:00
Abseil Team
98ca420679 Googletest export
Internal change

PiperOrigin-RevId: 362040448
2021-03-16 09:50:49 -04:00
Abseil Team
bf465ff05d Internal change
PiperOrigin-RevId: 361213113
2021-03-09 10:59:19 -08: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
eac6a02cc2 Googletest export
Mark move constructor noexcept

PiperOrigin-RevId: 356772642
2021-02-11 12:49:46 -05:00
Abseil Team
d4144d4ee2 Googletest export
Revert include guard fix

PiperOrigin-RevId: 356588893
2021-02-11 12:49:24 -05:00
Abseil Team
9c2293af06 Googletest export
Fix build for MinGW + clang

In [1], empty_bases "is only supported when using the Microsoft C++ ABI." Disable it for MinGW.

https://clang.llvm.org/docs/AttributeReference.html#empty-bases

PiperOrigin-RevId: 356373782
2021-02-11 12:48:52 -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
997c36c188 Googletest export
Stop using pump for generating internal/custom/gmock-generated-actions.h

PiperOrigin-RevId: 352660735
2021-01-26 15:42:55 -05:00
Abseil Team
2c06d021d6 Googletest export
Internal change

PiperOrigin-RevId: 352607401
2021-01-26 15:42:30 -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
Abseil Team
18f8200e30 Googletest export
Add static_asserts that verify that no class hierarchy contains more than one
of {NiceMock, NaggyMock, StrictMock}. This sort of nesting has always been
disallowed, but this CL adds a compile-time check to prevent it.

PiperOrigin-RevId: 347037822
2020-12-11 22:11:39 -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
a1adec799a Googletest export
Use a tagged constructor for FlatTuple instead.
Some versions of MSVC are getting confused with that constructor and generating invalid code.

PiperOrigin-RevId: 342050957
2020-11-12 13:32:33 -05:00
Abseil Team
fbef0711cf Googletest export
Change ACTION{,_Pn,_TEMPLATE} macros to build functors rather than ActionInterface<> subclasses, thus changing the Action<> wrappers they create to use the modernized (non-const) argument tuple type, allowing these macros to mutate their arguments.

Functor-based Action<>s deep-copy the implementing object, so have the functors use a shared_ptr to the non-trivial state of bound value parameters.  No longer specialize that shared state to the particular action signature, encoding that information instead only in the instantiation of the implementation function.

PiperOrigin-RevId: 341116208
2020-11-09 15:43:33 -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
ofats
710f9c11ca Googletest export
Rewrite InvokeArgument action without using pump.

PiperOrigin-RevId: 340861582
2020-11-05 15:07:26 -05:00
Abseil Team
2828773179 Googletest export
Remove obsolete comment about non-const references.

They used to be banned by the C++ style guide, but positions shifted, and this comment is no longer up to date.

There's another reference (heh) on lines 816-819 to how gmock is a "general framework", with the possible implication that support for non-const references was weird in some way and only there to be "general", but I left it alone because I don't really feel I understand what it's saying.

PiperOrigin-RevId: 339323428
2020-10-30 14:10:41 -04:00
dmauro
3c95bf5524 Googletest export
Fixes build warnings from previous CL
Add CMake to internal presubmit to prevent these

PiperOrigin-RevId: 337325504
2020-10-15 13:32:43 -04:00
Derek Mauro
ebbeee39f5 Merge pull request #3042 from Aralox:Issue-2135-modify-mock-template-args-AX-to-TArgX
PiperOrigin-RevId: 337217118
2020-10-15 13:32:33 -04: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
Aralox
ee66065bc5 Issue 2135: Change template args in NiceMock, NaggyMock and StrictMock from A1, A2, ... to TArg1, TArg2,... to avoid clash with legacy header files 2020-10-07 18:27:41 +11:00
Abseil Team
705b9c1af2 Googletest export
Fix typo

PiperOrigin-RevId: 333745750
2020-09-28 23:48:26 -04:00
Abseil Team
bb2725346d Googletest export
Reduce the demangled name bloat of the Action constructor.

PiperOrigin-RevId: 332234887
2020-09-20 18:48:32 -04:00
Abseil Team
a4ab0abb93 Googletest export
Mark ACTION_Pn()-generated functions as must-use-result.

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*)` and `ACTION(Use) { Use(arg); }` for later application to a Foo.  With such an overload, a client may then write `Use();`, forgetting the param and being confused why nothing happens.

This also catches when a client defines their own action in terms of an ACTION()-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: 330614454
2020-09-10 19:09:30 -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
Abseil Team
ec9be15bf8 Googletest export
Workaround static assert in early versions libc++

The error is "Attempted to construct a reference element in a tuple with an
rvalue". We can fix this by putting everything into a non temporary tuple_args
and implitly convert to the other tuple types. This avoids binding an rvalue
reference to an lvalue reference inside the tuple.

PiperOrigin-RevId: 327624990
2020-08-23 23:51:21 -04:00
vslashg
aa4cbcdcbd Merge pull request #2904 from AmatanHead:throw-matchers
PiperOrigin-RevId: 327294137
2020-08-23 23:51:02 -04:00
Abseil Team
fc1e778899 Googletest export
Fix DoAll to work with move-only sink arguments.

This changes types of the first n - 1 actions so that they only get a readonly
view of the arguments. The last action will accept move only objects.

PiperOrigin-RevId: 327031893
2020-08-23 23:50:54 -04:00
Abseil Team
5a5caab358 Googletest export
Fix DoAll to work with move-only sink arguments.

This changes types of the first n - 1 actions so that they only get a readonly
view of the arguments. The last action will accept move only objects.

PiperOrigin-RevId: 324619666
2020-08-07 13:08:00 -04:00
Abseil Team
48ec64092a Googletest export
Fix DoAll to work with move-only sink arguments.

This changes types of the first n - 1 actions so that they only get a readonly
view of the arguments. The last action will accept move only objects.

PiperOrigin-RevId: 324600664
2020-08-07 13:07:51 -04:00
Vladimir Goncharov
7f1c8bb447 Remove ThrowsMessageHasSubstr and fix some nits after review 2020-08-03 23:47:57 +03:00
Vladimir Goncharov
a899cecb11 Cleanup a bulky expression, document implementation details 2020-08-03 23:47:57 +03:00
Vladimir Goncharov
0a80845e73 Fix build under msvc 2020-08-03 23:47:57 +03:00
Vladimir Goncharov
69c510fb51 Add a test for duplicate catch clauses in throw matchers, fix a couple of nitpicks. 2020-08-03 23:47:57 +03:00
Vladimir Goncharov
49d1201a7e Add missing documentation piece 2020-08-03 23:47:57 +03:00