errno_test.cpp 800 B

12345678910111213141516171819202122232425262728293031323334
  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/get_error_info.hpp>
  5. #include <boost/exception/info.hpp>
  6. #include <boost/detail/lightweight_test.hpp>
  7. #include <boost/detail/workaround.hpp>
  8. #include <errno.h>
  9. typedef boost::error_info<struct tag_errno,int> info_errno;
  10. class
  11. my_exception:
  12. public boost::exception
  13. {
  14. };
  15. int
  16. main()
  17. {
  18. try
  19. {
  20. errno=1;
  21. throw my_exception() << info_errno(errno);
  22. }
  23. catch(
  24. my_exception & x )
  25. {
  26. BOOST_TEST(1==*boost::get_error_info<info_errno>(x));
  27. }
  28. return boost::report_errors();
  29. }