0
0
mirror of https://github.com/google/googletest.git synced 2025-03-21 20:03:48 +00:00

4463 Commits

Author SHA1 Message Date
Abseil Team
4a00a24fff Add SaveArgByMove
Allows capture of move-only argument types (e.g. AnyInvocable)

PiperOrigin-RevId: 725262899
Change-Id: Idcd46e333a42d99ff05d58a1bc57d8791f6d45a6
2025-02-10 10:22:27 -08:00
Derek Mauro
a866428a78 Update docs for v1.16.x branch
Also update the minimum required CMake version
https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md

PiperOrigin-RevId: 724375734
Change-Id: Iefa6c7e2061457bc6149a280d2408085b1fb9d11
2025-02-07 09:41:05 -08:00
Derek Mauro
445e9bd8d0 Update GoogleTest deps in preparation for release
PiperOrigin-RevId: 724135630
Change-Id: I24622387e508d27337769e83f7de8fecae9ad425
2025-02-06 17:40:25 -08:00
Derek Mauro
e5443e5c65 Remove empty glob pattern, which is now an error.
It look like this may be a copy-paste bug from the root BUILD file.

PiperOrigin-RevId: 724062332
Change-Id: I8eda2275d996dd14693aee569254db28d9bc4f9d
2025-02-06 13:52:23 -08:00
Abseil Team
e235eb34c6 Pull Regexp syntax out of Death test section in advanced.md
Regexps seem to have nothing in common with death tests, yet their description is planted right in the middle of the death test section.

This CL pulls the regexp section one level up and just before death tests.

PiperOrigin-RevId: 721817710
Change-Id: Idc52f450fb10960a590ceb1a70339f86d4478fe4
2025-01-31 10:23:04 -08:00
Abseil Team
66d7401378 Fix extended regular expressions reference URL in advanced.md
The original URL started with https://www.opengroup.org and fails to redirect to the reference page. According to Chrome's dev tools (Network tab), the response to that request is a HTTP 302 Found, with the new location being "balancer://pubs/onlinepubs/009695399/basedefs/xbd_chap09.html". Chrome does not know what to do with that and displays a blank page.

Changing the `www` subdomain to `pubs` results in HTTP 200.

PiperOrigin-RevId: 721804738
Change-Id: I816d08d5baf957c63ac97506d04c7cc49c3a5ce7
2025-01-31 09:45:17 -08:00
Abseil Team
b4aae50ce1 Export testsuite properties as XML elements, not attributes.
With this change, arbitrary property names in the testsuite no longer
cause the produced XML output to be ill-formed.

PiperOrigin-RevId: 721549090
Change-Id: Iedffa89bf914478f563c8f3b82cd50557762a665
2025-01-30 16:01:31 -08:00
Abseil Team
2b6b042a77 Cast mutable lvalue references to const from testing::ResultOf
PiperOrigin-RevId: 716343482
Change-Id: I125bc4725886958d026c88f3902a8289e476598b
2025-01-16 12:51:11 -08:00
Abseil Team
e4ece4881d Enable safe matcher casts from Matcher<const T&> to Matcher<T>.
PiperOrigin-RevId: 715826130
Change-Id: Id962fd456f6da21ea2a909f331f92d814f1dad46
2025-01-15 09:16:57 -08:00
Abseil Team
504ea69cf7 Document unexpected interaction with death test error code and gmock.
If you have a death test that uses mock objects, it's very likely that those mock objects are not properly cleaned up before death. The gMock atexit leak detector will call `_exit(1)`, overriding your expected exit code.

PiperOrigin-RevId: 713722657
Change-Id: I92a326f3923efc9f0e235d825616f3094eca995c
2025-01-09 10:43:08 -08:00
Abseil Team
4bbf80823c Add UnpackStructImpl for structs with 20 fields.
PiperOrigin-RevId: 713272335
Change-Id: I2b289ece4ce3f91834a8c9ba11a4bd18e6e40fca
2025-01-08 06:38:13 -08:00
Abseil Team
7d76a231b0 gtest: Output a canned test case for test suite setup / teardown failures in XML/JSON
This surfaces useful information about the environment failure in a structured form.

As we can see from the updated test, previously unsurfaced information is now present.

PiperOrigin-RevId: 709892315
Change-Id: I2656294d50c33f995bef5c96195a66cff3c4b907
2024-12-26 15:30:52 -08:00
Abseil Team
e54519b094 Put the fake Fuchsia SDK in a module extension
This allows users to override the fake SDK with a real one using https://bazel.build/rules/lib/globals/module#override_repo.

Without this change, it is impossible for a project that depends on googletest as a `bazel_dep` to build tests using the "real" Fuchsia SDK, because any references to `@fuchsia_sdk` within googletest `BUILD.bazel` files unconditionally resolve to the "fake" Fuchsia SDK. With this change, if you have the real Fuchsia SDK declared in your `MODULE.bazel`, you can add the following lines to coerce googletest to use the real Fuchsia SDK as well:

    fake_fuchsia_sdk_extension =
    use_extension("@com_google_googletest//:fake_fuchsia_sdk.bzl", "fuchsia_sdk")
    override_repo(fake_fuchsia_sdk_extension, "fuchsia_sdk")

PiperOrigin-RevId: 709139784
Change-Id: I4d10d441c76b7a2481f15723a24f11525dba3878
2024-12-23 13:33:10 -08:00
Abseil Team
f3c355f9dd the public version already has the const qualifier
PiperOrigin-RevId: 706721910
Change-Id: I8a76a66d62028176a70678954f095ac70996cc9e
2024-12-16 08:40:16 -08:00
Abseil Team
79219e26e0 Update the links to ISTQB glossary.
PiperOrigin-RevId: 705108072
Change-Id: I209e7fb24bd093412dda1cd5eba10e9ccc2306f4
2024-12-11 08:00:11 -08:00
Abseil Team
d122c0d435 Add support for printing C++20 std::*_ordering types to gtest.
Adds feature test macro for C++20 <compare> header, a pretty-printer, and tests.
Inexplicably, these types aren't enums, so can't be handled with a switch.

PiperOrigin-RevId: 704783038
Change-Id: I29688989d18f43520fe610c12a447a20d2f98c95
2024-12-10 11:23:04 -08:00
Copybara-Service
35d0c36560 Merge pull request #4662 from asoffer:patch-1
PiperOrigin-RevId: 698420375
Change-Id: I786e5b50d171c697c21579659a67716442f224df
2024-11-20 09:37:33 -08:00
Andy Soffer
7927f8e93d
Fix documentation bug.
Matchers require the signature of these three functions to be `const`.
2024-11-15 10:19:57 -05:00
Abseil Team
d144031940 Fixing a typo in the documentation of IsSubsetOf().
PiperOrigin-RevId: 692957797
Change-Id: Ifd3efe64cd2a3a5623167fa13de61d6e3358662d
2024-11-04 07:26:27 -08:00
Abseil Team
1204d63444 Remove mention of using ASSERT_... statements inside custom matcher definitions.
PiperOrigin-RevId: 691994071
Change-Id: I63913152217c99b8c08ae6af8924bc28b02aa9d0
2024-10-31 18:04:00 -07:00
Peter Boström
5ed2186395 Use FAIL() in GTEST_SKIP() documentation
This replaces EXPECT_EQ(0, 1) which would fail if hit.

PiperOrigin-RevId: 690491467
Change-Id: Ieff4e616348254f29200e0ba1d9a6900a2eea130
2024-10-27 23:57:15 -07:00
Abseil Team
df1544bcee Avoid creating std::vector<const T> in UnorderedElementsAreArrayMatcher and others.
std::vector<const T> for trivially relocatable types is not allowed by C++ and is rejected by libc++ starting from 4e112e5c1c
PiperOrigin-RevId: 686487841
Change-Id: I3c90c7c0a6e8e23ffa5ebd1702a3f30ebc4a702f
2024-10-16 06:39:54 -07:00
Abseil Team
62df7bdbc1 This change adjusts how ASSERT_NEAR and EXPECT_NEAR treats infinity, such that ASSERT_NEAR(inf, inf, 0) passes. This makes the behavior more consistent with ASSERT_EQ(inf, inf) which succeeds.
Some examples of asserts that now pass:
```
ASSERT_NEAR(inf, inf, 0)
ASSERT_NEAR(-inf, inf, inf)
ASSERT_NEAR(inf, x, inf)  // x is any finite floating point value
```

PiperOrigin-RevId: 685748133
Change-Id: I7b3af377773e8e0031e4c6b86830cbbf76bf20c6
2024-10-14 10:13:58 -07:00
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
Derek Mauro
ff233bdd4c Update main to point to 1.15.2 patch release
PiperOrigin-RevId: 658382055
Change-Id: Ia5eed4bec26da8c8cbe29fbd3a41b44048c25e07
2024-08-01 06:34:56 -07:00
Derek Mauro
3e3b44c300 Remove auto-detection of Python toolchain from MODULE.bazel
since it affects downstream users

The correct solution appears to be
https://rules-python.readthedocs.io/en/stable/toolchains.html#library-modules-with-dev-only-python-usage

This change also includes a workaround for the new mechanism creating
paths that are too long for Windows to handle.

Fixes #4581

PiperOrigin-RevId: 657706984
Change-Id: I8ae6b9e5efeb7629d79d14e7d4d3889876282d17
2024-07-30 13:17:40 -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
Derek Mauro
cee1ba1f24 Change the Bazel build to use the canonical repo names used by Bzlmod
and the Bazel Central Registry

GoogleTest and its dependencies now use the following names:
GoogleTest: com_google_googletest -> googletest
Abseil: com_google_absl -> abseil-cpp
RE2: com_googlesource_code_re2 -> re2

Bazel users using the WORKSPACE file to specify dependencies may
need to use https://bazel.build/rules/lib/repo/http#http_archive-repo_mapping
to remap repositories to their former names if their dependencies do not
agree on on which name is used.

It is recommended that users migrate to bzlmod to manage Bazel dependencies.

PiperOrigin-RevId: 654430227
Change-Id: Iae8797994d7d87bd4f013dcdc889e7494a6ad2fb
2024-07-20 23:09:44 -07:00
Derek Mauro
9ff2450a56 Update GoogleTest Bazel quickstart for Bzlmod
PiperOrigin-RevId: 652824490
Change-Id: I5e6f57004708e7fa62abb454db9bae81fa265c83
2024-07-16 06:58:45 -07:00
Derek Mauro
b62593aceb Update main branch to reflect the release of 1.15.0
PiperOrigin-RevId: 652824317
Change-Id: I39085d9451405c3decb462a0b4682added365d17
2024-07-16 06:57:43 -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
Derek Mauro
7321f950df Update dependency versions in preparation for release
PiperOrigin-RevId: 652479800
Change-Id: I71574e7dc2ea2e9a2f3071aebbbf0e6b5ce32a35
2024-07-15 07:51:06 -07:00
Derek Mauro
4b21f1abdd README.md: Remove outdated notes about continuous integration and
documentation

PiperOrigin-RevId: 651816538
Change-Id: I3c85b4a26aff8277c627b99b1c5805bad0d29df6
2024-07-12 10:31:17 -07:00
Derek Mauro
b4aaf97d8f Workaround GCC 12 -Wrestrict false-positive
Suggested workaround from 751760ad54

Fixes #4570

PiperOrigin-RevId: 651044944
Change-Id: I21f099a15dd3182d335a7891d99b9b1293e5c53e
2024-07-10 09:15:21 -07:00
Derek Mauro
3ef16ef8b3 Fix the documentation that erroneously says you can use short versions
of help flags

Fixes #4564

PiperOrigin-RevId: 650730047
Change-Id: I3a52aca490338066c607e34ab20c827bfde5090d
2024-07-09 12:59:38 -07:00
Abseil Team
34ad51b3dc Add a bounds check to protect against an empty vector from GetArgs(), which
can cause an out of bounds access in GetCurrentExecutableName(). One way this
can happen is if the user forgets to call InitGoogleTest().

PiperOrigin-RevId: 647740658
Change-Id: Id87692aa3d515b8ae0836e474be477d2aafa3871
2024-06-28 11:12:56 -07:00
Abseil Team
1d17ea141d Skip the predicate on SIGSEGV in death-test on Android builds with API level <= 21.
PiperOrigin-RevId: 643076477
Change-Id: Id9486b7d73c3b17851df1eaf8f5ab2085238bf75
2024-06-13 12:00:01 -07:00
Abseil Team
a7f443b80b Mention the optional third argument to TYPED_TEST_SUITE
PiperOrigin-RevId: 637896001
Change-Id: Ia3a61ceec4b842e864a0cdfad13e9897bf0ecaaa
2024-05-28 07:42:39 -07:00
Derek Mauro
305e5a238b Update GoogleTest CI Docker image to use Clang 19, GCC 14, and CMake 3.29.3
PiperOrigin-RevId: 636977286
Change-Id: Id9e09398a991c74c2137672948a1eb7dd2d96596
2024-05-24 11:13:43 -07:00
Derek Mauro
9b4993ca7d Change GoogleTest flag removal to not read beyond the end of the array
to the NULL terminator.  #4532 says ASAN complains about this on some
platforms, although it is not clear if ASAN or the platform implementation
is incorrect about accessing the terminating NULL.

Fixes #4532

PiperOrigin-RevId: 635886009
Change-Id: Ibb4237055488c895b1dd09145ab979347bb9a390
2024-05-21 12:08:38 -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
33af80a883 Make EXPECT_DEATH_IF_SUPPORTED work with matchers
If death tests were not supported the macro would try
to force the second parameter as a string. The second
parameter can be a matcher or a string.

PiperOrigin-RevId: 633199517
Change-Id: If5e71b4be0b569adb273eb4960202197bb264a8f
2024-05-13 07:16:53 -07:00
Copybara-Service
fa6de7f438 Merge pull request #4527 from abhina-sree:abhina/add_zos
PiperOrigin-RevId: 631167807
Change-Id: I563883341972bbb82c7407ebf3755d64317b84fc
2024-05-06 13:31:42 -07:00