diff --git a/.github/workflows/gtest-ci.yml b/.github/workflows/gtest-ci.yml index b2dcab49..bcef926b 100644 --- a/.github/workflows/gtest-ci.yml +++ b/.github/workflows/gtest-ci.yml @@ -40,4 +40,4 @@ jobs: fetch-depth: 0 - name: Tests - run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... + run: bazel test --cxxopt=/std:c++14 --features=external_include_paths --test_output=errors ... diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md index 8a11d864..5be298d3 100644 --- a/docs/gmock_cook_book.md +++ b/docs/gmock_cook_book.md @@ -1424,11 +1424,12 @@ Use `Pair` when comparing maps or other associative containers. {% raw %} ```cpp -using testing::ElementsAre; -using testing::Pair; +using ::testing::UnorderedElementsAre; +using ::testing::Pair; ... - std::map m = {{"a", 1}, {"b", 2}, {"c", 3}}; - EXPECT_THAT(m, ElementsAre(Pair("a", 1), Pair("b", 2), Pair("c", 3))); + absl::flat_hash_map m = {{"a", 1}, {"b", 2}, {"c", 3}}; + EXPECT_THAT(m, UnorderedElementsAre( + Pair("a", 1), Pair("b", 2), Pair("c", 3))); ``` {% endraw %} @@ -1445,8 +1446,8 @@ using testing::Pair; * If the container is passed by pointer instead of by reference, just write `Pointee(ElementsAre*(...))`. * The order of elements *matters* for `ElementsAre*()`. If you are using it - with containers whose element order are undefined (e.g. `hash_map`) you - should use `WhenSorted` around `ElementsAre`. + with containers whose element order are undefined (such as a + `std::unordered_map`) you should use `UnorderedElementsAre`. ### Sharing Matchers diff --git a/googlemock/include/gmock/gmock-function-mocker.h b/googlemock/include/gmock/gmock-function-mocker.h index f565d980..b568aefe 100644 --- a/googlemock/include/gmock/gmock-function-mocker.h +++ b/googlemock/include/gmock/gmock-function-mocker.h @@ -34,8 +34,8 @@ // IWYU pragma: private, include "gmock/gmock.h" // IWYU pragma: friend gmock/.* -#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT -#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT +#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_FUNCTION_MOCKER_H_ +#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_FUNCTION_MOCKER_H_ #include // IWYU pragma: keep #include // IWYU pragma: keep @@ -511,4 +511,4 @@ using internal::FunctionMocker; #define GMOCK_MOCKER_(arity, constness, Method) \ GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__) -#endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ +#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_FUNCTION_MOCKER_H_ diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index b1343fdc..92d8eb9d 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -290,13 +290,6 @@ class WithoutMatchers { // Internal use only: access the singleton instance of WithoutMatchers. GTEST_API_ WithoutMatchers GetWithoutMatchers(); -// Disable MSVC warnings for infinite recursion, since in this case the -// recursion is unreachable. -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4717) -#endif - // Invalid() is usable as an expression of type T, but will terminate // the program with an assertion failure if actually run. This is useful // when a value of type T is needed for compilation, but the statement @@ -314,10 +307,6 @@ inline T Invalid() { #endif } -#ifdef _MSC_VER -#pragma warning(pop) -#endif - // Given a raw type (i.e. having no top-level reference or const // modifier) RawContainer that's either an STL-style container or a // native array, class StlContainerView has the diff --git a/googlemock/src/gmock-internal-utils.cc b/googlemock/src/gmock-internal-utils.cc index f7d740c0..7bfff02a 100644 --- a/googlemock/src/gmock-internal-utils.cc +++ b/googlemock/src/gmock-internal-utils.cc @@ -199,9 +199,10 @@ GTEST_API_ void IllegalDoDefault(const char* file, int line) { } constexpr char UnBase64Impl(char c, const char* const base64, char carry) { - return *base64 == 0 ? static_cast(65) - : *base64 == c ? carry - : UnBase64Impl(c, base64 + 1, carry + 1); + return *base64 == 0 ? static_cast(65) + : *base64 == c + ? carry + : UnBase64Impl(c, base64 + 1, static_cast(carry + 1)); } template diff --git a/googletest/src/gtest-printers.cc b/googletest/src/gtest-printers.cc index f3976d23..d475ad36 100644 --- a/googletest/src/gtest-printers.cc +++ b/googletest/src/gtest-printers.cc @@ -315,7 +315,7 @@ void PrintTo(__uint128_t v, ::std::ostream* os) { low = low / 10 + high_mod * 1844674407370955161 + carry / 10; char digit = static_cast(carry % 10); - *--p = '0' + digit; + *--p = static_cast('0' + digit); } *os << p; } diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 513a8878..81409a33 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -3245,18 +3245,15 @@ bool ShouldUseColor(bool stdout_is_tty) { #else // On non-Windows platforms, we rely on the TERM variable. const char* const term = posix::GetEnv("TERM"); - const bool term_supports_color = + const bool term_supports_color = term != nullptr && ( String::CStringEquals(term, "xterm") || String::CStringEquals(term, "xterm-color") || - String::CStringEquals(term, "xterm-256color") || String::CStringEquals(term, "screen") || - String::CStringEquals(term, "screen-256color") || String::CStringEquals(term, "tmux") || - String::CStringEquals(term, "tmux-256color") || String::CStringEquals(term, "rxvt-unicode") || - String::CStringEquals(term, "rxvt-unicode-256color") || String::CStringEquals(term, "linux") || - String::CStringEquals(term, "cygwin"); + String::CStringEquals(term, "cygwin") || + String::EndsWithCaseInsensitive(term, "-256color")); return stdout_is_tty && term_supports_color; #endif // GTEST_OS_WINDOWS }