Commit Graph

330 Commits

Author SHA1 Message Date
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
Gennadiy Civil
a0d60bed4d Merge pull request #2170 from ngie-eign:issue-2146-ver2
PiperOrigin-RevId: 244069956
2019-04-18 09:44:24 -04:00
Enji Cooper
3829b84e99 clang: fix -Wsign-conversion errors
Cast some values as their unsigned equivalents or `size_t` to match the
parameter type used for the template object under test. Also, provide
UInt32 equivalent delegate methods for some callers (with
int-equivalents for backwards compatibility).

This closes #2146.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
2019-04-05 21:30:19 -07:00
Abseil Team
d982543131 Googletest export
Remove support for "global" ::string and ::wstring types.
This support existed for legacy codebases that existed from before namespaces
where a thing. It is no longer necessary.

PiperOrigin-RevId: 241335738
2019-04-01 15:05:10 -04:00
Abseil Team
f1883b1824 Googletest export
Remove mention of unused type ProtocolMessage.

PiperOrigin-RevId: 239242706
2019-03-21 10:43:06 -04:00
Abseil Team
a1dd07786b Googletest export
Build gmock cleanly with clang -Wextra-semi and -Wextra-semi-stmt

Extends 56ef07a203 to take -Wc++98-compat-extra-semi
(https://reviews.llvm.org/D43162) and -Wextra-semi-stmt
(https://reviews.llvm.org/D52695) into account.

For https://crbug.com/926235.

PiperOrigin-RevId: 236643095
2019-03-05 08:39:28 -05:00
Abseil Team
56ef07a203 Googletest export
Build gmock cleanly with clang -Wextra-semi

For https://crbug.com/926235.
From https://github.com/google/googletest/pull/2139.
Fixes https://github.com/google/googletest/issues/2138.

PiperOrigin-RevId: 235832527
2019-03-01 16:18:17 -05:00
Enji Cooper
1c22797cd3 Fix clang -Wunused-parameter warnings
Comment out unused method parameters in their relevant definitions.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
2019-02-13 14:38:51 -08:00
Enji Cooper
5388473acf Fix clang -Winconsistent-missing-override warnings
`DescribeTo(..)` and `MatchAndExplain(..)` in `gmock-matchers_test` both
override virtual methods. Remove the `virtual` keyword and apply `override` to
them instead.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
2019-02-13 14:38:51 -08:00
Enji Cooper
ed2fe122f8 Fix -Wunused-private-field issues with clang
Provide dummy accessors for private values that are set in initializers,
but not actually used.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
2019-02-12 16:40:01 -08:00
Abseil Team
28a96d1834 Googletest export
Fix matcher comparisons for std::reference_wrapper.

The googletest docs indicate that std::reference_wrapper should be used to for
objects that should not be copied by the matcher (in fact, the ByRef() function
is basically the same as a call to std::cref).

However, for many types (such as std::string), the overloaded operator== will
not resolve correctly. Specifically, this is problematic if operator== depends
on template argument deduction, where the same type is named on LHS and RHS.

Because template argument deduction happens before any implict conversions for
purposes of overload resolution, attempting to compare T with
std::reference_wrapper<T> simply looks like a comparison of unlike types.

For exapmle, std::reference_wrapper<std::string> is implicitly convertible to
'const std::string&', which would be able to choose an overload specialization
of operator==. However, the implicit conversion can only happen after template
argument deduction for operator==, so a specialization that would other be an
applicable overload is never considered.

Note also that this change only affects matchers. There are good reasons that
matchers may need to transparently hold a std::reference_wrapper. Other
comparisons (like EXPECT_EQ, et. al.) don't need to capture a reference: they
don't need to defer evaluation (as in googlemock), and they don't need to avoid
copies (as the call chain of matchers does).

PiperOrigin-RevId: 232499175
2019-02-12 13:20:14 -05:00
misterg
52ea4f7bea Googletest export
Mark legacy _TEST_CASE_ macros as deprecated

PiperOrigin-RevId: 232303251
2019-02-04 14:19:50 -05:00
Abseil Team
0ea2d8f8fa Googletest export
Fix stack overflow in AnyOfArray tests.

PiperOrigin-RevId: 231881125
2019-02-01 12:52:31 -05:00
Abseil Team
fdc59ffd05 Googletest export
Add AllOfArray matcher that verifies a value matches all member of some array/container/list/set/..., e.g:
EXPECT_THAT(1, AnyOfArray({1, 2, 3}))
In the simplest form this is identical to AnyOf(1, 2, 3). But unlike that one it works on containers.

Add AnyOfArray matcher that verifies a value matches any member of some
array/container/list/set/...

PiperOrigin-RevId: 230403653
2019-01-23 13:27:08 -05:00
Abseil Team
9518a57428 Googletest export
Fix mocking method arguments with templated copy constructors.

A previous change removed workarounds for old compilers from googletest and googlemock. Unfortunately, a bit of code that started as a workaround for Symbian's C++ compiler is still needed to avoid copy/move constructor ambiguity when mocking functions with certain argument types.

The test case added by this CL is extracted from Chrome's codebase, and was discovered while attempting to roll googletest.

PiperOrigin-RevId: 229801765
2019-01-18 14:06:03 -05:00
Abseil Team
0adeadd283 Googletest export
Refactor the `Invoke` and `InvokeWithoutArgs` actions:
 - Replace pump'd classes and functions with templates.
 - Make the polymorphic actions be polymorphic functors instead.
 - Fix Invoke(Callback*) to work with subclasses of the callbacks, instead of trying to diagnose that in gmock_doctor.

PiperOrigin-RevId: 229604112
2019-01-17 14:41:08 -05:00
Abseil Team
9acd065a90 Googletest export
Add move-only argument support to almost all remaining matchers.

PiperOrigin-RevId: 229030728
2019-01-14 17:02:03 -05:00
Abseil Team
097407fd3c Googletest export
Deduplicate testing::ReferenceWrapper with std::reference_wrapper.
Minor cleanups in matchers_test.

PiperOrigin-RevId: 229022872
2019-01-14 17:01:56 -05:00
Abseil Team
216c37f057 Googletest export
Drop generated file gmock-generated-internal-utils.h.

PiperOrigin-RevId: 228232195
2019-01-08 11:50:56 -05:00
misterg
14c2fba734 Googletest export
Internal Change

PiperOrigin-RevId: 227575279
2019-01-02 16:51:40 -05:00
Abseil Team
f8b1c1af17 Googletest export
Remove the #ifs for old, unsupported and buggy compilers:
* old versions of GCC & MSVC
* Symbian

PiperOrigin-RevId: 227116941
2019-01-02 16:51:33 -05:00
Abseil Team
34a99e547a Googletest export
Get rid of code generation for NiceMock / StrictMock.
They got small enough that it doesn't make sense to generate them.

PiperOrigin-RevId: 226455689
2018-12-21 11:30:20 -05:00
Abseil Team
e26a3fa13c Googletest export
Unifdef c++11-related macros from googletest now that it requires C++11.

PiperOrigin-RevId: 225905601
2018-12-20 14:09:31 -05:00
misterg
9ab640ce5e Googletest export
Suppress C4503 for MCVS , again

PiperOrigin-RevId: 225895719
2018-12-17 17:57:39 -05:00
misterg
7515e39943 Googletest export
Suppress C4503 for MCVS

PiperOrigin-RevId: 225871050
2018-12-17 15:37:31 -05:00
Abseil Team
1ec20f87e3 Googletest export
Allow container matchers to accept move-only containers.

PiperOrigin-RevId: 225667441
2018-12-17 13:53:33 -05:00
misterg
81f0026066 Googletest export
Internal Change

PiperOrigin-RevId: 225231727
2018-12-13 16:00:11 -05:00