Helper to check that an exception is thrown. More...
#include <cassert>Go to the source code of this file.
Defines | |
| #define | EXPECT_EXCEPTION(EXC, CODE) |
| Helper to check that an exception is thrown. | |
Helper to check that an exception is thrown.
| #define EXPECT_EXCEPTION | ( | EXC, | |||
| CODE | ) |
do { \ bool caught = false; \ try { \ CODE; \ } \ catch (const EXC&) { \ caught = true; \ } \ assert (caught); \ } while(0)
Helper to check that an exception is thrown.
Use like this:
EXPECT_EXCEPTION (std::runtime_error, doSomething());
This will produce an exception failure if doSomething() does _not_ throw a std::runtime_error exception.
1.6.1