]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/log/test/run/unhandled_exception_count.cpp
Add patch for failing prerm scripts
[ceph.git] / ceph / src / boost / libs / log / test / run / unhandled_exception_count.cpp
CommitLineData
7c673cae
FG
1/*
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)
6 */
7/*!
8 * \file unhandled_exception_count.cpp
9 * \author Andrey Semashev
10 * \date 20.04.2013
11 *
12 * \brief This file contains tests for the unhandled_exception_count internal function.
13 *
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.
16 *
17 * This file only contains the very basic checks of functionality that can be portably achieved
18 * through std::unhandled_exception.
19 */
20
21#define BOOST_TEST_MODULE unhandled_exception_count
22
23#include <boost/test/unit_test.hpp>
24#include <boost/log/detail/unhandled_exception_count.hpp>
25
26struct my_exception {};
27
28class exception_watcher
29{
30 unsigned int& m_count;
31
32public:
33 explicit exception_watcher(unsigned int& count) : m_count(count) {}
34 ~exception_watcher() { m_count = boost::log::aux::unhandled_exception_count(); }
35};
36
37// Tests for unhandled_exception_count when used in a destructor while an exception propagates
38BOOST_AUTO_TEST_CASE(in_destructor)
39{
40 const unsigned int root_count = boost::log::aux::unhandled_exception_count();
41
42 unsigned int level1_count = root_count;
43 try
44 {
45 exception_watcher watcher(level1_count);
46 throw my_exception();
47 }
48 catch (...)
49 {
50 }
51
52 BOOST_CHECK_NE(root_count, level1_count);
53}