1 // Copyright 2020 Peter Dimov
2 // Distributed under the Boost Software License, Version 1.0
3 // http://www.boost.org/LICENSE_1_0.txt
4 
5 #include <boost/system/system_category.hpp>
6 #include <boost/system/generic_category.hpp>
7 #include <boost/system/error_condition.hpp>
8 #include <boost/core/lightweight_test.hpp>
9 
10 namespace sys = boost::system;
11 
main()12 int main()
13 {
14     sys::error_category const & cat = sys::system_category();
15 
16     // name
17     BOOST_TEST_CSTR_EQ( cat.name(), "system" );
18 
19     // default_error_condition
20     BOOST_TEST( cat.default_error_condition( 0 ) == sys::error_condition() );
21     BOOST_TEST( cat.default_error_condition( -1 ) == sys::error_condition( -1, cat ) );
22 
23 #if defined(BOOST_WINDOWS_API)
24 
25     BOOST_TEST( cat.default_error_condition( 5 ) == sys::error_condition( EACCES, sys::generic_category() ) );
26 
27 #else
28 
29     BOOST_TEST( cat.default_error_condition( EACCES ) == sys::error_condition( EACCES, sys::generic_category() ) );
30 
31 #endif
32 
33     // failed
34     BOOST_TEST( !cat.failed( 0 ) );
35     BOOST_TEST( cat.failed( 5 ) );
36     BOOST_TEST( cat.failed( -1 ) );
37 
38     return boost::report_errors();
39 }
40