4566 Commits

Author SHA1 Message Date
Krzysztof Kosiński
94be250af7 Add documentation for two-argument floating point matchers.
PiperOrigin-RevId: 881536386
Change-Id: Idd38bded4dda5a0d0c1c5fd7847fc8134e7c2ece
2026-03-10 11:25:48 -07:00
Abseil Team
a35bc7693c Make gmock-matchers.h auto-detect the value_type of ranges that don't have a typedef for it based on the ranges' iterators
This is needed for ranges such as [`std::ranges::subrange`](https://en.cppreference.com/w/cpp/ranges/subrange.html) that don't expose the typical typedefs.

PiperOrigin-RevId: 879124865
Change-Id: Ie89e6ff249ee861d1b2d880079dc162bb9801679
2026-03-05 10:09:30 -08:00
Abseil Team
73a63ea05d Improve str concatenation performance on MatchesTest
Update str concatenation, instead of use operation+ use absl::StrCat
whenever available.

PiperOrigin-RevId: 874649732
Change-Id: I0acd91c04a9e50fa306e7130479bc330c1a0f068
2026-02-24 09:27:22 -08:00
Abseil Team
a407966592 Revert Optimize copying of matchers vector to speed up ElementsAreArray by reserving a std::vector copied via push_back.
If the iterators are forward iterators, we can measure the size and reserve the vector, avoiding reallocations and copying.

PiperOrigin-RevId: 874172640
Change-Id: Ie081fdf7952858d7e41ddda63a3ae15d9867c8c5
2026-02-23 11:30:44 -08:00
Dillon Sharlet
73e0fc18eb Optimize copying of matchers vector to speed up ElementsAreArray by reserving a std::vector copied via push_back.
If the iterators are forward iterators, we can measure the size and reserve the vector, avoiding reallocations and copying.

PiperOrigin-RevId: 874129590
Change-Id: I6cdcaf38e28ac90c1cf596977b703d8de93994e5
2026-02-23 10:02:03 -08:00
Abseil Team
e9907112b4 Update doc for Optional.
Change a mention of Eq(Optional(nullopt)) to Optional(Eq(nullopt)).

Optional is supposed to wrap matchers, not values. For example, Optional("bla") doesn't compile but Optional(std::string("bla")) does. Optional(Eq("bla")) is the functionally correct version. Eq() cannot wrap a matcher.

PiperOrigin-RevId: 872885639
Change-Id: I941f515308fa419162998073f6da9731fcf2168a
2026-02-20 07:10:28 -08:00
Max Shavrick
850cb69efd Add string_view overload to AssertHelper
PiperOrigin-RevId: 871382613
Change-Id: I286ccbf8b8622a740e99642b4ed853e9f67cf51c
2026-02-17 10:26:39 -08:00
Abseil Team
77f6bd3e75 Update comment for SizeIs matcher.
Clarify that SizeIs only requires the container to have a size() method, and the argument type can be any type compatible with the return type of size(). The previous comment incorrectly mentioned a requirement for size_type.

PiperOrigin-RevId: 869184176
Change-Id: Ib2d867fbfecde0006734772cf07958871a171199
2026-02-12 06:25:24 -08:00
Abseil Team
f68374efa7 Replacing an internal lib name with absl in test case
PiperOrigin-RevId: 868759119
Change-Id: I85fc3723bb2108d8a3f0ec063e081d93b00ae1bf
2026-02-11 11:12:56 -08:00
Abseil Team
ef6cf65af5 Fix typo in Optional(m) description.
PiperOrigin-RevId: 868638000
Change-Id: I952801ff229e4b1d195ef69761de36c34724604e
2026-02-11 06:02:51 -08:00
Derek Mauro
5a9c3f9e8d Upgrade most builds to use Bazel 9.0.0
Keep one build on 8.5.1 to test WORKSPACE

Fixes the -Wdeprecated-declaration warnings
enabled by default in Bazel 9 that come from the
single-arg Invoke().

Fixes the new -Winconsistent-missing-override that
we intentionally use in a test.

Upgrades RE2 to a version compatible with Bazel 9.

PiperOrigin-RevId: 865966282
Change-Id: I5f7c3b60daf5f8a90be08004d96aaa59611e35c4
2026-02-05 08:42:50 -08:00
Abseil Team
32c3dce34b Display the actual error code when RE::Init() fails
PiperOrigin-RevId: 865923485
Change-Id: I5530050f7ff3fe295e2bbd7ad0dd90cd0de3e2c3
2026-02-05 06:52:14 -08:00
Derek Mauro
872d386a87 Upgrade CI to XCode 26.2
The new build environment (Sequoia) does not have CMake
pre-installed, so install it, and set the variables necessary
for parallel builds.

PiperOrigin-RevId: 865468933
Change-Id: I0316281d0065bc52b653258556a6928faacb7c0e
2026-02-04 10:23:53 -08:00
Derek Mauro
2151d93c2f Update GoogleTest CI to latest tools
PiperOrigin-RevId: 865144486
Change-Id: I5d68e07bde952e7913d3e641dfaa10d17a968a58
2026-02-03 18:45:21 -08:00
Abseil Team
7c3b4d54e3 Automated Code Change
PiperOrigin-RevId: 864656526
Change-Id: If6e887f492d312730e7ab4e124cad23823497b0d
2026-02-02 20:35:39 -08:00
Abseil Team
56efe39831 Allow implicit matcher construction from nullptr. This allows "nullptr" to be used as a valid matcher for smart pointer types.
PiperOrigin-RevId: 861759501
Change-Id: I09ff55cd532014015725ec61356f480760819b29
2026-01-27 09:35:08 -08:00
Abseil Team
5fd443cdc3 Automated Code Change
PiperOrigin-RevId: 861479667
Change-Id: I3c64fef567065529f18a04b98df7b015256dfed1
2026-01-26 20:27:23 -08:00
Abseil Team
85087857ad Automated Code Change
PiperOrigin-RevId: 857421343
Change-Id: I6b64c34c1b0ccd31ec5277fbbdcc6c0e800e6241
2026-01-16 21:50:57 -08:00
Corentin Le Molgat
ff6133ab49 cmake: Fix declspec of gtest flag when using BUILD_SHARED_LIBS=ON and absl
On windows flags declaration must be prepend by `GTEST_API_`
to have the correct declspec (dllexport or dllimport)

This patch also fix super build integration of googletest by adding the necessary `INSTALL_RPATH` and `$<BUILD_INTERFACE:` needed to be able to `FetchContent` or `add_subdirectory()` googletest in a user CMake project.

Fix #4718
related to abseil/abseil-cpp#1817

PiperOrigin-RevId: 854187933
Change-Id: I4341fdb7e88a51c5f9a1c72c58bcc8c4d6bfd1c5
2026-01-09 07:34:16 -08:00
Derek Mauro
cb1bd88191 Bump Abseil version used by GoogleTest
Making this change requires an update to the CI scripts to ignore
warnings coming from external repositories so we don't error on
deprecation warnings (RE2 has warnings about deprecated Mutex methods)

PiperOrigin-RevId: 853824282
Change-Id: Ic79663943d3b7c8cfa95e9a73b49a7ad761e1eae
2026-01-08 11:37:01 -08:00
Abseil Team
5554fcaab4 Separate the creation of the Premature Exit File from supporting Death Tests.
The [Premature Exit File](https://google.github.io/googletest/advanced.html#detecting-test-premature-exit)
can be used for more than just death tests. Runners can use it to detect any
kind of unexpected exit.

Presently, its creation is tied to whether a platform supports Death
Tests. This change removes that coupling (though if Death Tests are supported,
then the Premature Exit file is implicitly supported).

PiperOrigin-RevId: 853416224
Change-Id: I5354730b82bc8a20981120f4e1df59b58cb31f6e
2026-01-07 14:34:06 -08:00
Derek Mauro
7d7e750850 Fix "error: standard attributes in middle of decl-specifiers"
Between the friend declaration, visibility declaration, and
attribute placement rules, compilers can't seem to agree on the
how to write this, so I switched to a static factory function.

Fixes https://github.com/google/googletest/issues/4881

PiperOrigin-RevId: 852842303
Change-Id: I7fe737819abf05ea2911693f8d93683446e326cc
2026-01-06 10:37:35 -08:00
Abseil Team
76cd89bcf1 Point from the "Defining Matchers" section in the reference doc to the cookbook, which is much more detailed.
PiperOrigin-RevId: 852639172
Change-Id: Ia39a01702c7c64404950a1be19b1ebdfdff8f010
2026-01-06 00:09:54 -08:00
Abseil Team
9156d4caac Automated Code Change
PiperOrigin-RevId: 845060939
Change-Id: Iab4c4a0842e79f5835d84fa892ee977d9bdf0fe0
2025-12-15 21:11:24 -08:00
Chris Kennelly
065127f1e4 Add [[nodiscard]] throughput Google Test.
`EXPECT_THAT(foo, Matcher(bar))` can sometimes get accidentally written as a
no-op `foo, Matcher(bar)`, causing the code to be exercised but defeating the
purpose of testing.

PiperOrigin-RevId: 841880995
Change-Id: Ia55548e3dd83a6f44fff7b5433c8c8ecd7ecbe03
2025-12-08 12:55:11 -08:00
Derek Mauro
1b96fa13f5 Switch to referenceful lock holder for Abseil compatibility
PiperOrigin-RevId: 831156684
Change-Id: I8a8b017ec2fc318a65f57e04428c030c707ee682
2025-11-11 18:56:52 -08:00
Abseil Team
085af2cc08 Automated rollback of commit 37678c92fb.
PiperOrigin-RevId: 829765029
Change-Id: Ia5534b109e0abfd17a74d89ce58d6588a6255f94
2025-11-08 02:53:26 -08:00
Abseil Team
37678c92fb gtest_fail_if_no_test_selected: Rephrase error message.
Sharded tests interact awkwardly with --gtest_fail_if_no_test_selected, but we
can't speak clearly enough to the use cases to complicate the mental model, so
instead we attempt to clarify the simplest approach to debugging a single test
when sharding and --gtest_fail_if_no_test_selected are both in use: unset the
flag.

PiperOrigin-RevId: 829686145
Change-Id: I9ebbddc6e7537feefe2a3707fd323fc9132b99d1
2025-11-07 20:50:29 -08:00
David Pizzuto
dedab73a68 gtest_fail_if_no_test_selected: Rephrase error message.
Sharded tests interact awkwardly with --gtest_fail_if_no_test_selected, but we
can't speak clearly enough to the use cases to complicate the mental model, so
instead we attempt to clarify the simplest approach to debugging a single test
when sharding and --gtest_fail_if_no_test_selected are both in use: unset the
flag.

PiperOrigin-RevId: 829609266
Change-Id: I090d5bfac979171532249e9312feef8d9aad5f16
2025-11-07 16:02:48 -08:00
Abseil Team
6ec14dfd8c Modernize example of combining matchers.
As of C++14 an ordinary function can have an `auto` return type.

PiperOrigin-RevId: 826617761
Change-Id: I2ceecc8430643c0ac7843fb216b5a117cfe10ab3
2025-10-31 13:56:00 -07:00
Justin Bassett
17d335d7c7 Remove short-circuiting from AllOf, for better failure messages
For `EXPECT_THAT` matcher usage, showing only the first failure meant
that users would sometimes have to make a fix and run the test again
only to notice that there's another failure. It's better to show more
failures so that the user can fix several issues in one go.

In practice, very little code actually wants the short circuiting here,
only a handful of cases with custom matchers used like
`AllOf(BoundsCheck(), UncheckedAccess())`. These cases are fixable by
refactoring `UncheckedAccess()` to instead also apply a bounds check to
fail the matcher rather than crash. Notably, this change doesn't affect
`AnyOf`, so another workaround is to change `AllOf(m1, m2, ...)` into
`Not(AnyOf(Not(m1), Not(m2), ...))`.

PiperOrigin-RevId: 826316273
Change-Id: Ie8186f75c10443d8da35b5d07b6a8cd9ae85b451
2025-10-30 21:53:01 -07:00
Derek Mauro
4fe3307fb2 macOS CI: Move the Bazel vendor_dir to ${HOME} to workaround a Bazel issue
where it does not work when it is in ${TMP} and also fix the quoting
which was causing it to incorrectly receive the argument

https://github.com/bazelbuild/bazel/issues/27156

PiperOrigin-RevId: 826083231
Change-Id: If8f069c42c62434893db27bdaae0b0e25b67839d
2025-10-30 10:11:17 -07:00
Abseil Team
b2b9072ecb Mark InternalDefaultActionSetAt as nodiscard.
PiperOrigin-RevId: 820207225
Change-Id: I8e053f724c18b466bd287f80a720542a535615d2
2025-10-16 06:31:44 -07:00
Abseil Team
e17e37a115 Automated Code Change
PiperOrigin-RevId: 820039898
Change-Id: I910d8ec41198794e7344a2d79566a19243532251
2025-10-15 21:01:54 -07:00
Abseil Team
8dbd60f7d5 Restore the documentation of AnyWith<T>(m) in the matchers reference.
PiperOrigin-RevId: 818813216
Change-Id: If4cb881a61a05b2c6634aa0d5ee66ea2962f168a
2025-10-13 13:44:23 -07:00
Abseil Team
2ce9d8f2e8 Allow for passing non-pointers to DeleteArg and have them emit a deprecation warning instead.
This allows for simpler migration of function args to smart pointers without needing all changes to tests to be atomic.

PiperOrigin-RevId: 818635600
Change-Id: I9434685d9640f82b98d0b5261701b78c93d3ec1e
2025-10-13 06:51:01 -07:00
Abseil Team
279f847946 Fix typo.
PiperOrigin-RevId: 816417379
Change-Id: I4ccfe2bf291b8c2b318ac6e2d0c2d176684e42c8
2025-10-07 16:03:37 -07:00
Abseil Team
de1c609262 Automated Code Change
PiperOrigin-RevId: 816182689
Change-Id: Ie2aaa55be6c2e4508aaafa7a0b30fe52ec334893
2025-10-07 06:39:30 -07:00
Abseil Team
9706f75b8f Automated Code Change
PiperOrigin-RevId: 813050069
Change-Id: I7c778db5bda5d681097af5d3569b5f4b980603e4
2025-09-29 20:05:42 -07:00
Derek Mauro
50b8600c63 Add rules_cc dependency, required by Bazel going forward
This also adds the dependencies of rules_cc to WORKSPACE.
bzlmod automatically pulls in dependencies.
skylib is removed as it is pulled in by a deps function.

PiperOrigin-RevId: 808659470
Change-Id: Idc41cad7b05019793d4a1898bdb80bc4797da5cf
2025-09-18 11:16:02 -07:00
Derek Mauro
0934b7e112 Use an internal symbol for deprecate-and-inline that allows
the use of a deprecation message

PiperOrigin-RevId: 807753856
Change-Id: I34b0c7c6faf34cad11ea2aca5ccd16bca16acdec
2025-09-16 10:39:10 -07:00
Abseil Team
4969d0ad54 Automated Code Change
PiperOrigin-RevId: 806527439
Change-Id: I2e9aa5de44c011938e0bfc8e86af6c7d10c23ab0
2025-09-12 20:45:06 -07:00
Derek Mauro
9df216cc9d Update spelling of Mutex::lock and Mutex::unlock for compatibility
with the standard and the latest Abseil

PiperOrigin-RevId: 806260850
Change-Id: Ie973be4a3aaf7e174cd692ce6df7a82c8f261bf7
2025-09-12 06:17:43 -07:00
Derek Mauro
7917641ff9 Bump Abseil dependency to 20250814.0
PiperOrigin-RevId: 802131359
Change-Id: I96671848148ca51c755c1b3598af32a444ac9739
2025-09-02 07:15:01 -07:00
Abseil Team
eb2d85edd0 Remove unused syslog dependency for Fuchsia.
PiperOrigin-RevId: 798883577
Change-Id: Id248b44a45c6d3eb173513b1cd2bb8fb564885ed
2025-08-24 14:51:30 -07:00
Abseil Team
6986c2b575 Internal header include changes.
PiperOrigin-RevId: 797151958
Change-Id: I26ce36684e8822cd76723e664782764cf222152c
2025-08-19 22:05:22 -07:00
Abseil Team
a05c091507 Deprecate single-argument DoAll and Invoke.
PiperOrigin-RevId: 795969677
Change-Id: I56d88ec715475d91fb527a9281bc62574fb4608b
2025-08-16 20:08:07 -07:00
Abseil Team
244cec869d Update the document in typed tests to use using-declaration instead of typedef
PiperOrigin-RevId: 793600153
Change-Id: I0c78f180f3b681ef20133af2cc822af66c3344fe
2025-08-11 05:10:05 -07:00
Abseil Team
373af2e3df Provide a better error message when ASSERT and SKIP macros are used in methods that return values
PiperOrigin-RevId: 788083860
Change-Id: I91583f0c0f816144428d56ab07e58fd035c532d1
2025-07-28 11:13:39 -07:00
Abseil Team
32f9f4c82a Skip the predicate on SIGSEGV in death-test on Android builds with API level <= 23.
PiperOrigin-RevId: 786394374
Change-Id: I5188b55ae8ae6d3188e6492f3865b21ae6d2285e
2025-07-23 13:04:17 -07:00