Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:19:59

0001 // Copyright 2009, Google Inc.
0002 // All rights reserved.
0003 //
0004 // Redistribution and use in source and binary forms, with or without
0005 // modification, are permitted provided that the following conditions are
0006 // met:
0007 //
0008 //     * Redistributions of source code must retain the above copyright
0009 // notice, this list of conditions and the following disclaimer.
0010 //     * Redistributions in binary form must reproduce the above
0011 // copyright notice, this list of conditions and the following disclaimer
0012 // in the documentation and/or other materials provided with the
0013 // distribution.
0014 //     * Neither the name of Google Inc. nor the names of its
0015 // contributors may be used to endorse or promote products derived from
0016 // this software without specific prior written permission.
0017 //
0018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0019 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0020 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0021 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0022 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0023 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0024 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0025 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0026 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0027 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0028 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0029 //
0030 // Author: vladl@google.com (Vlad Losev)
0031 
0032 // Google Mock - a framework for writing C++ mock classes.
0033 //
0034 // This file tests that:
0035 // a. A header file defining a mock class can be included in multiple
0036 //    translation units without causing a link error.
0037 // b. Actions and matchers can be instantiated with identical template
0038 //    arguments in different translation units without causing link
0039 //    errors.
0040 //    The following constructs are currently tested:
0041 //    Actions:
0042 //      Return()
0043 //      Return(value)
0044 //      ReturnNull
0045 //      ReturnRef
0046 //      Assign
0047 //      SetArgPointee
0048 //      SetArrayArgument
0049 //      SetErrnoAndReturn
0050 //      Invoke(function)
0051 //      Invoke(object, method)
0052 //      InvokeWithoutArgs(function)
0053 //      InvokeWithoutArgs(object, method)
0054 //      InvokeArgument
0055 //      WithArg
0056 //      WithArgs
0057 //      WithoutArgs
0058 //      DoAll
0059 //      DoDefault
0060 //      IgnoreResult
0061 //      Throw
0062 //      ACTION()-generated
0063 //      ACTION_P()-generated
0064 //      ACTION_P2()-generated
0065 //    Matchers:
0066 //      _
0067 //      A
0068 //      An
0069 //      Eq
0070 //      Gt, Lt, Ge, Le, Ne
0071 //      NotNull
0072 //      Ref
0073 //      TypedEq
0074 //      DoubleEq
0075 //      FloatEq
0076 //      NanSensitiveDoubleEq
0077 //      NanSensitiveFloatEq
0078 //      ContainsRegex
0079 //      MatchesRegex
0080 //      EndsWith
0081 //      HasSubstr
0082 //      StartsWith
0083 //      StrCaseEq
0084 //      StrCaseNe
0085 //      StrEq
0086 //      StrNe
0087 //      ElementsAre
0088 //      ElementsAreArray
0089 //      ContainerEq
0090 //      Field
0091 //      Property
0092 //      ResultOf(function)
0093 //      Pointee
0094 //      Truly(predicate)
0095 //      AllOf
0096 //      AnyOf
0097 //      Not
0098 //      MatcherCast<T>
0099 //
0100 //  Please note: this test does not verify the functioning of these
0101 //  constructs, only that the programs using them will link successfully.
0102 //
0103 // Implementation note:
0104 // This test requires identical definitions of Interface and Mock to be
0105 // included in different translation units.  We achieve this by writing
0106 // them in this header and #including it in gmock_link_test.cc and
0107 // gmock_link2_test.cc.  Because the symbols generated by the compiler for
0108 // those constructs must be identical in both translation units,
0109 // definitions of Interface and Mock tests MUST be kept in the SAME
0110 // NON-ANONYMOUS namespace in this file.  The test fixture class LinkTest
0111 // is defined as LinkTest1 in gmock_link_test.cc and as LinkTest2 in
0112 // gmock_link2_test.cc to avoid producing linker errors.
0113 
0114 #ifndef GMOCK_TEST_GMOCK_LINK_TEST_H_
0115 #define GMOCK_TEST_GMOCK_LINK_TEST_H_
0116 
0117 #include "gmock/gmock.h"
0118 
0119 #if !GTEST_OS_WINDOWS_MOBILE
0120 # include <errno.h>
0121 #endif
0122 
0123 #include "gmock/internal/gmock-port.h"
0124 #include "gtest/gtest.h"
0125 #include <iostream>
0126 #include <vector>
0127 
0128 using testing::_;
0129 using testing::A;
0130 using testing::AllOf;
0131 using testing::AnyOf;
0132 using testing::Assign;
0133 using testing::ContainerEq;
0134 using testing::DoAll;
0135 using testing::DoDefault;
0136 using testing::DoubleEq;
0137 using testing::ElementsAre;
0138 using testing::ElementsAreArray;
0139 using testing::EndsWith;
0140 using testing::Eq;
0141 using testing::Field;
0142 using testing::FloatEq;
0143 using testing::Ge;
0144 using testing::Gt;
0145 using testing::HasSubstr;
0146 using testing::IgnoreResult;
0147 using testing::Invoke;
0148 using testing::InvokeArgument;
0149 using testing::InvokeWithoutArgs;
0150 using testing::IsNull;
0151 using testing::Le;
0152 using testing::Lt;
0153 using testing::Matcher;
0154 using testing::MatcherCast;
0155 using testing::NanSensitiveDoubleEq;
0156 using testing::NanSensitiveFloatEq;
0157 using testing::Ne;
0158 using testing::Not;
0159 using testing::NotNull;
0160 using testing::Pointee;
0161 using testing::Property;
0162 using testing::Ref;
0163 using testing::ResultOf;
0164 using testing::Return;
0165 using testing::ReturnNull;
0166 using testing::ReturnRef;
0167 using testing::SetArgPointee;
0168 using testing::SetArrayArgument;
0169 using testing::StartsWith;
0170 using testing::StrCaseEq;
0171 using testing::StrCaseNe;
0172 using testing::StrEq;
0173 using testing::StrNe;
0174 using testing::Truly;
0175 using testing::TypedEq;
0176 using testing::WithArg;
0177 using testing::WithArgs;
0178 using testing::WithoutArgs;
0179 
0180 #if !GTEST_OS_WINDOWS_MOBILE
0181 using testing::SetErrnoAndReturn;
0182 #endif
0183 
0184 #if GTEST_HAS_EXCEPTIONS
0185 using testing::Throw;
0186 #endif
0187 
0188 using testing::ContainsRegex;
0189 using testing::MatchesRegex;
0190 
0191 class Interface {
0192  public:
0193   virtual ~Interface() {}
0194   virtual void VoidFromString(char* str) = 0;
0195   virtual char* StringFromString(char* str) = 0;
0196   virtual int IntFromString(char* str) = 0;
0197   virtual int& IntRefFromString(char* str) = 0;
0198   virtual void VoidFromFunc(void(*func)(char* str)) = 0;
0199   virtual void VoidFromIntRef(int& n) = 0;  // NOLINT
0200   virtual void VoidFromFloat(float n) = 0;
0201   virtual void VoidFromDouble(double n) = 0;
0202   virtual void VoidFromVector(const std::vector<int>& v) = 0;
0203 };
0204 
0205 class Mock: public Interface {
0206  public:
0207   Mock() {}
0208 
0209   MOCK_METHOD1(VoidFromString, void(char* str));
0210   MOCK_METHOD1(StringFromString, char*(char* str));
0211   MOCK_METHOD1(IntFromString, int(char* str));
0212   MOCK_METHOD1(IntRefFromString, int&(char* str));
0213   MOCK_METHOD1(VoidFromFunc, void(void(*func)(char* str)));
0214   MOCK_METHOD1(VoidFromIntRef, void(int& n));  // NOLINT
0215   MOCK_METHOD1(VoidFromFloat, void(float n));
0216   MOCK_METHOD1(VoidFromDouble, void(double n));
0217   MOCK_METHOD1(VoidFromVector, void(const std::vector<int>& v));
0218 
0219  private:
0220   GTEST_DISALLOW_COPY_AND_ASSIGN_(Mock);
0221 };
0222 
0223 class InvokeHelper {
0224  public:
0225   static void StaticVoidFromVoid() {}
0226   void VoidFromVoid() {}
0227   static void StaticVoidFromString(char* /* str */) {}
0228   void VoidFromString(char* /* str */) {}
0229   static int StaticIntFromString(char* /* str */) { return 1; }
0230   static bool StaticBoolFromString(const char* /* str */) { return true; }
0231 };
0232 
0233 class FieldHelper {
0234  public:
0235   explicit FieldHelper(int a_field) : field_(a_field) {}
0236   int field() const { return field_; }
0237   int field_;  // NOLINT -- need external access to field_ to test
0238                //           the Field matcher.
0239 };
0240 
0241 // Tests the linkage of the ReturnVoid action.
0242 TEST(LinkTest, TestReturnVoid) {
0243   Mock mock;
0244 
0245   EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Return());
0246   mock.VoidFromString(NULL);
0247 }
0248 
0249 // Tests the linkage of the Return action.
0250 TEST(LinkTest, TestReturn) {
0251   Mock mock;
0252   char ch = 'x';
0253 
0254   EXPECT_CALL(mock, StringFromString(_)).WillOnce(Return(&ch));
0255   mock.StringFromString(NULL);
0256 }
0257 
0258 // Tests the linkage of the ReturnNull action.
0259 TEST(LinkTest, TestReturnNull) {
0260   Mock mock;
0261 
0262   EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Return());
0263   mock.VoidFromString(NULL);
0264 }
0265 
0266 // Tests the linkage of the ReturnRef action.
0267 TEST(LinkTest, TestReturnRef) {
0268   Mock mock;
0269   int n = 42;
0270 
0271   EXPECT_CALL(mock, IntRefFromString(_)).WillOnce(ReturnRef(n));
0272   mock.IntRefFromString(NULL);
0273 }
0274 
0275 // Tests the linkage of the Assign action.
0276 TEST(LinkTest, TestAssign) {
0277   Mock mock;
0278   char ch = 'x';
0279 
0280   EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Assign(&ch, 'y'));
0281   mock.VoidFromString(NULL);
0282 }
0283 
0284 // Tests the linkage of the SetArgPointee action.
0285 TEST(LinkTest, TestSetArgPointee) {
0286   Mock mock;
0287   char ch = 'x';
0288 
0289   EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArgPointee<0>('y'));
0290   mock.VoidFromString(&ch);
0291 }
0292 
0293 // Tests the linkage of the SetArrayArgument action.
0294 TEST(LinkTest, TestSetArrayArgument) {
0295   Mock mock;
0296   char ch = 'x';
0297   char ch2 = 'y';
0298 
0299   EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArrayArgument<0>(&ch2,
0300                                                                     &ch2 + 1));
0301   mock.VoidFromString(&ch);
0302 }
0303 
0304 #if !GTEST_OS_WINDOWS_MOBILE
0305 
0306 // Tests the linkage of the SetErrnoAndReturn action.
0307 TEST(LinkTest, TestSetErrnoAndReturn) {
0308   Mock mock;
0309 
0310   int saved_errno = errno;
0311   EXPECT_CALL(mock, IntFromString(_)).WillOnce(SetErrnoAndReturn(1, -1));
0312   mock.IntFromString(NULL);
0313   errno = saved_errno;
0314 }
0315 
0316 #endif  // !GTEST_OS_WINDOWS_MOBILE
0317 
0318 // Tests the linkage of the Invoke(function) and Invoke(object, method) actions.
0319 TEST(LinkTest, TestInvoke) {
0320   Mock mock;
0321   InvokeHelper test_invoke_helper;
0322 
0323   EXPECT_CALL(mock, VoidFromString(_))
0324       .WillOnce(Invoke(&InvokeHelper::StaticVoidFromString))
0325       .WillOnce(Invoke(&test_invoke_helper, &InvokeHelper::VoidFromString));
0326   mock.VoidFromString(NULL);
0327   mock.VoidFromString(NULL);
0328 }
0329 
0330 // Tests the linkage of the InvokeWithoutArgs action.
0331 TEST(LinkTest, TestInvokeWithoutArgs) {
0332   Mock mock;
0333   InvokeHelper test_invoke_helper;
0334 
0335   EXPECT_CALL(mock, VoidFromString(_))
0336       .WillOnce(InvokeWithoutArgs(&InvokeHelper::StaticVoidFromVoid))
0337       .WillOnce(InvokeWithoutArgs(&test_invoke_helper,
0338                                   &InvokeHelper::VoidFromVoid));
0339   mock.VoidFromString(NULL);
0340   mock.VoidFromString(NULL);
0341 }
0342 
0343 // Tests the linkage of the InvokeArgument action.
0344 TEST(LinkTest, TestInvokeArgument) {
0345   Mock mock;
0346   char ch = 'x';
0347 
0348   EXPECT_CALL(mock, VoidFromFunc(_)).WillOnce(InvokeArgument<0>(&ch));
0349   mock.VoidFromFunc(InvokeHelper::StaticVoidFromString);
0350 }
0351 
0352 // Tests the linkage of the WithArg action.
0353 TEST(LinkTest, TestWithArg) {
0354   Mock mock;
0355 
0356   EXPECT_CALL(mock, VoidFromString(_))
0357       .WillOnce(WithArg<0>(Invoke(&InvokeHelper::StaticVoidFromString)));
0358   mock.VoidFromString(NULL);
0359 }
0360 
0361 // Tests the linkage of the WithArgs action.
0362 TEST(LinkTest, TestWithArgs) {
0363   Mock mock;
0364 
0365   EXPECT_CALL(mock, VoidFromString(_))
0366       .WillOnce(WithArgs<0>(Invoke(&InvokeHelper::StaticVoidFromString)));
0367   mock.VoidFromString(NULL);
0368 }
0369 
0370 // Tests the linkage of the WithoutArgs action.
0371 TEST(LinkTest, TestWithoutArgs) {
0372   Mock mock;
0373 
0374   EXPECT_CALL(mock, VoidFromString(_)).WillOnce(WithoutArgs(Return()));
0375   mock.VoidFromString(NULL);
0376 }
0377 
0378 // Tests the linkage of the DoAll action.
0379 TEST(LinkTest, TestDoAll) {
0380   Mock mock;
0381   char ch = 'x';
0382 
0383   EXPECT_CALL(mock, VoidFromString(_))
0384       .WillOnce(DoAll(SetArgPointee<0>('y'), Return()));
0385   mock.VoidFromString(&ch);
0386 }
0387 
0388 // Tests the linkage of the DoDefault action.
0389 TEST(LinkTest, TestDoDefault) {
0390   Mock mock;
0391   char ch = 'x';
0392 
0393   ON_CALL(mock, VoidFromString(_)).WillByDefault(Return());
0394   EXPECT_CALL(mock, VoidFromString(_)).WillOnce(DoDefault());
0395   mock.VoidFromString(&ch);
0396 }
0397 
0398 // Tests the linkage of the IgnoreResult action.
0399 TEST(LinkTest, TestIgnoreResult) {
0400   Mock mock;
0401 
0402   EXPECT_CALL(mock, VoidFromString(_)).WillOnce(IgnoreResult(Return(42)));
0403   mock.VoidFromString(NULL);
0404 }
0405 
0406 #if GTEST_HAS_EXCEPTIONS
0407 // Tests the linkage of the Throw action.
0408 TEST(LinkTest, TestThrow) {
0409   Mock mock;
0410 
0411   EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Throw(42));
0412   EXPECT_THROW(mock.VoidFromString(NULL), int);
0413 }
0414 #endif  // GTEST_HAS_EXCEPTIONS
0415 
0416 // The ACTION*() macros trigger warning C4100 (unreferenced formal
0417 // parameter) in MSVC with -W4.  Unfortunately they cannot be fixed in
0418 // the macro definition, as the warnings are generated when the macro
0419 // is expanded and macro expansion cannot contain #pragma.  Therefore
0420 // we suppress them here.
0421 #ifdef _MSC_VER
0422 # pragma warning(push)
0423 # pragma warning(disable:4100)
0424 #endif
0425 
0426 // Tests the linkage of actions created using ACTION macro.
0427 namespace {
0428 ACTION(Return1) { return 1; }
0429 }
0430 
0431 TEST(LinkTest, TestActionMacro) {
0432   Mock mock;
0433 
0434   EXPECT_CALL(mock, IntFromString(_)).WillOnce(Return1());
0435   mock.IntFromString(NULL);
0436 }
0437 
0438 // Tests the linkage of actions created using ACTION_P macro.
0439 namespace {
0440 ACTION_P(ReturnArgument, ret_value) { return ret_value; }
0441 }
0442 
0443 TEST(LinkTest, TestActionPMacro) {
0444   Mock mock;
0445 
0446   EXPECT_CALL(mock, IntFromString(_)).WillOnce(ReturnArgument(42));
0447   mock.IntFromString(NULL);
0448 }
0449 
0450 // Tests the linkage of actions created using ACTION_P2 macro.
0451 namespace {
0452 ACTION_P2(ReturnEqualsEitherOf, first, second) {
0453   return arg0 == first || arg0 == second;
0454 }
0455 }
0456 
0457 #ifdef _MSC_VER
0458 # pragma warning(pop)
0459 #endif
0460 
0461 TEST(LinkTest, TestActionP2Macro) {
0462   Mock mock;
0463   char ch = 'x';
0464 
0465   EXPECT_CALL(mock, IntFromString(_))
0466       .WillOnce(ReturnEqualsEitherOf("one", "two"));
0467   mock.IntFromString(&ch);
0468 }
0469 
0470 // Tests the linkage of the "_" matcher.
0471 TEST(LinkTest, TestMatcherAnything) {
0472   Mock mock;
0473 
0474   ON_CALL(mock, VoidFromString(_)).WillByDefault(Return());
0475 }
0476 
0477 // Tests the linkage of the A matcher.
0478 TEST(LinkTest, TestMatcherA) {
0479   Mock mock;
0480 
0481   ON_CALL(mock, VoidFromString(A<char*>())).WillByDefault(Return());
0482 }
0483 
0484 // Tests the linkage of the Eq and the "bare value" matcher.
0485 TEST(LinkTest, TestMatchersEq) {
0486   Mock mock;
0487   const char* p = "x";
0488 
0489   ON_CALL(mock, VoidFromString(Eq(p))).WillByDefault(Return());
0490   ON_CALL(mock, VoidFromString(const_cast<char*>("y")))
0491       .WillByDefault(Return());
0492 }
0493 
0494 // Tests the linkage of the Lt, Gt, Le, Ge, and Ne matchers.
0495 TEST(LinkTest, TestMatchersRelations) {
0496   Mock mock;
0497 
0498   ON_CALL(mock, VoidFromFloat(Lt(1.0f))).WillByDefault(Return());
0499   ON_CALL(mock, VoidFromFloat(Gt(1.0f))).WillByDefault(Return());
0500   ON_CALL(mock, VoidFromFloat(Le(1.0f))).WillByDefault(Return());
0501   ON_CALL(mock, VoidFromFloat(Ge(1.0f))).WillByDefault(Return());
0502   ON_CALL(mock, VoidFromFloat(Ne(1.0f))).WillByDefault(Return());
0503 }
0504 
0505 // Tests the linkage of the NotNull matcher.
0506 TEST(LinkTest, TestMatcherNotNull) {
0507   Mock mock;
0508 
0509   ON_CALL(mock, VoidFromString(NotNull())).WillByDefault(Return());
0510 }
0511 
0512 // Tests the linkage of the IsNull matcher.
0513 TEST(LinkTest, TestMatcherIsNull) {
0514   Mock mock;
0515 
0516   ON_CALL(mock, VoidFromString(IsNull())).WillByDefault(Return());
0517 }
0518 
0519 // Tests the linkage of the Ref matcher.
0520 TEST(LinkTest, TestMatcherRef) {
0521   Mock mock;
0522   int a = 0;
0523 
0524   ON_CALL(mock, VoidFromIntRef(Ref(a))).WillByDefault(Return());
0525 }
0526 
0527 // Tests the linkage of the TypedEq matcher.
0528 TEST(LinkTest, TestMatcherTypedEq) {
0529   Mock mock;
0530   long a = 0;
0531 
0532   ON_CALL(mock, VoidFromIntRef(TypedEq<int&>(a))).WillByDefault(Return());
0533 }
0534 
0535 // Tests the linkage of the FloatEq, DoubleEq, NanSensitiveFloatEq and
0536 // NanSensitiveDoubleEq matchers.
0537 TEST(LinkTest, TestMatchersFloatingPoint) {
0538   Mock mock;
0539   float a = 0;
0540 
0541   ON_CALL(mock, VoidFromFloat(FloatEq(a))).WillByDefault(Return());
0542   ON_CALL(mock, VoidFromDouble(DoubleEq(a))).WillByDefault(Return());
0543   ON_CALL(mock, VoidFromFloat(NanSensitiveFloatEq(a))).WillByDefault(Return());
0544   ON_CALL(mock, VoidFromDouble(NanSensitiveDoubleEq(a)))
0545       .WillByDefault(Return());
0546 }
0547 
0548 // Tests the linkage of the ContainsRegex matcher.
0549 TEST(LinkTest, TestMatcherContainsRegex) {
0550   Mock mock;
0551 
0552   ON_CALL(mock, VoidFromString(ContainsRegex(".*"))).WillByDefault(Return());
0553 }
0554 
0555 // Tests the linkage of the MatchesRegex matcher.
0556 TEST(LinkTest, TestMatcherMatchesRegex) {
0557   Mock mock;
0558 
0559   ON_CALL(mock, VoidFromString(MatchesRegex(".*"))).WillByDefault(Return());
0560 }
0561 
0562 // Tests the linkage of the StartsWith, EndsWith, and HasSubstr matchers.
0563 TEST(LinkTest, TestMatchersSubstrings) {
0564   Mock mock;
0565 
0566   ON_CALL(mock, VoidFromString(StartsWith("a"))).WillByDefault(Return());
0567   ON_CALL(mock, VoidFromString(EndsWith("c"))).WillByDefault(Return());
0568   ON_CALL(mock, VoidFromString(HasSubstr("b"))).WillByDefault(Return());
0569 }
0570 
0571 // Tests the linkage of the StrEq, StrNe, StrCaseEq, and StrCaseNe matchers.
0572 TEST(LinkTest, TestMatchersStringEquality) {
0573   Mock mock;
0574   ON_CALL(mock, VoidFromString(StrEq("a"))).WillByDefault(Return());
0575   ON_CALL(mock, VoidFromString(StrNe("a"))).WillByDefault(Return());
0576   ON_CALL(mock, VoidFromString(StrCaseEq("a"))).WillByDefault(Return());
0577   ON_CALL(mock, VoidFromString(StrCaseNe("a"))).WillByDefault(Return());
0578 }
0579 
0580 // Tests the linkage of the ElementsAre matcher.
0581 TEST(LinkTest, TestMatcherElementsAre) {
0582   Mock mock;
0583 
0584   ON_CALL(mock, VoidFromVector(ElementsAre('a', _))).WillByDefault(Return());
0585 }
0586 
0587 // Tests the linkage of the ElementsAreArray matcher.
0588 TEST(LinkTest, TestMatcherElementsAreArray) {
0589   Mock mock;
0590   char arr[] = { 'a', 'b' };
0591 
0592   ON_CALL(mock, VoidFromVector(ElementsAreArray(arr))).WillByDefault(Return());
0593 }
0594 
0595 // Tests the linkage of the ContainerEq matcher.
0596 TEST(LinkTest, TestMatcherContainerEq) {
0597   Mock mock;
0598   std::vector<int> v;
0599 
0600   ON_CALL(mock, VoidFromVector(ContainerEq(v))).WillByDefault(Return());
0601 }
0602 
0603 // Tests the linkage of the Field matcher.
0604 TEST(LinkTest, TestMatcherField) {
0605   FieldHelper helper(0);
0606 
0607   Matcher<const FieldHelper&> m = Field(&FieldHelper::field_, Eq(0));
0608   EXPECT_TRUE(m.Matches(helper));
0609 
0610   Matcher<const FieldHelper*> m2 = Field(&FieldHelper::field_, Eq(0));
0611   EXPECT_TRUE(m2.Matches(&helper));
0612 }
0613 
0614 // Tests the linkage of the Property matcher.
0615 TEST(LinkTest, TestMatcherProperty) {
0616   FieldHelper helper(0);
0617 
0618   Matcher<const FieldHelper&> m = Property(&FieldHelper::field, Eq(0));
0619   EXPECT_TRUE(m.Matches(helper));
0620 
0621   Matcher<const FieldHelper*> m2 = Property(&FieldHelper::field, Eq(0));
0622   EXPECT_TRUE(m2.Matches(&helper));
0623 }
0624 
0625 // Tests the linkage of the ResultOf matcher.
0626 TEST(LinkTest, TestMatcherResultOf) {
0627   Matcher<char*> m = ResultOf(&InvokeHelper::StaticIntFromString, Eq(1));
0628   EXPECT_TRUE(m.Matches(NULL));
0629 }
0630 
0631 // Tests the linkage of the ResultOf matcher.
0632 TEST(LinkTest, TestMatcherPointee) {
0633   int n = 1;
0634 
0635   Matcher<int*> m = Pointee(Eq(1));
0636   EXPECT_TRUE(m.Matches(&n));
0637 }
0638 
0639 // Tests the linkage of the Truly matcher.
0640 TEST(LinkTest, TestMatcherTruly) {
0641   Matcher<const char*> m = Truly(&InvokeHelper::StaticBoolFromString);
0642   EXPECT_TRUE(m.Matches(NULL));
0643 }
0644 
0645 // Tests the linkage of the AllOf matcher.
0646 TEST(LinkTest, TestMatcherAllOf) {
0647   Matcher<int> m = AllOf(_, Eq(1));
0648   EXPECT_TRUE(m.Matches(1));
0649 }
0650 
0651 // Tests the linkage of the AnyOf matcher.
0652 TEST(LinkTest, TestMatcherAnyOf) {
0653   Matcher<int> m = AnyOf(_, Eq(1));
0654   EXPECT_TRUE(m.Matches(1));
0655 }
0656 
0657 // Tests the linkage of the Not matcher.
0658 TEST(LinkTest, TestMatcherNot) {
0659   Matcher<int> m = Not(_);
0660   EXPECT_FALSE(m.Matches(1));
0661 }
0662 
0663 // Tests the linkage of the MatcherCast<T>() function.
0664 TEST(LinkTest, TestMatcherCast) {
0665   Matcher<const char*> m = MatcherCast<const char*>(_);
0666   EXPECT_TRUE(m.Matches(NULL));
0667 }
0668 
0669 #endif  // GMOCK_TEST_GMOCK_LINK_TEST_H_