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
10namespace sys = boost::system;
11
12int 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
22 // No longer holds; returns a generic condition
23 // BOOST_TEST( cat.default_error_condition( -1 ) == sys::error_condition( -1, cat ) );
24
25#if defined(BOOST_WINDOWS_API)
26
27 BOOST_TEST( cat.default_error_condition( 5 ) == sys::error_condition( EACCES, sys::generic_category() ) );
28
29#else
30
31 BOOST_TEST( cat.default_error_condition( EACCES ) == sys::error_condition( EACCES, sys::generic_category() ) );
32
33#endif
34
35 // failed
36 BOOST_TEST( !cat.failed( 0 ) );
37 BOOST_TEST( cat.failed( 5 ) );
38 BOOST_TEST( cat.failed( -1 ) );
39
40 return boost::report_errors();
41}
42

source code of boost/libs/system/test/system_category_test3.cpp