]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/log/test/run/unhandled_exception_count.cpp
2 * Copyright Andrey Semashev 2007 - 2015.
3 * Distributed under the Boost Software License, Version 1.0.
4 * (See accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
8 * \file unhandled_exception_count.cpp
9 * \author Andrey Semashev
12 * \brief This file contains tests for the unhandled_exception_count internal function.
14 * The unhandled_exception_count function is not for public use but its tests show
15 * whether the library will be able to emit log records in contexts when exceptions are being thrown.
17 * This file only contains the very basic checks of functionality that can be portably achieved
18 * through std::unhandled_exception.
21 #define BOOST_TEST_MODULE unhandled_exception_count
23 #include <boost/test/unit_test.hpp>
24 #include <boost/log/detail/unhandled_exception_count.hpp>
26 struct my_exception
{};
28 class exception_watcher
30 unsigned int& m_count
;
33 explicit exception_watcher(unsigned int& count
) : m_count(count
) {}
34 ~exception_watcher() { m_count
= boost::log::aux::unhandled_exception_count(); }
37 // Tests for unhandled_exception_count when used in a destructor while an exception propagates
38 BOOST_AUTO_TEST_CASE(in_destructor
)
40 const unsigned int root_count
= boost::log::aux::unhandled_exception_count();
42 unsigned int level1_count
= root_count
;
45 exception_watcher
watcher(level1_count
);
52 BOOST_CHECK_NE(root_count
, level1_count
);