Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
gmock_link_test.h File Reference
#include "gmock/gmock.h"
#include <errno.h>
#include <iostream>
#include <vector>
#include "gtest/gtest.h"
#include "gtest/internal/gtest-port.h"
Include dependency graph for gmock_link_test.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Interface
 
class  Mock
 
class  InvokeHelper
 
class  FieldHelper
 

Functions

 TEST (LinkTest, TestReturnVoid)
 
 TEST (LinkTest, TestReturn)
 
 TEST (LinkTest, TestReturnNull)
 
 TEST (LinkTest, TestReturnRef)
 
 TEST (LinkTest, TestAssign)
 
 TEST (LinkTest, TestSetArgPointee)
 
 TEST (LinkTest, TestSetArrayArgument)
 
 TEST (LinkTest, TestSetErrnoAndReturn)
 
 TEST (LinkTest, TestInvoke)
 
 TEST (LinkTest, TestInvokeWithoutArgs)
 
 TEST (LinkTest, TestInvokeArgument)
 
 TEST (LinkTest, TestWithArg)
 
 TEST (LinkTest, TestWithArgs)
 
 TEST (LinkTest, TestWithoutArgs)
 
 TEST (LinkTest, TestDoAll)
 
 TEST (LinkTest, TestDoDefault)
 
 TEST (LinkTest, TestIgnoreResult)
 
 TEST (LinkTest, TestActionMacro)
 
 TEST (LinkTest, TestActionPMacro)
 
 TEST (LinkTest, TestActionP2Macro)
 
 TEST (LinkTest, TestMatcherAnything)
 
 TEST (LinkTest, TestMatcherA)
 
 TEST (LinkTest, TestMatchersEq)
 
 TEST (LinkTest, TestMatchersRelations)
 
 TEST (LinkTest, TestMatcherNotNull)
 
 TEST (LinkTest, TestMatcherIsNull)
 
 TEST (LinkTest, TestMatcherRef)
 
 TEST (LinkTest, TestMatcherTypedEq)
 
 TEST (LinkTest, TestMatchersFloatingPoint)
 
 TEST (LinkTest, TestMatcherContainsRegex)
 
 TEST (LinkTest, TestMatcherMatchesRegex)
 
 TEST (LinkTest, TestMatchersSubstrings)
 
 TEST (LinkTest, TestMatchersStringEquality)
 
 TEST (LinkTest, TestMatcherElementsAre)
 
 TEST (LinkTest, TestMatcherElementsAreArray)
 
 TEST (LinkTest, TestMatcherIsSubsetOf)
 
 TEST (LinkTest, TestMatcherIsSupersetOf)
 
 TEST (LinkTest, TestMatcherContainerEq)
 
 TEST (LinkTest, TestMatcherField)
 
 TEST (LinkTest, TestMatcherProperty)
 
 TEST (LinkTest, TestMatcherResultOf)
 
 TEST (LinkTest, TestMatcherPointee)
 
 TEST (LinkTest, TestMatcherTruly)
 
 TEST (LinkTest, TestMatcherAllOf)
 
 TEST (LinkTest, TestMatcherAnyOf)
 
 TEST (LinkTest, TestMatcherNot)
 
 TEST (LinkTest, TestMatcherCast)
 

Function Documentation

◆ TEST() [1/47]

TEST ( LinkTest ,
TestActionMacro  )

Definition at line 437 of file gmock_link_test.h.

437 {
438 Mock mock;
439
440 EXPECT_CALL(mock, IntFromString(_)).WillOnce(Return1());
441 mock.IntFromString(NULL);
442}
virtual int IntFromString(char *str)=0
#define EXPECT_CALL(obj, call)
Here is the call graph for this function:

◆ TEST() [2/47]

TEST ( LinkTest ,
TestActionP2Macro  )

Definition at line 467 of file gmock_link_test.h.

467 {
468 Mock mock;
469 char ch = 'x';
470
471 EXPECT_CALL(mock, IntFromString(_))
472 .WillOnce(ReturnEqualsEitherOf("one", "two"));
473 mock.IntFromString(&ch);
474}
static const Reg8 ch(Operand::CH)
Here is the call graph for this function:

◆ TEST() [3/47]

TEST ( LinkTest ,
TestActionPMacro  )

Definition at line 449 of file gmock_link_test.h.

449 {
450 Mock mock;
451
452 EXPECT_CALL(mock, IntFromString(_)).WillOnce(ReturnArgument(42));
453 mock.IntFromString(NULL);
454}
Here is the call graph for this function:

◆ TEST() [4/47]

TEST ( LinkTest ,
TestAssign  )

Definition at line 282 of file gmock_link_test.h.

282 {
283 Mock mock;
284 char ch = 'x';
285
286 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Assign(&ch, 'y'));
287 mock.VoidFromString(NULL);
288}
virtual void VoidFromString(char *str)=0
Here is the call graph for this function:

◆ TEST() [5/47]

TEST ( LinkTest ,
TestDoAll  )

Definition at line 385 of file gmock_link_test.h.

385 {
386 Mock mock;
387 char ch = 'x';
388
389 EXPECT_CALL(mock, VoidFromString(_))
390 .WillOnce(DoAll(SetArgPointee<0>('y'), Return()));
391 mock.VoidFromString(&ch);
392}
Here is the call graph for this function:

◆ TEST() [6/47]

TEST ( LinkTest ,
TestDoDefault  )

Definition at line 395 of file gmock_link_test.h.

395 {
396 Mock mock;
397 char ch = 'x';
398
399 ON_CALL(mock, VoidFromString(_)).WillByDefault(Return());
400 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(DoDefault());
401 mock.VoidFromString(&ch);
402}
#define ON_CALL(obj, call)
Here is the call graph for this function:

◆ TEST() [7/47]

TEST ( LinkTest ,
TestIgnoreResult  )

Definition at line 405 of file gmock_link_test.h.

405 {
406 Mock mock;
407
408 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(IgnoreResult(Return(42)));
409 mock.VoidFromString(NULL);
410}
Here is the call graph for this function:

◆ TEST() [8/47]

TEST ( LinkTest ,
TestInvoke  )

Definition at line 325 of file gmock_link_test.h.

325 {
326 Mock mock;
327 InvokeHelper test_invoke_helper;
328
329 EXPECT_CALL(mock, VoidFromString(_))
330 .WillOnce(Invoke(&InvokeHelper::StaticVoidFromString))
331 .WillOnce(Invoke(&test_invoke_helper, &InvokeHelper::VoidFromString));
332 mock.VoidFromString(NULL);
333 mock.VoidFromString(NULL);
334}
static void StaticVoidFromString(char *)
void VoidFromString(char *)
Here is the call graph for this function:

◆ TEST() [9/47]

TEST ( LinkTest ,
TestInvokeArgument  )

Definition at line 350 of file gmock_link_test.h.

350 {
351 Mock mock;
352 char ch = 'x';
353
354 EXPECT_CALL(mock, VoidFromFunc(_)).WillOnce(InvokeArgument<0>(&ch));
356}
virtual void VoidFromFunc(void(*func)(char *str))=0
Here is the call graph for this function:

◆ TEST() [10/47]

TEST ( LinkTest ,
TestInvokeWithoutArgs  )

Definition at line 337 of file gmock_link_test.h.

337 {
338 Mock mock;
339 InvokeHelper test_invoke_helper;
340
341 EXPECT_CALL(mock, VoidFromString(_))
342 .WillOnce(InvokeWithoutArgs(&InvokeHelper::StaticVoidFromVoid))
343 .WillOnce(InvokeWithoutArgs(&test_invoke_helper,
345 mock.VoidFromString(NULL);
346 mock.VoidFromString(NULL);
347}
static void StaticVoidFromVoid()
Here is the call graph for this function:

◆ TEST() [11/47]

TEST ( LinkTest ,
TestMatcherA  )

Definition at line 484 of file gmock_link_test.h.

484 {
485 Mock mock;
486
487 ON_CALL(mock, VoidFromString(A<char*>())).WillByDefault(Return());
488}

◆ TEST() [12/47]

TEST ( LinkTest ,
TestMatcherAllOf  )

Definition at line 668 of file gmock_link_test.h.

668 {
669 Matcher<int> m = AllOf(_, Eq(1));
670 EXPECT_TRUE(m.Matches(1));
671}
bool Matches(GTEST_REFERENCE_TO_CONST_(T) x) const
#define EXPECT_TRUE(condition)
Definition gtest.h:1895
Here is the call graph for this function:

◆ TEST() [13/47]

TEST ( LinkTest ,
TestMatcherAnyOf  )

Definition at line 674 of file gmock_link_test.h.

674 {
675 Matcher<int> m = AnyOf(_, Eq(1));
676 EXPECT_TRUE(m.Matches(1));
677}
Here is the call graph for this function:

◆ TEST() [14/47]

TEST ( LinkTest ,
TestMatcherAnything  )

Definition at line 477 of file gmock_link_test.h.

477 {
478 Mock mock;
479
480 ON_CALL(mock, VoidFromString(_)).WillByDefault(Return());
481}

◆ TEST() [15/47]

TEST ( LinkTest ,
TestMatcherCast  )

Definition at line 686 of file gmock_link_test.h.

686 {
687 Matcher<const char*> m = MatcherCast<const char*>(_);
688 EXPECT_TRUE(m.Matches(NULL));
689}
Here is the call graph for this function:

◆ TEST() [16/47]

TEST ( LinkTest ,
TestMatcherContainerEq  )

Definition at line 618 of file gmock_link_test.h.

618 {
619 Mock mock;
620 std::vector<int> v;
621
622 ON_CALL(mock, VoidFromVector(ContainerEq(v))).WillByDefault(Return());
623}

◆ TEST() [17/47]

TEST ( LinkTest ,
TestMatcherContainsRegex  )

Definition at line 555 of file gmock_link_test.h.

555 {
556 Mock mock;
557
558 ON_CALL(mock, VoidFromString(ContainsRegex(".*"))).WillByDefault(Return());
559}

◆ TEST() [18/47]

TEST ( LinkTest ,
TestMatcherElementsAre  )

Definition at line 587 of file gmock_link_test.h.

587 {
588 Mock mock;
589
590 ON_CALL(mock, VoidFromVector(ElementsAre('a', _))).WillByDefault(Return());
591}

◆ TEST() [19/47]

TEST ( LinkTest ,
TestMatcherElementsAreArray  )

Definition at line 594 of file gmock_link_test.h.

594 {
595 Mock mock;
596 char arr[] = { 'a', 'b' };
597
598 ON_CALL(mock, VoidFromVector(ElementsAreArray(arr))).WillByDefault(Return());
599}

◆ TEST() [20/47]

TEST ( LinkTest ,
TestMatcherField  )

Definition at line 626 of file gmock_link_test.h.

626 {
627 FieldHelper helper(0);
628
630 EXPECT_TRUE(m.Matches(helper));
631
633 EXPECT_TRUE(m2.Matches(&helper));
634}
Here is the call graph for this function:

◆ TEST() [21/47]

TEST ( LinkTest ,
TestMatcherIsNull  )

Definition at line 519 of file gmock_link_test.h.

519 {
520 Mock mock;
521
522 ON_CALL(mock, VoidFromString(IsNull())).WillByDefault(Return());
523}

◆ TEST() [22/47]

TEST ( LinkTest ,
TestMatcherIsSubsetOf  )

Definition at line 602 of file gmock_link_test.h.

602 {
603 Mock mock;
604 char arr[] = {'a', 'b'};
605
606 ON_CALL(mock, VoidFromVector(IsSubsetOf(arr))).WillByDefault(Return());
607}

◆ TEST() [23/47]

TEST ( LinkTest ,
TestMatcherIsSupersetOf  )

Definition at line 610 of file gmock_link_test.h.

610 {
611 Mock mock;
612 char arr[] = {'a', 'b'};
613
614 ON_CALL(mock, VoidFromVector(IsSupersetOf(arr))).WillByDefault(Return());
615}

◆ TEST() [24/47]

TEST ( LinkTest ,
TestMatcherMatchesRegex  )

Definition at line 562 of file gmock_link_test.h.

562 {
563 Mock mock;
564
565 ON_CALL(mock, VoidFromString(MatchesRegex(".*"))).WillByDefault(Return());
566}

◆ TEST() [25/47]

TEST ( LinkTest ,
TestMatcherNot  )

Definition at line 680 of file gmock_link_test.h.

680 {
681 Matcher<int> m = Not(_);
682 EXPECT_FALSE(m.Matches(1));
683}
#define EXPECT_FALSE(condition)
Definition gtest.h:1898
Here is the call graph for this function:

◆ TEST() [26/47]

TEST ( LinkTest ,
TestMatcherNotNull  )

Definition at line 512 of file gmock_link_test.h.

512 {
513 Mock mock;
514
515 ON_CALL(mock, VoidFromString(NotNull())).WillByDefault(Return());
516}

◆ TEST() [27/47]

TEST ( LinkTest ,
TestMatcherPointee  )

Definition at line 654 of file gmock_link_test.h.

654 {
655 int n = 1;
656
657 Matcher<int*> m = Pointee(Eq(1));
658 EXPECT_TRUE(m.Matches(&n));
659}
Here is the call graph for this function:

◆ TEST() [28/47]

TEST ( LinkTest ,
TestMatcherProperty  )

Definition at line 637 of file gmock_link_test.h.

637 {
638 FieldHelper helper(0);
639
641 EXPECT_TRUE(m.Matches(helper));
642
643 Matcher<const FieldHelper*> m2 = Property(&FieldHelper::field, Eq(0));
644 EXPECT_TRUE(m2.Matches(&helper));
645}
int field() const
Here is the call graph for this function:

◆ TEST() [29/47]

TEST ( LinkTest ,
TestMatcherRef  )

Definition at line 526 of file gmock_link_test.h.

526 {
527 Mock mock;
528 int a = 0;
529
530 ON_CALL(mock, VoidFromIntRef(Ref(a))).WillByDefault(Return());
531}
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181

◆ TEST() [30/47]

TEST ( LinkTest ,
TestMatcherResultOf  )

Definition at line 648 of file gmock_link_test.h.

648 {
650 EXPECT_TRUE(m.Matches(NULL));
651}
static int StaticIntFromString(char *)
Here is the call graph for this function:

◆ TEST() [31/47]

TEST ( LinkTest ,
TestMatchersEq  )

Definition at line 491 of file gmock_link_test.h.

491 {
492 Mock mock;
493 const char* p = "x";
494
495 ON_CALL(mock, VoidFromString(Eq(p))).WillByDefault(Return());
496 ON_CALL(mock, VoidFromString(const_cast<char*>("y")))
497 .WillByDefault(Return());
498}
const mie::Vuint & p
Definition bn.cpp:27

◆ TEST() [32/47]

TEST ( LinkTest ,
TestMatchersFloatingPoint  )

Definition at line 543 of file gmock_link_test.h.

543 {
544 Mock mock;
545 float a = 0;
546
547 ON_CALL(mock, VoidFromFloat(FloatEq(a))).WillByDefault(Return());
548 ON_CALL(mock, VoidFromDouble(DoubleEq(a))).WillByDefault(Return());
549 ON_CALL(mock, VoidFromFloat(NanSensitiveFloatEq(a))).WillByDefault(Return());
550 ON_CALL(mock, VoidFromDouble(NanSensitiveDoubleEq(a)))
551 .WillByDefault(Return());
552}

◆ TEST() [33/47]

TEST ( LinkTest ,
TestMatchersRelations  )

Definition at line 501 of file gmock_link_test.h.

501 {
502 Mock mock;
503
504 ON_CALL(mock, VoidFromFloat(Lt(1.0f))).WillByDefault(Return());
505 ON_CALL(mock, VoidFromFloat(Gt(1.0f))).WillByDefault(Return());
506 ON_CALL(mock, VoidFromFloat(Le(1.0f))).WillByDefault(Return());
507 ON_CALL(mock, VoidFromFloat(Ge(1.0f))).WillByDefault(Return());
508 ON_CALL(mock, VoidFromFloat(Ne(1.0f))).WillByDefault(Return());
509}

◆ TEST() [34/47]

TEST ( LinkTest ,
TestMatchersStringEquality  )

Definition at line 578 of file gmock_link_test.h.

578 {
579 Mock mock;
580 ON_CALL(mock, VoidFromString(StrEq("a"))).WillByDefault(Return());
581 ON_CALL(mock, VoidFromString(StrNe("a"))).WillByDefault(Return());
582 ON_CALL(mock, VoidFromString(StrCaseEq("a"))).WillByDefault(Return());
583 ON_CALL(mock, VoidFromString(StrCaseNe("a"))).WillByDefault(Return());
584}

◆ TEST() [35/47]

TEST ( LinkTest ,
TestMatchersSubstrings  )

Definition at line 569 of file gmock_link_test.h.

569 {
570 Mock mock;
571
572 ON_CALL(mock, VoidFromString(StartsWith("a"))).WillByDefault(Return());
573 ON_CALL(mock, VoidFromString(EndsWith("c"))).WillByDefault(Return());
574 ON_CALL(mock, VoidFromString(HasSubstr("b"))).WillByDefault(Return());
575}

◆ TEST() [36/47]

TEST ( LinkTest ,
TestMatcherTruly  )

Definition at line 662 of file gmock_link_test.h.

662 {
664 EXPECT_TRUE(m.Matches(NULL));
665}
static bool StaticBoolFromString(const char *)
Here is the call graph for this function:

◆ TEST() [37/47]

TEST ( LinkTest ,
TestMatcherTypedEq  )

Definition at line 534 of file gmock_link_test.h.

534 {
535 Mock mock;
536 long a = 0;
537
538 ON_CALL(mock, VoidFromIntRef(TypedEq<int&>(a))).WillByDefault(Return());
539}

◆ TEST() [38/47]

TEST ( LinkTest ,
TestReturn  )

Definition at line 256 of file gmock_link_test.h.

256 {
257 Mock mock;
258 char ch = 'x';
259
260 EXPECT_CALL(mock, StringFromString(_)).WillOnce(Return(&ch));
261 mock.StringFromString(NULL);
262}
virtual char * StringFromString(char *str)=0
Here is the call graph for this function:

◆ TEST() [39/47]

TEST ( LinkTest ,
TestReturnNull  )

Definition at line 265 of file gmock_link_test.h.

265 {
266 Mock mock;
267
268 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Return());
269 mock.VoidFromString(NULL);
270}
Here is the call graph for this function:

◆ TEST() [40/47]

TEST ( LinkTest ,
TestReturnRef  )

Definition at line 273 of file gmock_link_test.h.

273 {
274 Mock mock;
275 int n = 42;
276
277 EXPECT_CALL(mock, IntRefFromString(_)).WillOnce(ReturnRef(n));
278 mock.IntRefFromString(NULL);
279}
virtual int & IntRefFromString(char *str)=0
Here is the call graph for this function:

◆ TEST() [41/47]

TEST ( LinkTest ,
TestReturnVoid  )

Definition at line 248 of file gmock_link_test.h.

248 {
249 Mock mock;
250
251 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Return());
252 mock.VoidFromString(NULL);
253}
Here is the call graph for this function:

◆ TEST() [42/47]

TEST ( LinkTest ,
TestSetArgPointee  )

Definition at line 291 of file gmock_link_test.h.

291 {
292 Mock mock;
293 char ch = 'x';
294
295 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArgPointee<0>('y'));
296 mock.VoidFromString(&ch);
297}
Here is the call graph for this function:

◆ TEST() [43/47]

TEST ( LinkTest ,
TestSetArrayArgument  )

Definition at line 300 of file gmock_link_test.h.

300 {
301 Mock mock;
302 char ch = 'x';
303 char ch2 = 'y';
304
305 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArrayArgument<0>(&ch2,
306 &ch2 + 1));
307 mock.VoidFromString(&ch);
308}
Here is the call graph for this function:

◆ TEST() [44/47]

TEST ( LinkTest ,
TestSetErrnoAndReturn  )

Definition at line 313 of file gmock_link_test.h.

313 {
314 Mock mock;
315
316 int saved_errno = errno;
317 EXPECT_CALL(mock, IntFromString(_)).WillOnce(SetErrnoAndReturn(1, -1));
318 mock.IntFromString(NULL);
319 errno = saved_errno;
320}
Here is the call graph for this function:

◆ TEST() [45/47]

TEST ( LinkTest ,
TestWithArg  )

Definition at line 359 of file gmock_link_test.h.

359 {
360 Mock mock;
361
362 EXPECT_CALL(mock, VoidFromString(_))
363 .WillOnce(WithArg<0>(Invoke(&InvokeHelper::StaticVoidFromString)));
364 mock.VoidFromString(NULL);
365}
Here is the call graph for this function:

◆ TEST() [46/47]

TEST ( LinkTest ,
TestWithArgs  )

Definition at line 368 of file gmock_link_test.h.

368 {
369 Mock mock;
370
371 EXPECT_CALL(mock, VoidFromString(_))
372 .WillOnce(WithArgs<0>(Invoke(&InvokeHelper::StaticVoidFromString)));
373 mock.VoidFromString(NULL);
374}
Here is the call graph for this function:

◆ TEST() [47/47]

TEST ( LinkTest ,
TestWithoutArgs  )

Definition at line 377 of file gmock_link_test.h.

377 {
378 Mock mock;
379
380 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(WithoutArgs(Return()));
381 mock.VoidFromString(NULL);
382}
Here is the call graph for this function: