]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/exception/test/no_exceptions_test.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / exception / test / no_exceptions_test.cpp
1 //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
2
3 //Distributed under the Boost Software License, Version 1.0. (See accompanying
4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #define BOOST_NO_EXCEPTIONS
7 #include <boost/config.hpp>
8 #include <boost/throw_exception.hpp>
9 #include <boost/exception/info.hpp>
10 #include <boost/exception/diagnostic_information.hpp>
11 #include <boost/core/lightweight_test.hpp>
12 #include <stdlib.h>
13
14 struct
15 my_exception:
16 boost::exception,
17 std::exception
18 {
19 char const *
20 what() const BOOST_NOEXCEPT_OR_NOTHROW
21 {
22 return "my_exception";
23 }
24 };
25
26 typedef boost::error_info<struct my_tag,int> my_int;
27
28 bool called=false;
29
30 namespace
31 boost
32 {
33 void
34 throw_exception( std::exception const & x )
35 {
36 called=true;
37 std::string s=boost::diagnostic_information(x);
38 std::cout << s;
39 #ifndef BOOST_NO_RTTI
40 BOOST_TEST(s.find("my_tag")!=std::string::npos);
41 #endif
42 exit(boost::report_errors());
43 }
44 }
45
46 int
47 main()
48 {
49 BOOST_THROW_EXCEPTION( my_exception() << my_int(42) );
50 BOOST_TEST(called);
51 return boost::report_errors();
52 }