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#include <boost/config.hpp>
7
8#if defined( BOOST_NO_EXCEPTIONS )
9# error This program requires exception handling.
10#endif
11
12#include <boost/exception/error_info.hpp>
13#include <boost/exception/exception.hpp>
14#include <boost/exception/info.hpp>
15#include <boost/exception/get_error_info.hpp>
16#include <boost/core/lightweight_test.hpp>
17#include <string>
18#include <string.h>
19
20struct my_exception: virtual boost::exception {};
21typedef boost::error_info<struct error_info_string_, std::string> error_info_string;
22
23int
24main()
25 {
26 try
27 {
28 throw my_exception() << error_info_string("doh");
29 }
30 catch( my_exception & e )
31 {
32 BOOST_TEST(boost::get_error_info<error_info_string>(e) && !strcmp(boost::get_error_info<error_info_string>(e)->c_str(),"doh"));
33 }
34 return boost::report_errors();
35 }
36

source code of boost/libs/exception/test/error_info_basic_test.cpp