blob: bbac8ae2d8aa842c19d6ddc2420a6da8607cd647 [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.wanf7af24c2009-09-24 21:17:24 +0000119#if !GTEST_OS_WINDOWS_MOBILE
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000120#include <errno.h>
zhanyong.wan5b5d62f2009-03-11 23:37:56 +0000121#endif
122
zhanyong.wanbf550852009-06-09 06:09:53 +0000123#include <gmock/internal/gmock-port.h>
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000124#include <gtest/gtest.h>
125#include <iostream>
126#include <vector>
127
128using testing::_;
129using testing::A;
130using testing::AllOf;
131using testing::AnyOf;
132using testing::Assign;
133using testing::ContainerEq;
134using testing::DoAll;
135using testing::DoDefault;
136using testing::DoubleEq;
137using testing::ElementsAre;
138using testing::ElementsAreArray;
139using testing::EndsWith;
140using testing::Eq;
141using testing::Field;
142using testing::FloatEq;
143using testing::Ge;
144using testing::Gt;
145using testing::HasSubstr;
146using testing::IgnoreResult;
147using testing::Invoke;
148using testing::InvokeArgument;
149using testing::InvokeWithoutArgs;
150using testing::Le;
151using testing::Lt;
152using testing::Matcher;
153using testing::MatcherCast;
154using testing::NanSensitiveDoubleEq;
155using testing::NanSensitiveFloatEq;
156using testing::Ne;
157using testing::Not;
158using testing::NotNull;
159using testing::Pointee;
160using testing::Property;
161using testing::Ref;
162using testing::ResultOf;
163using testing::Return;
164using testing::ReturnNull;
165using testing::ReturnRef;
166using testing::SetArgumentPointee;
167using testing::SetArrayArgument;
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000168using testing::StartsWith;
169using testing::StrCaseEq;
170using testing::StrCaseNe;
171using testing::StrEq;
172using testing::StrNe;
173using testing::Truly;
174using testing::TypedEq;
175using testing::WithArg;
176using testing::WithArgs;
177using testing::WithoutArgs;
178
zhanyong.wanf7af24c2009-09-24 21:17:24 +0000179#if !GTEST_OS_WINDOWS_MOBILE
zhanyong.wan5b5d62f2009-03-11 23:37:56 +0000180using testing::SetErrnoAndReturn;
zhanyong.wanf7af24c2009-09-24 21:17:24 +0000181#endif
zhanyong.wan5b5d62f2009-03-11 23:37:56 +0000182
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000183#if GTEST_HAS_EXCEPTIONS
184using testing::Throw;
zhanyong.wanf7af24c2009-09-24 21:17:24 +0000185#endif
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000186
187#if GMOCK_HAS_REGEX
188using testing::ContainsRegex;
189using testing::MatchesRegex;
zhanyong.wanf7af24c2009-09-24 21:17:24 +0000190#endif
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000191
192class Interface {
193 public:
194 virtual ~Interface() {}
195 virtual void VoidFromString(char* str) = 0;
196 virtual char* StringFromString(char* str) = 0;
197 virtual int IntFromString(char* str) = 0;
198 virtual int& IntRefFromString(char* str) = 0;
199 virtual void VoidFromFunc(void(*)(char*)) = 0;
200 virtual void VoidFromIntRef(int& n) = 0;
201 virtual void VoidFromFloat(float n) = 0;
202 virtual void VoidFromDouble(double n) = 0;
203 virtual void VoidFromVector(const std::vector<int>& v) = 0;
204};
205
206class Mock: public Interface {
207 public:
208 MOCK_METHOD1(VoidFromString, void(char* str));
209 MOCK_METHOD1(StringFromString, char*(char* str));
210 MOCK_METHOD1(IntFromString, int(char* str));
211 MOCK_METHOD1(IntRefFromString, int&(char* str));
212 MOCK_METHOD1(VoidFromFunc, void(void(*func)(char* str)));
213 MOCK_METHOD1(VoidFromIntRef, void(int& n));
214 MOCK_METHOD1(VoidFromFloat, void(float n));
215 MOCK_METHOD1(VoidFromDouble, void(double n));
216 MOCK_METHOD1(VoidFromVector, void(const std::vector<int>& v));
217};
218
219class InvokeHelper {
220 public:
221 static void StaticVoidFromVoid() {}
222 void VoidFromVoid() {}
223 static void StaticVoidFromString(char*) {}
224 void VoidFromString(char*) {}
225 static int StaticIntFromString(char*) { return 1; }
226 static bool StaticBoolFromString(const char*) { return true; }
227};
228
229class FieldHelper {
230 public:
231 FieldHelper(int field) : field_(field) {}
232 int field() const { return field_; }
233 int field_; // NOLINT -- need external access to field_ to test
234 // the Field matcher.
235};
236
237// Tests the linkage of the ReturnVoid action.
238TEST(LinkTest, TestReturnVoid) {
239 Mock mock;
240
241 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Return());
242 mock.VoidFromString(NULL);
243}
244
245// Tests the linkage of the Return action.
246TEST(LinkTest, TestReturn) {
247 Mock mock;
248 char ch = 'x';
249
250 EXPECT_CALL(mock, StringFromString(_)).WillOnce(Return(&ch));
251 mock.StringFromString(NULL);
252}
253
254// Tests the linkage of the ReturnNull action.
255TEST(LinkTest, TestReturnNull) {
256 Mock mock;
257
258 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Return());
259 mock.VoidFromString(NULL);
260}
261
262// Tests the linkage of the ReturnRef action.
263TEST(LinkTest, TestReturnRef) {
264 Mock mock;
265 int n = 42;
266
267 EXPECT_CALL(mock, IntRefFromString(_)).WillOnce(ReturnRef(n));
268 mock.IntRefFromString(NULL);
269}
270
271// Tests the linkage of the Assign action.
272TEST(LinkTest, TestAssign) {
273 Mock mock;
274 char ch = 'x';
275
276 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Assign(&ch, 'y'));
277 mock.VoidFromString(NULL);
278}
279
280// Tests the linkage of the SetArgumentPointee action.
281TEST(LinkTest, TestSetArgumentPointee) {
282 Mock mock;
283 char ch = 'x';
284
285 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArgumentPointee<0>('y'));
286 mock.VoidFromString(&ch);
287}
288
289// Tests the linkage of the SetArrayArgument action.
290TEST(LinkTest, TestSetArrayArgument) {
291 Mock mock;
292 char ch = 'x';
293 char ch2 = 'y';
294
295 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArrayArgument<0>(&ch2,
296 &ch2 + 1));
297 mock.VoidFromString(&ch);
298}
299
zhanyong.wanf7af24c2009-09-24 21:17:24 +0000300#if !GTEST_OS_WINDOWS_MOBILE
zhanyong.wan5b5d62f2009-03-11 23:37:56 +0000301
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000302// Tests the linkage of the SetErrnoAndReturn action.
303TEST(LinkTest, TestSetErrnoAndReturn) {
304 Mock mock;
305
306 int saved_errno = errno;
307 EXPECT_CALL(mock, IntFromString(_)).WillOnce(SetErrnoAndReturn(1, -1));
308 mock.IntFromString(NULL);
309 errno = saved_errno;
310}
311
zhanyong.wanf7af24c2009-09-24 21:17:24 +0000312#endif // !GTEST_OS_WINDOWS_MOBILE
zhanyong.wan5b5d62f2009-03-11 23:37:56 +0000313
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000314// Tests the linkage of the Invoke(function) and Invoke(object, method) actions.
315TEST(LinkTest, TestInvoke) {
316 Mock mock;
317 InvokeHelper test_invoke_helper;
318
319 EXPECT_CALL(mock, VoidFromString(_))
320 .WillOnce(Invoke(&InvokeHelper::StaticVoidFromString))
321 .WillOnce(Invoke(&test_invoke_helper, &InvokeHelper::VoidFromString));
322 mock.VoidFromString(NULL);
323 mock.VoidFromString(NULL);
324}
325
326// Tests the linkage of the InvokeWithoutArgs action.
327TEST(LinkTest, TestInvokeWithoutArgs) {
328 Mock mock;
329 InvokeHelper test_invoke_helper;
330
331 EXPECT_CALL(mock, VoidFromString(_))
332 .WillOnce(InvokeWithoutArgs(&InvokeHelper::StaticVoidFromVoid))
333 .WillOnce(InvokeWithoutArgs(&test_invoke_helper,
334 &InvokeHelper::VoidFromVoid));
335 mock.VoidFromString(NULL);
336 mock.VoidFromString(NULL);
337}
338
339// Tests the linkage of the InvokeArgument action.
340TEST(LinkTest, TestInvokeArgument) {
341 Mock mock;
342 char ch = 'x';
343
344 EXPECT_CALL(mock, VoidFromFunc(_)).WillOnce(InvokeArgument<0>(&ch));
345 mock.VoidFromFunc(InvokeHelper::StaticVoidFromString);
346}
347
348// Tests the linkage of the WithArg action.
349TEST(LinkTest, TestWithArg) {
350 Mock mock;
351
352 EXPECT_CALL(mock, VoidFromString(_))
353 .WillOnce(WithArg<0>(Invoke(&InvokeHelper::StaticVoidFromString)));
354 mock.VoidFromString(NULL);
355}
356
357// Tests the linkage of the WithArgs action.
358TEST(LinkTest, TestWithArgs) {
359 Mock mock;
360
361 EXPECT_CALL(mock, VoidFromString(_))
362 .WillOnce(WithArgs<0>(Invoke(&InvokeHelper::StaticVoidFromString)));
363 mock.VoidFromString(NULL);
364}
365
366// Tests the linkage of the WithoutArgs action.
367TEST(LinkTest, TestWithoutArgs) {
368 Mock mock;
369
370 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(WithoutArgs(Return()));
371 mock.VoidFromString(NULL);
372}
373
374// Tests the linkage of the DoAll action.
375TEST(LinkTest, TestDoAll) {
376 Mock mock;
377 char ch = 'x';
378
379 EXPECT_CALL(mock, VoidFromString(_))
380 .WillOnce(DoAll(SetArgumentPointee<0>('y'), Return()));
381 mock.VoidFromString(&ch);
382}
383
384// Tests the linkage of the DoDefault action.
385TEST(LinkTest, TestDoDefault) {
386 Mock mock;
387 char ch = 'x';
388
389 ON_CALL(mock, VoidFromString(_)).WillByDefault(Return());
390 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(DoDefault());
391 mock.VoidFromString(&ch);
392}
393
394// Tests the linkage of the IgnoreResult action.
395TEST(LinkTest, TestIgnoreResult) {
396 Mock mock;
397
398 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(IgnoreResult(Return(42)));
399 mock.VoidFromString(NULL);
400}
401
402#if GTEST_HAS_EXCEPTIONS
403// Tests the linkage of the Throw action.
404TEST(LinkTest, TestThrow) {
405 Mock mock;
406
407 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Throw(42));
408 EXPECT_THROW(mock.VoidFromString(NULL), int);
409}
410#endif // GTEST_HAS_EXCEPTIONS
411
412// Tests the linkage of actions created using ACTION macro.
413namespace {
414ACTION(Return1) { return 1; }
415}
416
417TEST(LinkTest, TestActionMacro) {
418 Mock mock;
419
420 EXPECT_CALL(mock, IntFromString(_)).WillOnce(Return1());
421 mock.IntFromString(NULL);
422}
423
424// Tests the linkage of actions created using ACTION_P macro.
425namespace {
426ACTION_P(ReturnArgument, ret_value) { return ret_value; }
427}
428
429TEST(LinkTest, TestActionPMacro) {
430 Mock mock;
431
432 EXPECT_CALL(mock, IntFromString(_)).WillOnce(ReturnArgument(42));
433 mock.IntFromString(NULL);
434}
435
436// Tests the linkage of actions created using ACTION_P2 macro.
437namespace {
438ACTION_P2(ReturnEqualsEitherOf, first, second) {
439 return arg0 == first || arg0 == second;
440}
441}
442
443TEST(LinkTest, TestActionP2Macro) {
444 Mock mock;
445 char ch = 'x';
446
447 EXPECT_CALL(mock, IntFromString(_))
448 .WillOnce(ReturnEqualsEitherOf("one", "two"));
449 mock.IntFromString(&ch);
450}
451
452// Tests the linkage of the "_" matcher.
453TEST(LinkTest, TestMatcherAnything) {
454 Mock mock;
455
456 ON_CALL(mock, VoidFromString(_)).WillByDefault(Return());
457}
458
459// Tests the linkage of the A matcher.
460TEST(LinkTest, TestMatcherA) {
461 Mock mock;
462
463 ON_CALL(mock, VoidFromString(A<char*>())).WillByDefault(Return());
464}
465
466// Tests the linkage of the Eq and the "bare value" matcher.
467TEST(LinkTest, TestMatchersEq) {
468 Mock mock;
469 const char* p = "x";
470
471 ON_CALL(mock, VoidFromString(Eq(p))).WillByDefault(Return());
472 ON_CALL(mock, VoidFromString(const_cast<char*>("y")))
473 .WillByDefault(Return());
474}
475
476// Tests the linkage of the Lt, Gt, Le, Ge, and Ne matchers.
477TEST(LinkTest, TestMatchersRelations) {
478 Mock mock;
479
480 ON_CALL(mock, VoidFromFloat(Lt(1.0f))).WillByDefault(Return());
481 ON_CALL(mock, VoidFromFloat(Gt(1.0f))).WillByDefault(Return());
482 ON_CALL(mock, VoidFromFloat(Le(1.0f))).WillByDefault(Return());
483 ON_CALL(mock, VoidFromFloat(Ge(1.0f))).WillByDefault(Return());
484 ON_CALL(mock, VoidFromFloat(Ne(1.0f))).WillByDefault(Return());
485}
486
487// Tests the linkage of the NotNull matcher.
488TEST(LinkTest, TestMatcherNotNull) {
489 Mock mock;
490
491 ON_CALL(mock, VoidFromString(NotNull())).WillByDefault(Return());
492}
493
494// Tests the linkage of the Ref matcher.
495TEST(LinkTest, TestMatcherRef) {
496 Mock mock;
497 int a = 0;
498
499 ON_CALL(mock, VoidFromIntRef(Ref(a))).WillByDefault(Return());
500}
501
502// Tests the linkage of the TypedEq matcher.
503TEST(LinkTest, TestMatcherTypedEq) {
504 Mock mock;
zhanyong.wan3fbd2dd2009-03-26 19:06:45 +0000505 long a = 0;
zhanyong.wan38ca64d2009-02-19 22:30:22 +0000506
507 ON_CALL(mock, VoidFromIntRef(TypedEq<int&>(a))).WillByDefault(Return());
508}
509
510// Tests the linkage of the FloatEq, DoubleEq, NanSensitiveFloatEq and
511// NanSensitiveDoubleEq matchers.
512TEST(LinkTest, TestMatchersFloatingPoint) {
513 Mock mock;
514 float a = 0;
515
516 ON_CALL(mock, VoidFromFloat(FloatEq(a))).WillByDefault(Return());
517 ON_CALL(mock, VoidFromDouble(DoubleEq(a))).WillByDefault(Return());
518 ON_CALL(mock, VoidFromFloat(NanSensitiveFloatEq(a))).WillByDefault(Return());
519 ON_CALL(mock, VoidFromDouble(NanSensitiveDoubleEq(a)))
520 .WillByDefault(Return());
521}
522
523#if GMOCK_HAS_REGEX
524// Tests the linkage of the ContainsRegex matcher.
525TEST(LinkTest, TestMatcherContainsRegex) {
526 Mock mock;
527
528 ON_CALL(mock, VoidFromString(ContainsRegex(".*"))).WillByDefault(Return());
529}
530
531// Tests the linkage of the MatchesRegex matcher.
532TEST(LinkTest, TestMatcherMatchesRegex) {
533 Mock mock;
534
535 ON_CALL(mock, VoidFromString(MatchesRegex(".*"))).WillByDefault(Return());
536}
537#endif // GMOCK_HAS_REGEX
538
539// Tests the linkage of the StartsWith, EndsWith, and HasSubstr matchers.
540TEST(LinkTest, TestMatchersSubstrings) {
541 Mock mock;
542
543 ON_CALL(mock, VoidFromString(StartsWith("a"))).WillByDefault(Return());
544 ON_CALL(mock, VoidFromString(EndsWith("c"))).WillByDefault(Return());
545 ON_CALL(mock, VoidFromString(HasSubstr("b"))).WillByDefault(Return());
546}
547
548// Tests the linkage of the StrEq, StrNe, StrCaseEq, and StrCaseNe matchers.
549TEST(LinkTest, TestMatchersStringEquality) {
550 Mock mock;
551 ON_CALL(mock, VoidFromString(StrEq("a"))).WillByDefault(Return());
552 ON_CALL(mock, VoidFromString(StrNe("a"))).WillByDefault(Return());
553 ON_CALL(mock, VoidFromString(StrCaseEq("a"))).WillByDefault(Return());
554 ON_CALL(mock, VoidFromString(StrCaseNe("a"))).WillByDefault(Return());
555}
556
557// Tests the linkage of the ElementsAre matcher.
558TEST(LinkTest, TestMatcherElementsAre) {
559 Mock mock;
560
561 ON_CALL(mock, VoidFromVector(ElementsAre('a', _))).WillByDefault(Return());
562}
563
564// Tests the linkage of the ElementsAreArray matcher.
565TEST(LinkTest, TestMatcherElementsAreArray) {
566 Mock mock;
567 char arr[] = { 'a', 'b' };
568
569 ON_CALL(mock, VoidFromVector(ElementsAreArray(arr))).WillByDefault(Return());
570}
571
572// Tests the linkage of the ContainerEq matcher.
573TEST(LinkTest, TestMatcherContainerEq) {
574 Mock mock;
575 std::vector<int> v;
576
577 ON_CALL(mock, VoidFromVector(ContainerEq(v))).WillByDefault(Return());
578}
579
580// Tests the linkage of the Field matcher.
581TEST(LinkTest, TestMatcherField) {
582 FieldHelper helper(0);
583
584 Matcher<const FieldHelper&> m = Field(&FieldHelper::field_, Eq(0));
585 EXPECT_TRUE(m.Matches(helper));
586
587 Matcher<const FieldHelper*> m2 = Field(&FieldHelper::field_, Eq(0));
588 EXPECT_TRUE(m2.Matches(&helper));
589}
590
591// Tests the linkage of the Property matcher.
592TEST(LinkTest, TestMatcherProperty) {
593 FieldHelper helper(0);
594
595 Matcher<const FieldHelper&> m = Property(&FieldHelper::field, Eq(0));
596 EXPECT_TRUE(m.Matches(helper));
597
598 Matcher<const FieldHelper*> m2 = Property(&FieldHelper::field, Eq(0));
599 EXPECT_TRUE(m2.Matches(&helper));
600}
601
602// Tests the linkage of the ResultOf matcher.
603TEST(LinkTest, TestMatcherResultOf) {
604 Matcher<char*> m = ResultOf(&InvokeHelper::StaticIntFromString, Eq(1));
605 EXPECT_TRUE(m.Matches(NULL));
606}
607
608// Tests the linkage of the ResultOf matcher.
609TEST(LinkTest, TestMatcherPointee) {
610 int n = 1;
611
612 Matcher<int*> m = Pointee(Eq(1));
613 EXPECT_TRUE(m.Matches(&n));
614}
615
616// Tests the linkage of the Truly matcher.
617TEST(LinkTest, TestMatcherTruly) {
618 Matcher<const char*> m = Truly(&InvokeHelper::StaticBoolFromString);
619 EXPECT_TRUE(m.Matches(NULL));
620}
621
622// Tests the linkage of the AllOf matcher.
623TEST(LinkTest, TestMatcherAllOf) {
624 Matcher<int> m = AllOf(_, Eq(1));
625 EXPECT_TRUE(m.Matches(1));
626}
627
628// Tests the linkage of the AnyOf matcher.
629TEST(LinkTest, TestMatcherAnyOf) {
630 Matcher<int> m = AnyOf(_, Eq(1));
631 EXPECT_TRUE(m.Matches(1));
632}
633
634// Tests the linkage of the Not matcher.
635TEST(LinkTest, TestMatcherNot) {
636 Matcher<int> m = Not(_);
637 EXPECT_FALSE(m.Matches(1));
638}
639
640// Tests the linkage of the MatcherCast<T>() function.
641TEST(LinkTest, TestMatcherCast) {
642 Matcher<const char*> m = MatcherCast<const char*>(_);
643 EXPECT_TRUE(m.Matches(NULL));
644}
645
646#endif // GMOCK_TEST_GMOCK_LINK_TEST_H_