]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/system/test/system_error_test3.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / system / test / system_error_test3.cpp
1 // Copyright 2021, 2022 Peter Dimov
2 // Distributed under the Boost Software License, Version 1.0
3 // https://www.boost.org/LICENSE_1_0.txt
4
5 #include <boost/system/system_error.hpp>
6 #include <boost/core/lightweight_test.hpp>
7 #include <cerrno>
8
9 namespace sys = boost::system;
10
11 int main()
12 {
13 {
14 sys::error_code ec( 5, sys::generic_category() );
15 sys::system_error x1( ec );
16
17 BOOST_TEST_EQ( std::string( x1.what() ), ec.what() );
18 }
19
20 {
21 sys::error_code ec( 5, sys::generic_category() );
22 sys::system_error x1( ec, "prefix" );
23
24 BOOST_TEST_EQ( std::string( x1.what() ), "prefix: " + ec.what() );
25 }
26
27 {
28 sys::error_code ec( 5, sys::generic_category() );
29 sys::system_error x1( ec, std::string( "prefix2" ) );
30
31 BOOST_TEST_EQ( std::string( x1.what() ), "prefix2: " + ec.what() );
32 }
33
34 {
35 BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
36
37 sys::error_code ec( 5, sys::generic_category(), &loc );
38 sys::system_error x1( ec, "prefix3" );
39
40 BOOST_TEST_EQ( std::string( x1.what() ), "prefix3: " + ec.what() );
41 }
42
43 {
44 sys::system_error x1( 5, sys::system_category() );
45
46 BOOST_TEST_EQ( std::string( x1.what() ), sys::error_code( 5, sys::system_category() ).what() );
47 }
48
49 {
50 sys::system_error x1( 5, sys::system_category(), "prefix" );
51
52 BOOST_TEST_EQ( std::string( x1.what() ), "prefix: " + sys::error_code( 5, sys::system_category() ).what() );
53 }
54
55 {
56 sys::system_error x1( 5, sys::system_category(), std::string( "prefix2" ) );
57
58 BOOST_TEST_EQ( std::string( x1.what() ), "prefix2: " + sys::error_code( 5, sys::system_category() ).what() );
59 }
60
61 return boost::report_errors();
62 }