ifw-daq  3.0.0-pre2
IFW Data Acquisition modules
expect.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup daq_test
4  * @copyright ESO - European Southern Observatory
5  */
6 #ifndef DAQ_TEST_EXPECT_HPP
7 #define DAQ_TEST_EXPECT_HPP
8 
9 #include <daq/error/report.hpp>
10 
11 /**
12  * Expect that stmt throws exception of type etype
13  * and that the exception message matches matcher.
14  */
15 #define EXPECT_THROW_WITH_MESSAGE(stmt, etype, matcher) \
16  EXPECT_THROW( \
17  try { stmt; } catch (const etype& ex) { \
18  std::stringstream ss; \
19  daq::error::ReportNestedExceptions(ss, ex); \
20  EXPECT_THAT(ss.str(), matcher); \
21  throw; \
22  }, \
23  etype)
24 #endif // #ifndef DAQ_TEST_EXPECT_HPP