aboutsummaryrefslogtreecommitdiffstats
path: root/test/gmock-generated-actions_test.cc
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2009-02-06 01:09:43 +0000
committerzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2009-02-06 01:09:43 +0000
commite1cdce5f761ed0fb04be0aea4d1b9138e9dbc1f7 (patch)
tree7460e6ee2c8098de00d09294ecb5f6d2b8f3c2b4 /test/gmock-generated-actions_test.cc
parentc069d7fe27bfe8cfdaff77ef38455688c453c28d (diff)
downloadgoogletest-e1cdce5f761ed0fb04be0aea4d1b9138e9dbc1f7.tar.gz
googletest-e1cdce5f761ed0fb04be0aea4d1b9138e9dbc1f7.tar.bz2
googletest-e1cdce5f761ed0fb04be0aea4d1b9138e9dbc1f7.zip
Implements action Throw(exception).
Diffstat (limited to 'test/gmock-generated-actions_test.cc')
-rw-r--r--test/gmock-generated-actions_test.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/gmock-generated-actions_test.cc b/test/gmock-generated-actions_test.cc
index aee2c905..0d5260a2 100644
--- a/test/gmock-generated-actions_test.cc
+++ b/test/gmock-generated-actions_test.cc
@@ -1310,5 +1310,26 @@ TEST(ActionPnMacroTest, CanExplicitlyInstantiateWithReferenceTypes) {
EXPECT_EQ(55, a.Perform(empty));
}
+#if GTEST_HAS_EXCEPTIONS
+
+TEST(ThrowActionTest, ThrowsGivenExceptionInVoidFunction) {
+ const Action<void(int n)> a = Throw('a');
+ EXPECT_THROW(a.Perform(make_tuple(0)), char);
+}
+
+class MyException {};
+
+TEST(ThrowActionTest, ThrowsGivenExceptionInNonVoidFunction) {
+ const Action<double(char ch)> a = Throw(MyException());
+ EXPECT_THROW(a.Perform(make_tuple('0')), MyException);
+}
+
+TEST(ThrowActionTest, ThrowsGivenExceptionInNullaryFunction) {
+ const Action<double()> a = Throw(MyException());
+ EXPECT_THROW(a.Perform(make_tuple()), MyException);
+}
+
+#endif // GTEST_HAS_EXCEPTIONS
+
} // namespace gmock_generated_actions_test
} // namespace testing