error_info_basic_test.cpp 934 B

1234567891011121314151617181920212223242526272829
  1. //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
  2. //Distributed under the Boost Software License, Version 1.0. (See accompanying
  3. //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #include <boost/exception/error_info.hpp>
  5. #include <boost/exception/exception.hpp>
  6. #include <boost/exception/info.hpp>
  7. #include <boost/exception/get_error_info.hpp>
  8. #include <boost/core/lightweight_test.hpp>
  9. #include <string>
  10. #include <string.h>
  11. struct my_exception: virtual boost::exception {};
  12. typedef boost::error_info<struct error_info_string_, std::string> error_info_string;
  13. int
  14. main()
  15. {
  16. try
  17. {
  18. throw my_exception() << error_info_string("doh");
  19. }
  20. catch( my_exception & e )
  21. {
  22. BOOST_TEST(boost::get_error_info<error_info_string>(e) && !strcmp(boost::get_error_info<error_info_string>(e)->c_str(),"doh"));
  23. }
  24. return boost::report_errors();
  25. }