| 1 | // Copyright 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.hpp> |
| 6 | #include <boost/config.hpp> |
| 7 | #include <boost/config/pragma_message.hpp> |
| 8 | |
| 9 | #if !defined(BOOST_MSSTL_VERSION) || BOOST_MSSTL_VERSION < 140 |
| 10 | |
| 11 | BOOST_PRAGMA_MESSAGE( "Skipping test, BOOST_MSSTL_VERSION is not defined or is less than 140" ) |
| 12 | int main() {} |
| 13 | |
| 14 | #else |
| 15 | |
| 16 | #include <system_error> |
| 17 | #include <iostream> |
| 18 | |
| 19 | int main() |
| 20 | { |
| 21 | namespace sys = boost::system; |
| 22 | |
| 23 | int n = 0; |
| 24 | |
| 25 | for( int i = 0; i < 65000; ++i ) |
| 26 | { |
| 27 | sys::error_code ec1( i, sys::system_category() ); |
| 28 | sys::error_condition en1 = ec1.default_error_condition(); |
| 29 | |
| 30 | std::error_code ec2( i, std::system_category() ); |
| 31 | std::error_condition en2 = ec2.default_error_condition(); |
| 32 | |
| 33 | if( en1 != en2 ) |
| 34 | { |
| 35 | std::cout << i << ": " << en1 << " (" << en1.message() << ") != cond:" << en2.category().name() << ":" << en2.value() << " (" << en2.message() << ")\n" ; |
| 36 | |
| 37 | if( en2.category() == std::generic_category() && i != 123 ) // msvc-14.0, msvc-14.1 disagree with us on ERROR_INVALID_NAME |
| 38 | { |
| 39 | ++n; |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | return n < 256 ? n: 255; |
| 45 | } |
| 46 | |
| 47 | #endif |
| 48 | |