forked from boostorg/system
Mark platform-specific error headers as deprecated; split tests
This commit is contained in:
@@ -10,6 +10,13 @@
|
|||||||
#ifndef BOOST_SYSTEM_CYGWIN_ERROR_HPP
|
#ifndef BOOST_SYSTEM_CYGWIN_ERROR_HPP
|
||||||
#define BOOST_SYSTEM_CYGWIN_ERROR_HPP
|
#define BOOST_SYSTEM_CYGWIN_ERROR_HPP
|
||||||
|
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
|
||||||
|
#if !defined(BOOST_ALLOW_DEPRECATED_HEADERS)
|
||||||
|
BOOST_PRAGMA_MESSAGE("This header is deprecated and is slated for removal."
|
||||||
|
" If you want it retained, please open an issue in github.com/boostorg/system.")
|
||||||
|
#endif
|
||||||
|
|
||||||
// This header is effectively empty for compiles on operating systems where
|
// This header is effectively empty for compiles on operating systems where
|
||||||
// it is not applicable.
|
// it is not applicable.
|
||||||
|
|
||||||
|
@@ -10,6 +10,13 @@
|
|||||||
#ifndef BOOST_SYSTEM_LINUX_ERROR_HPP
|
#ifndef BOOST_SYSTEM_LINUX_ERROR_HPP
|
||||||
#define BOOST_SYSTEM_LINUX_ERROR_HPP
|
#define BOOST_SYSTEM_LINUX_ERROR_HPP
|
||||||
|
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
|
||||||
|
#if !defined(BOOST_ALLOW_DEPRECATED_HEADERS)
|
||||||
|
BOOST_PRAGMA_MESSAGE("This header is deprecated and is slated for removal."
|
||||||
|
" If you want it retained, please open an issue in github.com/boostorg/system.")
|
||||||
|
#endif
|
||||||
|
|
||||||
// This header is effectively empty for compiles on operating systems where
|
// This header is effectively empty for compiles on operating systems where
|
||||||
// it is not applicable.
|
// it is not applicable.
|
||||||
|
|
||||||
|
@@ -10,6 +10,13 @@
|
|||||||
#ifndef BOOST_SYSTEM_WINDOWS_ERROR_HPP
|
#ifndef BOOST_SYSTEM_WINDOWS_ERROR_HPP
|
||||||
#define BOOST_SYSTEM_WINDOWS_ERROR_HPP
|
#define BOOST_SYSTEM_WINDOWS_ERROR_HPP
|
||||||
|
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
|
||||||
|
#if !defined(BOOST_ALLOW_DEPRECATED_HEADERS)
|
||||||
|
BOOST_PRAGMA_MESSAGE("This header is deprecated and is slated for removal."
|
||||||
|
" If you want it retained, please open an issue in github.com/boostorg/system.")
|
||||||
|
#endif
|
||||||
|
|
||||||
// This header is effectively empty for compiles on operating systems where
|
// This header is effectively empty for compiles on operating systems where
|
||||||
// it is not applicable.
|
// it is not applicable.
|
||||||
|
|
||||||
|
@@ -85,3 +85,7 @@ run generic_category_test2.cpp ;
|
|||||||
run generic_category_test3.cpp ;
|
run generic_category_test3.cpp ;
|
||||||
run system_category_test2.cpp ;
|
run system_category_test2.cpp ;
|
||||||
run system_category_test3.cpp ;
|
run system_category_test3.cpp ;
|
||||||
|
|
||||||
|
run windows_error_test.cpp ;
|
||||||
|
run cygwin_error_test.cpp ;
|
||||||
|
run linux_error_test.cpp ;
|
||||||
|
29
test/cygwin_error_test.cpp
Normal file
29
test/cygwin_error_test.cpp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2020 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/system/cygwin_error.hpp>
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
|
||||||
|
#if !defined(__CYGWIN__)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE( "Skipping test, __CYGWIN__ is not defined" )
|
||||||
|
int main() {}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
namespace sys = boost::system;
|
||||||
|
|
||||||
|
sys::error_code ec = sys::cygwin_error::no_package;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( ec, sys::cygwin_error::no_package );
|
||||||
|
BOOST_TEST_EQ( ec, sys::error_code( ENOPKG, sys::system_category() ) );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@@ -11,11 +11,8 @@
|
|||||||
|
|
||||||
#include <boost/config/warning_disable.hpp>
|
#include <boost/config/warning_disable.hpp>
|
||||||
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
#include <boost/system/error_code.hpp>
|
#include <boost/system/error_code.hpp>
|
||||||
#include <boost/system/cygwin_error.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/system/linux_error.hpp>
|
|
||||||
#include <boost/system/windows_error.hpp>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -294,29 +291,7 @@ int main( int, char ** )
|
|||||||
BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied );
|
BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied );
|
||||||
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
|
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
|
||||||
|
|
||||||
# ifdef __CYGWIN__
|
|
||||||
|
|
||||||
std::cout << "Cygwin tests...\n";
|
|
||||||
ec = cygwin_error::no_package;
|
|
||||||
BOOST_TEST( ec == cygwin_error::no_package );
|
|
||||||
BOOST_TEST( ec == error_code( ENOPKG, system_category() ) );
|
|
||||||
BOOST_TEST( ec == error_code( cygwin_error::no_package, system_category() ) );
|
|
||||||
BOOST_TEST( ec.default_error_condition().category() == system_category() );
|
|
||||||
|
|
||||||
# elif defined(linux) || defined(__linux) || defined(__linux__)
|
|
||||||
|
|
||||||
std::cout << "Linux tests...\n";
|
|
||||||
ec = linux_error::dot_dot_error;
|
|
||||||
BOOST_TEST( ec == linux_error::dot_dot_error );
|
|
||||||
BOOST_TEST( ec == error_code( EDOTDOT, system_category() ) );
|
|
||||||
BOOST_TEST( ec == error_code( linux_error::dot_dot_error, system_category() ) );
|
|
||||||
BOOST_TEST( ec.default_error_condition().category() == system_category() );
|
|
||||||
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ::boost::report_errors();
|
return ::boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
29
test/linux_error_test.cpp
Normal file
29
test/linux_error_test.cpp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2020 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/system/linux_error.hpp>
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
|
||||||
|
#if !defined(__linux__)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE( "Skipping test, __linux__ is not defined" )
|
||||||
|
int main() {}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
namespace sys = boost::system;
|
||||||
|
|
||||||
|
sys::error_code ec = sys::linux_error::dot_dot_error;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( ec, sys::linux_error::dot_dot_error );
|
||||||
|
BOOST_TEST_EQ( ec, sys::error_code( EDOTDOT, sys::system_category() ) );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
31
test/windows_error_test.cpp
Normal file
31
test/windows_error_test.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// Copyright 2020 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/system/windows_error.hpp>
|
||||||
|
#include <boost/config/pragma_message.hpp>
|
||||||
|
|
||||||
|
#if !defined(BOOST_WINDOWS_API)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE( "Skipping test, BOOST_WINDOWS_API is not defined" )
|
||||||
|
int main() {}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
namespace sys = boost::system;
|
||||||
|
|
||||||
|
sys::error_code ec = sys::windows_error::invalid_function;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( ec, sys::windows_error::invalid_function );
|
||||||
|
BOOST_TEST_EQ( ec, sys::error_code( ERROR_INVALID_FUNCTION, sys::system_category() ) );
|
||||||
|
BOOST_TEST( ec == make_error_condition( sys::errc::function_not_supported ) );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user