From 5c82c8052ffcc8a19dd7f08fd682790f6530057c Mon Sep 17 00:00:00 2001 From: mat007 Date: Sat, 6 Jul 2013 21:19:12 +0000 Subject: [PATCH] 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 --- build/boost/doc/limitations.qbk | 46 ++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/build/boost/doc/limitations.qbk b/build/boost/doc/limitations.qbk index d7ec940..2d2ac44 100644 --- a/build/boost/doc/limitations.qbk +++ b/build/boost/doc/limitations.qbk @@ -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 :