ATLAS Offline Software
Macros
expect_exception.h File Reference

Helper to check that an exception is thrown. More...

#include <cassert>
Include dependency graph for expect_exception.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define EXPECT_EXCEPTION(EXC, CODE)
 Helper to check that an exception is thrown. More...
 

Detailed Description

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.

Macro Definition Documentation

◆ 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:

EXPECT_EXCEPTION (std::runtime_error, doSomething());

This will produce an assertion failure if doSomething() does not throw a std::runtime_error exception.

Definition at line 34 of file expect_exception.h.

EXPECT_EXCEPTION
#define EXPECT_EXCEPTION(EXC, CODE)
Helper to check that an exception is thrown.
Definition: expect_exception.h:33