4683 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
Copybara-Service 7e91a413e8 Merge pull request #5082 from Muszic:fix-json-utf8-output
PiperOrigin-RevId: 978191552
Change-Id: I2744f219171a97622333f7b84aa76f78dd63e975
2026-09-08 17:06:36 -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
Muszic b769fc08a4 Preserve UTF-8 strings in JSON output 2026-09-02 16:13:49 +05:30
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
Copybara-Service 7260682388 Merge pull request #5046 from UditDewan:fix/print-invalid-char-code-units
PiperOrigin-RevId: 968678073
Change-Id: I669221b694231e385acb9a0bf6640e6f1c319e1e
2026-08-21 14:02:47 -07:00
Copybara-Service 0daf775f8c Merge pull request #4824 from DoDoENT:fix/emscripten-without-threads
PiperOrigin-RevId: 967351125
Change-Id: I4637dd19dfbd8c39d31a4a2bb6f4068e0f631e15
2026-08-19 12:35:58 -07:00
Nenad Mikša 1a447fdce7 avoid -lpthread link option when building with emscripten without threads
- having this flag causes emscripten to generate binary with pthread
  support, which is not compatible with browsers that do not support
  pthreads or with web pages that do not enable pthread support
2026-08-19 17:40:01 +02: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
Prashant Kumar 963dd8ea18 Update version strings to 1.18
PiperOrigin-RevId: 962756240
Change-Id: Ibb440cda59a55a1dafc721f00140cbe0d726d077
2026-08-11 06:59:21 -07:00
Copybara-Service d89aac5f0d Merge pull request #5053 from zmajeedforks:zmajeed_fix_msvc_crt_override
PiperOrigin-RevId: 961026014
Change-Id: I91e5a221e335372a9c5fef9082ab05800f5b2081
2026-08-07 11:15:29 -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
zmajeed c0afb7f69d Fix issue 5042: Don't override VC++ project C runtime library settings when googletest is used through cmake FetchContent or add_subdirectory 2026-08-06 09:52:33 -05: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
Prashant Kumar b607d9f590 Update GoogleTest dependencies in preparation for release
PiperOrigin-RevId: 959806818
Change-Id: I1504c832eba1d5fb9f99c21d16b269897c40aea0
2026-08-05 12:29:28 -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
Prashant Kumar 3940de9189 Relax std::monostate printing assertion in test on Windows
PiperOrigin-RevId: 956505817
Change-Id: I63dadf346271e88cfefeb1e3e9e9a37d6c2dd6ad
2026-07-30 07:16:47 -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
Copybara-Service 3ff51c3e80 Merge pull request #5041 from alvinjaison:fix/get-test-suite-shuffle-index
PiperOrigin-RevId: 955317170
Change-Id: I40e01cdafe58768ccdb743dcf38717e48edcde41
2026-07-28 09:58:12 -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
uditDewan 806b89cf63 Print char8_t/char16_t code units that aren't code points as code units
PrintTo(char8_t) and PrintTo(char16_t) widened their argument to char32_t
and printed it with the U+XXXX notation. That notation names a code point,
but char8_t and char16_t hold code units, so it is wrong for every value
that does not encode a code point on its own: any non-ASCII char8_t (always
part of a multi-unit UTF-8 sequence) and the UTF-16 surrogates D800-DFFF.
For example, PrintTo(char8_t(0x80)) printed "U+0080", the code point of a
character that value cannot represent.

Print those values as code units instead, using the same escape-plus-code
form already used for char, unsigned char and wchar_t: char8_t(0x80) now
prints as u8'\x80' (128) and char16_t(0xD800) as u'\xD800' (55296). Values
that do encode a code point keep the U+XXXX notation.

Fixes #4762
2026-07-26 15:58:15 -04:00