diff options
author | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-09-16 17:38:08 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-09-16 17:38:08 +0000 |
commit | 4bd79e4f25a86f3a2a99f6af06cc43cdacc55853 (patch) | |
tree | 7500e3e892696d384d320f8c6c95320d1e3c58b7 /include/gmock | |
parent | f5e1ce5b9237edbc2e524ae9ebcb2452dc842937 (diff) | |
download | googletest-4bd79e4f25a86f3a2a99f6af06cc43cdacc55853.tar.gz googletest-4bd79e4f25a86f3a2a99f6af06cc43cdacc55853.tar.bz2 googletest-4bd79e4f25a86f3a2a99f6af06cc43cdacc55853.zip |
Simplifies the definition of NativeArray. Works around a VC bug in StrictMock & NiceMock.
Diffstat (limited to 'include/gmock')
-rw-r--r-- | include/gmock/gmock-generated-nice-strict.h | 72 | ||||
-rw-r--r-- | include/gmock/gmock-generated-nice-strict.h.pump | 24 | ||||
-rw-r--r-- | include/gmock/internal/gmock-internal-utils.h | 28 |
3 files changed, 73 insertions, 51 deletions
diff --git a/include/gmock/gmock-generated-nice-strict.h b/include/gmock/gmock-generated-nice-strict.h index f961d796..fc9a81b5 100644 --- a/include/gmock/gmock-generated-nice-strict.h +++ b/include/gmock/gmock-generated-nice-strict.h @@ -70,42 +70,49 @@ class NiceMock : public MockClass { // We don't factor out the constructor body to a common method, as // we have to avoid a possible clash with members of MockClass. NiceMock() { - Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::AllowUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } // C++ doesn't (yet) allow inheritance of constructors, so we have // to define it for each arity. template <typename A1> explicit NiceMock(const A1& a1) : MockClass(a1) { - Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::AllowUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2> NiceMock(const A1& a1, const A2& a2) : MockClass(a1, a2) { - Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::AllowUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2, typename A3> NiceMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) { - Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::AllowUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2, typename A3, typename A4> NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4) : MockClass(a1, a2, a3, a4) { - Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::AllowUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2, typename A3, typename A4, typename A5> NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5) : MockClass(a1, a2, a3, a4, a5) { - Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::AllowUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2, typename A3, typename A4, typename A5, typename A6> NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) { - Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::AllowUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2, typename A3, typename A4, typename A5, @@ -113,7 +120,8 @@ class NiceMock : public MockClass { NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5, a6, a7) { - Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::AllowUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2, typename A3, typename A4, typename A5, @@ -121,7 +129,8 @@ class NiceMock : public MockClass { NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8) { - Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::AllowUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2, typename A3, typename A4, typename A5, @@ -129,7 +138,8 @@ class NiceMock : public MockClass { NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) { - Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::AllowUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2, typename A3, typename A4, typename A5, @@ -137,11 +147,13 @@ class NiceMock : public MockClass { NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) { - Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::AllowUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } virtual ~NiceMock() { - Mock::UnregisterCallReaction(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::UnregisterCallReaction( + internal::implicit_cast<MockClass*>(this)); } }; @@ -151,40 +163,47 @@ class StrictMock : public MockClass { // We don't factor out the constructor body to a common method, as // we have to avoid a possible clash with members of MockClass. StrictMock() { - Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::FailUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1> explicit StrictMock(const A1& a1) : MockClass(a1) { - Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::FailUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2> StrictMock(const A1& a1, const A2& a2) : MockClass(a1, a2) { - Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::FailUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2, typename A3> StrictMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) { - Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::FailUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2, typename A3, typename A4> StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4) : MockClass(a1, a2, a3, a4) { - Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::FailUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2, typename A3, typename A4, typename A5> StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5) : MockClass(a1, a2, a3, a4, a5) { - Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::FailUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2, typename A3, typename A4, typename A5, typename A6> StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) { - Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::FailUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2, typename A3, typename A4, typename A5, @@ -192,7 +211,8 @@ class StrictMock : public MockClass { StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5, a6, a7) { - Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::FailUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2, typename A3, typename A4, typename A5, @@ -200,7 +220,8 @@ class StrictMock : public MockClass { StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8) { - Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::FailUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2, typename A3, typename A4, typename A5, @@ -208,7 +229,8 @@ class StrictMock : public MockClass { StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) { - Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::FailUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1, typename A2, typename A3, typename A4, typename A5, @@ -216,11 +238,13 @@ class StrictMock : public MockClass { StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) { - Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::FailUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } virtual ~StrictMock() { - Mock::UnregisterCallReaction(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::UnregisterCallReaction( + internal::implicit_cast<MockClass*>(this)); } }; diff --git a/include/gmock/gmock-generated-nice-strict.h.pump b/include/gmock/gmock-generated-nice-strict.h.pump index 580e79f0..b265c2e4 100644 --- a/include/gmock/gmock-generated-nice-strict.h.pump +++ b/include/gmock/gmock-generated-nice-strict.h.pump @@ -73,14 +73,16 @@ class NiceMock : public MockClass { // We don't factor out the constructor body to a common method, as // we have to avoid a possible clash with members of MockClass. NiceMock() { - Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::AllowUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } // C++ doesn't (yet) allow inheritance of constructors, so we have // to define it for each arity. template <typename A1> explicit NiceMock(const A1& a1) : MockClass(a1) { - Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::AllowUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } $range i 2..n @@ -88,13 +90,15 @@ $for i [[ $range j 1..i template <$for j, [[typename A$j]]> NiceMock($for j, [[const A$j& a$j]]) : MockClass($for j, [[a$j]]) { - Mock::AllowUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::AllowUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } ]] virtual ~NiceMock() { - Mock::UnregisterCallReaction(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::UnregisterCallReaction( + internal::implicit_cast<MockClass*>(this)); } }; @@ -104,25 +108,29 @@ class StrictMock : public MockClass { // We don't factor out the constructor body to a common method, as // we have to avoid a possible clash with members of MockClass. StrictMock() { - Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::FailUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } template <typename A1> explicit StrictMock(const A1& a1) : MockClass(a1) { - Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::FailUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } $for i [[ $range j 1..i template <$for j, [[typename A$j]]> StrictMock($for j, [[const A$j& a$j]]) : MockClass($for j, [[a$j]]) { - Mock::FailUninterestingCalls(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::FailUninterestingCalls( + internal::implicit_cast<MockClass*>(this)); } ]] virtual ~StrictMock() { - Mock::UnregisterCallReaction(internal::implicit_cast<MockClass*>(this)); + ::testing::Mock::UnregisterCallReaction( + internal::implicit_cast<MockClass*>(this)); } }; diff --git a/include/gmock/internal/gmock-internal-utils.h b/include/gmock/internal/gmock-internal-utils.h index ee6aa1e2..39e70b3f 100644 --- a/include/gmock/internal/gmock-internal-utils.h +++ b/include/gmock/internal/gmock-internal-utils.h @@ -581,21 +581,9 @@ class NativeArray { typedef Element value_type; typedef const Element* const_iterator; - // Constructs from a native array passed by reference. - template <size_t N> - NativeArray(const Element (&array)[N], RelationToSource relation) { - Init(array, N, relation); - } - - // Constructs from a native array passed by a pointer and a size. - // For generality we don't artificially restrict the types of the - // pointer and the size. - template <typename Pointer, typename Size> - NativeArray(const ::std::tr1::tuple<Pointer, Size>& array, - RelationToSource relation) { - Init(internal::GetRawPointer(::std::tr1::get<0>(array)), - ::std::tr1::get<1>(array), - relation); + // Constructs from a native array. + NativeArray(const Element* array, size_t count, RelationToSource relation) { + Init(array, count, relation); } // Copy constructor. @@ -691,10 +679,10 @@ class StlContainerView<Element[N]> { static const_reference ConstReference(const Element (&array)[N]) { // Ensures that Element is not a const type. testing::StaticAssertTypeEq<Element, RawElement>(); - return type(array, kReference); + return type(array, N, kReference); } static type Copy(const Element (&array)[N]) { - return type(array, kCopy); + return type(array, N, kCopy); } }; @@ -710,10 +698,12 @@ class StlContainerView< ::std::tr1::tuple<ElementPointer, Size> > { static const_reference ConstReference( const ::std::tr1::tuple<ElementPointer, Size>& array) { - return type(array, kReference); + using ::std::tr1::get; + return type(get<0>(array), get<1>(array), kReference); } static type Copy(const ::std::tr1::tuple<ElementPointer, Size>& array) { - return type(array, kCopy); + using ::std::tr1::get; + return type(get<0>(array), get<1>(array), kCopy); } }; |