Helper to check that an exception is thrown.
More...
#include <cassert>
Go to the source code of this file.
|
| #define | EXPECT_EXCEPTION(EXC, CODE) |
| | Helper to check that an exception is thrown.
|
Helper to check that an exception is thrown.
- Author
- scott snyder snyde.nosp@m.r@bn.nosp@m.l.gov
- Date
- Aug, 2014
Definition in file expect_exception.h.
◆ EXPECT_EXCEPTION
| #define EXPECT_EXCEPTION |
( |
| EXC, |
|
|
| CODE ) |
Value: 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:
#define EXPECT_EXCEPTION(EXC, CODE)
Helper to check that an exception is thrown.
This will produce an assertion failure if doSomething() does not throw a std::runtime_error exception.
Definition at line 33 of file expect_exception.h.
33#define EXPECT_EXCEPTION(EXC, CODE) do { \
34 bool caught = false; \
35 try { \
36 CODE; \
37 } \
38 catch (const EXC&) { \
39 caught = true; \
40 } \
41 assert (caught); \
42} while(0)