mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
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:
parent
4d98e599c6
commit
5c82c8052f
1 changed files with 45 additions and 1 deletions
|
|
@ -95,7 +95,7 @@ The following code does not compile :
|
||||||
MOCK_METHOD( method, 0 ) // this fails to compile because 'method' is not visible
|
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 )
|
MOCK_BASE_CLASS( mock_base, base )
|
||||||
{
|
{
|
||||||
|
|
@ -104,6 +104,50 @@ The workaround would be to add the signature to MOCK_METHOD :
|
||||||
|
|
||||||
[endsect]
|
[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]
|
[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 :
|
For compilers without support for variadic macros the following code does not compile :
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue