Removes dead code in gmock-more-actions_test.cc.
This commit is contained in:
parent
04d6ed817e
commit
c53b3dca1b
|
@ -350,25 +350,6 @@ TEST(InvokeTest, FunctionWithCompatibleType) {
|
|||
EXPECT_EQ(4321, a.Perform(make_tuple(4000, 300, 20, true)));
|
||||
}
|
||||
|
||||
#if GMOCK_HAS_GOOGLE3_CALLBACK_
|
||||
|
||||
// Tests IgnoreResult(Invoke(result_callback)).
|
||||
TEST(InvokeTest, IgnoreResultOfResultCallback) {
|
||||
ResultCallback<int>* c = NewPermanentCallback(Nullary);
|
||||
Action<void()> a = IgnoreResult(Invoke(c));
|
||||
a.Perform(make_tuple());
|
||||
}
|
||||
|
||||
// Tests IgnoreResult(Invoke(result_callback4)).
|
||||
TEST(InvokeTest, IgnoreResultOfResultCallback4) {
|
||||
ResultCallback4<int, int, int, int, int>* c =
|
||||
NewPermanentCallback(SumOf4);
|
||||
Action<void(int, int, int, int)> a = IgnoreResult(Invoke(c));
|
||||
a.Perform(make_tuple(1, 2, 3, 4));
|
||||
}
|
||||
|
||||
#endif // GMOCK_HAS_GOOGLE3_CALLBACK_
|
||||
|
||||
// Tests using Invoke() with an object pointer and a method pointer.
|
||||
|
||||
// Tests using Invoke() with a nullary method.
|
||||
|
@ -479,119 +460,6 @@ TEST(InvokeMethodTest, MethodWithCompatibleType) {
|
|||
EXPECT_EQ(4444, a.Perform(make_tuple(4000, 300, 20, true)));
|
||||
}
|
||||
|
||||
#if GMOCK_HAS_GOOGLE3_CALLBACK_
|
||||
|
||||
// We don't have dedicated tests to verify that Invoke(callback) and
|
||||
// InvokeWithoutArgs(callback) delete the callback argument. Instead,
|
||||
// we rely on the heap checker linked in this test program to do that.
|
||||
|
||||
// Tests that Invoke(non-permanent-callback) kills the process.
|
||||
TEST(InvokeCallbackDeathTest, RejectsNonPermanentCallback) {
|
||||
EXPECT_DEATH({
|
||||
Action<int()> a = Invoke(NewCallback(Nullary)); // NOLINT
|
||||
}, "");
|
||||
}
|
||||
|
||||
// Tests using Invoke() with a nullary callback.
|
||||
TEST(InvokeCallbackTest, Nullary) {
|
||||
// Tests using Invoke(callback) as an action of the exact type.
|
||||
Action<int()> a = Invoke(NewPermanentCallback(Nullary)); // NOLINT
|
||||
EXPECT_EQ(1, a.Perform(make_tuple()));
|
||||
|
||||
// Tests using Invoke(callback) as an action of a compatible type.
|
||||
Action<bool()> a2 = Invoke(NewPermanentCallback(Nullary)); // NOLINT
|
||||
EXPECT_TRUE(a2.Perform(make_tuple()));
|
||||
|
||||
// Tests using Invoke() on a callback that returns void.
|
||||
Action<void()> a3 = Invoke(NewPermanentCallback(VoidNullary)); // NOLINT
|
||||
g_done = false;
|
||||
a3.Perform(make_tuple());
|
||||
EXPECT_TRUE(g_done);
|
||||
}
|
||||
|
||||
// Tests using Invoke() with a unary callback.
|
||||
TEST(InvokeCallbackTest, Unary) {
|
||||
// Tests using Invoke(callback1) as an action of the exact type.
|
||||
Action<bool(int)> a = Invoke(NewPermanentCallback(Unary)); // NOLINT
|
||||
EXPECT_FALSE(a.Perform(make_tuple(1)));
|
||||
EXPECT_TRUE(a.Perform(make_tuple(-1)));
|
||||
|
||||
// Tests using Invoke(callback1) as an action of a compatible type.
|
||||
Action<int(long)> a2 = Invoke(NewPermanentCallback(Unary)); // NOLINT
|
||||
EXPECT_EQ(0, a2.Perform(make_tuple(1L)));
|
||||
EXPECT_EQ(1, a2.Perform(make_tuple(-1L)));
|
||||
|
||||
// Tests using Invoke() on a callback that returns void.
|
||||
Action<void(char)> a3 = Invoke(NewPermanentCallback(VoidUnary)); // NOLINT
|
||||
g_done = false;
|
||||
a3.Perform(make_tuple('a'));
|
||||
EXPECT_TRUE(g_done);
|
||||
}
|
||||
|
||||
// Tests using Invoke() with a binary callback.
|
||||
TEST(InvokeCallbackTest, Binary) {
|
||||
// Tests using Invoke(callback2) as an action of the exact type.
|
||||
Action<const char*(const char*, short)> a = // NOLINT
|
||||
Invoke(NewPermanentCallback(Binary));
|
||||
const char* p = "Hello";
|
||||
EXPECT_EQ(p + 2, a.Perform(make_tuple(p, 2)));
|
||||
|
||||
// Tests using Invoke(callback2) as an action of a compatible type.
|
||||
Action<bool(char*, int)> a2 = // NOLINT
|
||||
Invoke(NewPermanentCallback(Binary));
|
||||
char str[] = "Hello";
|
||||
EXPECT_TRUE(a2.Perform(make_tuple(str, 2)));
|
||||
|
||||
// Tests using Invoke() on a callback that returns void.
|
||||
Action<void(char, char)> a3 =
|
||||
Invoke(NewPermanentCallback(VoidBinary)); // NOLINT
|
||||
g_done = false;
|
||||
a3.Perform(make_tuple('a', 'b'));
|
||||
EXPECT_TRUE(g_done);
|
||||
}
|
||||
|
||||
// Tests using Invoke() with a ternary callback.
|
||||
TEST(InvokeCallbackTest, Ternary) {
|
||||
// Tests using Invoke(callback3) as an action of the exact type.
|
||||
Action<int(int, char, short)> a = // NOLINT
|
||||
Invoke(NewPermanentCallback(Ternary));
|
||||
EXPECT_EQ(6, a.Perform(make_tuple(1, '\2', 3)));
|
||||
|
||||
// Tests using Invoke(callback3) as an action of a compatible type.
|
||||
Action<long(char, int, int)> a2 = // NOLINT
|
||||
Invoke(NewPermanentCallback(Ternary));
|
||||
EXPECT_EQ(6, a2.Perform(make_tuple('\1', 2, 3)));
|
||||
|
||||
// Tests using Invoke() on a callback that returns void.
|
||||
Action<void(char, char, bool)> a3 =
|
||||
Invoke(NewPermanentCallback(VoidTernary)); // NOLINT
|
||||
g_done = false;
|
||||
a3.Perform(make_tuple('a', 'b', true));
|
||||
EXPECT_TRUE(g_done);
|
||||
}
|
||||
|
||||
// Tests using Invoke() with a 4-argument callback.
|
||||
TEST(InvokeCallbackTest, CallbackThatTakes4Arguments) {
|
||||
// Tests using Invoke(callback4) as an action of the exact type.
|
||||
Action<int(int, int, int, int)> a = // NOLINT
|
||||
Invoke(NewPermanentCallback(SumOf4));
|
||||
EXPECT_EQ(1234, a.Perform(make_tuple(1000, 200, 30, 4)));
|
||||
|
||||
// Tests using Invoke(callback4) as an action of a compatible type.
|
||||
Action<long(int, short, char, bool)> a2 = // NOLINT
|
||||
Invoke(NewPermanentCallback(SumOf4));
|
||||
EXPECT_EQ(4321, a2.Perform(make_tuple(4000, 300, 20, true)));
|
||||
|
||||
// Tests using Invoke() on a callback that returns void.
|
||||
Action<void(char, char, double, double)> a3 =
|
||||
Invoke(NewPermanentCallback(VoidFunctionWithFourArguments)); // NOLINT
|
||||
g_done = false;
|
||||
a3.Perform(make_tuple('a', 'b', 0, 1));
|
||||
EXPECT_TRUE(g_done);
|
||||
}
|
||||
|
||||
#endif // GMOCK_HAS_GOOGLE3_CALLBACK_
|
||||
|
||||
// Tests using WithoutArgs with an action that takes no argument.
|
||||
TEST(WithoutArgsTest, NoArg) {
|
||||
Action<int(int n)> a = WithoutArgs(Invoke(Nullary)); // NOLINT
|
||||
|
|
Loading…
Reference in New Issue
Block a user