Remove support for "global" ::string and ::wstring types.
This support existed for legacy codebases that existed from before namespaces
where a thing. It is no longer necessary.
PiperOrigin-RevId: 241335738
gtest prior to this change would completely ignore `GTEST_SKIP()` if
called in `Environment::SetUp()`, instead of bailing out early, unlike
`Test::SetUp()`, which would cause the tests themselves to be skipped.
The only way (prior to this change) to skip the tests would be to
trigger a fatal error via `GTEST_FAIL()`.
Desirable behavior, in this case, when dealing with
`Environment::SetUp()` is to check for prerequisites on a system
(example, kernel supports a particular featureset, e.g., capsicum), and
skip the tests. The alternatives prior to this change would be
undesirable:
- Failing sends the wrong message to the test user, as the result of the
tests is indeterminate, not failed.
- Having to add per-test class abstractions that override `SetUp()` to
test for the capsicum feature set, then skip all of the tests in their
respective SetUp fixtures, would be a lot of human and computational
work; checking for the feature would need to be done for all of the
tests, instead of once for all of the tests.
For those reasons, making `Environment::SetUp()` handle `GTEST_SKIP()`,
by not executing the testcases, is the most desirable solution.
In order to properly diagnose what happened when running the tests if
they are skipped, print out the diagnostics in an ad hoc manner.
Update the documentation to note this change and integrate a new test,
gtest_skip_in_environment_setup_test, into the test suite.
This change addresses #2189.
Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Fix emission of -Wzero-as-null-pointer-constant when comparing integers.
The following code fails to compile:
#pragma clang diagnostic error "-Wzero-as-null-pointer-constant"
void foo() {
EXPECT_EQ(0, 0);
}
This happens because gtest checks the first argument to EXPECT_EQ and
ASSERT_EQ is a null pointer constant. The magic it does to do this causes the
warning to be emitted.
This patch removes that check. It replaces the explicit check with a Compare
overload that can only be selected when 0 or nullptr is passed on the LHS
with a pointer on the right.
This patch does not suppress -Wzero-as-null-pointer-constant when users
are actually using it as NULL.
PiperOrigin-RevId: 236654634
Let embedders customize GTEST_INTERNAL_DEPRECATED().
GTEST_INTERNAL_DEPRECATED is currently used to nudge googletest users to migrate off old TEST_CASE macros to the new TEST_SUITE macros. This move is non-trivial for Chromium (see https://crbug.com/925652), and might be difficult for other big projects with many dependencies.
This CL facilitates moving off of deprecated APIs by making it possible for an embedder to define GTEST_INTERNAL_DEPRECATED() in gtest/internal/custom/gtest-port.h. Example usage:
1) #define GTEST_INTERNAL_DEPRECATED() to nothing, to disable deprecation warnings while migrating off googletest's deprecated APIs. This can be preferable to having to disable all deprecation warnings (-Wno-error=deprecated or -Wno-deprecated-declarations).
2) #define GTEST_INTERNAL_DEPRECATED() for an unsupported compiler.
PiperOrigin-RevId: 236171043
Due to some caveats in the FreeBSD build system and the fact that the
source file is used to compile 2 different death tests with different
flags, I needed (as a shortterm workaround) to copy the test to 2
differently named files.
While this works for compiling the test, as I discovered, this doesn't
work with running `CxxExceptionDeathTest.PrintsMessageForStdException`,
as the testcase hardcodes `googletest-death-test_ex_test.cc`. Use `__FILE__`
when looking for failures, as opposed to looking for the hardcoded name
as it can vary depending on how the test was built.
Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Update gtest-death-test to use new Fuchsia API
Fuchsia has renamed this API and removed the need for several parameters. We now use the newer, simpler API.
PiperOrigin-RevId: 234617715
clang++ compilation when `-Wsign-conversion` is currently broken and the
issues within the code are varied and widespread. For the time being
ignore `-Wsign-conversion` issues, even though some of them are valid
and bleed over into issues that would be found with
`-Wtautological-compare`, et al.
Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Fix matcher comparisons for std::reference_wrapper.
The googletest docs indicate that std::reference_wrapper should be used to for
objects that should not be copied by the matcher (in fact, the ByRef() function
is basically the same as a call to std::cref).
However, for many types (such as std::string), the overloaded operator== will
not resolve correctly. Specifically, this is problematic if operator== depends
on template argument deduction, where the same type is named on LHS and RHS.
Because template argument deduction happens before any implict conversions for
purposes of overload resolution, attempting to compare T with
std::reference_wrapper<T> simply looks like a comparison of unlike types.
For exapmle, std::reference_wrapper<std::string> is implicitly convertible to
'const std::string&', which would be able to choose an overload specialization
of operator==. However, the implicit conversion can only happen after template
argument deduction for operator==, so a specialization that would other be an
applicable overload is never considered.
Note also that this change only affects matchers. There are good reasons that
matchers may need to transparently hold a std::reference_wrapper. Other
comparisons (like EXPECT_EQ, et. al.) don't need to capture a reference: they
don't need to defer evaluation (as in googlemock), and they don't need to avoid
copies (as the call chain of matchers does).
PiperOrigin-RevId: 232499175
When building and using googletest from an install tree
we want libtool to generate rpath in the dependent binaries
to allow them to be executed from a build without a need
for LD_LIBRARY_PATH or similar.
For libtool based project this happens automatically
as projects generates .la files and install them.
Provide such a file for gtest as well to allow it to
work smoothly with libtool based projects.
Signed-off-by: Knut Omang <knut.omang@oracle.com>
This is just a mistake in the document. Google Test doesn't output
such an invalid JSON report.
Signed-off-by: Keiichi Watanabe <keiichiw@chromium.org>
Address -Wgnu-zero-variadic-macro-arguments
Originally in OSS PR #2063https://github.com/google/googletest/pull/2063
Fix regression in INSTANTIATE_TEST_SUITE_P macro to accept function pointers properly.
PiperOrigin-RevId: 232316698
I made a few updates to the Makefile.am files so that "make dist"
succeeds and produces a usable tarball. We need this for protobuf
because the protobuf tarballs include a bundled copy of googletest.
Fix warning about deprecation of implicit operations such as copy constructors or assignment operators.
Specifically:
MatcherBase's default copy constructor, assignment operator, move operator, and move assignment operator are now declared explicitly rather than depending on the compiler implicit generation (which is disallowed/warned against due to MatcherBase's declaration of the destructor).
PiperOrigin-RevId: 228573333
Improved flexibility by removing the Arduino entry points in favor of manual calls to setup/loop that the user can call from their entry point. This is the more common use case for Arudino.
Also added the gtest/gmock_main files to the PlatformIO ignore list since we are not supporting that feature.
Improve Bazel build files.
New target gtest_prod allows access to the FRIEND_TEST macro without depending on the entirety of GTest in production executables. Additionally, duplicate config_setting rules were removed and formatting was adjusted.
PiperOrigin-RevId: 220279205
[Fuchsia] Create the death test child process in a separate job.
This creates a separate job to launch the child process into. The
exception port can then be attached to the new job before the child
process is launched, solving a potential race condition.
PiperOrigin-RevId: 219366531
[Fuchsia] Make the child process stderr redirection use a socket.
This changes the stderr redirection mechanism for the child process in Fuchsia death tests to use a Zircon socket rather than fd redirection. This should improve performance and reliability of the redirection process.
This also includes some minor style cleanups.
PiperOrigin-RevId: 218903196
Per #1883, builds of Google Test may fail if the version C++ is not manually
set to C++11 during the build process.
Signed-off-by: Joel Anderson <joelanderson333@gmail.com>
New variadic implementation for gtest-param-test
Removed non-variadic implementation and added variadic for ValueArray and Values
PiperOrigin-RevId: 217703627
Using absolute paths in the pkg-config file makes it not relocatable and
leads to problems, when trying to use it with precompiled cross
toolchains. Setting prefix to relative path based on pcfiledir makes it
more reliable for such cases.