I need to mock the following function:
virtual void fun() noexcept = 0;
Is it possible using gmock ?
Gmock has the following macro:#define GMOCK_METHOD0_(tn, constness, ct, Method, ...)
but there is a comment: // INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!
Moreover I don't know how to use that macro (what the parameters tn and ct means) ?
Edit
The following mock:
GMOCK_METHOD0_(, noexcept, ,fun, void());
compiles with gmock 1.7.0 but when I compile it using gmock 1.8.1 I get the compilation errors:
main.cpp:17: error: expected identifier before ‘noexcept’
GMOCK_METHOD0_(, noexcept, ,fun, void());
^
gmock-generated-function-mockers.h:153: in definition of macro ‘GMOCK_METHOD0_’
constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
^
main.cpp:17: error: expected ‘,’ or ‘...’ before ‘noexcept’
GMOCK_METHOD0_(, noexcept, ,fun, void());
^
gmock-generated-function-mockers.h:153: in definition of macro ‘GMOCK_METHOD0_’
constness ::testing::internal::Function<__VA_ARGS__>* ) const { \
^
main.cpp:-1: In member function ‘testing::internal::MockSpec<void()> MockX::gmock_fun(const testing::internal::WithoutMatchers&, int) const’:
gmock-generated-function-mockers.h:154: error: ‘AdjustConstness_noexcept’ is not a member of ‘testing::internal’
return ::testing::internal::AdjustConstness_##constness(this)-> \
^
main.cpp:17: in expansion of macro ‘GMOCK_METHOD0_’
GMOCK_METHOD0_(, noexcept, ,fun, void());
^