The INSTALL_INTERFACE include directory was written as
$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}, which unconditionally
prepends the install prefix. When CMAKE_INSTALL_INCLUDEDIR is an
absolute path, the exported GTestTargets.cmake ends up with an invalid
doubled path such as "/usr/local//usr/local/include", and find_package
consumers fail at configure time with "Imported target includes
non-existent path".
Relative paths inside $<INSTALL_INTERFACE:...> are already interpreted
relative to the installation prefix, so the explicit $<INSTALL_PREFIX>/
prefix is redundant for relative values and wrong for absolute ones.
Dropping it keeps the exported path identical for relative values
(${_IMPORT_PREFIX}/include) and uses absolute values as-is.
Fixes#4817
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
Since we can't directly depend on proto headers, we rely on ADL + proto headers being included by calling code for this matcher to choose the right overload of `DynamicCastMessage`.
PiperOrigin-RevId: 940593408
Change-Id: I7374aed3c5cfe61a183d28ea02e6583ab340f647
Protobuf messages have a custom dynamic_cast, for when RTTI is not available on the messages.
PiperOrigin-RevId: 933270097
Change-Id: Iaeb50bce3fe1b746306a7507ab1985b111c03416
Both OnceAction compatibility traits, IsDirectlyCompatible and
IsCompatibleAfterIgnoringArguments, check std::is_constructible before
is_callable_r.
On libc++ that order breaks. Evaluating
is_constructible<std::tuple<OnceAction&&>, ...> drives libc++'s tuple
constructor SFINAE, which calls back into OnceAction's converting
constructor and re-enters the conjunction while it is still incomplete.
GCC <= 8 (e.g. QNX 7.1's gcc 8.3) rejects this with:
incomplete type ... used in nested name specifier
so EXPECT_CALL(m, f()).WillOnce(Return(...)) fails to compile. GCC >= 9
and every Clang accept the original order; libstdc++ is unaffected.
Swapping the two checks fixes it: is_callable_r is cheap and
non-recursive, so the conjunction short-circuits to false for the
non-callable tuple before is_constructible is instantiated.
Fixes#3947.
In particular this automatically gives us support for examples like the
following:
using SomeFn = absl::AnyInvocable<R(Args...) const>;
MockFunction<SomeFn> some_fn;
PiperOrigin-RevId: 921303527
Change-Id: I19bf59671781e85db65cc20c0d6ea10b056c528a
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
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
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
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
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
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
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
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
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
`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
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
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
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