diff options
author | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2013-04-24 02:49:43 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2013-04-24 02:49:43 +0000 |
commit | f4274520da256a3e8dd4fe2aa2e714f44ad89d18 (patch) | |
tree | 3776c14250f66f840ff9706e0a37aa71e4aebda2 | |
parent | 061f1d4d167a0c118ae653516770e9d78bab320e (diff) | |
download | googletest-f4274520da256a3e8dd4fe2aa2e714f44ad89d18.tar.gz googletest-f4274520da256a3e8dd4fe2aa2e714f44ad89d18.tar.bz2 googletest-f4274520da256a3e8dd4fe2aa2e714f44ad89d18.zip |
Makes EXPECT_THAT typesafe; updates CHANGES for 1.7.0; pulls in gtest r653
-rw-r--r-- | CHANGES | 22 | ||||
-rw-r--r-- | include/gmock/gmock-matchers.h | 6 | ||||
-rw-r--r-- | test/gmock-matchers_test.cc | 9 |
3 files changed, 34 insertions, 3 deletions
@@ -1,6 +1,26 @@ Changes for 1.7.0: -TO BE WRITTEN. +* All new improvements in Google Test 1.7.0. +* New feature: matchers WhenSorted(), WhenSortedBy(), IsEmpty(), and + SizeIs(). +* Improvement: Google Mock can now be built as a DLL. +* Improvement: when exceptions are enabled, a mock method with no + default action now throws instead crashing the test. +* Improvement: function return types used in MOCK_METHOD*() macros can + now contain unprotected commas. +* Improvement (potentially breaking): EXPECT_THAT() and ASSERT_THAT() + are now more strict in ensuring that the value type and the matcher + type are compatible, catching potential bugs in tests. +* Improvement: Pointee() now works on an optional<T>. +* Improvement: the ElementsAreArray() matcher can now take a vector or + iterator range as input, and makes a copy of its input elements + before the conversion to a Matcher. +* Bug fix: mock object destruction triggerred by another mock object's + destruction no longer hangs. +* Improvement: Google Mock Doctor works better with newer Clang and + GCC now. +* Compatibility fixes. +* Bug/warning fixes. Changes for 1.6.0: diff --git a/include/gmock/gmock-matchers.h b/include/gmock/gmock-matchers.h index 962cfde9..d4977273 100644 --- a/include/gmock/gmock-matchers.h +++ b/include/gmock/gmock-matchers.h @@ -1613,10 +1613,12 @@ class PredicateFormatterFromMatcher { // know which type to instantiate it to until we actually see the // type of x here. // - // We write MatcherCast<const T&>(matcher_) instead of + // We write SafeMatcherCast<const T&>(matcher_) instead of // Matcher<const T&>(matcher_), as the latter won't compile when // matcher_ has type Matcher<T> (e.g. An<int>()). - const Matcher<const T&> matcher = MatcherCast<const T&>(matcher_); + // We don't write MatcherCast<const T&> either, as that allows + // potentially unsafe downcasting of the matcher argument. + const Matcher<const T&> matcher = SafeMatcherCast<const T&>(matcher_); StringMatchResultListener listener; if (MatchPrintAndExplain(x, matcher, &listener)) return AssertionSuccess(); diff --git a/test/gmock-matchers_test.cc b/test/gmock-matchers_test.cc index 66459464..3ec2989e 100644 --- a/test/gmock-matchers_test.cc +++ b/test/gmock-matchers_test.cc @@ -721,6 +721,15 @@ TEST(ATest, MatchesAnyValue) { EXPECT_TRUE(m2.Matches(b)); } +TEST(ATest, WorksForDerivedClass) { + Base base; + Derived derived; + EXPECT_THAT(&base, A<Base*>()); + // This shouldn't compile: EXPECT_THAT(&base, A<Derived*>()); + EXPECT_THAT(&derived, A<Base*>()); + EXPECT_THAT(&derived, A<Derived*>()); +} + // Tests that A<T>() describes itself properly. TEST(ATest, CanDescribeSelf) { EXPECT_EQ("is anything", Describe(A<bool>())); |