• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // Copyright 2017, 2019 Peter Dimov.
3 //
4 // Distributed under the Boost Software License, Version 1.0.
5 //
6 // See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt
8 
9 // See library home page at http://www.boost.org/libs/system
10 
11 #if defined(__GNUC__) && __GNUC__ >= 5 && __cplusplus >= 201103L
12 # pragma GCC diagnostic error "-Wsuggest-override"
13 #endif
14 
15 #include <boost/config.hpp>
16 
17 #if defined( BOOST_GCC ) && BOOST_GCC < 40600
18 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
19 #endif
20 
21 #include <boost/system/system_error.hpp>
22 #include <boost/system/error_code.hpp>
23 #include <boost/core/lightweight_test.hpp>
24 #include <cerrno>
25 
main()26 int main()
27 {
28     boost::system::error_category const & bt = boost::system::generic_category();
29 
30     int ev = ENOENT;
31 
32     boost::system::error_code bc( ev, bt );
33 
34     BOOST_TEST_EQ( bc.value(), ev );
35     BOOST_TEST_EQ( &bc.category(), &bt );
36 
37     boost::system::error_condition bn = bt.default_error_condition( ev );
38 
39     BOOST_TEST_EQ( bn.value(), ev );
40     BOOST_TEST_EQ( &bn.category(), &bt );
41 
42     BOOST_TEST( bt.equivalent( ev, bn ) );
43 
44     BOOST_TEST( bc == bn );
45 
46     boost::system::system_error x( bc, "prefix" );
47 
48     BOOST_TEST_EQ( x.code(), bc );
49     BOOST_TEST_EQ( std::string( x.what() ), "prefix: " + bc.message() );
50 
51     return boost::report_errors();
52 }
53