Lines Matching full:action
530 Action<MyGlobalFunction> action = MakeAction(new MyActionImpl); in TEST() local
532 // When exercising the Perform() method of Action<F>, we must pass in TEST()
537 EXPECT_EQ(5, action.Perform(std::make_tuple(true, 5))); in TEST()
540 // Tests that Action<F> can be constructed from a pointer to
543 Action<MyGlobalFunction> action(new MyActionImpl); in TEST() local
546 // Tests that Action<F> delegates actual work to ActionInterface<F>.
548 const Action<MyGlobalFunction> action(new MyActionImpl); in TEST() local
550 EXPECT_EQ(5, action.Perform(std::make_tuple(true, 5))); in TEST()
551 EXPECT_EQ(0, action.Perform(std::make_tuple(false, 1))); in TEST()
554 // Tests that Action<F> can be copied.
556 Action<MyGlobalFunction> a1(new MyActionImpl); in TEST()
557 Action<MyGlobalFunction> a2(a1); // Tests the copy constructor. in TEST()
563 // a2 should work like the action it was copied from. in TEST()
573 // a2 should work like the action it was copied from. in TEST()
578 // Tests that an Action<From> object can be converted to a
579 // compatible Action<To> object.
589 const Action<bool(int)> a1(new IsNotZero); // NOLINT in TEST()
590 const Action<int(char)> a2 = Action<int(char)>(a1); // NOLINT in TEST()
597 // Implements a polymorphic action that returns the second of the
602 // polymorphic action whose Perform() method template is either
610 // Implements a polymorphic action that can be used in a nullary
619 // polymorphic action whose Perform() method template is either
639 // Tests that MakePolymorphicAction() turns a polymorphic action
640 // implementation class into a polymorphic action.
642 Action<int(bool, int, double)> a1 = ReturnSecondArgument(); // NOLINT in TEST()
649 Action<int()> a1 = ReturnZeroFromNullaryFunction(); in TEST()
652 Action<void*()> a2 = ReturnZeroFromNullaryFunction(); in TEST()
656 // Tests that Return() works as an action for void-returning
659 const Action<void(int)> ret = Return(); // NOLINT in TEST()
665 Action<int()> ret = Return(1); // NOLINT in TEST()
674 Action<const char*()> a1 = Return("Hello"); in TEST()
677 Action<std::string()> a2 = Return("world"); in TEST()
691 // Set up an action for a mock function that returns the reference wrapper in TEST()
695 // that's embedded within the action itself (which should stay alive as long in TEST()
787 static_assert(!std::is_convertible<RA, Action<S()>>::value, ""); in TEST()
804 // The result of Return should not be convertible to Action (so it can't be in TEST()
807 Action<std::unique_ptr<int>()>>::value, in TEST()
824 Action<Base*()> ret = Return(&base); in TEST()
832 // when the action is cast to Action<T(...)> rather than when the action is
853 Action<ToType()> action(Return(x)); in TEST() local
857 action.Perform(std::tuple<>()); in TEST()
858 EXPECT_FALSE(converted) << "Action must NOT convert its argument " in TEST()
864 const Action<int*()> a1 = ReturnNull(); in TEST()
867 const Action<const char*(bool)> a2 = ReturnNull(); // NOLINT in TEST()
874 const Action<std::unique_ptr<const int>()> a1 = ReturnNull(); in TEST()
877 const Action<std::shared_ptr<int>(std::string)> a2 = ReturnNull(); in TEST()
884 const Action<const int&(bool)> ret = ReturnRef(n); // NOLINT in TEST()
893 Action<Base&()> a = ReturnRef(base); in TEST()
940 const Action<const int&()> ret = ReturnRefOfCopy(n); in TEST()
954 Action<Base&()> a = ReturnRefOfCopy(base); in TEST()
963 Action<int()> ret = ReturnRoundRobin({1, 2, 3}); in TEST()
976 Action<double()> ret = ReturnRoundRobin(v); in TEST()
986 // Tests that DoDefault() does the default action for the mock method.
1026 // Tests that using DoDefault() inside a composite action leads to a
1053 // Tests that DoDefault() does the action specified by ON_CALL().
1075 Action<MyFunction> a = SetArgPointee<1>(2); in TEST()
1094 Action<MyFunction> a = SetArgPointee<0>("hi"); in TEST()
1110 Action<MyFunction> a = SetArgPointee<0>(L"world"); in TEST()
1118 Action<MyStringFunction> a2 = SetArgPointee<0>(L"world"); in TEST()
1130 Action<MyFunction> a = SetArgPointee<1>(hi); in TEST()
1149 Action<MyFunction> a = SetArgPointee<1>(hi); in TEST()
1159 Action<MyStringFunction> a2 = SetArgPointee<1>(world); in TEST()
1170 Action<MyFunction> a = SetArgumentPointee<1>(2); in TEST()
1229 // As an action that takes one argument. in TEST()
1230 Action<int(int)> a = InvokeWithoutArgs(Nullary); // NOLINT in TEST()
1233 // As an action that takes two arguments. in TEST()
1234 Action<int(int, double)> a2 = InvokeWithoutArgs(Nullary); // NOLINT in TEST()
1237 // As an action that returns void. in TEST()
1238 Action<void(int)> a3 = InvokeWithoutArgs(VoidNullary); // NOLINT in TEST()
1246 // As an action that takes no argument. in TEST()
1247 Action<int()> a = InvokeWithoutArgs(NullaryFunctor()); // NOLINT in TEST()
1250 // As an action that takes three arguments. in TEST()
1251 Action<int(int, double, char)> a2 = // NOLINT in TEST()
1255 // As an action that returns void. in TEST()
1256 Action<void()> a3 = InvokeWithoutArgs(VoidNullaryFunctor()); in TEST()
1265 Action<int(bool, char)> a = // NOLINT in TEST()
1270 // Tests using IgnoreResult() on a polymorphic action.
1272 Action<void(int)> a = IgnoreResult(Return(5)); // NOLINT in TEST()
1276 // Tests using IgnoreResult() on a monomorphic action.
1285 Action<void()> a = IgnoreResult(Invoke(ReturnOne)); in TEST()
1290 // Tests using IgnoreResult() on an action that returns a class type.
1299 Action<void(int)> a = in TEST()
1307 Action<void(int)> a = Assign(&x, 5); in TEST()
1314 Action<void(void)> a = Assign(&x, "Hello, world"); in TEST()
1321 Action<void(int)> a = Assign(&x, 5); in TEST()
1342 // mock action itself accepts an rvalue reference or a non-scalar object by
1343 // value then the final action should receive an rvalue reference, but initial
1348 // Mock action accepts by value: the initial action should be fed a const in TEST()
1349 // lvalue reference, and the final action an rvalue reference. in TEST()
1367 // Mock action accepts by const lvalue reference: both actions should receive in TEST()
1387 // Mock action accepts by non-const lvalue reference: both actions should get in TEST()
1405 // Mock action accepts by rvalue reference: the initial actions should receive in TEST()
1406 // a non-const lvalue reference if it wants it, and the final action an rvalue in TEST()
1450 // DoAll should support being used with type-erased Action objects, both through
1454 const Action<void()> initial_action = [] {}; in TEST()
1455 const Action<int()> final_action = [] { return 17; }; in TEST()
1464 // With &&-qualified and move-only final action. in TEST()
1480 // Tests using WithArgs and with an action that takes 1 argument.
1482 Action<bool(double x, int n)> a = WithArgs<1>(Invoke(Unary)); // NOLINT in TEST()
1487 // Tests using WithArgs with an action that takes 2 arguments.
1489 Action<const char*(const char* s, double x, short n)> a = // NOLINT in TEST()
1503 // Tests using WithArgs with an action that takes 10 arguments.
1505 Action<std::string(const char*, const char*, const char*, const char*)> a = in TEST()
1512 // Tests using WithArgs with an action that is not Invoke().
1521 Action<int(const std::string&, int, int)> a = in TEST()
1530 Action<int(int x, char y, short z)> a = // NOLINT in TEST()
1537 Action<int(bool, int m, int n)> a = // NOLINT in TEST()
1544 Action<const char*(short n, const char* input)> a = // NOLINT in TEST()
1552 Action<long(short x, char y, double z, char c)> a = // NOLINT in TEST()
1558 // Tests using WithArgs with an action that returns void.
1560 Action<void(double x, char c, int n)> a = WithArgs<2, 1>(Invoke(VoidBinary)); in TEST()
1567 Action<int&(int&, void*)> aa = WithArgs<0>([](int& a) -> int& { return a; }); in TEST()
1574 Action<Derived*()> inner = [] { return nullptr; }; in TEST()
1585 // It should be possible to use an &&-qualified inner action as long as the
1609 Action<int(void)> a = SetErrnoAndReturn(ENOTTY, -5); in TEST_F()
1616 Action<int*(void)> a = SetErrnoAndReturn(ENOTTY, &x); in TEST_F()
1622 Action<double()> a = SetErrnoAndReturn(EINVAL, 5); in TEST_F()
1719 Action<UnaryConstructorClass*()> a = ReturnNew<UnaryConstructorClass>(4000); in TEST()
1726 Action<UnaryConstructorClass*(bool, int)> a = in TEST()
1734 Action<const UnaryConstructorClass*()> a = in TEST()
1751 Action<TenArgConstructorClass*()> a = ReturnNew<TenArgConstructorClass>( in TEST()
1858 // The unique_ptr can be saved by the action. in TEST()
1876 // Action is directly compatible with mocked function type. in TEST()
1884 // Action doesn't want mocked function arguments. in TEST()
1893 // Edge case: if an action has both a const-qualified and an &&-qualified call
1896 // action beyond one call), and the const-qualified one by WillRepeatedly.
1924 // WillOnce should have no problem coping with a move-only action, whether it is
1962 // It should be possible to use an action that returns a value with a mock
1977 // possible to hand an lvalue reference to a copyable action to WillOnce.
1981 const auto action = [] { return 17; }; in TEST() local
1982 EXPECT_CALL(mock, Call).WillOnce(action); in TEST()
2023 operator Action<int(Args...)>() const { // NOLINT in operator Action<int(Args...)>()
2029 // defines templated conversion operators to OnceAction and Action. WillOnce
2041 // Tests for std::function based action.
2062 Action<int(int, int&, int*)> a = &Add; in TEST()
2068 Action<int(std::unique_ptr<int>)> a1 = &Deref; in TEST()
2073 Action<int(bool, int)> a1 = [](bool b, int i) { return b ? i : 0; }; in TEST()
2078 Action<void(std::unique_ptr<int>)> a2 = [&saved](std::unique_ptr<int> p) { in TEST()
2086 Action<int(int)> ai = Double(); in TEST()
2088 Action<double(double)> ad = Double(); // Double? Double double! in TEST()
2094 const Action<bool(int)> a1 = [](int i) { return i > 1; }; in TEST()
2095 const Action<int(bool)> a2 = Action<int(bool)>(a1); in TEST()
2100 const Action<bool(std::string)> s1 = [](std::string s) { return !s.empty(); }; in TEST()
2101 const Action<int(const char*)> s2 = Action<int(const char*)>(s1); in TEST()
2105 // Also between the lambda and the action itself. in TEST()
2106 const Action<bool(std::string)> x1 = [](Unused) { return 42; }; in TEST()
2107 const Action<bool(std::string)> x2 = [] { return 42; }; in TEST()
2113 Action<int(int)> d = f; in TEST()
2117 // Ensure creation of an empty action succeeds. in TEST()
2118 Action<void(int)>(nullptr); in TEST()
2123 Action<int(int, double y, double z)> a = [](int i, Unused, Unused) { in TEST()
2132 Action<int(std::unique_ptr<int>)> a = Return(1); in TEST()
2138 Action<void(std::unique_ptr<int>, int*)> a2 = testing::SetArgPointee<1>(3); in TEST()
2144 ACTION(ReturnArity) { return std::tuple_size<args_type>::value; } in ACTION() function
2148 1, testing::Action<int(int)>(ReturnArity()).Perform(std::make_tuple(0))); in TEST()
2151 testing::Action<int(int, int, int, int, int, int, int, int, int, int)>( in TEST()
2156 testing::Action<int(int, int, int, int, int, int, int, int, int, int, int, in TEST()