diff options
-rw-r--r-- | googlemock/include/gmock/gmock-matchers.h | 11 | ||||
-rw-r--r-- | googlemock/test/gmock-matchers_test.cc | 13 | ||||
-rw-r--r-- | googletest/include/gtest/gtest-matchers.h | 11 | ||||
-rw-r--r-- | googletest/include/gtest/internal/gtest-port-arch.h | 2 | ||||
-rw-r--r-- | googletest/include/gtest/internal/gtest-port.h | 28 | ||||
-rw-r--r-- | googletest/src/gtest-death-test.cc | 12 | ||||
-rw-r--r-- | googletest/src/gtest-internal-inl.h | 11 | ||||
-rw-r--r-- | googletest/src/gtest.cc | 38 | ||||
-rw-r--r-- | googletest/test/gtest_unittest.cc | 15 |
9 files changed, 84 insertions, 57 deletions
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 3e4ee40..fcf8cf2 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -58,9 +58,16 @@ #include "gmock/internal/gmock-port.h" #include "gtest/gtest.h" +// MSVC warning C5046 is new as of VS2017 version 15.8. +#if defined(_MSC_VER) && _MSC_VER >= 1915 +#define GMOCK_MAYBE_5046_ 5046 +#else +#define GMOCK_MAYBE_5046_ +#endif + GTEST_DISABLE_MSC_WARNINGS_PUSH_( - 4251 5046 /* class A needs to have dll-interface to be used by clients of - class B */ + 4251 GMOCK_MAYBE_5046_ /* class A needs to have dll-interface to be used by + clients of class B */ /* Symbol involving type with internal linkage not defined */) namespace testing { diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index 5a5a786..eb0a050 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -4310,9 +4310,11 @@ TEST(ResultOfTest, WorksForPolymorphicFunctorsIgnoringResultType) { } TEST(ResultOfTest, WorksForLambdas) { - Matcher<int> matcher = - ResultOf([](int str_len) { - return std::string(static_cast<size_t>(str_len), 'x'); }, "xxx"); + Matcher<int> matcher = ResultOf( + [](int str_len) { + return std::string(static_cast<size_t>(str_len), 'x'); + }, + "xxx"); EXPECT_TRUE(matcher.Matches(3)); EXPECT_FALSE(matcher.Matches(1)); } @@ -5813,7 +5815,7 @@ class BacktrackingBPMTest : public ::testing::Test { }; // Tests the MaxBipartiteMatching algorithm with square matrices. // The single int param is the # of nodes on each of the left and right sides. -class BipartiteTest : public ::testing::TestWithParam<size_t> { }; +class BipartiteTest : public ::testing::TestWithParam<size_t> {}; // Verify all match graphs up to some moderate number of edges. TEST_P(BipartiteTest, Exhaustive) { @@ -5842,8 +5844,7 @@ TEST_P(BipartiteTest, Exhaustive) { } INSTANTIATE_TEST_SUITE_P(AllGraphs, BipartiteTest, - ::testing::Range(static_cast<size_t>(0), - static_cast<size_t>(5))); + ::testing::Range(size_t{0}, size_t{5})); // Parameterized by a pair interpreted as (LhsSize, RhsSize). class BipartiteNonSquareTest diff --git a/googletest/include/gtest/gtest-matchers.h b/googletest/include/gtest/gtest-matchers.h index bf500fc..6e73ba1 100644 --- a/googletest/include/gtest/gtest-matchers.h +++ b/googletest/include/gtest/gtest-matchers.h @@ -47,9 +47,16 @@ #include "gtest/internal/gtest-internal.h" #include "gtest/internal/gtest-port.h" +// MSVC warning C5046 is new as of VS2017 version 15.8. +#if defined(_MSC_VER) && _MSC_VER >= 1915 +#define GTEST_MAYBE_5046_ 5046 +#else +#define GTEST_MAYBE_5046_ +#endif + GTEST_DISABLE_MSC_WARNINGS_PUSH_( - 4251 5046 /* class A needs to have dll-interface to be used by clients of - class B */ + 4251 GTEST_MAYBE_5046_ /* class A needs to have dll-interface to be used by + clients of class B */ /* Symbol involving type with internal linkage not defined */) namespace testing { diff --git a/googletest/include/gtest/internal/gtest-port-arch.h b/googletest/include/gtest/internal/gtest-port-arch.h index 779872d..cece93d 100644 --- a/googletest/include/gtest/internal/gtest-port-arch.h +++ b/googletest/include/gtest/internal/gtest-port-arch.h @@ -100,6 +100,8 @@ # define GTEST_OS_OPENBSD 1 #elif defined __QNX__ # define GTEST_OS_QNX 1 +#elif defined(__HAIKU__) +#define GTEST_OS_HAIKU 1 #endif // __CYGWIN__ #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_ diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 4f80c2e..0a9a331 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -117,6 +117,7 @@ // GTEST_OS_FREEBSD - FreeBSD // GTEST_OS_FUCHSIA - Fuchsia // GTEST_OS_GNU_KFREEBSD - GNU/kFreeBSD +// GTEST_OS_HAIKU - Haiku // GTEST_OS_HPUX - HP-UX // GTEST_OS_LINUX - Linux // GTEST_OS_LINUX_ANDROID - Google Android @@ -136,7 +137,7 @@ // GTEST_OS_WINDOWS_RT - Windows Store App/WinRT // GTEST_OS_ZOS - z/OS // -// Among the platforms, Cygwin, Linux, Max OS X, and Windows have the +// Among the platforms, Cygwin, Linux, Mac OS X, and Windows have the // most stable support. Since core members of the Google Test project // don't have access to other platforms, support for them may be less // stable. If you notice any problems on your platform, please notify @@ -458,8 +459,9 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // Cygwin 1.7 and below doesn't support ::std::wstring. // Solaris' libc++ doesn't support it either. Android has // no support for it at least as recent as Froyo (2.2). -# define GTEST_HAS_STD_WSTRING \ - (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS)) +#define GTEST_HAS_STD_WSTRING \ + (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \ + GTEST_OS_HAIKU)) #endif // GTEST_HAS_STD_WSTRING @@ -533,10 +535,11 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // // To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0 // to your compiler flags. -#define GTEST_HAS_PTHREAD \ - (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX || \ +#define GTEST_HAS_PTHREAD \ + (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX || \ GTEST_OS_FREEBSD || GTEST_OS_NACL || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \ - GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_OPENBSD) + GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_OPENBSD || \ + GTEST_OS_HAIKU) #endif // GTEST_HAS_PTHREAD #if GTEST_HAS_PTHREAD @@ -590,13 +593,12 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // Determines whether to support death tests. // pops up a dialog window that cannot be suppressed programmatically. -#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \ - (GTEST_OS_MAC && !GTEST_OS_IOS) || \ - (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER) || \ - GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \ - GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD || \ - GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || GTEST_OS_DRAGONFLY || \ - GTEST_OS_GNU_KFREEBSD) +#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \ + (GTEST_OS_MAC && !GTEST_OS_IOS) || \ + (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER) || GTEST_OS_WINDOWS_MINGW || \ + GTEST_OS_AIX || GTEST_OS_HPUX || GTEST_OS_OPENBSD || GTEST_OS_QNX || \ + GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \ + GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_HAIKU) # define GTEST_HAS_DEATH_TEST 1 #endif diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc index 52031f3..9bfe315 100644 --- a/googletest/src/gtest-death-test.cc +++ b/googletest/src/gtest-death-test.cc @@ -888,7 +888,7 @@ int FuchsiaDeathTest::Wait() { // Register to wait for the socket to be readable or closed. status_zx = stderr_socket_.wait_async( port_, kSocketKey, ZX_SOCKET_READABLE | ZX_SOCKET_PEER_CLOSED, - ZX_WAIT_ASYNC_REPEATING); + ZX_WAIT_ASYNC_ONCE); GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); bool process_terminated = false; @@ -912,7 +912,7 @@ int FuchsiaDeathTest::Wait() { process_terminated = true; } } else if (packet.key == kSocketKey) { - GTEST_DEATH_TEST_CHECK_(ZX_PKT_IS_SIGNAL_REP(packet.type)); + GTEST_DEATH_TEST_CHECK_(ZX_PKT_IS_SIGNAL_ONE(packet.type)); if (packet.signal.observed & ZX_SOCKET_READABLE) { // Read data from the socket. constexpr size_t kBufferSize = 1024; @@ -929,6 +929,10 @@ int FuchsiaDeathTest::Wait() { socket_closed = true; } else { GTEST_DEATH_TEST_CHECK_(status_zx == ZX_ERR_SHOULD_WAIT); + status_zx = stderr_socket_.wait_async( + port_, kSocketKey, ZX_SOCKET_READABLE | ZX_SOCKET_PEER_CLOSED, + ZX_WAIT_ASYNC_ONCE); + GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); } } else { GTEST_DEATH_TEST_CHECK_(packet.signal.observed & ZX_SOCKET_PEER_CLOSED); @@ -990,7 +994,7 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() { zx_handle_t child_pipe_handle; int child_pipe_fd; status = fdio_pipe_half2(&child_pipe_fd, &child_pipe_handle); - GTEST_DEATH_TEST_CHECK_(status != ZX_OK); + GTEST_DEATH_TEST_CHECK_(status == ZX_OK); set_read_fd(child_pipe_fd); // Set the pipe handle for the child. @@ -1350,7 +1354,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) { if (!use_fork) { static const bool stack_grows_down = StackGrowsDown(); - const size_t stack_size = static_cast<size_t>(getpagesize()); + const auto stack_size = static_cast<size_t>(getpagesize()); // MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead. void* const stack = mmap(nullptr, stack_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h index b3e2724..53cd22b 100644 --- a/googletest/src/gtest-internal-inl.h +++ b/googletest/src/gtest-internal-inl.h @@ -298,8 +298,8 @@ void ForEach(const Container& c, Functor functor) { // in range [0, v.size()). template <typename E> inline E GetElementOr(const std::vector<E>& v, int i, E default_value) { - return (i < 0 || i >= static_cast<int>(v.size())) ? default_value : - v[static_cast<size_t>(i)]; + return (i < 0 || i >= static_cast<int>(v.size())) ? default_value + : v[static_cast<size_t>(i)]; } // Performs an in-place shuffle of a range of the vector's elements. @@ -321,8 +321,9 @@ void ShuffleRange(internal::Random* random, int begin, int end, // http://en.wikipedia.org/wiki/Fisher-Yates_shuffle for (int range_width = end - begin; range_width >= 2; range_width--) { const int last_in_range = begin + range_width - 1; - const int selected = begin + - static_cast<int>(random->Generate(static_cast<UInt32>(range_width))); + const int selected = + begin + + static_cast<int>(random->Generate(static_cast<UInt32>(range_width))); std::swap((*v)[static_cast<size_t>(selected)], (*v)[static_cast<size_t>(last_in_range)]); } @@ -1086,7 +1087,7 @@ class StreamingListener : public EmptyTestEventListener { GTEST_CHECK_(sockfd_ != -1) << "Send() can be called only when there is a connection."; - const size_t len = static_cast<size_t>(message.length()); + const auto len = static_cast<size_t>(message.length()); if (write(sockfd_, message.c_str(), len) != static_cast<ssize_t>(len)) { GTEST_LOG_(WARNING) << "stream_result_to: failed to stream to " diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 320f7cf..36210c6 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -1241,8 +1241,7 @@ std::string CreateUnifiedDiff(const std::vector<std::string>& left, for (; edit_i < edits.size(); ++edit_i) { if (n_suffix >= context) { // Continue only if the next hunk is very close. - std::vector<EditType>::const_iterator it = edits.begin() + - static_cast<int>(edit_i); + auto it = edits.begin() + static_cast<int>(edit_i); while (it != edits.end() && *it == kMatch) ++it; if (it == edits.end() || static_cast<size_t>(it - edits.begin()) - edit_i >= context) { @@ -1811,14 +1810,15 @@ inline bool IsUtf16SurrogatePair(wchar_t first, wchar_t second) { // Creates a Unicode code point from UTF16 surrogate pair. inline UInt32 CreateCodePointFromUtf16SurrogatePair(wchar_t first, wchar_t second) { - const UInt32 first_u = static_cast<UInt32>(first); - const UInt32 second_u = static_cast<UInt32>(second); + const auto first_u = static_cast<UInt32>(first); + const auto second_u = static_cast<UInt32>(second); const UInt32 mask = (1 << 10) - 1; - return (sizeof(wchar_t) == 2) ? - (((first_u & mask) << 10) | (second_u & mask)) + 0x10000 : - // This function should not be called when the condition is - // false, but we provide a sensible default in case it is. - first_u; + return (sizeof(wchar_t) == 2) + ? (((first_u & mask) << 10) | (second_u & mask)) + 0x10000 + : + // This function should not be called when the condition is + // false, but we provide a sensible default in case it is. + first_u; } // Converts a wide string to a narrow string in UTF-8 encoding. @@ -3431,14 +3431,14 @@ void TestEventRepeater::Name(const Type& parameter) { \ } // This defines a member that forwards the call to all listeners in reverse // order. -#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type) \ -void TestEventRepeater::Name(const Type& parameter) { \ - if (forwarding_enabled_) { \ - for (size_t i = listeners_.size(); i != 0; i--) { \ - listeners_[i-1]->Name(parameter); \ - } \ - } \ -} +#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type) \ + void TestEventRepeater::Name(const Type& parameter) { \ + if (forwarding_enabled_) { \ + for (size_t i = listeners_.size(); i != 0; i--) { \ + listeners_[i - 1]->Name(parameter); \ + } \ + } \ + } GTEST_REPEATER_METHOD_(OnTestProgramStart, UnitTest) GTEST_REPEATER_METHOD_(OnEnvironmentsSetUpStart, UnitTest) @@ -3476,7 +3476,7 @@ void TestEventRepeater::OnTestIterationEnd(const UnitTest& unit_test, int iteration) { if (forwarding_enabled_) { for (size_t i = listeners_.size(); i > 0; i--) { - listeners_[i-1]->OnTestIterationEnd(unit_test, iteration); + listeners_[i - 1]->OnTestIterationEnd(unit_test, iteration); } } } @@ -4080,7 +4080,7 @@ static std::string FormatEpochTimeInMillisAsRFC3339(TimeInMillis ms) { } static inline std::string Indent(size_t width) { - return std::string(static_cast<size_t>(width), ' '); + return std::string(width, ' '); } void JsonUnitTestResultPrinter::OutputJsonKey( diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 0c8bf99..28ced73 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -1018,7 +1018,8 @@ TEST_F(VectorShuffleTest, ShufflesStartOfVector) { ASSERT_PRED1(VectorIsNotCorrupt, vector_); EXPECT_PRED3(RangeIsShuffled, vector_, 0, kRangeSize); - EXPECT_PRED3(RangeIsUnshuffled, vector_, kRangeSize, static_cast<int>(kVectorSize)); + EXPECT_PRED3(RangeIsUnshuffled, vector_, kRangeSize, + static_cast<int>(kVectorSize)); } TEST_F(VectorShuffleTest, ShufflesEndOfVector) { @@ -1027,17 +1028,19 @@ TEST_F(VectorShuffleTest, ShufflesEndOfVector) { ASSERT_PRED1(VectorIsNotCorrupt, vector_); EXPECT_PRED3(RangeIsUnshuffled, vector_, 0, kRangeSize); - EXPECT_PRED3(RangeIsShuffled, vector_, kRangeSize, static_cast<int>(kVectorSize)); + EXPECT_PRED3(RangeIsShuffled, vector_, kRangeSize, + static_cast<int>(kVectorSize)); } TEST_F(VectorShuffleTest, ShufflesMiddleOfVector) { - int kRangeSize = static_cast<int>(kVectorSize)/3; + const int kRangeSize = static_cast<int>(kVectorSize) / 3; ShuffleRange(&random_, kRangeSize, 2*kRangeSize, &vector_); ASSERT_PRED1(VectorIsNotCorrupt, vector_); EXPECT_PRED3(RangeIsUnshuffled, vector_, 0, kRangeSize); EXPECT_PRED3(RangeIsShuffled, vector_, kRangeSize, 2*kRangeSize); - EXPECT_PRED3(RangeIsUnshuffled, vector_, 2*kRangeSize, static_cast<int>(kVectorSize)); + EXPECT_PRED3(RangeIsUnshuffled, vector_, 2 * kRangeSize, + static_cast<int>(kVectorSize)); } TEST_F(VectorShuffleTest, ShufflesRepeatably) { @@ -5654,8 +5657,8 @@ class ParseFlagsTest : public Test { // Asserts that two narrow or wide string arrays are equal. template <typename CharType> - static void AssertStringArrayEq(int size1, CharType** array1, - int size2, CharType** array2) { + static void AssertStringArrayEq(int size1, CharType** array1, int size2, + CharType** array2) { ASSERT_EQ(size1, size2) << " Array sizes different."; for (int i = 0; i != size1; i++) { |