File: boost_test_helper.h

package info (click to toggle)
tango 10.0.2%2Bdfsg1-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 89,480 kB
  • sloc: cpp: 201,245; sh: 1,645; python: 953; java: 800; perl: 467; javascript: 447; xml: 325; makefile: 269; sql: 72; ruby: 24
file content (69 lines) | stat: -rw-r--r-- 5,543 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// A custom definition allows to output exception messages in case BOOST_XXX_NO_THROW does throw.
// Taken from https://stackoverflow.com/a/16701468/4859183 and expanded for Tango

#define BOOST_CHECK_THROW_IMPL_OVERRIDE(S, E, TL, Ppassed, Mpassed, Pcaught, Mcaught)          \
do                                                                                             \
{                                                                                              \
  try                                                                                          \
  {                                                                                            \
    BOOST_TEST_PASSPOINT();                                                                    \
    S;                                                                                         \
    BOOST_TEST_TOOL_DIRECT_IMPL( Ppassed, TL, Mpassed );                                       \
}                                                                                              \
    catch(const Tango::DevFailed & e)                                                          \
    {                                                                                          \
      std::stringstream ss;                                                                    \
      ss << std::endl                                                                          \
      << "-----------------------------------------------" << std::endl                        \
      << "test case: " << boost::unit_test::framework::current_test_case().p_name << std::endl \
      << std::endl << "exception message: " << std::endl                                       \
      << e.errors[0].reason << std::endl                                                       \
      << e.errors[0].desc   << std::endl                                                       \
      << e.errors[0].origin << std::endl;                                                      \
      BOOST_TEST_MESSAGE(ss.str());                                                            \
      BOOST_TEST_TOOL_DIRECT_IMPL( Pcaught, TL, Mcaught );                                     \
    }                                                                                          \
    catch(const std::exception &e)                                                             \
    {                                                                                          \
      std::stringstream ss;                                                                    \
      ss << std::endl                                                                          \
      << "-----------------------------------------------" << std::endl                        \
      << "test case: " << boost::unit_test::framework::current_test_case().p_name << std::endl \
      << std::endl << "exception message: " << e.what() << std::endl;                          \
      BOOST_TEST_MESSAGE(ss.str());                                                            \
      BOOST_TEST_TOOL_DIRECT_IMPL( Pcaught, TL, Mcaught );                                     \
    }                                                                                          \
    catch(...)                                                                                 \
    {                                                                                          \
      std::stringstream ss;                                                                    \
      ss << std::endl                                                                          \
      << "-----------------------------------------------" << std::endl                        \
      << "test case: " << boost::unit_test::framework::current_test_case().p_name << std::endl \
      << std::endl << "exception message : <unknown exception>" << std::endl;                  \
      BOOST_TEST_MESSAGE(ss.str());                                                            \
      BOOST_TEST_TOOL_DIRECT_IMPL( Pcaught, TL, Mcaught );                                     \
    }                                                                                          \
    /**/                                                                                       \
} while( ::boost::test_tools::tt_detail::dummy_cond() )                                        \
/**/

#undef BOOST_WARN_NO_THROW
#undef BOOST_CHECK_NO_THROW
#undef BOOST_REQUIRE_NO_THROW

#define BOOST_WARN_NO_THROW( S )                                            \
    BOOST_CHECK_THROW_IMPL_OVERRIDE(S, ..., WARN,                           \
            true , "no exceptions thrown by " BOOST_STRINGIZE( S ),         \
            false, "exception thrown by " BOOST_STRINGIZE( S ) )            \
/**/
#define BOOST_CHECK_NO_THROW( S )                                           \
    BOOST_CHECK_THROW_IMPL_OVERRIDE(S, ..., CHECK,                          \
            true , "no exceptions thrown by " BOOST_STRINGIZE( S ),         \
            false, "exception thrown by " BOOST_STRINGIZE( S ) )            \
/**/
#define BOOST_REQUIRE_NO_THROW( S )                                         \
    BOOST_CHECK_THROW_IMPL_OVERRIDE(S, ..., REQUIRE,                        \
            true , "no exceptions thrown by " BOOST_STRINGIZE( S ),         \
            false, "exception thrown by " BOOST_STRINGIZE( S ) )

BOOST_TEST_DONT_PRINT_LOG_VALUE(std::vector<std::string>::iterator)