diff options
-rw-r--r-- | CMakeLists.txt | 10 | ||||
-rw-r--r-- | googlemock/test/gmock-matchers_test.cc | 14 | ||||
-rw-r--r-- | googletest/include/gtest/gtest-matchers.h | 13 | ||||
-rw-r--r-- | googletest/include/gtest/gtest.h | 3 | ||||
-rw-r--r-- | library.json | 4 |
5 files changed, 33 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index be14229e..afe79593 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,20 +1,22 @@ cmake_minimum_required(VERSION 2.8.8) +project(googletest-distribution) +set(GOOGLETEST_VERSION 1.9.0) + if (CMAKE_VERSION VERSION_LESS "3.1") add_definitions(-std=c++11) else() set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) - set(CMAKE_CXX_EXTENSIONS OFF) + if(NOT CYGWIN) + set(CMAKE_CXX_EXTENSIONS OFF) + endif() endif() if (POLICY CMP0048) cmake_policy(SET CMP0048 NEW) endif (POLICY CMP0048) -project(googletest-distribution) -set(GOOGLETEST_VERSION 1.9.0) - enable_testing() include(CMakeDependentOption) diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index 1f14a056..c2f1d0ad 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -452,6 +452,20 @@ TEST(StringViewMatcherTest, CanBeImplicitlyConstructedFromStringView) { } #endif // GTEST_HAS_ABSL +// Tests that a std::reference_wrapper<std::string> object can be implicitly +// converted to a Matcher<std::string> or Matcher<const std::string&> via Eq(). +TEST(StringMatcherTest, + CanBeImplicitlyConstructedFromEqReferenceWrapperString) { + std::string value = "cats"; + Matcher<std::string> m1 = Eq(std::ref(value)); + EXPECT_TRUE(m1.Matches("cats")); + EXPECT_FALSE(m1.Matches("dogs")); + + Matcher<const std::string&> m2 = Eq(std::ref(value)); + EXPECT_TRUE(m2.Matches("cats")); + EXPECT_FALSE(m2.Matches("dogs")); +} + // Tests that MakeMatcher() constructs a Matcher<T> from a // MatcherInterface* without requiring the user to explicitly // write the type. diff --git a/googletest/include/gtest/gtest-matchers.h b/googletest/include/gtest/gtest-matchers.h index 9a8841bb..846b9455 100644 --- a/googletest/include/gtest/gtest-matchers.h +++ b/googletest/include/gtest/gtest-matchers.h @@ -599,21 +599,26 @@ class ComparisonBase { } private: - template <typename Lhs> + template <typename T> + static const T& Unwrap(const T& v) { return v; } + template <typename T> + static const T& Unwrap(std::reference_wrapper<T> v) { return v; } + + template <typename Lhs, typename = Rhs> class Impl : public MatcherInterface<Lhs> { public: explicit Impl(const Rhs& rhs) : rhs_(rhs) {} bool MatchAndExplain(Lhs lhs, MatchResultListener* /* listener */) const override { - return Op()(lhs, rhs_); + return Op()(lhs, Unwrap(rhs_)); } void DescribeTo(::std::ostream* os) const override { *os << D::Desc() << " "; - UniversalPrint(rhs_, os); + UniversalPrint(Unwrap(rhs_), os); } void DescribeNegationTo(::std::ostream* os) const override { *os << D::NegatedDesc() << " "; - UniversalPrint(rhs_, os); + UniversalPrint(Unwrap(rhs_), os); } private: diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index beda83f7..5046f7dd 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -2394,7 +2394,8 @@ bool StaticAssertTypeEq() { // EXPECT_EQ(a_.size(), 0); // EXPECT_EQ(b_.size(), 1); // } - +// +// GOOGLETEST_CM0011 DO NOT DELETE #define TEST_F(test_fixture, test_name)\ GTEST_TEST_(test_fixture, test_name, test_fixture, \ ::testing::internal::GetTypeId<test_fixture>()) diff --git a/library.json b/library.json index d8392726..e46fcbda 100644 --- a/library.json +++ b/library.json @@ -27,7 +27,7 @@ "googlemock/make", "googlemock/msvc", "googlemock/scripts", - "googlemock/src/gmock_all.cc", + "googlemock/src/gmock-all.cc", "googlemock/src/gmock_main.cc", "googlemock/test", "googlemock/CMakeLists.txt", @@ -39,7 +39,7 @@ "googletest/make", "googletest/msvc", "googletest/scripts", - "googletest/src/gtest_all.cc", + "googletest/src/gtest-all.cc", "googletest/src/gtest_main.cc", "googletest/test", "googletest/xcode", |