Commit Graph
100 Commits
Author SHA1 Message Date
Abseil Team 4267679b68 Fix the compilation of the matcher UnorderedElementsAre when used with
a native pointer and size

PiperOrigin-RevId: 983276604
Change-Id: I76ee9771bae7b0801e6aa74c0786bf5809b43226
2026-09-17 10:23:06 -07:00
Abseil Team f840327b0f Fix misc-override-with-different-visibility warning
TEST_P overrides TestBody() with public visibility instead
of private as defined in the Test base class

PiperOrigin-RevId: 981828756
Change-Id: I9ad0852642520b6b8585df15c3e63885f6fbd135
2026-09-15 08:06:08 -07:00
Abseil Team 8eff9e3366 Fix a null initializer for pthread_t in GTest's Mutex.
Static (linker-initialized) global mutex has a
pthread_t member, which is currently initialized
with 0. This is incorrect, since pthread_t is
an opaque type, which can be a struct in some
libc implementations (e.g. in LLVM-libc). Using
POSIX-specified PTHREAD_NULL is a better option,
however it may not be available on older platforms.
So, use PTHREAD_NULL if it's available, but
fallback to the original behavior for compatibility.

PiperOrigin-RevId: 979239391
Change-Id: I79a292868f85f62bb1962b3ac956ad40eb145907
2026-09-10 09:47:58 -07:00
Abseil Team dd0a37b843 Use std::regex (defining GTEST_USES_STD_RE) instead of hand-rolled regex engine (defining GTEST_USES_SIMPLE_RE) in GoogleTest
Previously, non-Abseil builds of GoogleTest used either the POSIX <regex.h> header, or a hand-rolled bare-bones regex engine in GoogleTest.

This commit removes the custom regex engine and switches to the C++11 <regex> header instead, which primarily affects Windows builds. Correspondingly, the GTEST_USES_SIMPLE_RE macro is removed and GTEST_USES_STD_RE is defined in its place, so users that depend on the macro should update their code accordingly.

This commit may break on any exotic toolchains or platforms that lack all of these libraries, but these have been long unsupported, as GoogleTest requires C++17.

Note: MSVC's engine can be prone to overflowing the stack on some patterns and inputs. As a trivial example:

    #include <regex>

    int main() {
      std::string corpus;
      for (size_t i = 0; i < 1000; ++i) {
         corpus += "a\n";
      }
      // Stack overflow
      std::regex_match(corpus, std::regex("(\n|.)*", std::regex_constants::ECMAScript));
    }

In such cases, it is recommended to use alternative patterns accomplishing the same goal, such as checking for pieces of a pattern independently.

PiperOrigin-RevId: 978659894
Change-Id: I4594285e696af12a008e1e4cee300f292bbdbf32
2026-09-09 11:34:13 -07:00
Abseil Team 283c17563f Remove workarounds for MSVC with versions _MSC_VER < 1925
GoogleTest only supports Visual Studio 2022 or later.

PiperOrigin-RevId: 975742423
Change-Id: Ibc09f5cd2c8cb1f9097bd27b584ec136ec2ce42a
2026-09-03 08:29:26 -07:00
Abseil Team efbef50b59 Remove workarounds for MSVC with versions _MSC_VER < 1915
Compilers before this do not support C++17 at all, which is required by GoogleTest.

PiperOrigin-RevId: 975312508
Change-Id: I77a0649a11ea9162010a8a26807e4a970610616f
2026-09-02 14:02:24 -07:00
Abseil Team 8ecdd89c69 Remove obsolete IBM VisualAge / XL C++ workarounds in googletest
Classic IBM XL C/C++ (__IBMCPP__) only supported up to C++14 (V16.1 for AIX) before IBM retired the proprietary frontend and transitioned to IBM Open XL C/C++ (which is Clang-based and defines __clang__).

Since the legacy XL frontend never supported C++17, the workarounds are obsolete and should be removed.

PiperOrigin-RevId: 975123206
Change-Id: Ia706c7759d3f1df73d375fca68f91eee3aaef825
2026-09-02 07:37:31 -07:00
Abseil Team 5f31f20eda Remove obsolete Borland C++ workarounds in googletest
Classic Borland C++ (bcc32) only supported up to C++98/C++03 before Embarcadero transitioned C++Builder to Clang-based compilers (bcc32c/bcc64, which define __clang__) and is long obsolete.

PiperOrigin-RevId: 974883761
Change-Id: I220f736485710f37fe4a2b922bda3116304e3812
2026-09-01 21:38:56 -07:00
Abseil Team 3b49a56fe3 Remove obsolete Sun Studio/Solaris workarounds in googletest
Oracle Developer Studio 12.6 (released July 2017) was the final release of the SunPro/Solaris Studio compiler suite, providing only partial/experimental support for C++14 before Oracle discontinued active compiler development. Sun Studio never supported C++17.

Additionally, Solaris 8 and 9 reached EOL over a decade ago. Therefore, workarounds for non-standard putenv/getenv memory behavior in legacy Solaris libc are obsolete, and should be removed.

PiperOrigin-RevId: 974866696
Change-Id: I29db7a1123642c7db0975522c641bd0500a40682
2026-09-01 20:54:21 -07:00
Abseil Team c3e1e7fe8e Avoid linter warning about multiline comments
PiperOrigin-RevId: 974701766
Change-Id: I8098fe21ed27f0e3bed9568837579551fe0918dd
2026-09-01 14:16:50 -07:00
Abseil Team defb708946 Remove obsolete HP aC++ workarounds in googletest
HP aC++ for HP-UX on Itanium (A.06.28) only supported up to C++03 and partial C++11 before HPE placed HP-UX and Itanium into maintenance mode. It was discontinued without ever supporting C++14 or C++17.

As GoogleTest requires C++17, the HP-specific workarounds are obsolete and should be removed.

PiperOrigin-RevId: 974700202
Change-Id: Iff9a41101f90f65d76394752bf197b8f2e97311f
2026-09-01 14:13:40 -07:00
Abseil Team 4957858705 Remove some obsolete GCC workarounds
PiperOrigin-RevId: 974635453
Change-Id: I7bb066be8461080d6f908671d2001dbca3ee4a03
2026-09-01 12:12:57 -07:00
Abseil Team c06edf0146 Remove obsolete Clang check for __has_warning("-Wzero-as-null-pointer-constant")
The warning has been in Clang since version 5.0.

PiperOrigin-RevId: 974506387
Change-Id: I0d1c37511f098fdd6336c48fffd8db8218c19586
2026-09-01 08:17:40 -07:00
Abseil Team d94a7326e9 Remove BiggestInt and just use intmax_t
PiperOrigin-RevId: 974011716
Change-Id: I5dacc23eae25b749ad6c77b10b9bc0d75fac11c5
2026-08-31 12:16:29 -07:00
Abseil Team 36ba75f0ad UnorderedElementsAre(): Allow matching containers where end is a [sentinel](https://en.cppreference.com/cpp/iterator/sentinel_for). ElementsAre already supports that.
PiperOrigin-RevId: 971869110
Change-Id: I1316463fbd0b532bdf5d636d47165aace84b3801
2026-08-27 04:14:10 -07:00
Abseil Team 938220d0f6 Use non-POSIX function names on MSVC to avoid errors when _CRT_DECLARE_NONSTDC_NAMES = 0
Fixes: #4571
PiperOrigin-RevId: 971422465
Change-Id: Ic32cceedd80490bd688cb240600becc23efb7191
2026-08-26 12:05:52 -07:00
Abseil Team e273a2d81e Use non-POSIX function names on MSVC to avoid errors when _CRT_DECLARE_NONSTDC_NAMES = 0
Fixes: #4571
PiperOrigin-RevId: 970216754
Change-Id: Iadfed64d59d0cfd32568a3f46001b19f64cfb125
2026-08-24 18:40:34 -07:00
Abseil Team bfff9fc387 Use non-POSIX function names on MSVC to avoid errors when _CRT_DECLARE_NONSTDC_NAMES = 0
Fixes: #4571
PiperOrigin-RevId: 970040273
Change-Id: Id1aed06aeddde7dbcdff6eaa4702f356c034cadb
2026-08-24 13:25:36 -07:00
Abseil Team 91c99b6ffe Add missing const in INSTANTIATE_TEST_SUITE_P.
Dropping this causes tools like [misc-const-correctness](http://clang.llvm.org/extra/clang-tidy/checks/misc/const-correctness.html) to flag GTEST macro invocations as non-const-correct.

PiperOrigin-RevId: 966588433
Change-Id: I896acca9e079288e971a2912c7aa6d17ec6a15e4
2026-08-18 07:44:33 -07:00
Abseil Team 7358557f03 Remove wchar_t overloads if GTEST_HAS_STD_WSTRING is disabled
PiperOrigin-RevId: 966053142
Change-Id: I6535e5577b430186a57ad9c401877aaa83cf37d1
2026-08-17 10:35:06 -07:00
Abseil Team 71edd0ef29 Extract GTEST_HAS_NATIVE_WCHAR
Define `GTEST_HAS_NATIVE_WCHAR` as a replacement for the `!defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)` condition used to remove `wchar_t*` overloads when `wchar_t` is a typedef. Remove `GMOCK_WCHAR_T_IS_NATIVE_` and migrate its uses to the GTest define.

PiperOrigin-RevId: 966022317
Change-Id: Ic929f45763566b9e8d194f280d1f32f5a582ff61
2026-08-17 09:42:15 -07:00
Abseil Team a2118f6587 Use std::make_unique to avoid clang-tidy false positive in GTEST_TEST_ macro.
PiperOrigin-RevId: 965352463
Change-Id: I4062f4f7a48cba6bf514abd7860d422f6e98cee7
2026-08-15 18:34:42 -07:00
Abseil Team 49495eacfd Use STL capabilities to choose GTEST_HAS_STD_WSTRING default
If the standard library claims not to support wide character strings, disable `GTEST_HAS_STD_WSTRING` and disallow users overriding it. If the standard library implementation can't be recognized, fall back to using the existing list of OSes with a known lack of support.

PiperOrigin-RevId: 964237076
Change-Id: I906f296259f8f17099990d51447a0d0d04dead66
2026-08-13 12:44:03 -07:00
Abseil Team aa1eefe02c Don't reference std::char_traits<wchar_t> when !GTEST_HAS_STD_WSTRING
If the standard library doesn't support wide character strings, `std::char_traits<Char>` won't be defined, so the definition of `PrintTo` shouldn't reference it. Use `wstrlen` directly instead.

PiperOrigin-RevId: 964168903
Change-Id: Ic628e6583679073b47bb1218dcf52b4c9eadaaf6
2026-08-13 10:39:39 -07:00
Abseil Team 002d14757f When Return is passed to WillOnce (i.e. converted to OnceAction) delegate to be equivalent to Return(ByMove(...))
This should eliminate most required usages of ByMove(...).

PiperOrigin-RevId: 964026018
Change-Id: I2dd5a56842ae3823b200c16b575960b6c367ca20
2026-08-13 05:34:04 -07:00
Abseil Team 02e50550c6 Default-enable wstring support for Android API level 21 and above.
Android started supporting std::wstring with API Level 21 (Lollipop). On Android, unless `GTEST_HAS_STD_WSTRING` is explicitly defined, set it based on the current Android API level.

PiperOrigin-RevId: 963538624
Change-Id: I1a19c4e5b0fef841e0650a1f95b45fa3439dee92
2026-08-12 10:47:59 -07:00
Abseil Team 4cb0ab12a1 Remove -WX to prevent compilation errors for users when a symbol becomes deprecated
Fixes: #5048
PiperOrigin-RevId: 960463020
Change-Id: I88690156683c995735c1c7495addab67a66b7877
2026-08-06 13:13:43 -07:00
Abseil Team 4f472747b1 Set GTEST_INTERNAL_HAS_STRING_VIEW = 1 in googletest as C++17 always supports it
PiperOrigin-RevId: 959873168
Change-Id: I66fc09077383f307c98a62f67a57005ce3c96502
2026-08-05 14:31:52 -07:00
Abseil Team c5a47cc5bd Fix forward broken gmock-matchers_test
Missing #if GTEST_HAS_STD_WSTRING around ToString() in the test

PiperOrigin-RevId: 959658357
Change-Id: I5e601749205672c4582df518c85552fb48b6147c
2026-08-05 07:52:19 -07:00
Abseil Team 488c47cc68 Make string matchers work with std::wstring_view
This reapplies the change that was rolled back, with the change that it removes the convertibility requirement to string_view, because that excluded some desirable explicit conversions (like absl::Cord). Note that this is now the same criterion previously used by testing::internal::StringLike.

Fixes: #4912
PiperOrigin-RevId: 959205696
Change-Id: I002cb1224f5a2701bdf8e68ea4d91776b9c38593
2026-08-04 13:42:29 -07:00
Abseil Team 5f9ad7d401 Add missing const in GTEST_TEST_BOOLEAN_.
Dropping this causes tools like [misc-const-correctness](http://clang.llvm.org/extra/clang-tidy/checks/misc/const-correctness.html) to flag GTEST macro invocations as non-const-correct.

PiperOrigin-RevId: 958710143
Change-Id: I0f28c4bfc581e5dc9faa9158c4a0792ff546533e
2026-08-03 19:06:37 -07:00
Abseil Team 51725d1111 Rollback: Improve detection for wchar_t and wstring support.
Add a configurable `GTEST_HAS_WCHAR` option to control whether to provide `wchar_t*` overloads for `PrintTo`. Check implementation-specific standard library defines to determine proper defaults for  `GTEST_HAS_WCHAR` and `GTEST_HAS_STD_WSTRING` and to produce compile errors if the users pick a configuration that depends on unavailable standard library features.

PiperOrigin-RevId: 958668507
Change-Id: Ic9b78d83fb455dff7d993303d54a0bde749a8cd8
2026-08-03 17:36:46 -07:00
Abseil Team 92f71eddb0 Improve detection for wchar_t and wstring support.
Add a configurable `GTEST_HAS_WCHAR` option to control whether to provide `wchar_t*` overloads for `PrintTo`. Check implementation-specific standard library defines to determine proper defaults for  `GTEST_HAS_WCHAR` and `GTEST_HAS_STD_WSTRING` and to produce compile errors if the users pick a configuration that depends on unavailable standard library features.

PiperOrigin-RevId: 958595883
Change-Id: I5ff25b395e4cbdab679effa7e760d64c31ac6572
2026-08-03 15:00:16 -07:00
Abseil Team 1b6f64d659 Automated Code Change
PiperOrigin-RevId: 957522754
Change-Id: I824b98844e25a2830518b8a740314092c5282ba9
2026-08-01 00:07:09 -07:00
Abseil Team a0f06a70e3 Make GoogleTest handle std::monostate and valueless_by_exception() for std::variant similarly to how it handles std::nullopt
Fixes: #2066
PiperOrigin-RevId: 955981465
Change-Id: I6b34dc2e634d4b727a50fb3e21e5d8e25c39a13b
2026-07-29 11:08:13 -07:00
Abseil Team c6f04243ed Automated Code Change
PiperOrigin-RevId: 955021426
Change-Id: I3ab06e960011d1d0cd44ea00595a5067aaa7f30b
2026-07-27 22:07:28 -07:00
Abseil Team af4c3cfcb3 Automated Code Change
PiperOrigin-RevId: 955017590
Change-Id: I5125f56376603462fb63796fec1fbc50fd4d935f
2026-07-27 21:57:20 -07:00
Abseil Team ecb18f0b03 Automated Code Change
PiperOrigin-RevId: 955003621
Change-Id: I83518a7f947d9f7d9b89fe14e1219d32bcdc95a3
2026-07-27 21:17:32 -07:00
Abseil Team b78aa5ee64 Automated Code Change
PiperOrigin-RevId: 953750672
Change-Id: I9314622e998cb9d17eec0dc1baeb6d8bc8a801fd
2026-07-24 23:56:31 -07:00
Abseil Team 56cf341d9c Remove useless casts in gtest-internal-inl.h
Fixes: #4711
PiperOrigin-RevId: 953674507
Change-Id: Id744824553157d54eade6de5a542a5783fefd1d8
2026-07-24 19:31:32 -07:00
Abseil Team 425811f10e Undo make string matchers work with std::wstring_view due to internal breakages
Reopens: #4912
PiperOrigin-RevId: 953470061
Change-Id: Ie979aa352f0ecbfb27dec5a41aae4b668cf7541b
2026-07-24 11:27:08 -07:00
Abseil Team 80b3670e1a Maintain constness in assertions & expectations to resolve operator bool() cv-qualifier inconsistency between ASSERT_FALSE/EXPECT_FALSE vs. ASSERT_TRUE/EXPECT_TRUE
Currently, these macros do not behave consistently in how they convert objects to bool, adding extra const qualifiers or using operator!(). This causes them to produce unexpected behavior on types such as the following:

```
struct example {
    operator bool() { throw std::runtime_error("constness not propagated"); }
    operator bool() const { return ...; }
};
```

This change preserves the qualifiers of the evaluated objects and makes the evaluation strategy uniform across macros.

Fixes: #4832
PiperOrigin-RevId: 953424646
Change-Id: I670a72eec11272c3b68d7eb6f739a15da227acde
2026-07-24 10:05:36 -07:00
Abseil Team fef8e5e23b Make string matchers work with std::wstring_view
Fixes: #4912
PiperOrigin-RevId: 953423131
Change-Id: Id288c01c9d1bd9c92ce78b89ec3e8587f4ffc2a7
2026-07-24 10:03:44 -07:00
Abseil Team a798392000 Avoid triggering -Wzero-as-null-pointer-constant in HandleExceptionsInMethodIfSupported()
Fixes: #2916
PiperOrigin-RevId: 953422776
Change-Id: Ic5a167e93d611adb184c516a6383dcc119e11fd7
2026-07-24 10:02:58 -07:00
Abseil Team 0dbcd8d006 Fix typo in docs/gmock_cheat_sheet.md
Closes: #4735
PiperOrigin-RevId: 953422159
Change-Id: I6c0c227ee4a997d346091fee32bd9b23bcc760ab
2026-07-24 10:01:33 -07:00
Abseil Team a901203eff Display the Win32 error code when GetTempFileName() fails on Windows to aid debugging
Closes: #4578
Fixes: #4566
PiperOrigin-RevId: 953335097
Change-Id: Ibc6ed3f2695cafb230e245dca625413f12536323
2026-07-24 06:29:02 -07:00
Abseil Team 7ec05f657d Handle both -F and /F formats in GoogleTest CMake command lines as MSVC accepts both
This is the legacy fix for https://github.com/google/googletest/issues/4731, and to prevent similar breakages in the future with other flags.

The modern fix will be handled separately.

PiperOrigin-RevId: 953333662
Change-Id: I7c58b0123170878f0fe6909cabd5decc922b38f1
2026-07-24 06:25:09 -07:00
Abseil Team 7f7595f67d Make GTEST_DEFINE... macros also declare the flag to avoid triggering -Wmissing-variable-declarations
The alternate implementation based on ABSL_FLAG() already does this internally, so this resolves the inconsistency.

Fixes: #4897
PiperOrigin-RevId: 952840499
Change-Id: I7b8f61d2e9a97ffcd3db091abc373c9d9b48db79
2026-07-23 10:39:55 -07:00
Abseil Team fa005b296f Set up inlining for InvokeWithoutArgs when passed a functor.
Actions can now be implicitly constructed from zero-argument callables. There is no need to create wrapper objects using InvokeWithoutArgs().

PiperOrigin-RevId: 949656497
Change-Id: Ida2bc38e446e7b33aaf185ec593caf2a1959138e
2026-07-17 10:58:22 -07:00
Abseil Team 8b53336594 Automated Code Change
PiperOrigin-RevId: 936635684
Change-Id: I3b1bfa2ef921cdc3d0aaa1fc95986b64a9ad0282
2026-06-23 06:45:34 -07:00
Abseil Team aa40ee603e Automated Code Change
PiperOrigin-RevId: 936616624
Change-Id: I3a05afadf807fc372337186c26b5d73a2bc21410
2026-06-23 06:03:11 -07:00
Abseil Team 1fc11dea10 Automated Code Change
PiperOrigin-RevId: 935893961
Change-Id: I90f8e57a7337f66a2afd37a2f0bc0e418e1ef51e
2026-06-22 00:44:28 -07:00
Abseil Team 44f22083d7 Automated Code Change
PiperOrigin-RevId: 932837091
Change-Id: Ie65ce7e76ecb97b62483b8ee0ba95e5a96b8039e
2026-06-15 20:54:24 -07:00
Abseil Team a721f1b20c Automated Code Change
PiperOrigin-RevId: 924116072
Change-Id: I3e04ebbff65c897e50c37e1a47a2018f31382104
2026-05-30 20:49:30 -07:00
Abseil Team 09f45f51fb Mark gtest_dt_ptr as const.
PiperOrigin-RevId: 920667027
Change-Id: I3dd71c96e206eb19bf3e62bb08ce7043d83fb526
2026-05-24 16:31:25 -07:00
Abseil Team add971c7cb Introduce ContainsSubsequence matcher.
Subsequences are defined as: "a subsequence of a given sequence is a sequence that can be derived from the given sequence by deleting some or no elements without changing the order of the remaining elements."
See: https://en.wikipedia.org/wiki/Subsequence

This new matcher checks if a container contains elements that match a given sequence of matchers in the specified order, but not necessarily contiguously.
The implementation is very similar to other matchers like ElementsAre or Contains.

PiperOrigin-RevId: 918323422
Change-Id: I56d7ebbe6f81038c93546ef7585db59eea5dbd57
2026-05-20 02:39:49 -07:00
Abseil Team dc3c9eda2f Double the MOCK_METHOD parameter count limit to mitigate users running into it
PiperOrigin-RevId: 916092228
Change-Id: Ifb22a4583b3cf8e4b31a51a5f7373137c9e3b9f0
2026-05-15 11:11:10 -07:00
Abseil Team 5fddfab2d2 Define DieInCRTDebugElse12() inside #ifdef _DEBUG
DieInCRTDebugElse12() is only used inside a #ifdef _DEBUG block. Put
its definition inside a #ifdef _DEBUG block, too, otherwise we get a
"defined but not used [-Wunused-function]" warning under MinGW GCC.

PiperOrigin-RevId: 891795658
Change-Id: Ic9109eebc354dd20b2a5430794f491c9b451931f
2026-03-30 10:47:55 -07:00
Abseil Team 2461743991 Automated Code Change
PiperOrigin-RevId: 890778982
Change-Id: Idef51b737a250560d0b71130e6e87b6249d8c47a
2026-03-27 21:30:37 -07:00
Abseil Team 015950a936 Add an implmenetation of Notification for MinGW
Add an alternative implementation of the Notification class for MinGW
using a Windows manual-reset event object.

GCC version < 13 in MinGW, if configured with the win32 thread model
(with the --enable-threads=win32 configure option), does not implement
std::mutex and std::condition_variable in the <mutex> and
<condition_variable> headers. So the current implementation of the
Notification class, which uses std::mutex and std::condition_variable,
has compilation errors. Windows has a synchronization object called a
manual-reset event object that behaves just like the Notification class.
So we can easily implement the Notification class using a Windows
manual-reset event object.

This GCC issue is fixed in GCC 13. See
https://gcc.gnu.org/gcc-13/changes.html#windows. This alternative
implementation of Notification should be removed when GoogleTest
requires GCC version >= 13 in MinGW.

Fixes https://github.com/google/googletest/issues/4031 and
https://github.com/google/googletest/issues/4464.

PiperOrigin-RevId: 888752598
Change-Id: I69e01b2e7953e1fe72d87b6d0804c7a8a8d0e740
2026-03-24 10:53:29 -07:00
Abseil Team f38004c441 Fix typo in monomorphic matcher documentation.
PiperOrigin-RevId: 886900324
Change-Id: I96832e8162b4631783cf0f2badf160d18d3256f8
2026-03-20 11:42:04 -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
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
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
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
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
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
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
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
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
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
Abseil Team 4969d0ad54 Automated Code Change
PiperOrigin-RevId: 806527439
Change-Id: I2e9aa5de44c011938e0bfc8e86af6c7d10c23ab0
2025-09-12 20:45:06 -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
Abseil Team 7e17b15f15 Fix the sample usage of ConvertGenerator by removing the type-id name.
PiperOrigin-RevId: 784561837
Change-Id: I6792fdde81762797c64ac24d297d93938932aef4
2025-07-18 06:24:47 -07:00
Abseil Team 309dab8d4b Automated Code Change
PiperOrigin-RevId: 782277586
Change-Id: Idd7ffd0a585fa8b307ecafb8b3d53abbf124a774
2025-07-12 02:06:50 -07:00
Abseil Team 3983f67e32 Replace internal link in GoogleTest docs
Replace an internal link to AbslStringify's documentation with the equivalent public link.

PiperOrigin-RevId: 779085254
Change-Id: I2cbd2b6262a5ced06f166d4fcc7c08796e5a60af
2025-07-04 01:14:13 -07:00
Abseil Team f8ed0e687c Add documentation for exception matchers.
PiperOrigin-RevId: 775205267
Change-Id: I3ad59ff4b1fa095cbf7dd04dd97a152cb33c7435
2025-06-24 06:22:36 -07:00
Abseil Team 35b75a2cba Although the following paragraph explains there is a better solution, having this technique in the bullet point seems to suggest that this technique is considered as a valid alternative. It would be better to drop it or make it clear that this technique is not recommended.
PiperOrigin-RevId: 771116391
Change-Id: I753560115ed65e8858b749473935df57b6a50488
2025-06-13 09:13:47 -07:00
Abseil Team 175c1b55cf Add UnpackStructImpl for structs with 24, 25 and 26 fields.
PiperOrigin-RevId: 770690821
Change-Id: Ic759e29f46a34d0f2c0ef831e0ddc784290a938f
2025-06-12 09:37:31 -07:00
Abseil Team fd15f51d57 Automated Code Change
PiperOrigin-RevId: 769938700
Change-Id: I3f36d03a5d54f1f2fbeda9fbaa5e205736c3cdbc
2025-06-10 21:03:35 -07:00