423 Commits

Author SHA1 Message Date
Abseil Team
71815bbf7d Automated Code Change
PiperOrigin-RevId: 682549952
Change-Id: Ica81f0020c3001c01543a5851dae7d0b42730c66
2024-10-04 20:54:14 -07:00
Abseil Team
a1e255a582 Optional(): Add support for std::optional<>-like types lacking bool conversion.
PiperOrigin-RevId: 681053268
Change-Id: If80ba667fd4c91340e1405a9691f5ca0350fa9eb
2024-10-01 09:35:17 -07:00
Abseil Team
6dae7eb4a5 Use matcher's description in AnyOf when matcher has no explanation.
PiperOrigin-RevId: 675298308
Change-Id: I32d32cafebc7a63fd03e6d957c3a47043d71e5d9
2024-09-16 14:49:27 -07:00
Abseil Team
0953a17a42 Automated Code Change
PiperOrigin-RevId: 668944316
Change-Id: I65aa0a4f3b8a980242849963a3e921ec7fd92b28
2024-08-29 08:17:22 -07:00
Abseil Team
ffa31aec1c Directly include gmock.h and gtest.h in gmock-matchers tests.
These headers have been included through `gmock-matchers_test.h`

PiperOrigin-RevId: 657612455
Change-Id: I65675f1cfe7789f1821ccacbe60acf90efd5c221
2024-07-30 09:03:18 -07:00
Abseil Team
5bcb2d78a1 Use matcher's description in AllOf if matcher has no explanation.
PiperOrigin-RevId: 655569834
Change-Id: Ia760d74d1cdde766e9719864c5e19c0159da3128
2024-07-24 08:07:57 -07:00
Aaron Jacobs
352788321f gmock-actions: make DoAll convert to OnceAction via custom conversions.
Currently it will refuse to become a `OnceAction` if its component sub-actions
have an `Action` conversion operator but don't know about `OnceAction` in
particular because although `Action` is convertible to `OnceAction`, the
compiler won't follow the chain of conversions.

Instead, teach it explicitly that it can always be a `OnceAction` when it can be
an `Action`.

PiperOrigin-RevId: 655393035
Change-Id: Ib205b518ceef5f256627f4b02cd93ec9bd98343b
2024-07-23 19:43:42 -07:00
Aaron Jacobs
57e107a10e Run clang-format.
PiperOrigin-RevId: 655106304
Change-Id: Ie69b407fce74b31cf71d6dcc1361910d30e86bb5
2024-07-23 03:57:23 -07:00
Abseil Team
d49a665484 Use matcher's description in AllOf if matcher has no explanation.
PiperOrigin-RevId: 652798234
Change-Id: I8e92248a2d9faf2a5719fe220145ea563acc14ff
2024-07-16 05:22:42 -07:00
Abseil Team
417158b8bc Use matcher's description in AllOf if matcher has no explanation.
PiperOrigin-RevId: 652634229
Change-Id: I5fd7eaef4db3dea3d4142e1fb5fc97e46f654358
2024-07-15 16:40:10 -07:00
Abseil Team
c8393f8554 Print mismatches for UnorderedElements() of different sizes.
Changes the behavior of UnorderedElements()/UnorderedElementsAreArray() to print items-without-matchers and matchers-without-items in the case where the actual and expected are different sizes.

PiperOrigin-RevId: 635451316
Change-Id: I2181bb28a14c14cdb577af9268d403e12e942bea
2024-05-20 07:36:47 -07:00
Abseil Team
c231e6f5b1 Add test for move-only type in Action signature
PiperOrigin-RevId: 616031018
Change-Id: Ie724f9562174387eab866a824d28106f344c558d
2024-03-15 00:00:12 -07:00
Abseil Team
e4fdb87e76 Accept one-shot callables in InvokeArgument.
PiperOrigin-RevId: 611467660
Change-Id: Ic89ffc986141bee61f835cb60088aee92eb8bad9
2024-02-29 07:42:26 -08:00
Abseil Team
dddb219c3e Accept move-only callables in InvokeArguments
PiperOrigin-RevId: 594223533
Change-Id: I491fae7d851d4e0df07fb3627416949071fec8d6
2023-12-28 04:04:00 -08:00
Abseil Team
76bb2afb8b Implement testing::Rethrow to throw exceptions more easily via std::exception_ptr
We avoid overloading or specializing `testing::Throw` as this is fundamentally a different operation than throwing the object.
However, we disable the corresponding overload of `testing::Throw` to prevent likely mistakes in the usage.

Fixes: #4412
PiperOrigin-RevId: 585745469
Change-Id: I03bb585427ce51983d914e88f2bf65a13545c920
2023-11-27 13:32:49 -08:00
Dino Radakovic
518387203b StartsWith: Explicitly construct matcher-typed strings from matchee parameter
The current implementation breaks for absl::string_view on gcc, c++14: https://godbolt.org/z/Tzd3q1fqx

Closes #4391

PiperOrigin-RevId: 575853981
Change-Id: I7b782598add480eb69d4ca27ea4a4bf5f758f6a3
2023-10-23 10:11:36 -07:00
Abseil Team
762d3a7f66 Clean up typos: Exhaused => Exhausted
PiperOrigin-RevId: 558801066
Change-Id: Ia225d12014748db87639414f4c8c28a0d0e9e489
2023-08-21 08:47:54 -07:00
Copybara-Service
a3580180d1 Merge pull request #4146 from lygstate:fixes_std_pair_diff
PiperOrigin-RevId: 528781910
Change-Id: I4038332a6255921792bfb4a8098aa84243d48e15
2023-05-02 07:52:02 -07:00
Andy Soffer
76bce79a34
Merge branch 'main' into fixes_std_pair_diff 2023-05-01 14:27:38 -04:00
Dino Radakovic
797b0ad2a3 Use GTEST_INTERNAL_CPLUSPLUS_LANG instead of __cplusplus
Some versions of MSVC provide incorrect values for the latter and rely on _MSVC_LANG instead.
Fixes #4226.

PiperOrigin-RevId: 527919195
Change-Id: Ifcca4612074f5ebc5337094426866a187f79f90a
2023-04-28 10:16:07 -07:00
Tom Hughes
0bdaac5a14 Add qualifier to avoid argument dependent lookup
PiperOrigin-RevId: 527740306
Change-Id: I61308cc232c346d5ff8b0548d4c552a59633fffc
2023-04-27 18:17:59 -07:00
Patryk Gawroński
51eeae5a55 gmock: fix issue #4222
Rename 'Result' struct to 'NonMoveableStruct' in
gmock-spec-builders_test.cc in ExpectCallTest.NonMoveableType test
2023-04-25 01:45:26 +02:00
Tom Hughes
783d00fd19 Use '=default' to define trivial constructor/destructors
https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-equals-default.html

PiperOrigin-RevId: 526079054
Change-Id: Ia4db21e3e5f58b90de05d52fd94b291ed06d785d
2023-04-21 10:41:25 -07:00
Tom Hughes
baf182e006 Use the empty method to check for emptiness
PiperOrigin-RevId: 526046714
Change-Id: I6ad0deff2a7f6dfef75a643c95ad914c83b9ba38
2023-04-21 08:42:42 -07:00
Tom Hughes
a5308bb992 Add missing std includes
PiperOrigin-RevId: 525850646
Change-Id: I64387f5b933beb79cd05636dca81b7a75213383e
2023-04-20 14:29:09 -07:00
Aaron Jacobs
5fce13091d gtest.cc: add a newline after a failure when there is no OS stack trace.
This makes the behavior consistent when GTEST_STACK_TRACE_DEPTH is set to zero
and not: there is always vertical whitespace separating failure messages.

PiperOrigin-RevId: 518744611
Change-Id: I5b4af40633849850660504c3f497a76601d4311d
2023-03-22 20:19:44 -07:00
Abseil Team
471087fbfc Introduce std::make_unique and bool literals where possible
PiperOrigin-RevId: 517910526
Change-Id: I398704f4b2ca0a55c86a06ca8b47d34c8670ddd7
2023-03-20 02:43:48 -07:00
Tom Hughes
dc10c3b5e5 Use "#ifdef" with public macros
This allows compilation with "-Wundef" (#3267).

PiperOrigin-RevId: 513944726
Change-Id: I1a3854bb2333d5dec6c0ff91ee1eddd9a766ab91
2023-03-06 07:15:44 -08:00
Tom Hughes
23142843f7 Use "#ifdef GTEST_OS_..." instead of "#if GTEST_OS_..."
This is compatible with compiling with "-Wundef" (#3267).

PiperOrigin-RevId: 513943378
Change-Id: I47cf5fabbb77be061c4483a0adc54511af6b191c
2023-03-06 07:14:21 -08:00
Yonggang Luo
6f1c4b3d7b Fixes the test gmock_output_test.py with MSVC
For MSVC, gmock_output_test.py output struct std::pair<int,bool>, for GCC, it's output
std::pair<int, bool>, it's not the same, my intention is getting these to be same by removing
struct  for MSVC's outptu, and strip redundant space for GCC.

As a by-product,
```
#ifdef _MSC_VER
#define ERROR_DESC "class std::runtime_error"
#else
#define ERROR_DESC "std::runtime_error"
#endif
```
can be simplified to

```
#define ERROR_DESC "std::runtime_error"
```

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
2023-03-01 00:13:32 +08:00
Abseil Team
7a7231c442 Fix link in ReportUninterestingCall message
This CL changes the link in the ReportUninterestingCall message from
.../gmock_cook_book.md#knowing-when-to-expect to
.../gmock_cook_book.md#knowing-when-to-expect-useoncall. This is necessary
following https://github.com/google/googletest/commit/31ff597.

PiperOrigin-RevId: 510138974
Change-Id: Ic98c84b07751d27dfc95eddbe7874f76d68b456f
2023-02-16 07:33:48 -08:00
Yonggang Luo
097f64e986 Revert "Fix gmock_output_test when using MSVC"
This reverts commit 0a3b403fe037ff80daa1826ae99eed41e94dea05.
2023-02-09 15:29:01 +08:00
Tom Hughes
0570e2d930 Remove GTEST_USES_PCRE references
Nothing defines GTEST_USES_PCRE anymore. It was only meant for
internal use, so nothing public should be relying on it:
https://github.com/google/googletest/issues/2735#issuecomment-644849438.

Found when compiling with "-Wundef".

Fixes #2735.

PiperOrigin-RevId: 507823660
Change-Id: Ie19e576ff01dc3b16381338578ece92adccfc09b
2023-02-07 10:38:08 -08:00
Abseil Team
3d568bdda5 Add support for the alternative base64 encoding in RFC 4648 section 5 to WhenBase64Unescaped.
PiperOrigin-RevId: 507527786
Change-Id: Ie5e088b1814981f6c760d7e25418a430172705ec
2023-02-06 11:00:05 -08:00
Tom Hughes
ebedaa18c7 Fix include order
PiperOrigin-RevId: 506424617
Change-Id: If7f0beb92022589523db204a6b5cbe9249cebf62
2023-02-01 14:32:28 -08:00
Tom Hughes
394a8a568c Remove GMOCK_RENAME_MAIN
GMOCK_RENAME_MAIN appears unused.

PiperOrigin-RevId: 506387823
Change-Id: I732c1f64f9038991a5c9aea1f2ad6fff07622afa
2023-02-01 12:14:47 -08:00
Tom Hughes
0a3b403fe0 Fix gmock_output_test when using MSVC
std::pair is printed as "struct std::pair<int,bool>" when using MSVC
vs "std::pair<int,bool>" with other compilers. Switch to "std::tuple", which
is the same for all compilers.

See
https://learn.microsoft.com/en-us/cpp/standard-library/pair-structure
https://learn.microsoft.com/en-us/cpp/standard-library/tuple-class

PiperOrigin-RevId: 506340295
Change-Id: Ib4ce2f74d54888a4e4173f42da1b55cc5583f7d4
2023-02-01 09:33:23 -08:00
Tom Hughes
4fb7039fda Use GTEST_DISABLE_MSC_WARNINGS macros to disable warnings
Prior to this change we had a mixture of pragmas and
GTEST_DISABLE_MSC_WARNINGS; this change consolidates all instances
to use the macros.

PiperOrigin-RevId: 505786926
Change-Id: I2be8f6304387393995081af42ed32c2ad1bba5a7
2023-01-30 13:45:46 -08:00
Tom Hughes
f1c05d4544 Use explicit short to fix MSVC compiler warning
warning C4244: 'initializing': conversion from 'int' to 'short', possible
loss of data

PiperOrigin-RevId: 505774670
Change-Id: I3524040334a4b265bae12cfacdd2b615cbb1cfc8
2023-01-30 12:58:34 -08:00
Copybara-Service
e3dbee4b35 Merge pull request #4115 from SunBlack:codespell
PiperOrigin-RevId: 505740434
Change-Id: I963f6a6b667a030c87f211173f578f7c35733e68
2023-01-30 10:55:07 -08:00
Tom Hughes
137dcd18cc Remove pylint disable comments that no longer trigger warnings
PiperOrigin-RevId: 504633130
Change-Id: I3fdbc83975fea97aa53f7325d323adead0a30e24
2023-01-25 12:35:34 -08:00
Tom Hughes
d1ad27e0a4 Fix formatting in subset of Python files
These files were formatted with automated tools. The remaining Python
files require some manual fix ups, so they will be fixed separately.

PiperOrigin-RevId: 504579820
Change-Id: I3923bd414bffe3ded6163ec496cd09ace3951928
2023-01-25 09:14:26 -08:00
Tom Hughes
2491710524 Fix formatting of C++ files
PiperOrigin-RevId: 504325204
Change-Id: Iaa1d6d0ab1dccaaeef26f9cb109d530835499240
2023-01-24 11:10:09 -08:00
Derek Mauro
544c96ed5b Remove FloatingPoint::Max() in favor of std::numeric_limits::max()
In #4113 a user says Max clashes with a macro. Since it is only used in
a test, use std::numeric_limits::max() instead.

Note that in headers, the macro issue can be mitigated with
parenthesis like this: `(std::numeric_limits<T>::max)()`

PiperOrigin-RevId: 504284906
Change-Id: Ibf430caec1a6afdf6b303534fec6a4fd00a6373f
2023-01-24 08:41:35 -08:00
Tom Hughes
bdb3b0a493 Replace deprecated python calls
assert_ -> assertTrue/assertFalse/assertIn/assertNotIn
assertEquals -> assertEqual

PiperOrigin-RevId: 502654909
Change-Id: I25d30095a83c3806606cb80d676b3c979495e6bd
2023-01-17 12:16:29 -08:00
Abseil Team
ac7a126f39 gmock_output_test: normalize golden file output to unix line endings
When checked out on Windows, the repo might use \r\n line endings,
and so the golden output has them.  Adjust for that.

PiperOrigin-RevId: 502577222
Change-Id: Iabfe537f6d95a49bf6bdcb934e855d28c65f6f89
2023-01-17 07:12:50 -08:00
Tom Hughes
356fc30125 Fix -Wshadow warnings
../googlemock/test/gmock-actions_test.cc:687:36: warning: declaration of ‘v’ shadows a member of ‘testing::{anonymous}::ReturnTest_SupportsReferenceLikeReturnType_Test::TestBody()::Result’ [-Wshadow]
  687 |     Result(const std::vector<int>& v) : v(&v) {}  // NOLINT
      |            ~~~~~~~~~~~~~~~~~~~~~~~~^
../googlemock/test/gmock-actions_test.cc:686:29: note: shadowed declaration is here
  686 |     const std::vector<int>* v;
      |                             ^

../googlemock/test/gmock-actions_test.cc: In constructor ‘testing::{anonymous}::ReturnTest_PrefersConversionOperator_Test::TestBody()::Out::Out(int)’:
../googlemock/test/gmock-actions_test.cc:720:28: warning: declaration of ‘x’ shadows a member of ‘testing::{anonymous}::ReturnTest_PrefersConversionOperator_Test::TestBody()::Out’ [-Wshadow]
  720 |     explicit Out(const int x) : x(x) {}
      |                  ~~~~~~~~~~^
../googlemock/test/gmock-actions_test.cc:718:9: note: shadowed declaration is here
  718 |     int x;
      |         ^

PiperOrigin-RevId: 501580618
Change-Id: I584710fbbe440ec724f88746e51f3be5653c32d5
2023-01-12 09:04:13 -08:00
SunBlack
64e0945546 Fix typos found by codespell 2023-01-04 17:36:11 +01:00
Abseil Team
1f643f71d4 Make SizeIsMatcher::Impl conform to the contract of MatcherDescriberInterface.
MatcherDescriberInterface specifies that DescribeTo "should print a verb phrase", but "size ..." is not a verb phrase. Currently, ElementsAre(SizeIs(9)) is described as "has 1 element that size is equal to 9". With this change, it will be described as "has 1 element that has a size that is equal to 9".

PiperOrigin-RevId: 492022324
Change-Id: I4083335f2419462464957521c1e033643b53b763
2022-11-30 14:42:31 -08:00
Abseil Team
a16bfcfda1 Disables -Wunused-member-function and -Wused-but-marked-unused that trigger via MOCK_METHOD() and EXPECT_THAT() macros.
Fixes: #4052, #4055
PiperOrigin-RevId: 491647393
Change-Id: I8e2ad838156fa8c7e9dccd1740af797e694992b6
2022-11-29 08:44:15 -08:00