blob: 4e0adb71f76d032fab456cb68ce8a4e318cc935c [file] [log] [blame]
zhanyong.wan38ca64d2009-02-19 22:30:22 +00001// Copyright 2009, Google Inc.
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8// * Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// * Redistributions in binary form must reproduce the above
11// copyright notice, this list of conditions and the following disclaimer
12// in the documentation and/or other materials provided with the
13// distribution.
14// * Neither the name of Google Inc. nor the names of its
15// contributors may be used to endorse or promote products derived from
16// this software without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29//
30// Author: vladl@google.com (Vlad Losev)
31
32// Google Mock - a framework for writing C++ mock classes.
33//
34// This file tests that:
35// a. A header file defining a mock class can be included in multiple
36// translation units without causing a link error.
37// b. Actions and matchers can be instantiated with identical template
38// arguments in different translation units without causing link
39// errors.
40// The following constructs are currently tested:
41// Actions:
42// Return()
43// Return(value)
44// ReturnNull
45// ReturnRef
46// Assign
47// SetArgumentPointee
48// SetArrayArgument
49// SetErrnoAndReturn
50// Invoke(function)
51// Invoke(object, method)
52// InvokeWithoutArgs(function)
53// InvokeWithoutArgs(object, method)
54// InvokeArgument
55// WithArg
56// WithArgs
57// WithoutArgs
58// DoAll
59// DoDefault
60// IgnoreResult
61// Throw
62// ACTION()-generated
63// ACTION_P()-generated
64// ACTION_P2()-generated
65// Matchers:
66// _
67// A
68// An
69// Eq
70// Gt, Lt, Ge, Le, Ne
71// NotNull
72// Ref
73// TypedEq
74// DoubleEq
75// FloatEq
76// NanSensitiveDoubleEq
77// NanSensitiveFloatEq
78// ContainsRegex
79// MatchesRegex
80// EndsWith
81// HasSubstr
82// StartsWith
83// StrCaseEq
84// StrCaseNe
85// StrEq
86// StrNe
87// ElementsAre
88// ElementsAreArray
89// ContainerEq
90// Field
91// Property
92// ResultOf(function)
93// Pointee
94// Truly(predicate)
95// AllOf
96// AnyOf
97// Not
98// MatcherCast<T>
99//
100// Please note: this test does not verify the functioning of these
101// constructs, only that the programs using them will link successfully.
102//
103// Implementation note:
104// This test requires identical definitions of Interface and Mock to be
105// included in different translation units. We achieve this by writing
106// them in this header and #including it in gmock_link_test.cc and
107// gmock_link2_test.cc. Because the symbols generated by the compiler for
108// those constructs must be identical in both translation units,
109// definitions of Interface and Mock tests MUST be kept in the SAME
110// NON-ANONYMOUS namespace in this file. The test fixture class LinkTest
111// is defined as LinkTest1 in gmock_link_test.cc and as LinkTest2 in
112// gmock_link2_test.cc to avoid producing linker errors.
113
114#ifndef GMOCK_TEST_GMOCK_LINK_TEST_H_
115#define GMOCK_TEST_GMOCK_LINK_TEST_H_
116
117#include <gmock/gmock.h>
118
zhanyong.wan5b5d62f2009-03-11 23:37:56 +0000119#ifndef _WIN32_WCE
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000120#include <errno.h>
zhanyong.wan5b5d62f2009-03-11 23:37:56 +0000121#endif
122
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000123#include <gtest/gtest.h>
124#include <iostream>
125#include <vector>
126
127using testing::_;
128using testing::A;
129using testing::AllOf;
130using testing::AnyOf;
131using testing::Assign;
132using testing::ContainerEq;
133using testing::DoAll;
134using testing::DoDefault;
135using testing::DoubleEq;
136using testing::ElementsAre;
137using testing::ElementsAreArray;
138using testing::EndsWith;
139using testing::Eq;
140using testing::Field;
141using testing::FloatEq;
142using testing::Ge;
143using testing::Gt;
144using testing::HasSubstr;
145using testing::IgnoreResult;
146using testing::Invoke;
147using testing::InvokeArgument;
148using testing::InvokeWithoutArgs;
149using testing::Le;
150using testing::Lt;
151using testing::Matcher;
152using testing::MatcherCast;
153using testing::NanSensitiveDoubleEq;
154using testing::NanSensitiveFloatEq;
155using testing::Ne;
156using testing::Not;
157using testing::NotNull;
158using testing::Pointee;
159using testing::Property;
160using testing::Ref;
161using testing::ResultOf;
162using testing::Return;
163using testing::ReturnNull;
164using testing::ReturnRef;
165using testing::SetArgumentPointee;
166using testing::SetArrayArgument;
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000167using testing::StartsWith;
168using testing::StrCaseEq;
169using testing::StrCaseNe;
170using testing::StrEq;
171using testing::StrNe;
172using testing::Truly;
173using testing::TypedEq;
174using testing::WithArg;
175using testing::WithArgs;
176using testing::WithoutArgs;
177
zhanyong.wan5b5d62f2009-03-11 23:37:56 +0000178#ifndef _WIN32_WCE
179using testing::SetErrnoAndReturn;
180#endif // _WIN32_WCE
181
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000182#if GTEST_HAS_EXCEPTIONS
183using testing::Throw;
184#endif // GTEST_HAS_EXCEPTIONS
185
186#if GMOCK_HAS_REGEX
187using testing::ContainsRegex;
188using testing::MatchesRegex;
189#endif // GMOCK_HAS_REGEX
190
191class Interface {
192 public:
193 virtual ~Interface() {}
194 virtual void VoidFromString(char* str) = 0;
195 virtual char* StringFromString(char* str) = 0;
196 virtual int IntFromString(char* str) = 0;
197 virtual int& IntRefFromString(char* str) = 0;
198 virtual void VoidFromFunc(void(*)(char*)) = 0;
199 virtual void VoidFromIntRef(int& n) = 0;
200 virtual void VoidFromFloat(float n) = 0;
201 virtual void VoidFromDouble(double n) = 0;
202 virtual void VoidFromVector(const std::vector<int>& v) = 0;
203};
204
205class Mock: public Interface {
206 public:
207 MOCK_METHOD1(VoidFromString, void(char* str));
208 MOCK_METHOD1(StringFromString, char*(char* str));
209 MOCK_METHOD1(IntFromString, int(char* str));
210 MOCK_METHOD1(IntRefFromString, int&(char* str));
211 MOCK_METHOD1(VoidFromFunc, void(void(*func)(char* str)));
212 MOCK_METHOD1(VoidFromIntRef, void(int& n));
213 MOCK_METHOD1(VoidFromFloat, void(float n));
214 MOCK_METHOD1(VoidFromDouble, void(double n));
215 MOCK_METHOD1(VoidFromVector, void(const std::vector<int>& v));
216};
217
218class InvokeHelper {
219 public:
220 static void StaticVoidFromVoid() {}
221 void VoidFromVoid() {}
222 static void StaticVoidFromString(char*) {}
223 void VoidFromString(char*) {}
224 static int StaticIntFromString(char*) { return 1; }
225 static bool StaticBoolFromString(const char*) { return true; }
226};
227
228class FieldHelper {
229 public:
230 FieldHelper(int field) : field_(field) {}
231 int field() const { return field_; }
232 int field_; // NOLINT -- need external access to field_ to test
233 // the Field matcher.
234};
235
236// Tests the linkage of the ReturnVoid action.
237TEST(LinkTest, TestReturnVoid) {
238 Mock mock;
239
240 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Return());
241 mock.VoidFromString(NULL);
242}
243
244// Tests the linkage of the Return action.
245TEST(LinkTest, TestReturn) {
246 Mock mock;
247 char ch = 'x';
248
249 EXPECT_CALL(mock, StringFromString(_)).WillOnce(Return(&ch));
250 mock.StringFromString(NULL);
251}
252
253// Tests the linkage of the ReturnNull action.
254TEST(LinkTest, TestReturnNull) {
255 Mock mock;
256
257 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Return());
258 mock.VoidFromString(NULL);
259}
260
261// Tests the linkage of the ReturnRef action.
262TEST(LinkTest, TestReturnRef) {
263 Mock mock;
264 int n = 42;
265
266 EXPECT_CALL(mock, IntRefFromString(_)).WillOnce(ReturnRef(n));
267 mock.IntRefFromString(NULL);
268}
269
270// Tests the linkage of the Assign action.
271TEST(LinkTest, TestAssign) {
272 Mock mock;
273 char ch = 'x';
274
275 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Assign(&ch, 'y'));
276 mock.VoidFromString(NULL);
277}
278
279// Tests the linkage of the SetArgumentPointee action.
280TEST(LinkTest, TestSetArgumentPointee) {
281 Mock mock;
282 char ch = 'x';
283
284 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArgumentPointee<0>('y'));
285 mock.VoidFromString(&ch);
286}
287
288// Tests the linkage of the SetArrayArgument action.
289TEST(LinkTest, TestSetArrayArgument) {
290 Mock mock;
291 char ch = 'x';
292 char ch2 = 'y';
293
294 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArrayArgument<0>(&ch2,
295 &ch2 + 1));
296 mock.VoidFromString(&ch);
297}
298
zhanyong.wan5b5d62f2009-03-11 23:37:56 +0000299#ifndef _WIN32_WCE
300
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000301// Tests the linkage of the SetErrnoAndReturn action.
302TEST(LinkTest, TestSetErrnoAndReturn) {
303 Mock mock;
304
305 int saved_errno = errno;
306 EXPECT_CALL(mock, IntFromString(_)).WillOnce(SetErrnoAndReturn(1, -1));
307 mock.IntFromString(NULL);
308 errno = saved_errno;
309}
310
zhanyong.wan5b5d62f2009-03-11 23:37:56 +0000311#endif // _WIN32_WCE
312
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000313// Tests the linkage of the Invoke(function) and Invoke(object, method) actions.
314TEST(LinkTest, TestInvoke) {
315 Mock mock;
316 InvokeHelper test_invoke_helper;
317
318 EXPECT_CALL(mock, VoidFromString(_))
319 .WillOnce(Invoke(&InvokeHelper::StaticVoidFromString))
320 .WillOnce(Invoke(&test_invoke_helper, &InvokeHelper::VoidFromString));
321 mock.VoidFromString(NULL);
322 mock.VoidFromString(NULL);
323}
324
325// Tests the linkage of the InvokeWithoutArgs action.
326TEST(LinkTest, TestInvokeWithoutArgs) {
327 Mock mock;
328 InvokeHelper test_invoke_helper;
329
330 EXPECT_CALL(mock, VoidFromString(_))
331 .WillOnce(InvokeWithoutArgs(&InvokeHelper::StaticVoidFromVoid))
332 .WillOnce(InvokeWithoutArgs(&test_invoke_helper,
333 &InvokeHelper::VoidFromVoid));
334 mock.VoidFromString(NULL);
335 mock.VoidFromString(NULL);
336}
337
338// Tests the linkage of the InvokeArgument action.
339TEST(LinkTest, TestInvokeArgument) {
340 Mock mock;
341 char ch = 'x';
342
343 EXPECT_CALL(mock, VoidFromFunc(_)).WillOnce(InvokeArgument<0>(&ch));
344 mock.VoidFromFunc(InvokeHelper::StaticVoidFromString);
345}
346
347// Tests the linkage of the WithArg action.
348TEST(LinkTest, TestWithArg) {
349 Mock mock;
350
351 EXPECT_CALL(mock, VoidFromString(_))
352 .WillOnce(WithArg<0>(Invoke(&InvokeHelper::StaticVoidFromString)));
353 mock.VoidFromString(NULL);
354}
355
356// Tests the linkage of the WithArgs action.
357TEST(LinkTest, TestWithArgs) {
358 Mock mock;
359
360 EXPECT_CALL(mock, VoidFromString(_))
361 .WillOnce(WithArgs<0>(Invoke(&InvokeHelper::StaticVoidFromString)));
362 mock.VoidFromString(NULL);
363}
364
365// Tests the linkage of the WithoutArgs action.
366TEST(LinkTest, TestWithoutArgs) {
367 Mock mock;
368
369 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(WithoutArgs(Return()));
370 mock.VoidFromString(NULL);
371}
372
373// Tests the linkage of the DoAll action.
374TEST(LinkTest, TestDoAll) {
375 Mock mock;
376 char ch = 'x';
377
378 EXPECT_CALL(mock, VoidFromString(_))
379 .WillOnce(DoAll(SetArgumentPointee<0>('y'), Return()));
380 mock.VoidFromString(&ch);
381}
382
383// Tests the linkage of the DoDefault action.
384TEST(LinkTest, TestDoDefault) {
385 Mock mock;
386 char ch = 'x';
387
388 ON_CALL(mock, VoidFromString(_)).WillByDefault(Return());
389 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(DoDefault());
390 mock.VoidFromString(&ch);
391}
392
393// Tests the linkage of the IgnoreResult action.
394TEST(LinkTest, TestIgnoreResult) {
395 Mock mock;
396
397 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(IgnoreResult(Return(42)));
398 mock.VoidFromString(NULL);
399}
400
401#if GTEST_HAS_EXCEPTIONS
402// Tests the linkage of the Throw action.
403TEST(LinkTest, TestThrow) {
404 Mock mock;
405
406 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Throw(42));
407 EXPECT_THROW(mock.VoidFromString(NULL), int);
408}
409#endif // GTEST_HAS_EXCEPTIONS
410
411// Tests the linkage of actions created using ACTION macro.
412namespace {
413ACTION(Return1) { return 1; }
414}
415
416TEST(LinkTest, TestActionMacro) {
417 Mock mock;
418
419 EXPECT_CALL(mock, IntFromString(_)).WillOnce(Return1());
420 mock.IntFromString(NULL);
421}
422
423// Tests the linkage of actions created using ACTION_P macro.
424namespace {
425ACTION_P(ReturnArgument, ret_value) { return ret_value; }
426}
427
428TEST(LinkTest, TestActionPMacro) {
429 Mock mock;
430
431 EXPECT_CALL(mock, IntFromString(_)).WillOnce(ReturnArgument(42));
432 mock.IntFromString(NULL);
433}
434
435// Tests the linkage of actions created using ACTION_P2 macro.
436namespace {
437ACTION_P2(ReturnEqualsEitherOf, first, second) {
438 return arg0 == first || arg0 == second;
439}
440}
441
442TEST(LinkTest, TestActionP2Macro) {
443 Mock mock;
444 char ch = 'x';
445
446 EXPECT_CALL(mock, IntFromString(_))
447 .WillOnce(ReturnEqualsEitherOf("one", "two"));
448 mock.IntFromString(&ch);
449}
450
451// Tests the linkage of the "_" matcher.
452TEST(LinkTest, TestMatcherAnything) {
453 Mock mock;
454
455 ON_CALL(mock, VoidFromString(_)).WillByDefault(Return());
456}
457
458// Tests the linkage of the A matcher.
459TEST(LinkTest, TestMatcherA) {
460 Mock mock;
461
462 ON_CALL(mock, VoidFromString(A<char*>())).WillByDefault(Return());
463}
464
465// Tests the linkage of the Eq and the "bare value" matcher.
466TEST(LinkTest, TestMatchersEq) {
467 Mock mock;
468 const char* p = "x";
469
470 ON_CALL(mock, VoidFromString(Eq(p))).WillByDefault(Return());
471 ON_CALL(mock, VoidFromString(const_cast<char*>("y")))
472 .WillByDefault(Return());
473}
474
475// Tests the linkage of the Lt, Gt, Le, Ge, and Ne matchers.
476TEST(LinkTest, TestMatchersRelations) {
477 Mock mock;
478
479 ON_CALL(mock, VoidFromFloat(Lt(1.0f))).WillByDefault(Return());
480 ON_CALL(mock, VoidFromFloat(Gt(1.0f))).WillByDefault(Return());
481 ON_CALL(mock, VoidFromFloat(Le(1.0f))).WillByDefault(Return());
482 ON_CALL(mock, VoidFromFloat(Ge(1.0f))).WillByDefault(Return());
483 ON_CALL(mock, VoidFromFloat(Ne(1.0f))).WillByDefault(Return());
484}
485
486// Tests the linkage of the NotNull matcher.
487TEST(LinkTest, TestMatcherNotNull) {
488 Mock mock;
489
490 ON_CALL(mock, VoidFromString(NotNull())).WillByDefault(Return());
491}
492
493// Tests the linkage of the Ref matcher.
494TEST(LinkTest, TestMatcherRef) {
495 Mock mock;
496 int a = 0;
497
498 ON_CALL(mock, VoidFromIntRef(Ref(a))).WillByDefault(Return());
499}
500
501// Tests the linkage of the TypedEq matcher.
502TEST(LinkTest, TestMatcherTypedEq) {
503 Mock mock;
zhanyong.wan3fbd2dd2009-03-26 19:06:45 +0000504 long a = 0;
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000505
506 ON_CALL(mock, VoidFromIntRef(TypedEq<int&>(a))).WillByDefault(Return());
507}
508
509// Tests the linkage of the FloatEq, DoubleEq, NanSensitiveFloatEq and
510// NanSensitiveDoubleEq matchers.
511TEST(LinkTest, TestMatchersFloatingPoint) {
512 Mock mock;
513 float a = 0;
514
515 ON_CALL(mock, VoidFromFloat(FloatEq(a))).WillByDefault(Return());
516 ON_CALL(mock, VoidFromDouble(DoubleEq(a))).WillByDefault(Return());
517 ON_CALL(mock, VoidFromFloat(NanSensitiveFloatEq(a))).WillByDefault(Return());
518 ON_CALL(mock, VoidFromDouble(NanSensitiveDoubleEq(a)))
519 .WillByDefault(Return());
520}
521
522#if GMOCK_HAS_REGEX
523// Tests the linkage of the ContainsRegex matcher.
524TEST(LinkTest, TestMatcherContainsRegex) {
525 Mock mock;
526
527 ON_CALL(mock, VoidFromString(ContainsRegex(".*"))).WillByDefault(Return());
528}
529
530// Tests the linkage of the MatchesRegex matcher.
531TEST(LinkTest, TestMatcherMatchesRegex) {
532 Mock mock;
533
534 ON_CALL(mock, VoidFromString(MatchesRegex(".*"))).WillByDefault(Return());
535}
536#endif // GMOCK_HAS_REGEX
537
538// Tests the linkage of the StartsWith, EndsWith, and HasSubstr matchers.
539TEST(LinkTest, TestMatchersSubstrings) {
540 Mock mock;
541
542 ON_CALL(mock, VoidFromString(StartsWith("a"))).WillByDefault(Return());
543 ON_CALL(mock, VoidFromString(EndsWith("c"))).WillByDefault(Return());
544 ON_CALL(mock, VoidFromString(HasSubstr("b"))).WillByDefault(Return());
545}
546
547// Tests the linkage of the StrEq, StrNe, StrCaseEq, and StrCaseNe matchers.
548TEST(LinkTest, TestMatchersStringEquality) {
549 Mock mock;
550 ON_CALL(mock, VoidFromString(StrEq("a"))).WillByDefault(Return());
551 ON_CALL(mock, VoidFromString(StrNe("a"))).WillByDefault(Return());
552 ON_CALL(mock, VoidFromString(StrCaseEq("a"))).WillByDefault(Return());
553 ON_CALL(mock, VoidFromString(StrCaseNe("a"))).WillByDefault(Return());
554}
555
556// Tests the linkage of the ElementsAre matcher.
557TEST(LinkTest, TestMatcherElementsAre) {
558 Mock mock;
559
560 ON_CALL(mock, VoidFromVector(ElementsAre('a', _))).WillByDefault(Return());
561}
562
563// Tests the linkage of the ElementsAreArray matcher.
564TEST(LinkTest, TestMatcherElementsAreArray) {
565 Mock mock;
566 char arr[] = { 'a', 'b' };
567
568 ON_CALL(mock, VoidFromVector(ElementsAreArray(arr))).WillByDefault(Return());
569}
570
571// Tests the linkage of the ContainerEq matcher.
572TEST(LinkTest, TestMatcherContainerEq) {
573 Mock mock;
574 std::vector<int> v;
575
576 ON_CALL(mock, VoidFromVector(ContainerEq(v))).WillByDefault(Return());
577}
578
579// Tests the linkage of the Field matcher.
580TEST(LinkTest, TestMatcherField) {
581 FieldHelper helper(0);
582
583 Matcher<const FieldHelper&> m = Field(&FieldHelper::field_, Eq(0));
584 EXPECT_TRUE(m.Matches(helper));
585
586 Matcher<const FieldHelper*> m2 = Field(&FieldHelper::field_, Eq(0));
587 EXPECT_TRUE(m2.Matches(&helper));
588}
589
590// Tests the linkage of the Property matcher.
591TEST(LinkTest, TestMatcherProperty) {
592 FieldHelper helper(0);
593
594 Matcher<const FieldHelper&> m = Property(&FieldHelper::field, Eq(0));
595 EXPECT_TRUE(m.Matches(helper));
596
597 Matcher<const FieldHelper*> m2 = Property(&FieldHelper::field, Eq(0));
598 EXPECT_TRUE(m2.Matches(&helper));
599}
600
601// Tests the linkage of the ResultOf matcher.
602TEST(LinkTest, TestMatcherResultOf) {
603 Matcher<char*> m = ResultOf(&InvokeHelper::StaticIntFromString, Eq(1));
604 EXPECT_TRUE(m.Matches(NULL));
605}
606
607// Tests the linkage of the ResultOf matcher.
608TEST(LinkTest, TestMatcherPointee) {
609 int n = 1;
610
611 Matcher<int*> m = Pointee(Eq(1));
612 EXPECT_TRUE(m.Matches(&n));
613}
614
615// Tests the linkage of the Truly matcher.
616TEST(LinkTest, TestMatcherTruly) {
617 Matcher<const char*> m = Truly(&InvokeHelper::StaticBoolFromString);
618 EXPECT_TRUE(m.Matches(NULL));
619}
620
621// Tests the linkage of the AllOf matcher.
622TEST(LinkTest, TestMatcherAllOf) {
623 Matcher<int> m = AllOf(_, Eq(1));
624 EXPECT_TRUE(m.Matches(1));
625}
626
627// Tests the linkage of the AnyOf matcher.
628TEST(LinkTest, TestMatcherAnyOf) {
629 Matcher<int> m = AnyOf(_, Eq(1));
630 EXPECT_TRUE(m.Matches(1));
631}
632
633// Tests the linkage of the Not matcher.
634TEST(LinkTest, TestMatcherNot) {
635 Matcher<int> m = Not(_);
636 EXPECT_FALSE(m.Matches(1));
637}
638
639// Tests the linkage of the MatcherCast<T>() function.
640TEST(LinkTest, TestMatcherCast) {
641 Matcher<const char*> m = MatcherCast<const char*>(_);
642 EXPECT_TRUE(m.Matches(NULL));
643}
644
645#endif // GMOCK_TEST_GMOCK_LINK_TEST_H_