Add win32_generic_test. Refs #97.

This commit is contained in:
Peter Dimov
2022-12-10 18:24:34 +02:00
parent 7ae6b317f3
commit bfccd4b4d9
3 changed files with 56 additions and 0 deletions

View File

@ -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)

View File

@ -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 ;

View File

@ -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 <boost/system.hpp>
#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>
#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 <system_error>
#include <iostream>
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