/cvmfs/atlas.cern.ch/repo/sw/ASG/AnalysisBase/2.4.29/TestTools/TestTools/expect_exception.h File Reference

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.

Detailed Description

Helper to check that an exception is thrown.

Author:
scott snyder <snyder@bnl.gov>
Date:
Aug, 2014

Define Documentation

#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 exception failure if doSomething() does _not_ throw a std::runtime_error exception.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 15 Apr 2017 for RootCore Packages by  doxygen 1.6.1