Commit Graph

330 Commits

Author SHA1 Message Date
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
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
d0de618a58 Googletest export
Fixing exception-safety bug in googletest. Previously, if an exception was
thrown during a call to a mock that would have triggered an error, the error
was discarded.

Fixes #2890

PiperOrigin-RevId: 325017806
2020-08-07 13:08:09 -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
4ebbfea623 Fix build under msvc 2020-08-03 23:47:57 +03:00
Vladimir Goncharov
c46bdea43a Update tests after changing an error message 2020-08-03 23:47:57 +03:00
Vladimir Goncharov
92d0a6f7e2 Add a test to ensure that the Throws matcher only invokes its argument once. 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
Vladimir Goncharov
46734d9a66 Small improvements: code style and property name 2020-08-03 23:47:57 +03:00
Vladimir Goncharov
9ac4cd0f49 Add matchers for testing exception properties
This PR adds matchers that accept a callable and verify that when invoked, it throws an exception with the given type and properties.

Fixes #952
2020-08-03 23:47:57 +03:00
ofats
eb660507ff Googletest export
Move matchers' tests from *generated* to common files.

PiperOrigin-RevId: 320954068
2020-07-15 14:09:29 -04:00
vslashg
af287b4ffd Merge pull request #2903 from AmatanHead:informative-exception-asserts
PiperOrigin-RevId: 320425648
2020-07-15 14:09:20 -04:00
Abseil Team
9aaaaf3f3d Googletest export
Cleanup: Error message grammar fix.
PiperOrigin-RevId: 319992912
2020-07-09 13:35:10 -04:00
Abseil Team
13a433a94d Googletest export
Change string matchers, like HasSubstr, to accept `string_view` input if available.

PiperOrigin-RevId: 315726484
2020-06-10 17:37:39 -04: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
Xiaoyi Zhang
67cc66080d Merge pull request #2350 from adambadura:MockFunctionFromStdFunction
PiperOrigin-RevId: 302677275
2020-03-24 17:32:16 -04:00