Documented limitation for mocking a member function with a throw specifier

git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@671 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
mat007 2013-07-06 21:19:12 +00:00
parent 4d98e599c6
commit 5c82c8052f

View file

@ -95,7 +95,7 @@ The following code does not compile :
MOCK_METHOD( method, 0 ) // this fails to compile because 'method' is not visible
};
The workaround would be to add the signature to MOCK_METHOD :
A workaround would be to add the signature to MOCK_METHOD :
MOCK_BASE_CLASS( mock_base, base )
{
@ -104,6 +104,50 @@ The workaround would be to add the signature to MOCK_METHOD :
[endsect]
[section Methods with a throw specifier cannot be mocked]
The following code does not compile :
namespace
{
struct base_class
{
virtual ~base_class()
{}
virtual void method() throw;
};
MOCK_BASE_CLASS( mock_class, base_class )
{
MOCK_METHOD( method, 0 ) // this fails to compile because of the throw specifier
};
}
A workaround would be to write a proxy member function :
namespace
{
struct base_class
{
virtual ~base_class()
{}
virtual void method() throw;
};
MOCK_BASE_CLASS( mock_class, base_class )
{
void method() throw
{
method_proxy();
}
MOCK_METHOD( method_proxy, 0, void(), method )
};
}
[endsect]
[section Compilers without support for variadic macros fail on commas in MOCK_BASE_CLASS]
For compilers without support for variadic macros the following code does not compile :