Commit Graph

356 Commits

Author SHA1 Message Date
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
Adam Badura
53740ebc21 Add support for std::function in MockFunction (#2277) 2020-03-18 01:11:30 +01:00
Adam Badura
e41f31f2af Add tests for MockFunction deduction (#2277)
Add tests checking that ::testing::MockFunction template argument can
be deduced in a function call context. This is a property raised in the
review, however, not checked before by any tests.
2020-03-18 01:11:30 +01:00
dmauro
c43f7100f0 Googletest export
Use a polymorphic matcher instead of the GreaterThan<int> test matcher
to fix the sign-comparison warning on MSVC.

PiperOrigin-RevId: 301163657
2020-03-17 17:20:39 -04:00
Abseil Team
230afdb24e Googletest export
Internal change

PiperOrigin-RevId: 299345492
2020-03-17 17:20:23 -04:00
Abseil Team
909b1ccfca Googletest export
Relax the implementation of MatcherCast to allow conversion of `Matcher<T>` to
`Matcher<const T&>`. They have the same match signature.

PiperOrigin-RevId: 297115843
2020-02-28 16:41:01 -05: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
6f5fd0d719 Googletest export
Add gmock Matcher<std::string_view> specialization.

PiperOrigin-RevId: 294443240
2020-02-11 15:50:26 -05:00
Abseil Team
41b5f149ab Googletest export
Get rid of gmock-generated-matchers.h and gmock-generated-matchers.h.pump.

Stop using pump for MATCHER* macroses generation.

PiperOrigin-RevId: 293878808
2020-02-07 18:20:45 -05:00
Abseil Team
fbf67a70d0 Googletest export
Get rid of gmock-generated-function-mockers.h and
gmock-generated-function-mockers.h.pump.

Stop using pump for GMOCK_METHOD* macroses generation.

PiperOrigin-RevId: 293454519
2020-02-07 13:35:27 -05:00
Abseil Team
4f6609129a Googletest export
Fix std::move to std::forward where appropriate to support reference types.

PiperOrigin-RevId: 292923058
2020-02-07 13:35:00 -05:00
Abseil Team
572e261b60 Googletest export
Fix use of reserved names.
Minimize code duplication needed for explict-vs-nonexplicit constructor.

PiperOrigin-RevId: 292555014
2020-02-07 13:34:42 -05:00
Xiaoyi Zhang
9417fb401a Merge pull request #2665 from bysreg:fix_noshortcircuitfailure_detectsflakyshortcircuit_test
PiperOrigin-RevId: 290256504
2020-01-21 16:26:24 -05:00
Muhammad Hilman Beyri
c7137f0b84 Use IsReadableTypeName IsReadableTypeName in OfType function in gmock-matchers_test.cc 2020-01-12 21:29:54 -05:00
Muhammad Hilman Beyri
3aa538cbfc fix unit test failure on NoShortCircuitOnFailure and DetectsFlakyShortCircuit when GTEST_HAS_RTTI is 1 2020-01-12 16:53:09 -05:00
Matt Calabrese
a3097c826e Merge pull request #2592 from kuzkry:remove-workaround_msvc-error-C2665
PiperOrigin-RevId: 284207090
2019-12-13 12:57:26 -05:00
Gennadiy Rozental
39803f3c51 Merge pull request #2593 from kuzkry:remove-workaround_msvc-namespace-scope-from-nested-class
PiperOrigin-RevId: 282593823
2019-11-26 15:47:38 -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
Krystian Kuzniarek
a5136dbdd2 remove MSVC workaround: error C2665 2019-11-22 17:12:11 +01:00
Krystian Kuzniarek
21d276b5c4 remove MSVC workaround: accessing namespace scope from within nested classes 2019-11-22 17:10:39 +01:00
vslashg
057ee5063d Merge pull request #2533 from thejcannon:noexcept_spec
PiperOrigin-RevId: 277924721
2019-11-01 16:02:05 -04: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
vslashg
a8b1a66cfd Merge pull request #2388 from kuzkry:remove-gtest-type-util.pump
PiperOrigin-RevId: 276944601
2019-10-29 16:50:52 -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
Joshua Cannon
676d0444bf Revert "Merge pull request #2498 from thejcannon:noexcept_spec"
This reverts commit ba513d2c95, reversing
changes made to a3ca5b9e0b.
2019-10-23 14:46:46 -05:00
vslashg
8bab7883a6 Merge pull request #2514 from thejcannon:msvc_macro_issue
PiperOrigin-RevId: 276134684
2019-10-23 13:35:26 -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
Gennadiy Civil
de11283554 Merge pull request #2444 from kuzkry:remove-GTEST_ARRAY_SIZE_
PiperOrigin-RevId: 275842505
2019-10-22 09:38:21 -04:00
Abseil Team
011c4e23d5 Googletest export
Rolling forward IsNan() matcher with fixes in test for -Wconversion issues. Use
std::nanf and std::nanl where appropriate.
PiperOrigin-RevId: 275523003
2019-10-22 09:37:46 -04:00
misterg
f966ed1581 Googletest export
Added IsNan matcher

PiperOrigin-RevId: 275473218
2019-10-18 11:34:08 -04:00
Abseil Team
1f9edcd969 Googletest export
Addressing https://github.com/google/googletest/issues/2502

Add MOCK_METHOD support for returning function pointers.

PiperOrigin-RevId: 275323671
2019-10-18 11:33:59 -04:00
Abseil Team
bbe4b7363b Googletest export
Added IsNan matcher

PiperOrigin-RevId: 275278634
2019-10-17 13:08:00 -04:00
Andy Soffer
bdc29d5dc1 Merge pull request #2421 from kuzkry:cleanup-for-regex
PiperOrigin-RevId: 275058934
2019-10-16 14:32:31 -04:00
Joshua Cannon
5fe5233612 Removing extraneous test 2019-10-11 11:28:00 -05:00
Joshua Cannon
fe112cfee7 Replace compile-test with preprocessor test 2019-10-11 10:58:59 -05:00
Joshua Cannon
c1e8e71aab Add a compile test 2019-10-11 09:34:01 -05:00
Gennadiy Civil
ba513d2c95 Merge pull request #2498 from thejcannon:noexcept_spec
PiperOrigin-RevId: 274155281
2019-10-11 08:48:11 -04:00
Gennadiy Civil
37905b9d8c Merge pull request #2498 from thejcannon:noexcept_spec
PiperOrigin-RevId: 274097989
2019-10-11 07:07:12 -04:00
Joshua Cannon
bc996e0817 Made noexcept condition more exciting 2019-10-10 08:52:27 -05:00
Gennadiy Civil
cb1d5db1a1 Merge pull request #2448 from kuzkry:bad-googletest-export
PiperOrigin-RevId: 273585026
2019-10-10 09:21:38 -04:00
Joshua Cannon
20255e6f40 Use declval in noexcept expression 2019-10-07 16:27:11 -05:00
Joshua Cannon
7f8617a7c5 Switch to free function to avoid GCC bug 2019-10-07 15:49:52 -05:00
Joshua Cannon
872b9ceb60 Avoid comma operator 2019-10-07 15:12:51 -05:00
Joshua Cannon
10c1d8c4fa Use the verbatim noexcept spec in MOCKED_METHOD 2019-10-07 14:30:10 -05:00
Abseil Team
cb3f7ce1de Googletest export
Makes testing::ResultOf() work with non-copyable arguments.

PiperOrigin-RevId: 271222632
2019-09-27 16:48:33 -04:00
Krystian Kuzniarek
e0d16aa336 remove GTEST_ARRAY_SIZE_
This macro didn't work when an array was passed to a function by pointer,
in which case the information about its size was lost.
Better alternatives are:
* std::extent<T>::value (compile-time)
* std::array<T, N>::size() (compile-time)
* std::distance(std::begin(array), std::end(array)) (run-time)
2019-09-23 19:31:06 +02:00
Krystian Kuzniarek
7c2bd3af98 square away the stuff that hasn't been merged in a manual review
This fixes up ab8f346b (a manual merge) that has abandoned some things
from PR #2395.
2019-09-16 19:21:37 +02:00
kuzkry
f2fb48c3b3 Googletest export
Merge 3bdefdb473d304803d2a38e2a2cd5cdc1827c3bd into fb49e6c164

Closes #2407

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/googletest/pull/2407 from kuzkry:StaticAssertTypeEq 3bdefdb473d304803d2a38e2a2cd5cdc1827c3bd
PiperOrigin-RevId: 269255328
2019-09-16 11:47:35 -04:00
Krystian Kuzniarek
c96da8fea8 change usings 2019-09-12 18:21:31 +02:00
Shaindel Schwartz
c7a03daa99 Merge pull request #2387 from kuzkry:iff
PiperOrigin-RevId: 268693457
2019-09-12 12:10:51 -04:00
Hosein Ghahremanzadeh
ac24edd6e0 Googletest export
Merge 4c9ef099b29d2c840c04643cd9662fd7be712f7b into 565f1b8482

Closes #2403

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/googletest/pull/2403 from IYP-Programer-Yeah:remove-compile-assert-type-equal 4c9ef099b29d2c840c04643cd9662fd7be712f7b
PiperOrigin-RevId: 268681883
2019-09-12 12:10:41 -04:00
kuzkry
ab8f346b07 Googletest export
Merge 7f4f58da20e1066a888d3e4bcbef541db798a605 into 90a443f9c2

Closes #2395

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/googletest/pull/2395 from kuzkry:custom-type-traits-remove_reference 7f4f58da20e1066a888d3e4bcbef541db798a605
PiperOrigin-RevId: 266189044
2019-09-06 08:00:03 -04:00
misterg
6a3d632f40 Googletest export
Add tuple version of Optional() matches. This allows Optional() to be used in Pointwise matchers.

PiperOrigin-RevId: 265501882
2019-08-26 14:43:56 -04:00
Abseil Team
ed2eef6543 Googletest export
Add tuple version of Optional() matches. This allows Optional() to be used in Pointwise matchers.

PiperOrigin-RevId: 265110864
2019-08-23 16:39:21 -04:00
kuzkry
db1b739943 Googletest export
Merge b8ca465e73ac0954a0c9eec2a84bdd8913d5763b into 90a443f9c2

Closes #2396

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/googletest/pull/2396 from kuzkry:custom-type-traits-true/false_type-and-bool_constant b8ca465e73ac0954a0c9eec2a84bdd8913d5763b
PiperOrigin-RevId: 265064856
2019-08-23 16:39:13 -04:00
Krystian Kuzniarek
7bd4a7f3e9 restore mistakenly removed iffs in their explicit form
Due to confusion arisen from "iff" standing for "if and only if",
this commit uses the latter.
2019-08-20 12:14:22 +02:00
Gennadiy Civil
d5e9e0c38f Merge pull request #2397 from kuzkry:custom-type-traits-is_reference
PiperOrigin-RevId: 264193098
2019-08-19 14:20:11 -04:00
Gennadiy Civil
30e58a89a4 Merge pull request #2381 from Yannic:fix_bazel
PiperOrigin-RevId: 264186624
2019-08-19 14:20:03 -04: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
Krystian Kuzniarek
ec49fbca4c remove custom implementations of std::is_same 2019-08-14 14:00:44 +02:00
Krystian Kuzniarek
da76d01b98 remove a custom implementation of std::is_reference 2019-08-14 13:33:13 +02:00
Yannic Bonenberger
6fd262ecf7 Prepare for Bazel incompatible changes
Fixes googletest for upcoming `--incompatible_load_cc_rules_from_bzl` (https://github.com/bazelbuild/bazel/issues/8743) and `--incompatible_load_python_rules_from_bzl` (https://github.com/bazelbuild/bazel/issues/9006).

This change was automatically generated with `buildifier -lint=fix -warnings=all $(find . -name "BUILD" -o -name "BUILD.bazel" -o -name "*.bzl")`.
2019-08-07 17:08:10 +02:00
Krystian Kuzniarek
bf6df7eaee fix typos 2019-07-30 12:52:27 +02:00
Abseil Team
0ef404e2e7 Googletest export
Internal change

PiperOrigin-RevId: 258587862
2019-07-17 13:38:25 -04:00
misterg
3d9cdd5803 Googletest export
Fix documentation links

PiperOrigin-RevId: 258389329
2019-07-16 13:35:16 -04:00
Abseil Team
e4f097b5fb Googletest export
Update a broken link in a comment.

PiperOrigin-RevId: 257493975
2019-07-16 11:21:11 -04:00
Gennadiy Civil
5ed950c9e3 Renaming doc files to make the file names more palatable and in preparation for including documentation in sync process 2019-06-19 16:48:38 -04:00
misterg
ee32b72e12 Googletest export
gmock_output_test has to run under python2. Bazel 0.27.0 causes this test to break. Fixing it.

PiperOrigin-RevId: 253820111
2019-06-18 13:48:06 -04:00
Tom Lachecki
d515158d9c Fixed issue #2284 (Incompatibility with C++17) 2019-06-13 17:37:33 +01:00
Abseil Team
9f4f27b2a5 Googletest export
Remove GMock Doctor.
It has not been actively supported for a while.
We also now have better techniques to improve compiler errors where needed
instead of requiring a separate tool to diagnose them.

PiperOrigin-RevId: 244196068
2019-04-18 15:45:56 -04:00
misterg
fa52cd6363 Googletest export
Expose more information in SuiteApiResolver diagnostic output

PiperOrigin-RevId: 244179347
2019-04-18 15:45:49 -04:00