A user cannot define a template for `PrintTo` which just takes the type directly.
This is because gtest already defines an implementation for the function, which prints the type with the fallback strategy.
This prevents users from providing a `PrintTo` function like
```
template<typename T, typename = std::enable_if_t<...>>
void PrintTo(const T&, std::ostream*) { ... }
```
as it's ambiguous with the `PrintTo` template defined by gtest.
This change resolves this.
The current behaviour depends on the overload resolution priority for calling the right `PrintTo` function.
This change removes the default implementation of `PrintTo`, and instead detects whether there is a `PrintTo` function that can be called with the type. If it exists, it calls that, otherwise it uses the fallback behaviour.
Unfortunately it's not that simple: due to implicit conversions, once the `PrintTo` (unconstrained) template function is removed, many types will implicitly convert and use one of the other overloads of `PrintTo` defined by gtest, while before it would have used the unconstrained template, as it was a better match.
To address this, this change checks whether the type would ahve called the unconstrained template, if it existed.
In such situations, the fallback behaviour will be used, to remain backward compatible.
To check if the unconstrained template would have been called, such a function is added in a private namespace, and `decltype` is used to detect which overload would have been called.
When PrintTo is defined on a set of types which are accepted with a compile time predicate (using SFINAE), the current implementation fails to compile due to an ambiguous error.
Currently there is no test which checks that tuple with various reference categories can successfully be printed.
Tuples like that can happen when mocking a function which takes refererences
Revert CL that updated example for SetUpTestSuite/TearDownTestSuite to initialize static member variables inline.
It seems that non-const static data members for some reason still must be initialized out-of-line.
PiperOrigin-RevId: 408913846
Update example for SetUpTestSuite/TearDownTestSuite to use modern C++ standards.
Currently it is using an outdated C++ construct (defining static member variables separately from the declaration).
PiperOrigin-RevId: 408663014
Add missing InitGoogleTest line in "Registering tests" example code
Copying the original code gives the following error message
"""
IMPORTANT NOTICE - DO NOT IGNORE:
This test program did NOT call testing::InitGoogleTest() before calling RUN_ALL_TESTS(). This is INVALID. Soon Google Test will start to enforce the valid usage. Please fix it ASAP, or IT WILL START TO FAIL.
"""
PiperOrigin-RevId: 408385714
Guard #includes for threading related headers with GTEST_IS_THREADSAFE
Some platforms that don't support threading give errors for including
these headers
PiperOrigin-RevId: 406133623
Replace the multiple implementations of Notification with a single
portable implementation.
The also removes the awkward loop with sleep in Notification and will
allow the removal of SleepMilliseconds.
PiperOrigin-RevId: 405399733
Showing disabled tests is implemented by a new member function on the
TestEventListener interface (which is responsible for printing
testing output). The new function is called OnTestSkipped and it is
invoked when a disabled test is encountered.
The PrettyUnitTestResultPrinter has the canonical implementation of this
new function. The BriefUnitTestResultPrinter and the
EmptyTestEventListener get a nullary implementation. The
JsonUnitTestResultPrinter and XmlUnitTestResultPrinter
inherit that trivial implementation from the EmptyTestEventListener.
Do not attempt to continue running a test suite if it already failed during
`SetUpTestSuite`.
The suite already failed and running the tests might just add noise to the run, or even crash the process unnecessarily.
Fixes#2187
PiperOrigin-RevId: 397770405