Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
e1cdce5f
Commit
e1cdce5f
authored
Feb 06, 2009
by
zhanyong.wan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implements action Throw(exception).
parent
c069d7fe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
0 deletions
+41
-0
gmock-generated-actions.h
include/gmock/gmock-generated-actions.h
+10
-0
gmock-generated-actions.h.pump
include/gmock/gmock-generated-actions.h.pump
+10
-0
gmock-generated-actions_test.cc
test/gmock-generated-actions_test.cc
+21
-0
No files found.
include/gmock/gmock-generated-actions.h
View file @
e1cdce5f
...
...
@@ -2298,4 +2298,14 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
arg4_type arg4, arg5_type arg5, arg6_type arg6, arg7_type arg7, \
arg8_type arg8, arg9_type arg9) const
namespace
testing
{
// Action Throw(exception) can be used in a mock function of any type
// to throw the given exception. Any copyable value can be thrown.
#if GTEST_HAS_EXCEPTIONS
ACTION_P
(
Throw
,
exception
)
{
throw
exception
;
}
#endif // GTEST_HAS_EXCEPTIONS
}
// namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
include/gmock/gmock-generated-actions.h.pump
View file @
e1cdce5f
...
...
@@ -772,4 +772,14 @@ $arg_types_and_names) const
]]
namespace
testing
{
// Action Throw(exception) can be used in a mock function of any type
// to throw the given exception. Any copyable value can be thrown.
#if GTEST_HAS_EXCEPTIONS
ACTION_P
(
Throw
,
exception
)
{
throw
exception
;
}
#endif // GTEST_HAS_EXCEPTIONS
}
// namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
test/gmock-generated-actions_test.cc
View file @
e1cdce5f
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment