summaryrefslogtreecommitdiffstats
path: root/googletest
diff options
context:
space:
mode:
Diffstat (limited to 'googletest')
-rw-r--r--googletest/README.md4
-rw-r--r--googletest/include/gtest/gtest-message.h36
-rw-r--r--googletest/include/gtest/gtest.h9
-rw-r--r--googletest/include/gtest/internal/gtest-internal.h1
-rw-r--r--googletest/include/gtest/internal/gtest-param-util.h4
-rw-r--r--googletest/include/gtest/internal/gtest-port.h18
-rw-r--r--googletest/src/gtest-internal-inl.h2
-rw-r--r--googletest/src/gtest.cc2
-rw-r--r--googletest/test/BUILD.bazel1
-rw-r--r--googletest/test/googletest-message-test.cc23
-rw-r--r--googletest/test/googletest-port-test.cc4
-rwxr-xr-xgoogletest/test/gtest_help_test.py64
-rw-r--r--googletest/test/gtest_unittest.cc2
13 files changed, 99 insertions, 71 deletions
diff --git a/googletest/README.md b/googletest/README.md
index 6bbd7f8..9331fce 100644
--- a/googletest/README.md
+++ b/googletest/README.md
@@ -25,7 +25,7 @@ When building GoogleTest as a standalone project, the typical workflow starts
with
```
-git clone https://github.com/google/googletest.git -b v1.13.0
+git clone https://github.com/google/googletest.git -b v1.14.0
cd googletest # Main directory of the cloned repository.
mkdir build # Create a directory to hold the build output.
cd build
@@ -145,7 +145,7 @@ We list the most frequently used macros below. For a complete list, see file
### Multi-threaded Tests
GoogleTest is thread-safe where the pthread library is available. After
-`#include "gtest/gtest.h"`, you can check the
+`#include <gtest/gtest.h>`, you can check the
`GTEST_IS_THREADSAFE` macro to see whether this is the case (yes if the macro is
`#defined` to 1, no if it's undefined.).
diff --git a/googletest/include/gtest/gtest-message.h b/googletest/include/gtest/gtest-message.h
index 4d4b152..59b805e 100644
--- a/googletest/include/gtest/gtest-message.h
+++ b/googletest/include/gtest/gtest-message.h
@@ -56,6 +56,13 @@
#include "gtest/internal/gtest-port.h"
+#ifdef GTEST_HAS_ABSL
+#include <type_traits>
+
+#include "absl/strings/internal/has_absl_stringify.h"
+#include "absl/strings/str_cat.h"
+#endif // GTEST_HAS_ABSL
+
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
/* class A needs to have dll-interface to be used by clients of class B */)
@@ -111,8 +118,17 @@ class GTEST_API_ Message {
*ss_ << str;
}
- // Streams a non-pointer value to this object.
- template <typename T>
+ // Streams a non-pointer value to this object. If building a version of
+ // GoogleTest with ABSL, this overload is only enabled if the value does not
+ // have an AbslStringify definition.
+ template <typename T
+#ifdef GTEST_HAS_ABSL
+ ,
+ typename std::enable_if<
+ !absl::strings_internal::HasAbslStringify<T>::value, // NOLINT
+ int>::type = 0
+#endif // GTEST_HAS_ABSL
+ >
inline Message& operator<<(const T& val) {
// Some libraries overload << for STL containers. These
// overloads are defined in the global namespace instead of ::std.
@@ -133,6 +149,22 @@ class GTEST_API_ Message {
return *this;
}
+#ifdef GTEST_HAS_ABSL
+ // Streams a non-pointer value with an AbslStringify definition to this
+ // object.
+ template <typename T,
+ typename std::enable_if<
+ absl::strings_internal::HasAbslStringify<T>::value, // NOLINT
+ int>::type = 0>
+ inline Message& operator<<(const T& val) {
+ // ::operator<< is needed here for a similar reason as with the non-Abseil
+ // version above
+ using ::operator<<;
+ *ss_ << absl::StrCat(val);
+ return *this;
+ }
+#endif // GTEST_HAS_ABSL
+
// Streams a pointer value to this object.
//
// This function is an overload of the previous one. When you
diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index de7d528..a932e68 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -51,7 +51,6 @@
#include <cstddef>
#include <cstdint>
-#include <iomanip>
#include <limits>
#include <memory>
#include <ostream>
@@ -1574,12 +1573,12 @@ AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
}
::std::stringstream lhs_ss;
- lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
- << lhs_value;
+ lhs_ss.precision(std::numeric_limits<RawType>::digits10 + 2);
+ lhs_ss << lhs_value;
::std::stringstream rhs_ss;
- rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
- << rhs_value;
+ rhs_ss.precision(std::numeric_limits<RawType>::digits10 + 2);
+ rhs_ss << rhs_value;
return EqFailure(lhs_expression, rhs_expression,
StringStreamToString(&lhs_ss), StringStreamToString(&rhs_ss),
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index a04a920..97a9833 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -58,7 +58,6 @@
#include <cstdint>
#include <functional>
-#include <iomanip>
#include <limits>
#include <map>
#include <set>
diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h
index 6a81c37..dd39e98 100644
--- a/googletest/include/gtest/internal/gtest-param-util.h
+++ b/googletest/include/gtest/internal/gtest-param-util.h
@@ -584,7 +584,9 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
GTEST_CHECK_(IsValidParamName(param_name))
<< "Parameterized test name '" << param_name
- << "' is invalid, in " << file << " line " << line << std::endl;
+ << "' is invalid (contains spaces, dashes, underscores, or "
+ "non-alphanumeric characters), in "
+ << file << " line " << line << "" << std::endl;
GTEST_CHECK_(test_param_names.count(param_name) == 0)
<< "Duplicate parameterized test name '" << param_name << "', in "
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 656df26..b887e24 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -220,7 +220,6 @@
// GTEST_HAS_ALT_PATH_SEP_ - Always defined to 0 or 1.
// GTEST_WIDE_STRING_USES_UTF16_ - Always defined to 0 or 1.
// GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ - Always defined to 0 or 1.
-// GTEST_HAS_DOWNCAST_ - Always defined to 0 or 1.
// GTEST_HAS_NOTIFICATION_- Always defined to 0 or 1.
//
// Synchronization:
@@ -313,10 +312,6 @@
#include "gtest/internal/custom/gtest-port.h"
#include "gtest/internal/gtest-port-arch.h"
-#ifndef GTEST_HAS_DOWNCAST_
-#define GTEST_HAS_DOWNCAST_ 0
-#endif
-
#ifndef GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
#define GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ 0
#endif
@@ -1153,17 +1148,12 @@ inline To ImplicitCast_(To x) {
// check to enforce this.
template <class Derived, class Base>
Derived* CheckedDowncastToActualType(Base* base) {
+ static_assert(std::is_base_of<Base, Derived>::value,
+ "target type not derived from source type");
#if GTEST_HAS_RTTI
- GTEST_CHECK_(typeid(*base) == typeid(Derived));
-#endif
-
-#if GTEST_HAS_DOWNCAST_
- return ::down_cast<Derived*>(base);
-#elif GTEST_HAS_RTTI
- return dynamic_cast<Derived*>(base); // NOLINT
-#else
- return static_cast<Derived*>(base); // Poor man's downcast.
+ GTEST_CHECK_(base == nullptr || dynamic_cast<Derived*>(base) != nullptr);
#endif
+ return static_cast<Derived*>(base);
}
#if GTEST_HAS_STREAM_REDIRECTION
diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h
index 1e9b5c2..5b7fcbd 100644
--- a/googletest/src/gtest-internal-inl.h
+++ b/googletest/src/gtest-internal-inl.h
@@ -672,7 +672,7 @@ class GTEST_API_ UnitTestImpl {
void AddTestInfo(internal::SetUpTestSuiteFunc set_up_tc,
internal::TearDownTestSuiteFunc tear_down_tc,
TestInfo* test_info) {
-#ifdef GTEST_HAS_FILE_SYSTEM
+#if GTEST_HAS_FILE_SYSTEM
// In order to support thread-safe death tests, we need to
// remember the original working directory when the test program
// was first invoked. We cannot do this in RUN_ALL_TESTS(), as
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index e56ee1a..66a315e 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -3229,7 +3229,7 @@ static const char* GetAnsiColorCode(GTestColor color) {
return "3";
default:
assert(false);
- return "9" ;
+ return "9";
}
}
diff --git a/googletest/test/BUILD.bazel b/googletest/test/BUILD.bazel
index 7754c13..1890b6f 100644
--- a/googletest/test/BUILD.bazel
+++ b/googletest/test/BUILD.bazel
@@ -64,6 +64,7 @@ cc_test(
"googletest-global-environment-unittest_.cc",
"googletest-break-on-failure-unittest_.cc",
"googletest-listener-test.cc",
+ "googletest-message-test.cc",
"googletest-output-test_.cc",
"googletest-list-tests-unittest_.cc",
"googletest-shuffle-test_.cc",
diff --git a/googletest/test/googletest-message-test.cc b/googletest/test/googletest-message-test.cc
index 54e9d43..bf1f094 100644
--- a/googletest/test/googletest-message-test.cc
+++ b/googletest/test/googletest-message-test.cc
@@ -36,10 +36,26 @@
#include "gtest/gtest-message.h"
#include "gtest/gtest.h"
+#ifdef GTEST_HAS_ABSL
+#include "absl/strings/str_format.h"
+#endif // GTEST_HAS_ABSL
+
namespace {
using ::testing::Message;
+#ifdef GTEST_HAS_ABSL
+struct AbslStringifiablePoint {
+ template <typename Sink>
+ friend void AbslStringify(Sink& sink, const AbslStringifiablePoint& p) {
+ absl::Format(&sink, "(%d, %d)", p.x, p.y);
+ }
+
+ int x;
+ int y;
+};
+#endif // GTEST_HAS_ABSL
+
// Tests the testing::Message class
// Tests the default constructor.
@@ -128,6 +144,13 @@ TEST(MessageTest, StreamsInt) {
EXPECT_EQ("123", (Message() << 123).GetString());
}
+#ifdef GTEST_HAS_ABSL
+// Tests streaming a type with an AbslStringify definition.
+TEST(MessageTest, StreamsAbslStringify) {
+ EXPECT_EQ("(1, 2)", (Message() << AbslStringifiablePoint{1, 2}).GetString());
+}
+#endif // GTEST_HAS_ABSL
+
// Tests that basic IO manipulators (endl, ends, and flush) can be
// streamed to Message.
TEST(MessageTest, StreamsBasicIoManip) {
diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc
index 32a2a7b..e0793ba 100644
--- a/googletest/test/googletest-port-test.cc
+++ b/googletest/test/googletest-port-test.cc
@@ -418,8 +418,8 @@ TYPED_TEST(RETest, ImplicitConstructorWorks) {
const RE simple(TypeParam("hello"));
EXPECT_STREQ("hello", simple.pattern());
- const RE normal(TypeParam(".*(\\w+)"));
- EXPECT_STREQ(".*(\\w+)", normal.pattern());
+ const RE normal(TypeParam(".*([[:alnum:]_]+)"));
+ EXPECT_STREQ(".*([[:alnum:]_]+)", normal.pattern());
}
// Tests that RE's constructors reject invalid regular expressions.
diff --git a/googletest/test/gtest_help_test.py b/googletest/test/gtest_help_test.py
index 85a0c33..38fc90f 100755
--- a/googletest/test/gtest_help_test.py
+++ b/googletest/test/gtest_help_test.py
@@ -43,11 +43,22 @@ import sys
from googletest.test import gtest_test_utils
+FREEBSD = ('FreeBSD', 'GNU/kFreeBSD')
+NETBSD = ('NetBSD',)
+OPENBSD = ('OpenBSD',)
+
+
+def is_bsd_based_os() -> bool:
+ """Determine whether or not the OS is BSD-based."""
+ if os.name != 'posix':
+ return False
+
+ return os.uname()[0] in (FREEBSD + NETBSD + OPENBSD)
+
+
IS_DARWIN = os.name == 'posix' and os.uname()[0] == 'Darwin'
IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
IS_GNUHURD = os.name == 'posix' and os.uname()[0] == 'GNU'
-IS_GNUKFREEBSD = os.name == 'posix' and os.uname()[0] == 'GNU/kFreeBSD'
-IS_OPENBSD = os.name == 'posix' and os.uname()[0] == 'OpenBSD'
IS_WINDOWS = os.name == 'nt'
PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_help_test_')
@@ -96,7 +107,7 @@ HELP_REGEX = re.compile(
)
-def RunWithFlag(flag):
+def run_with_flag(flag):
"""Runs gtest_help_test_ with the given flag.
Returns:
@@ -116,17 +127,14 @@ def RunWithFlag(flag):
class GTestHelpTest(gtest_test_utils.TestCase):
"""Tests the --help flag and its equivalent forms."""
- def TestHelpFlag(self, flag):
+ def test_prints_help_with_full_flag(self):
"""Verifies correct behavior when help flag is specified.
The right message must be printed and the tests must
skipped when the given flag is specified.
-
- Args:
- flag: A flag to pass to the binary or None.
"""
- exit_code, output = RunWithFlag(flag)
+ exit_code, output = run_with_flag('--help')
if HAS_ABSL_FLAGS:
# The Abseil flags library prints the ProgramUsageMessage() with
# --help and returns 1.
@@ -136,7 +144,7 @@ class GTestHelpTest(gtest_test_utils.TestCase):
self.assertTrue(HELP_REGEX.search(output), output)
- if IS_DARWIN or IS_LINUX or IS_GNUHURD or IS_GNUKFREEBSD or IS_OPENBSD:
+ if IS_DARWIN or IS_LINUX or IS_GNUHURD or is_bsd_based_os():
self.assertIn(STREAM_RESULT_TO_FLAG, output)
else:
self.assertNotIn(STREAM_RESULT_TO_FLAG, output)
@@ -146,53 +154,27 @@ class GTestHelpTest(gtest_test_utils.TestCase):
else:
self.assertNotIn(DEATH_TEST_STYLE_FLAG, output)
- def TestUnknownFlagWithAbseil(self, flag):
- """Verifies correct behavior when an unknown flag is specified.
-
- The right message must be printed and the tests must
- skipped when the given flag is specified.
-
- Args:
- flag: A flag to pass to the binary or None.
- """
- exit_code, output = RunWithFlag(flag)
- self.assertEqual(1, exit_code)
- self.assertIn('ERROR: Unknown command line flag', output)
-
- def TestNonHelpFlag(self, flag):
+ def test_runs_tests_without_help_flag(self):
"""Verifies correct behavior when no help flag is specified.
Verifies that when no help flag is specified, the tests are run
and the help message is not printed.
-
- Args:
- flag: A flag to pass to the binary or None.
"""
- exit_code, output = RunWithFlag(flag)
+ exit_code, output = run_with_flag(None)
self.assertNotEqual(exit_code, 0)
self.assertFalse(HELP_REGEX.search(output), output)
- def testPrintsHelpWithFullFlag(self):
- self.TestHelpFlag('--help')
-
- def testRunsTestsWithoutHelpFlag(self):
- """Verifies correct behavior when no help flag is specified.
-
- Verifies that when no help flag is specified, the tests are run
- and the help message is not printed.
- """
-
- self.TestNonHelpFlag(None)
-
- def testRunsTestsWithGtestInternalFlag(self):
+ def test_runs_tests_with_gtest_internal_flag(self):
"""Verifies correct behavior when internal testing flag is specified.
Verifies that the tests are run and no help message is printed when
a flag starting with Google Test prefix and 'internal_' is supplied.
"""
- self.TestNonHelpFlag(INTERNAL_FLAG_FOR_TESTING)
+ exit_code, output = run_with_flag(INTERNAL_FLAG_FOR_TESTING)
+ self.assertNotEqual(exit_code, 0)
+ self.assertFalse(HELP_REGEX.search(output), output)
if __name__ == '__main__':
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index 6caa03f..67d776e 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -4113,7 +4113,7 @@ TEST(ExpectThrowTest, DoesNotGenerateUnreachableCodeWarning) {
EXPECT_THROW(throw 1, int);
EXPECT_NONFATAL_FAILURE(EXPECT_THROW(n++, int), "");
- EXPECT_NONFATAL_FAILURE(EXPECT_THROW(throw 1, const char*), "");
+ EXPECT_NONFATAL_FAILURE(EXPECT_THROW(throw n, const char*), "");
EXPECT_NO_THROW(n++);
EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(throw 1), "");
EXPECT_ANY_THROW(throw 1);