1// (C) Copyright Gennadiy Rozental 2001.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5
6// See http://www.boost.org/libs/test for the library home page.
7//
8//!@file
9//!@brief contains wrappers, which allows to build Boost.Test with no exception
10// ***************************************************************************
11
12#ifndef BOOST_TEST_DETAIL_THROW_EXCEPTION_HPP
13#define BOOST_TEST_DETAIL_THROW_EXCEPTION_HPP
14
15// Boost
16#include <boost/config.hpp> // BOOST_NO_EXCEPTION
17
18#ifdef BOOST_NO_EXCEPTION
19// C RUNTIME
20#include <stdlib.h>
21
22#endif
23
24#include <boost/test/detail/suppress_warnings.hpp>
25
26//____________________________________________________________________________//
27
28namespace boost {
29namespace unit_test {
30namespace ut_detail {
31
32#ifdef BOOST_NO_EXCEPTIONS
33
34template<typename E>
35BOOST_NORETURN inline void
36throw_exception(E const& e) { abort(); }
37
38#define BOOST_TEST_I_TRY
39#define BOOST_TEST_I_CATCH( T, var ) for(T const& var = *(T*)0; false;)
40#define BOOST_TEST_I_CATCH0( T ) if(0)
41#define BOOST_TEST_I_CATCHALL() if(0)
42#define BOOST_TEST_I_RETHROW
43
44#else
45
46template<typename E>
47BOOST_NORETURN inline void
48throw_exception(E const& e) { throw e; }
49
50#define BOOST_TEST_I_TRY try
51#define BOOST_TEST_I_CATCH( T, var ) catch( T const& var )
52#define BOOST_TEST_I_CATCH0( T ) catch( T const& )
53#define BOOST_TEST_I_CATCHALL() catch(...)
54#define BOOST_TEST_I_RETHROW throw
55#endif
56
57//____________________________________________________________________________//
58
59#define BOOST_TEST_I_THROW( E ) unit_test::ut_detail::throw_exception( E )
60#define BOOST_TEST_I_THROW( E ) unit_test::ut_detail::throw_exception( E )
61#define BOOST_TEST_I_ASSRT( cond, ex ) if( cond ) {} else BOOST_TEST_I_THROW( ex )
62
63
64} // namespace ut_detail
65} // namespace unit_test
66} // namespace boost
67
68//____________________________________________________________________________//
69
70#include <boost/test/detail/enable_warnings.hpp>
71
72#endif // BOOST_TEST_DETAIL_THROW_EXCEPTION_HPP
73