]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/system/test/system_error_test.cpp
32bd04ea50c1c578b8f80031be03cd31d063f9a6
1 // system_error_test.cpp ---------------------------------------------------//
3 // Copyright Beman Dawes 2006
4 // Copyright (c) Microsoft Corporation 2014
5 // Distributed under the Boost Software License, Version 1.0. (See accompanying
6 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 // See library home page at http://www.boost.org/libs/system
10 //----------------------------------------------------------------------------//
12 #include <boost/config/warning_disable.hpp>
14 #include <boost/detail/lightweight_test.hpp>
15 #include <boost/system/system_error.hpp>
19 #ifdef BOOST_WINDOWS_API
23 using boost::system::system_error
;
24 using boost::system::error_code
;
25 using boost::system::system_category
;
28 #define TEST(x,v,w) test(#x,x,v,w)
32 void test( const char * desc
, const system_error
& ex
,
33 int v
, const char * str
)
35 std::cout
<< "test " << desc
<< "\n what() returns \"" << ex
.what() << "\"\n";
36 BOOST_TEST( ex
.code().value() == v
);
37 BOOST_TEST( ex
.code().category() == system_category() );
38 # ifdef BOOST_WINDOWS_API
40 # if !defined(__MINGW32__) && !defined(__CYGWIN__) && !BOOST_PLAT_WINDOWS_RUNTIME
41 language_id
= ::GetUserDefaultUILanguage();
43 language_id
= 0x0409; // Assume US English
45 // std::cout << "GetUserDefaultUILanguage() returns " << language_id << '\n';
46 if ( language_id
== 0x0409 ) // English (United States)
48 BOOST_TEST( std::string( ex
.what() ) == str
);
49 if ( std::string( ex
.what() ) != str
)
50 std::cout
<< "expected \"" << str
<< "\", but what() returned \""
51 << ex
.what() << "\"\n";
56 const boost::uint_least32_t uvalue
= 2u;
59 int main( int, char *[] )
61 // all constructors, in the same order as they appear in the header:
63 system_error
c1_0( error_code(0, system_category()) );
64 system_error
c1_1( error_code(1, system_category()) );
65 system_error
c1_2u( error_code(uvalue
, system_category()) );
67 system_error
c2_0( error_code(0, system_category()), string("c2_0") );
68 system_error
c2_1( error_code(1, system_category()), string("c2_1") );
70 system_error
c3_0( error_code(0, system_category()), "c3_0" );
71 system_error
c3_1( error_code(1, system_category()), "c3_1" );
73 system_error
c4_0( 0, system_category() );
74 system_error
c4_1( 1, system_category() );
75 system_error
c4_2u( uvalue
, system_category() );
77 system_error
c5_0( 0, system_category(), string("c5_0") );
78 system_error
c5_1( 1, system_category(), string("c5_1") );
80 system_error
c6_0( 0, system_category(), "c6_0" );
81 system_error
c6_1( 1, system_category(), "c6_1" );
83 TEST( c1_0
, 0, "The operation completed successfully" );
84 TEST( c1_1
, 1, "Incorrect function" );
85 TEST( c1_2u
, 2, "The system cannot find the file specified" );
87 TEST( c2_0
, 0, "c2_0: The operation completed successfully" );
88 TEST( c2_1
, 1, "c2_1: Incorrect function" );
90 TEST( c3_0
, 0, "c3_0: The operation completed successfully" );
91 TEST( c3_1
, 1, "c3_1: Incorrect function" );
93 TEST( c4_0
, 0, "The operation completed successfully" );
94 TEST( c4_1
, 1, "Incorrect function" );
95 TEST( c4_2u
, 2, "The system cannot find the file specified" );
97 TEST( c5_0
, 0, "c5_0: The operation completed successfully" );
98 TEST( c5_1
, 1, "c5_1: Incorrect function" );
100 TEST( c6_0
, 0, "c6_0: The operation completed successfully" );
101 TEST( c6_1
, 1, "c6_1: Incorrect function" );
103 return ::boost::report_errors();