summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* | Add a `DistanceFrom()` matcher for general distance comparison.Zhanyong Wan2025-03-073-0/+276
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a bunch of matchers for asserting that a value is near the target value, e.g. `DoubleNear()` and `FloatNear()`. These matchers only work for specific types (`double` and `float`). They are not flexible enough to support other types that have the notion of a "distance" (e.g. N-dimensional points and vectors, which are commonly used in ML). In this diff, we generalize the idea to a `DistanceFrom(target, get_distance, m)` matcher that works on arbitrary types that have the "distance" concept (the `get_distance` argument is optional and can be omitted for types that support `-`, and `std::abs()`). What it does: 1. compute the distance between the value and the target using `get_distance(value, target)`; if `get_distance` is omitted, compute the distance as `std::abs(value - target)`. 2. match the distance against matcher `m`; if the match succeeds, the `DistanceFrom()` match succeeds. Examples: ``` // 0.5's distance from 0.6 should be <= 0.2. EXPECT_THAT(0.5, DistanceFrom(0.6, Le(0.2))); Vector2D v1(3.0, 4.0), v2(3.2, 6.0); // v1's distance from v2, as computed by EuclideanDistance(v1, v2), // should be >= 1.0. EXPECT_THAT(v1, DistanceFrom(v2, EuclideanDistance, Ge(1.0))); ``` PiperOrigin-RevId: 734593292 Change-Id: Id6bb7074dc4aa4d8abd78b57ad2426637e590de5
* | Add a `testing::ConvertGenerator` overload that accepts a converting ↵Abseil Team2025-03-044-20/+278
| | | | | | | | | | | | | | functor. This allows the use of classes that do not have a converting ctor to the desired type. PiperOrigin-RevId: 733383835 Change-Id: I6fbf79db0509b3d4fe8305a83ed47fceaa820e47
* | Try to warn the user when test filters do not match any testsDerek Mauro2025-02-283-0/+58
| | | | | | | | | | PiperOrigin-RevId: 732204780 Change-Id: I2c4ccabd123e3b79c3dd8bc768a4cd9a576d282c
* | googletest: Add testonly alias of :gtest for testonly cc_libraries to use.pizzud2025-02-271-0/+14
| | | | | | | | | | | | | | | | | | | | While a testonly library can certainly depend on a non-testonly library, gtest itself is logically testonly, but is not tagged as such for historical reasons. Having a testonly target allows gradual migrations towards a testonly-only world. PiperOrigin-RevId: 731807655 Change-Id: Ie16f17fb74b80bb6200767a3ac5bafa424162146
* | Add UnpackStructImpl for structs with 21 fields.Abseil Team2025-02-271-0/+7
| | | | | | | | | | PiperOrigin-RevId: 731737844 Change-Id: I3efeb26b0bf179958c8a3eda0b55dfc3d7778fb9
* | Output to the test warning file if no tests are linked.Derek Mauro2025-02-262-10/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | Bazel sets the environment variable TEST_WARNINGS_OUTPUT_FILE https://bazel.build/reference/test-encyclopedia#initial-conditions If no tests are linked and the new flag --gtest_fail_if_no_test_linked is not true (which is the current default), we can still warn the user as this may be a programming error without failing the test (which would break existing users). PiperOrigin-RevId: 731402363 Change-Id: Ia481689efd4bd18889feaaa38bc56049a3f651cd
* | Adds support for a --gtest_fail_if_no_test_linked flagZhanyong Wan2025-02-246-16/+270
| | | | | | | | | | | | | | | | to fail the test program if no test case is linked in (a common programmer mistake). PiperOrigin-RevId: 730571311 Change-Id: I1dab04adfe35581274d0b4ec79a017014d50e1ea
* | GoogleTest C++17 cleanupsDerek Mauro2025-02-2111-209/+145
| | | | | | | | | | | | | | | | | | | | * Use `[[nodiscard]]` instead of GTEST_MUST_USE_RESULT_ * Use `[[maybe_unused]]` instead of GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED * Use `[[deprecated]]` instead of `GTEST_INTERNAL_DEPRECATED` * Remove `GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL` PiperOrigin-RevId: 729523519 Change-Id: Ia1b901cf9c0a0e148eec419ada0e0b56aba2dd3d
* | Property: Promote note to warningJesse Rosenstock2025-02-172-4/+9
| | | | | | | | | | | | | | | | Property() should not be used against member functions that you do not own. Make this warning more prominent in matchers.md and add it to gmock-matchers.h. PiperOrigin-RevId: 727753777 Change-Id: Idf9155103b04b98efc957ff0d0cf3a8d8662eb72
* | Require C++17Derek Mauro2025-02-129-57/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Policy information: https://opensource.google/documentation/policies/cplusplus-support#c_language_standard https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md Some small fixes are included for C++17 compatibility. We had no tests for MSVC C++17 or C++20, so those tests that failed and had no obvious fix are disabled and a tracking bug has been filed. PiperOrigin-RevId: 726090558 Change-Id: I4d37d47e87c11f85bfd572deb10f67ca3eb2a9b5
* | Add SaveArgByMoveAbseil Team2025-02-103-11/+58
| | | | | | | | | | | | | | Allows capture of move-only argument types (e.g. AnyInvocable) PiperOrigin-RevId: 725262899 Change-Id: Idcd46e333a42d99ff05d58a1bc57d8791f6d45a6
* | Update docs for v1.16.x branchDerek Mauro2025-02-073-7/+10
| | | | | | | | | | | | | | | | 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
* | Update GoogleTest deps in preparation for releaseDerek Mauro2025-02-074-13/+12
| | | | | | | | | | PiperOrigin-RevId: 724135630 Change-Id: I24622387e508d27337769e83f7de8fecae9ad425
* | Remove empty glob pattern, which is now an error.Derek Mauro2025-02-061-1/+0
| | | | | | | | | | | | | | It look like this may be a copy-paste bug from the root BUILD file. PiperOrigin-RevId: 724062332 Change-Id: I8eda2275d996dd14693aee569254db28d9bc4f9d
* | Pull Regexp syntax out of Death test section in advanced.mdAbseil Team2025-01-311-45/+45
| | | | | | | | | | | | | | | | | | 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
* | Fix extended regular expressions reference URL in advanced.mdAbseil Team2025-01-311-1/+1
| | | | | | | | | | | | | | | | | | 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
* | Export testsuite properties as XML elements, not attributes.Abseil Team2025-01-314-88/+80
| | | | | | | | | | | | | | | | 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
* | Cast mutable lvalue references to const from testing::ResultOfAbseil Team2025-01-161-3/+6
| | | | | | | | | | PiperOrigin-RevId: 716343482 Change-Id: I125bc4725886958d026c88f3902a8289e476598b
* | Enable safe matcher casts from `Matcher<const T&>` to `Matcher<T>`.Abseil Team2025-01-154-17/+96
|/ | | | | PiperOrigin-RevId: 715826130 Change-Id: Id962fd456f6da21ea2a909f331f92d814f1dad46
* Document unexpected interaction with death test error code and gmock.Abseil Team2025-01-091-3/+9
| | | | | | | 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
* Add UnpackStructImpl for structs with 20 fields.Abseil Team2025-01-081-0/+5
| | | | | PiperOrigin-RevId: 713272335 Change-Id: I2b289ece4ce3f91834a8c9ba11a4bd18e6e40fca
* gtest: Output a canned test case for test suite setup / teardown failures in ↵Abseil Team2024-12-264-28/+198
| | | | | | | | | | | 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
* Put the fake Fuchsia SDK in a module extensionAbseil Team2024-12-232-22/+59
| | | | | | | | | | | | | 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
* the public version already has the const qualifierAbseil Team2024-12-161-9/+9
| | | | | PiperOrigin-RevId: 706721910 Change-Id: I8a76a66d62028176a70678954f095ac70996cc9e
* Update the links to ISTQB glossary.Abseil Team2024-12-111-2/+2
| | | | | PiperOrigin-RevId: 705108072 Change-Id: I209e7fb24bd093412dda1cd5eba10e9ccc2306f4
* Add support for printing C++20 std::*_ordering types to gtest.Abseil Team2024-12-103-0/+71
| | | | | | | | 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
* Merge pull request #4662 from asoffer:patch-1Copybara-Service2024-11-201-3/+3
|\ | | | | | | | | PiperOrigin-RevId: 698420375 Change-Id: I786e5b50d171c697c21579659a67716442f224df
| * Fix documentation bug.refs/pull/4662/headAndy Soffer2024-11-151-3/+3
|/ | | Matchers require the signature of these three functions to be `const`.
* Fixing a typo in the documentation of IsSubsetOf().Abseil Team2024-11-041-1/+1
| | | | | PiperOrigin-RevId: 692957797 Change-Id: Ifd3efe64cd2a3a5623167fa13de61d6e3358662d
* Remove mention of using `ASSERT_...` statements inside custom matcher ↵Abseil Team2024-11-011-3/+3
| | | | | | | definitions. PiperOrigin-RevId: 691994071 Change-Id: I63913152217c99b8c08ae6af8924bc28b02aa9d0
* Use FAIL() in GTEST_SKIP() documentationPeter Boström2024-10-281-2/+2
| | | | | | | This replaces EXPECT_EQ(0, 1) which would fail if hit. PiperOrigin-RevId: 690491467 Change-Id: Ieff4e616348254f29200e0ba1d9a6900a2eea130
* Avoid creating std::vector<const T> in UnorderedElementsAreArrayMatcher and ↵Abseil Team2024-10-161-6/+7
| | | | | | | | others. std::vector<const T> for trivially relocatable types is not allowed by C++ and is rejected by libc++ starting from https://github.com/llvm/llvm-project/commit/4e112e5c1c8511056030294af3264da35f95d93c PiperOrigin-RevId: 686487841 Change-Id: I3c90c7c0a6e8e23ffa5ebd1702a3f30ebc4a702f
* This change adjusts how `ASSERT_NEAR` and `EXPECT_NEAR` treats infinity, ↵Abseil Team2024-10-143-3/+74
| | | | | | | | | | | | | | 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
* Automated Code ChangeAbseil Team2024-10-051-2/+2
| | | | | PiperOrigin-RevId: 682549952 Change-Id: Ica81f0020c3001c01543a5851dae7d0b42730c66
* Optional(): Add support for std::optional<>-like types lacking bool conversion.Abseil Team2024-10-012-25/+82
| | | | | PiperOrigin-RevId: 681053268 Change-Id: If80ba667fd4c91340e1405a9691f5ca0350fa9eb
* Use matcher's description in AnyOf when matcher has no explanation.Abseil Team2024-09-164-45/+71
| | | | | PiperOrigin-RevId: 675298308 Change-Id: I32d32cafebc7a63fd03e6d957c3a47043d71e5d9
* Automated Code ChangeAbseil Team2024-08-291-1/+1
| | | | | PiperOrigin-RevId: 668944316 Change-Id: I65aa0a4f3b8a980242849963a3e921ec7fd92b28
* Update main to point to 1.15.2 patch releaseDerek Mauro2024-08-014-6/+6
| | | | | PiperOrigin-RevId: 658382055 Change-Id: Ia5eed4bec26da8c8cbe29fbd3a41b44048c25e07
* Remove auto-detection of Python toolchain from MODULE.bazelDerek Mauro2024-07-302-5/+18
| | | | | | | | | | | | | | | 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
* Directly include `gmock.h` and `gtest.h` in gmock-matchers tests.Abseil Team2024-07-304-4/+8
| | | | | | | These headers have been included through `gmock-matchers_test.h` PiperOrigin-RevId: 657612455 Change-Id: I65675f1cfe7789f1821ccacbe60acf90efd5c221
* Use matcher's description in AllOf if matcher has no explanation.Abseil Team2024-07-243-23/+39
| | | | | PiperOrigin-RevId: 655569834 Change-Id: Ia760d74d1cdde766e9719864c5e19c0159da3128
* gmock-actions: make DoAll convert to OnceAction via custom conversions.Aaron Jacobs2024-07-242-12/+98
| | | | | | | | | | | | | 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
* Run clang-format.Aaron Jacobs2024-07-238-21/+21
| | | | | PiperOrigin-RevId: 655106304 Change-Id: Ie69b407fce74b31cf71d6dcc1361910d30e86bb5
* Change the Bazel build to use the canonical repo names used by BzlmodDerek Mauro2024-07-214-21/+49
| | | | | | | | | | | | | | | | | | | 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
* Update GoogleTest Bazel quickstart for BzlmodDerek Mauro2024-07-161-30/+23
| | | | | PiperOrigin-RevId: 652824490 Change-Id: I5e6f57004708e7fa62abb454db9bae81fa265c83
* Update main branch to reflect the release of 1.15.0Derek Mauro2024-07-163-6/+6
| | | | | PiperOrigin-RevId: 652824317 Change-Id: I39085d9451405c3decb462a0b4682added365d17
* Use matcher's description in AllOf if matcher has no explanation.Abseil Team2024-07-163-39/+23
| | | | | PiperOrigin-RevId: 652798234 Change-Id: I8e92248a2d9faf2a5719fe220145ea563acc14ff
* Use matcher's description in AllOf if matcher has no explanation.Abseil Team2024-07-153-23/+39
| | | | | PiperOrigin-RevId: 652634229 Change-Id: I5fd7eaef4db3dea3d4142e1fb5fc97e46f654358
* Update dependency versions in preparation for releaseDerek Mauro2024-07-153-11/+14
| | | | | PiperOrigin-RevId: 652479800 Change-Id: I71574e7dc2ea2e9a2f3071aebbbf0e6b5ce32a35
* README.md: Remove outdated notes about continuous integration andDerek Mauro2024-07-121-5/+1
| | | | | | | documentation PiperOrigin-RevId: 651816538 Change-Id: I3c85b4a26aff8277c627b99b1c5805bad0d29df6