diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index eeab9c4..df51e4d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -130,6 +130,8 @@ boost_test(TYPE compile SOURCES constexpr_test2.cpp) boost_test(TYPE run SOURCES error_code_test3.cpp) boost_test(TYPE run SOURCES std_interop_test15.cpp) +boost_test(TYPE run SOURCES win32_generic_test.cpp) + # result set(BOOST_TEST_COMPILE_FEATURES cxx_std_11) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 9d9f146..306c5b4 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -158,6 +158,8 @@ compile constexpr_test2.cpp ; run error_code_test3.cpp ; run std_interop_test15.cpp ; +run win32_generic_test.cpp ; + # result import ../../config/checks/config : requires ; diff --git a/test/win32_generic_test.cpp b/test/win32_generic_test.cpp new file mode 100644 index 0000000..f571b17 --- /dev/null +++ b/test/win32_generic_test.cpp @@ -0,0 +1,52 @@ +// Copyright 2022 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include + +#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) + +BOOST_PRAGMA_MESSAGE( "Skipping test, BOOST_SYSTEM_HAS_SYSTEM_ERROR is not defined" ) +int main() {} + +#elif !defined(BOOST_MSSTL_VERSION) || BOOST_MSSTL_VERSION < 140 + +BOOST_PRAGMA_MESSAGE( "Skipping test, BOOST_MSSTL_VERSION is not defined or is less than 140" ) +int main() {} + +#else + +#include +#include + +int main() +{ + namespace sys = boost::system; + + int n = 0; + + for( int i = 0; i < 65000; ++i ) + { + sys::error_code ec1( i, sys::system_category() ); + sys::error_condition en1 = ec1.default_error_condition(); + + std::error_code ec2( i, std::system_category() ); + std::error_condition en2 = ec2.default_error_condition(); + + if( en1 != en2 ) + { + std::cout << en1 << " (" << en1.message() << ") != cond:" << en2.category().name() << ":" << en2.value() << " (" << en2.message() << ")\n"; + + if( en2.category() == std::generic_category() ) + { + ++n; + } + } + } + + return n < 256 ? n: 255; +} + +#endif