Sent from my iPad

On 1. mars 2013, at 01:58, Bas Vodde <notifications@github.com> wrote:

> In include/CppUTest/UtestMacros.h:
> 
> > @@ -189,6 +189,20 @@
> >  #define UT_PRINT(text) \
> >     UT_PRINT_LOCATION(text, __FILE__, __LINE__)
> >  
> > +#define CHECK_THROWS(expected, expression) \
> > +	std::string msg = "expected to throw "#expected "\nbut threw nothing"; \
> > +	bool caught_expected = false; \
> > +	try { \
> > +		(expression); \
> The usual way to write these is to have the UnitTest fail right after this line. That way, you won't need the boolean caught_expected and will keep your code a bit tighter.
> 
> (if it throws and exception, it'll jump over the FAIL. If the exception didn't happen, it'll fail)
> 
> —
> Reply to this email directly or view it on GitHub.
> 
This was my first attempt on this, but it turns out that fail throws, which jumps to the catch all case, and we actually get two test failures. This caused at least one of the test cases to fail as it got two failures on this.

I'll have a look at this, see if I can improve it, and fix the other comments you had.

- Martin