diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/system | |
parent | Initial commit. (diff) | |
download | ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/system')
43 files changed, 3454 insertions, 0 deletions
diff --git a/src/boost/libs/system/CMakeLists.txt b/src/boost/libs/system/CMakeLists.txt new file mode 100644 index 00000000..5190213c --- /dev/null +++ b/src/boost/libs/system/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright 2018 Mike Dev +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt + +# Partial (add_subdirectory only) and experimental CMake support +# Subject to change; please do not rely on the contents of this file yet + +cmake_minimum_required(VERSION 3.5) +project(BoostSystem LANGUAGES CXX) + +add_library(boost_system INTERFACE) +add_library(Boost::system ALIAS boost_system) + +target_include_directories(boost_system INTERFACE include) + +target_link_libraries(boost_system + INTERFACE + Boost::config + Boost::winapi +) diff --git a/src/boost/libs/system/build/Jamfile.v2 b/src/boost/libs/system/build/Jamfile.v2 new file mode 100644 index 00000000..30527048 --- /dev/null +++ b/src/boost/libs/system/build/Jamfile.v2 @@ -0,0 +1,25 @@ +# Boost System Library Build Jamfile + +# (C) Copyright Beman Dawes 2002, 2006 + +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or www.boost.org/LICENSE_1_0.txt) + +# See library home page at http://www.boost.org/libs/system + +project boost/system + : source-location ../src + : usage-requirements # pass these requirement to dependents (i.e. users) + <link>shared:<define>BOOST_SYSTEM_DYN_LINK=1 + <link>static:<define>BOOST_SYSTEM_STATIC_LINK=1 + ; + +SOURCES = error_code ; + +lib boost_system + : $(SOURCES).cpp + : <link>shared:<define>BOOST_SYSTEM_DYN_LINK=1 + <link>static:<define>BOOST_SYSTEM_STATIC_LINK=1 + ; + +boost-install boost_system ; diff --git a/src/boost/libs/system/index.html b/src/boost/libs/system/index.html new file mode 100644 index 00000000..3f89f4f4 --- /dev/null +++ b/src/boost/libs/system/index.html @@ -0,0 +1,15 @@ +<html> +<head> +<meta http-equiv="refresh" content="0; URL=doc/html/system.html"> +</head> +<body> +Automatic redirection failed, please go to +<a href="doc/html/system.html">doc/html/system.html</a>. +</body> +</html> +<!-- + © Copyright Beman Dawes, 2001 + Distributed under the Boost Software License, Version 1.0. + See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt +--> diff --git a/src/boost/libs/system/meta/libraries.json b/src/boost/libs/system/meta/libraries.json new file mode 100644 index 00000000..90d12182 --- /dev/null +++ b/src/boost/libs/system/meta/libraries.json @@ -0,0 +1,11 @@ +{ + "key": "system", + "name": "System", + "authors": [ + "Beman Dawes" + ], + "description": "Operating system support, including the diagnostics support that will be part of the C++0x standard library.", + "category": [ + "System" + ] +} diff --git a/src/boost/libs/system/src/error_code.cpp b/src/boost/libs/system/src/error_code.cpp new file mode 100644 index 00000000..b86a38c5 --- /dev/null +++ b/src/boost/libs/system/src/error_code.cpp @@ -0,0 +1,31 @@ +// error_code stub implementation, for compatibility only + +// Copyright Beman Dawes 2002, 2006 +// Copyright Peter Dimov 2018 + +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/system + +//----------------------------------------------------------------------------// + +// define BOOST_SYSTEM_SOURCE so that <boost/system/config.hpp> knows +// the library is being built (possibly exporting rather than importing code) +#define BOOST_SYSTEM_SOURCE + +#include <boost/system/config.hpp> + +namespace boost +{ + +namespace system +{ + +BOOST_SYSTEM_DECL void dummy_exported_function() +{ +} + +} // namespace system + +} // namespace boost diff --git a/src/boost/libs/system/test/Jamfile.v2 b/src/boost/libs/system/test/Jamfile.v2 new file mode 100644 index 00000000..b428ca0c --- /dev/null +++ b/src/boost/libs/system/test/Jamfile.v2 @@ -0,0 +1,71 @@ +# Boost System Library test Jamfile + +# Copyright Beman Dawes 2003, 2006 +# Copyright 2017-2019 Peter Dimov + +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt + +# See library home page at http://www.boost.org/libs/system + +import testing ; + +rule system-run ( sources + ) +{ + local result ; + + result += [ run $(sources) ] ; + result += [ run $(sources) : : : <library>/boost/system//boost_system <link>static : $(sources[1]:B)_static ] ; + result += [ run $(sources) : : : <library>/boost/system//boost_system <link>shared : $(sources[1]:B)_shared ] ; + result += [ run $(sources) : : : <define>BOOST_NO_ANSI_APIS : $(sources[1]:B)_no_ansi ] ; + result += [ run $(sources) : : : <define>BOOST_SYSTEM_USE_UTF8 : $(sources[1]:B)_utf8 ] ; + + return $(result) ; +} + +system-run error_code_test.cpp ; +system-run error_code_user_test.cpp ; +system-run system_error_test.cpp ; + +lib throw_test : throw_test.cpp : <link>shared:<define>THROW_DYN_LINK=1 ; + +run dynamic_link_test.cpp throw_test : : : <link>shared : throw_test_shared ; + +system-run initialization_test.cpp ; +system-run header_only_test.cpp ; + +run config_test.cpp : : : <test-info>always_show_run_output ; + +system-run std_interop_test.cpp ; +system-run std_mismatch_test.cpp ; + +lib single_instance_lib1 : single_instance_1.cpp : <link>shared:<define>SINGLE_INSTANCE_DYN_LINK ; +lib single_instance_lib2 : single_instance_2.cpp : <link>shared:<define>SINGLE_INSTANCE_DYN_LINK ; + +system-run single_instance_test.cpp single_instance_1.cpp single_instance_2.cpp ; +run single_instance_test.cpp single_instance_lib1 single_instance_lib2 : : : <link>static : single_instance_lib_static ; +run single_instance_test.cpp single_instance_lib1 single_instance_lib2 : : : <link>shared : single_instance_lib_shared ; + +system-run before_main_test.cpp ; +run-fail throws_assign_fail.cpp ; +system-run constexpr_test.cpp ; +system-run win32_hresult_test.cpp ; + +system-run error_category_test.cpp ; +system-run generic_category_test.cpp ; +system-run system_category_test.cpp ; +system-run after_main_test.cpp ; +system-run failed_test.cpp ; +system-run failed_constexpr_test.cpp ; + +# Quick (CI) test +run quick.cpp ; + +run warnings_test.cpp : : : <warnings>all <warnings-as-errors>on <toolset>gcc:<cxxflags>-Wnon-virtual-dtor <toolset>clang:<cxxflags>-Wnon-virtual-dtor ; + +lib std_single_instance_lib1 : std_single_instance_1.cpp : <link>shared:<define>STD_SINGLE_INSTANCE_DYN_LINK ; +lib std_single_instance_lib2 : std_single_instance_2.cpp : <link>shared:<define>STD_SINGLE_INSTANCE_DYN_LINK ; + +system-run std_single_instance_test.cpp std_single_instance_1.cpp std_single_instance_2.cpp ; +run std_single_instance_test.cpp std_single_instance_lib1 std_single_instance_lib2 : : : <link>static : std_single_instance_lib_static ; +run std_single_instance_test.cpp std_single_instance_lib1 std_single_instance_lib2 : : : <link>shared <define>STD_SINGLE_INSTANCE_SHARED : std_single_instance_lib_shared ; diff --git a/src/boost/libs/system/test/after_main_test.cpp b/src/boost/libs/system/test/after_main_test.cpp new file mode 100644 index 00000000..520f807f --- /dev/null +++ b/src/boost/libs/system/test/after_main_test.cpp @@ -0,0 +1,30 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include <boost/system/error_code.hpp> +#include <boost/core/lightweight_test.hpp> +#include <boost/core/quick_exit.hpp> +#include <cerrno> + +using namespace boost::system; + +struct Z +{ + ~Z() + { + BOOST_TEST_CSTR_EQ( generic_category().name(), "generic" ); + BOOST_TEST_CSTR_EQ( system_category().name(), "system" ); + + boost::quick_exit( boost::report_errors() ); + } +}; + +static Z z; + +static error_code e1( 1, system_category() ); +static error_code e2( ENOENT, generic_category() ); + +int main() +{ +} diff --git a/src/boost/libs/system/test/before_main_test.cpp b/src/boost/libs/system/test/before_main_test.cpp new file mode 100644 index 00000000..3b38abce --- /dev/null +++ b/src/boost/libs/system/test/before_main_test.cpp @@ -0,0 +1,30 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include <boost/system/error_code.hpp> +#include <boost/core/lightweight_test.hpp> +#include <cerrno> + +using namespace boost::system; + +static error_code e1( 1, system_category() ); +static std::string m1 = e1.message(); + +static error_code e2( ENOENT, generic_category() ); +static std::string m2 = e2.message(); + +int main() +{ + error_code e1_( 1, system_category() ); + + BOOST_TEST_EQ( e1, e1_ ); + BOOST_TEST_EQ( m1, e1_.message() ); + + error_code e2_( ENOENT, generic_category() ); + + BOOST_TEST_EQ( e2, e2_ ); + BOOST_TEST_EQ( m2, e2_.message() ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/system/test/cmake_subdir_test/CMakeLists.txt b/src/boost/libs/system/test/cmake_subdir_test/CMakeLists.txt new file mode 100644 index 00000000..587e7c61 --- /dev/null +++ b/src/boost/libs/system/test/cmake_subdir_test/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright 2018, 2019 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt + +cmake_minimum_required(VERSION 3.5) + +project(cmake_subdir_test LANGUAGES CXX) + +add_subdirectory(../.. boostorg/system) +add_subdirectory(../../../assert boostorg/assert) +add_subdirectory(../../../config boostorg/config) +add_subdirectory(../../../core boostorg/core) +add_subdirectory(../../../predef boostorg/predef) +add_subdirectory(../../../winapi boostorg/winapi) + +add_executable(quick ../quick.cpp) +target_link_libraries(quick Boost::system Boost::core) + +enable_testing() +add_test(quick quick) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>) diff --git a/src/boost/libs/system/test/config_test.cpp b/src/boost/libs/system/test/config_test.cpp new file mode 100644 index 00000000..eef8ab4e --- /dev/null +++ b/src/boost/libs/system/test/config_test.cpp @@ -0,0 +1,65 @@ +// error_code_test.cpp ---------------------------------------------------------------// + +// Copyright Beman Dawes 2014 + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +// See library home page at http://www.boost.org/libs/system + +#include <boost/system/config.hpp> +#include <iostream> + +using std::cout; +using std::endl; + +int main() +{ +#ifdef BOOST_WINDOWS_API + std::cout << "BOOST_WINDOWS_API is defined" << std::endl; +#else + std::cout << "BOOST_WINDOWS_API is not defined" << std::endl; +#endif +#ifdef _MSC_VER + std::cout << "_MSC_VER is defined as " << _MSC_VER << std::endl; +#else + std::cout << "_MSC_VER is not defined" << std::endl; +#endif +#ifdef __CYGWIN__ + std::cout << "__CYGWIN__ is defined" << std::endl; +#else + std::cout << "__CYGWIN__ is not defined" << std::endl; +#endif +#ifdef __MINGW32__ + std::cout << "__MINGW32__ is defined" << std::endl; +#else + std::cout << "__MINGW32__ is not defined" << std::endl; +#endif +#ifdef BOOST_POSIX_API + std::cout << "BOOST_POSIX_API is defined" << std::endl; +#else + std::cout << "BOOST_POSIX_API is not defined" << std::endl; +#endif +#ifdef BOOST_PLAT_WINDOWS_DESKTOP + std::cout << "BOOST_PLAT_WINDOWS_DESKTOP is defined as " + << BOOST_PLAT_WINDOWS_DESKTOP << std::endl; +#else + std::cout << "BOOST_PLAT_WINDOWS_DESKTOP is not defined" << std::endl; +#endif +#ifdef BOOST_NO_ANSI_APIS + std::cout << "BOOST_NO_ANSI_APIS is defined" << std::endl; +#else + std::cout << "BOOST_NO_ANSI_APIS is not defined" << std::endl; +#endif +#ifdef BOOST_NO_CXX11_NOEXCEPT + std::cout << "BOOST_NO_CXX11_NOEXCEPT is defined" << std::endl; +#else + std::cout << "BOOST_NO_CXX11_NOEXCEPT is not defined" << std::endl; +#endif +#ifdef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS + std::cout << "BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS is defined" << std::endl; +#else + std::cout << "BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS is not defined" << std::endl; +#endif + return 0; +} diff --git a/src/boost/libs/system/test/constexpr_test.cpp b/src/boost/libs/system/test/constexpr_test.cpp new file mode 100644 index 00000000..cbc9d53b --- /dev/null +++ b/src/boost/libs/system/test/constexpr_test.cpp @@ -0,0 +1,68 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include <boost/system/error_code.hpp> +#include <boost/core/lightweight_test.hpp> +#include <boost/config/pragma_message.hpp> +#include <boost/static_assert.hpp> +#include <boost/config.hpp> +#include <boost/config/workaround.hpp> + +#if !defined(BOOST_SYSTEM_HAS_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Skipping constexpr test, BOOST_SYSTEM_HAS_CONSTEXPR isn't defined") +int main() {} + +#else + +using namespace boost::system; + +constexpr error_code e1( 1, system_category() ); + +BOOST_STATIC_ASSERT( e1.value() == 1 ); +BOOST_STATIC_ASSERT( e1.category() == system_category() ); +BOOST_STATIC_ASSERT( e1 ); +BOOST_STATIC_ASSERT( e1 == e1 ); + +constexpr error_code e2( 2, generic_category() ); + +BOOST_STATIC_ASSERT( e2.value() == 2 ); +BOOST_STATIC_ASSERT( e2.category() == generic_category() ); +BOOST_STATIC_ASSERT( e2 ); +BOOST_STATIC_ASSERT( e2 == e2 ); + +#if !BOOST_WORKAROUND(BOOST_GCC, < 80200) + +BOOST_STATIC_ASSERT( e1 != e2 ); + +#endif + +constexpr error_code e3; + +BOOST_STATIC_ASSERT( e3.value() == 0 ); +BOOST_STATIC_ASSERT( e3.category() == system_category() ); +BOOST_STATIC_ASSERT( !e3 ); +BOOST_STATIC_ASSERT( e3 == e3 ); + +#if !BOOST_WORKAROUND(BOOST_GCC, < 80200) + +BOOST_STATIC_ASSERT( e1 != e3 ); + +#endif + +int main() +{ + error_code e1_( 1, system_category() ); + BOOST_TEST_EQ( e1, e1_ ); + + error_code e2_( 2, generic_category() ); + BOOST_TEST_EQ( e2, e2_ ); + + error_code e3_; + BOOST_TEST_EQ( e3, e3_ ); + + return boost::report_errors(); +} + +#endif diff --git a/src/boost/libs/system/test/dynamic_link_test.cpp b/src/boost/libs/system/test/dynamic_link_test.cpp new file mode 100644 index 00000000..8826f83a --- /dev/null +++ b/src/boost/libs/system/test/dynamic_link_test.cpp @@ -0,0 +1,47 @@ +// dynamic_link_test.cpp -------------------------------------------------------------// + +// Copyright Beman Dawes 2010 + +// Distributed under the Boost Software License, Version 1.0. +// See www.boost.org/LICENSE_1_0.txt + +// Library home page is www.boost.org/libs/system + +//--------------------------------------------------------------------------------------// + +// Dynamic link libraries (DLL's), also know as dynamic shared objects (DSO's), +// can cause symbol visability problems unless carefully configured. One of the +// manifestations, particularly with GCC, is that a system_error exception thrown from +// a DLL or DSO is not caught. +// +// The purpose of this program is to test for that error. + +//--------------------------------------------------------------------------------------// + +#include <boost/system/system_error.hpp> +#include <iostream> + +void throw_test(); + +int main() +{ + try + { + throw_test(); + } + catch (const boost::system::system_error& ex) + { + std::cout << " caught boost::system::system_error as expected\n"; + std::cout << " what() reports " << ex.what() << '\n'; + return 0; + } + catch (const std::runtime_error& ex) + { + std::cout << " error: caught std::runtime_error instead of boost::system::system_error\n"; + std::cout << " what() reports " << ex.what() << '\n'; + return 1; + } + + std::cout << " error: failed to catch boost::system::system_error\n"; + return 1; +} diff --git a/src/boost/libs/system/test/error_category_test.cpp b/src/boost/libs/system/test/error_category_test.cpp new file mode 100644 index 00000000..a403fc3d --- /dev/null +++ b/src/boost/libs/system/test/error_category_test.cpp @@ -0,0 +1,82 @@ + +// Copyright 2018 Peter Dimov. +// +// Distributed under the Boost Software License, Version 1.0. +// +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + +// See library home page at http://www.boost.org/libs/system + +// Avoid spurious VC++ warnings +# define _CRT_SECURE_NO_WARNINGS + +#include <boost/system/error_code.hpp> +#include <boost/core/lightweight_test.hpp> +#include <cstdio> + +// + +namespace sys = boost::system; + +class user_category: public sys::error_category +{ +public: + + virtual const char * name() const BOOST_NOEXCEPT + { + return "user"; + } + + virtual std::string message( int ev ) const + { + char buffer[ 256 ]; + std::sprintf( buffer, "user message %d", ev ); + + return buffer; + } + + using sys::error_category::message; +}; + +static user_category s_cat_1; +static user_category s_cat_2; + +int main() +{ + // default_error_condition + + BOOST_TEST( s_cat_1.default_error_condition( 1 ) == sys::error_condition( 1, s_cat_1 ) ); + BOOST_TEST( s_cat_2.default_error_condition( 2 ) == sys::error_condition( 2, s_cat_2 ) ); + + // equivalent + + BOOST_TEST( s_cat_1.equivalent( 1, sys::error_condition( 1, s_cat_1 ) ) ); + BOOST_TEST( !s_cat_1.equivalent( 1, sys::error_condition( 2, s_cat_1 ) ) ); + BOOST_TEST( !s_cat_1.equivalent( 1, sys::error_condition( 2, s_cat_2 ) ) ); + + // the other equivalent + + BOOST_TEST( s_cat_1.equivalent( sys::error_code( 1, s_cat_1 ), 1 ) ); + BOOST_TEST( !s_cat_1.equivalent( sys::error_code( 1, s_cat_1 ), 2 ) ); + BOOST_TEST( !s_cat_1.equivalent( sys::error_code( 1, s_cat_2 ), 1 ) ); + + // message + + { + char buffer[ 256 ]; + BOOST_TEST_CSTR_EQ( s_cat_1.message( 1, buffer, sizeof( buffer ) ), s_cat_1.message( 1 ).c_str() ); + } + + { + char buffer[ 4 ]; + BOOST_TEST_CSTR_EQ( s_cat_1.message( 1, buffer, sizeof( buffer ) ), "use" ); + } + + // == + + BOOST_TEST_NOT( s_cat_1 == s_cat_2 ); + BOOST_TEST( s_cat_1 != s_cat_2 ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/system/test/error_code_test.cpp b/src/boost/libs/system/test/error_code_test.cpp new file mode 100644 index 00000000..e77e8cef --- /dev/null +++ b/src/boost/libs/system/test/error_code_test.cpp @@ -0,0 +1,322 @@ +// error_code_test.cpp -----------------------------------------------------// + +// Copyright Beman Dawes 2006 + +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/system + +//----------------------------------------------------------------------------// + +#include <boost/config/warning_disable.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/system/error_code.hpp> +#include <boost/system/cygwin_error.hpp> +#include <boost/system/linux_error.hpp> +#include <boost/system/windows_error.hpp> +#include <iostream> +#include <sstream> +#include <string> +#include <cstring> +#include <functional> +#include <boost/cerrno.hpp> + +// Although using directives are not the best programming practice, testing +// with a boost::system using directive increases use scenario coverage. +using namespace boost::system; + +#if defined( BOOST_WINDOWS_API ) +// Neither MinGW or Cygwin versions of winerror.h work if used alone, so on +// either of those platforms include the full windows.h +# if defined(__MINGW32__) || defined(__CYGWIN__) +# include <windows.h> +# else +# include <winerror.h> +# endif +# define BOOST_ACCESS_ERROR_MACRO ERROR_ACCESS_DENIED +#elif defined( BOOST_POSIX_API ) +# define BOOST_ACCESS_ERROR_MACRO EACCES +#else +# error "Only supported for POSIX and Windows" +#endif + +namespace +{ + void check_ostream( error_code ec, const char * expected ) + { + std::stringstream ss; + std::string s; + + ss << ec; + ss >> s; + BOOST_TEST( s == expected ); + } + + // throws_function_test ------------------------------------------------------------// + + // usage example + + int divide(int dividend, int divisor, boost::system::error_code& ec = boost::throws()) + { + if (divisor == 0) // is there an error? + { + if (&ec == &boost::throws()) // throw on error + throw "oops!"; // whatever exception you prefer + ec = error_code(EDOM, generic_category()); // report error via error_code + return 0; + } + + if (&ec != &boost::throws()) // error reporting via error_code + ec.clear(); + return dividend / divisor; + } + + // test usage example + + void test_throws_usage() + { + std::cout << "Test throws() example and usage...\n"; + error_code ec; + + // no error tests + BOOST_TEST_EQ((divide(10, 2)), 5); // no error, report via exception + ec = make_error_code(errc::argument_out_of_domain); + BOOST_TEST_EQ((divide(10, 5, ec)), 2); // no error, report via error_code + BOOST_TEST(!ec); + + ec = make_error_code(errc::argument_out_of_domain); + BOOST_TEST_EQ((divide(10, 0, ec)), 0); // error, report via error_code + BOOST_TEST(ec); + + bool exception_thrown = false; + try + { divide(10, 0); } // error, report via exception + catch (...) + { exception_thrown = true; } + BOOST_TEST(exception_thrown); + + //error_code should_fail(boost::throws()); // should fail at runtime + //boost::throws() = ec; // should fail at runtime + } +} + +// main ------------------------------------------------------------------------------// + +// TODO: add hash_value tests + +int main( int, char ** ) +{ + + std::cout << "Conversion use cases...\n"; + error_condition x1( errc::file_exists ); + //error_code x2( errc::file_exists ); // should fail to compile + make_error_code(errc::file_exists); + make_error_condition(errc::file_exists); + + std::cout << "General tests...\n"; + // unit tests: + + BOOST_TEST( generic_category() == generic_category() ); + BOOST_TEST( system_category() == system_category() ); + BOOST_TEST( generic_category() != system_category() ); + BOOST_TEST( system_category() != generic_category() ); + + BOOST_TEST_NE( generic_category() < system_category(), system_category() < generic_category() ); + + error_code ec; + error_condition econd; + BOOST_TEST( !ec ); + BOOST_TEST( ec.value() == 0 ); + econd = ec.default_error_condition(); + BOOST_TEST( econd.value() == 0 ); + BOOST_TEST( econd.category() == generic_category() ); + BOOST_TEST( ec == errc::success ); + BOOST_TEST( ec.category() == system_category() ); + BOOST_TEST( std::strcmp( ec.category().name(), "system") == 0 ); + BOOST_TEST( !(ec < error_code( 0, system_category() )) ); + BOOST_TEST( !(error_code( 0, system_category() ) < ec) ); + BOOST_TEST( ec < error_code( 1, system_category() ) ); + BOOST_TEST( !(error_code( 1, system_category() ) < ec) ); + + error_code ec_0_system( 0, system_category() ); + BOOST_TEST( !ec_0_system ); + BOOST_TEST( ec_0_system.value() == 0 ); + econd = ec_0_system.default_error_condition(); + BOOST_TEST( econd.value() == 0 ); + BOOST_TEST( econd.category() == generic_category() ); + BOOST_TEST( ec_0_system == errc::success ); + BOOST_TEST( ec_0_system.category() == system_category() ); + BOOST_TEST( std::strcmp( ec_0_system.category().name(), "system") == 0 ); + check_ostream( ec_0_system, "system:0" ); + + BOOST_TEST( ec_0_system == ec ); + + error_code ec_1_system( 1, system_category() ); + BOOST_TEST( ec_1_system ); + BOOST_TEST( ec_1_system.value() == 1 ); + BOOST_TEST( ec_1_system.value() != 0 ); + BOOST_TEST( ec != ec_1_system ); + BOOST_TEST( ec_0_system != ec_1_system ); + check_ostream( ec_1_system, "system:1" ); + + ec = error_code( BOOST_ACCESS_ERROR_MACRO, system_category() ); + BOOST_TEST( ec ); + BOOST_TEST( ec.value() == BOOST_ACCESS_ERROR_MACRO ); + econd = ec.default_error_condition(); + BOOST_TEST( econd.value() == static_cast<int>(errc::permission_denied) ); + BOOST_TEST( econd.category() == generic_category() ); + BOOST_TEST( econd == error_condition( errc::permission_denied, generic_category() ) ); + BOOST_TEST( econd == errc::permission_denied ); + BOOST_TEST( errc::permission_denied == econd ); + BOOST_TEST( ec == errc::permission_denied ); + BOOST_TEST( ec.category() == system_category() ); + BOOST_TEST( std::strcmp( ec.category().name(), "system") == 0 ); + + // test the explicit make_error_code conversion for errc + ec = make_error_code( errc::bad_message ); + BOOST_TEST( ec ); + BOOST_TEST( ec == errc::bad_message ); + BOOST_TEST( errc::bad_message == ec ); + BOOST_TEST( ec != errc::permission_denied ); + BOOST_TEST( errc::permission_denied != ec ); + BOOST_TEST( ec.category() == generic_category() ); + + //// test the deprecated predefined error_category synonyms + //BOOST_TEST( &system_category() == &native_ecat ); + //BOOST_TEST( &generic_category() == &errno_ecat ); + //BOOST_TEST( system_category() == native_ecat ); + //BOOST_TEST( generic_category() == errno_ecat ); + + // test error_code and error_condition message(); + // see Boost.Filesystem operations_test for code specific message() tests + ec = error_code( -1, system_category() ); + std::cout << "error_code message for -1 is \"" << ec.message() << "\"\n"; + std::cout << "error_code message for 0 is \"" << ec_0_system.message() << "\"\n"; +#if defined(BOOST_WINDOWS_API) + // Borland appends newline, so just check text + BOOST_TEST( ec.message().substr(0,13) == "Unknown error" ); + // Fails when the language isn't US English + // BOOST_TEST( ec_0_system.message().substr(0,36) == "The operation completed successfully" ); +#elif defined(linux) || defined(__linux) || defined(__linux__) + // Linux appends value to message as unsigned, so it varies with # of bits + BOOST_TEST( ec.message().substr(0,13) == "Unknown error" ); +#elif defined(__hpux) + BOOST_TEST( ec.message() == "" ); +#elif defined(__osf__) + BOOST_TEST( ec.message() == "Error -1 occurred." ); +#elif defined(__vms) + BOOST_TEST( ec.message() == "error -1" ); +#endif + + ec = error_code( BOOST_ACCESS_ERROR_MACRO, system_category() ); + BOOST_TEST( ec.message() != "" ); + BOOST_TEST( ec.message().substr( 0, 13) != "Unknown error" ); + + econd = error_condition( -1, generic_category() ); + error_condition econd_ok; + std::cout << "error_condition message for -1 is \"" << econd.message() << "\"\n"; + std::cout << "error_condition message for 0 is \"" << econd_ok.message() << "\"\n"; +#if defined(BOOST_WINDOWS_API) + // Borland appends newline, so just check text + BOOST_TEST( econd.message().substr(0,13) == "Unknown error" ); + BOOST_TEST( econd_ok.message().substr(0,8) == "No error" ); +#elif defined(linux) || defined(__linux) || defined(__linux__) + // Linux appends value to message as unsigned, so it varies with # of bits + BOOST_TEST( econd.message().substr(0,13) == "Unknown error" ); +#elif defined(__hpux) + BOOST_TEST( econd.message() == "" ); +#elif defined(__osf__) + BOOST_TEST( econd.message() == "Error -1 occurred." ); +#elif defined(__vms) + BOOST_TEST( econd.message() == "error -1" ); +#endif + + econd = error_condition( BOOST_ACCESS_ERROR_MACRO, generic_category() ); + BOOST_TEST( econd.message() != "" ); + BOOST_TEST( econd.message().substr( 0, 13) != "Unknown error" ); + + test_throws_usage(); + +#ifdef BOOST_WINDOWS_API + std::cout << "Windows tests...\n"; + // these tests probe the Windows errc decoder + // test the first entry in the decoder table: + ec = error_code( ERROR_ACCESS_DENIED, system_category() ); + BOOST_TEST( ec.value() == ERROR_ACCESS_DENIED ); + BOOST_TEST( ec == errc::permission_denied ); + BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied ); + BOOST_TEST( ec.default_error_condition().category() == generic_category() ); + + // test the second entry in the decoder table: + ec = error_code( ERROR_ALREADY_EXISTS, system_category() ); + BOOST_TEST( ec.value() == ERROR_ALREADY_EXISTS ); + BOOST_TEST( ec == errc::file_exists ); + BOOST_TEST( ec.default_error_condition().value() == errc::file_exists ); + BOOST_TEST( ec.default_error_condition().category() == generic_category() ); + + // test the third entry in the decoder table: + ec = error_code( ERROR_BAD_UNIT, system_category() ); + BOOST_TEST( ec.value() == ERROR_BAD_UNIT ); + BOOST_TEST( ec == errc::no_such_device ); + BOOST_TEST( ec.default_error_condition().value() == errc::no_such_device ); + BOOST_TEST( ec.default_error_condition().category() == generic_category() ); + + // test the last non-Winsock entry in the decoder table: + ec = error_code( ERROR_WRITE_PROTECT, system_category() ); + BOOST_TEST( ec.value() == ERROR_WRITE_PROTECT ); + BOOST_TEST( ec == errc::permission_denied ); + BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied ); + BOOST_TEST( ec.default_error_condition().category() == generic_category() ); + + // test the last Winsock entry in the decoder table: + ec = error_code( WSAEWOULDBLOCK, system_category() ); + BOOST_TEST( ec.value() == WSAEWOULDBLOCK ); + BOOST_TEST( ec == errc::operation_would_block ); + BOOST_TEST( ec.default_error_condition().value() == errc::operation_would_block ); + BOOST_TEST( ec.default_error_condition().category() == generic_category() ); + + // test not-in-table condition: + ec = error_code( 1234567890, system_category() ); + BOOST_TEST( ec.value() == 1234567890 ); + BOOST_TEST( ec.default_error_condition().value() == 1234567890 ); + BOOST_TEST( ec.default_error_condition().category() == system_category() ); + +#else // POSIX + + std::cout << "POSIX tests...\n"; + ec = error_code( EACCES, system_category() ); + BOOST_TEST( ec == error_code( errc::permission_denied, system_category() ) ); + BOOST_TEST( error_code( errc::permission_denied, system_category() ) == ec ); + BOOST_TEST( ec == errc::permission_denied ); + BOOST_TEST( errc::permission_denied == ec ); + BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied ); + 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 + + return ::boost::report_errors(); +} + + diff --git a/src/boost/libs/system/test/error_code_user_test.cpp b/src/boost/libs/system/test/error_code_user_test.cpp new file mode 100644 index 00000000..e9e5845f --- /dev/null +++ b/src/boost/libs/system/test/error_code_user_test.cpp @@ -0,0 +1,402 @@ +// error_code_user_test.cpp ------------------------------------------------// + +// Copyright Beman Dawes 2006 + +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/system + +// ------------------------------------------------------------------------ // + +// This program demonstrates creation and use of new categories of error +// codes. Several scenarios are demonstrated and tested. + +// Motivation was a Boost posting by Christopher Kohlhoff on June 28, 2006. + +#include <boost/system/error_code.hpp> +#include <boost/cerrno.hpp> +#include <string> +#include <cstdio> +#include <boost/detail/lightweight_test.hpp> + +#ifdef BOOST_POSIX_API +# include <sys/stat.h> +#else +# include <windows.h> +#endif + +// ------------------------------------------------------------------------ // + +// Library 1: User function passes through an error code from the +// operating system. + + +boost::system::error_code my_mkdir( const std::string & path ) +{ + return boost::system::error_code( +# ifdef BOOST_POSIX_API + ::mkdir( path.c_str(), S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH ) == 0 ? 0 : errno, +# else + ::CreateDirectoryA( path.c_str(), 0 ) != 0 ? 0 : ::GetLastError(), +# endif + boost::system::system_category() ); +} + +// ------------------------------------------------------------------------ // + +// Library 2: User function passes through errno from the C-runtime. + +#include <cstdio> + +boost::system::error_code my_remove( const std::string & path ) +{ + return boost::system::error_code( + std::remove( path.c_str() ) == 0 ? 0 : errno, + boost::system::generic_category() ); // OK for both Windows and POSIX + // Alternatively, could use generic_category() + // on Windows and system_category() on + // POSIX-based systems. +} + +// ------------------------------------------------------------------------ // + +// Library 3: Library uses enum to identify library specific errors. + +// This particular example is for a library within the parent namespace. For +// an example of a library not within the parent namespace, see library 4. + +// header lib3.hpp: + +namespace boost +{ + namespace lib3 + { + // lib3 has its own error_category: + const boost::system::error_category & get_lib3_error_category() BOOST_SYSTEM_NOEXCEPT; + const boost::system::error_category & lib3_error_category = get_lib3_error_category(); + + enum error + { + boo_boo=123, + big_boo_boo + }; + } + + namespace system + { + template<> struct is_error_code_enum<boost::lib3::error> + { static const bool value = true; }; + } + + namespace lib3 + { + inline boost::system::error_code make_error_code(error e) + { return boost::system::error_code(e,lib3_error_category); } + } + +} + +// implementation file lib3.cpp: + +// #include <lib3.hpp> + +namespace boost +{ + namespace lib3 + { + class lib3_error_category_imp : public boost::system::error_category + { + public: + lib3_error_category_imp() : boost::system::error_category() { } + + const char * name() const BOOST_SYSTEM_NOEXCEPT + { + return "lib3"; + } + + boost::system::error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT + { + return ev == boo_boo + ? boost::system::error_condition( boost::system::errc::io_error, + boost::system::generic_category() ) + : boost::system::error_condition( ev, + boost::lib3::lib3_error_category ); + } + + std::string message( int ev ) const + { + if ( ev == boo_boo ) return std::string("boo boo"); + if ( ev == big_boo_boo ) return std::string("big boo boo"); + return std::string("unknown error"); + } + + }; + + const boost::system::error_category & get_lib3_error_category() BOOST_SYSTEM_NOEXCEPT + { + static const lib3_error_category_imp l3ecat; + return l3ecat; + } + } +} + +// ------------------------------------------------------------------------ // + +// Library 4: Library uses const error_code's to identify library specific +// errors. + +// This particular example is for a library not within the parent namespace. +// For an example of a library within the parent namespace, see library 3. + +// header lib4.hpp: + +namespace lib4 +{ + // lib4 has its own error_category: + const boost::system::error_category & get_lib4_error_category() BOOST_SYSTEM_NOEXCEPT; + const boost::system::error_category & lib4_error_category = get_lib4_error_category(); + + extern const boost::system::error_code boo_boo; + extern const boost::system::error_code big_boo_boo; +} + +// implementation file lib4.cpp: + +// #include <lib4.hpp> + +namespace lib4 +{ + class lib4_error_category_imp : public boost::system::error_category + { + public: + lib4_error_category_imp() : boost::system::error_category() { } + + const char * name() const BOOST_SYSTEM_NOEXCEPT + { + return "lib4"; + } + + boost::system::error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT + { + return ev == boo_boo.value() + ? boost::system::error_condition( boost::system::errc::io_error, + boost::system::generic_category() ) + : boost::system::error_condition( ev, lib4::lib4_error_category ); + } + + std::string message( int ev ) const + { + if ( ev == boo_boo.value() ) return std::string("boo boo"); + if ( ev == big_boo_boo.value() ) return std::string("big boo boo"); + return std::string("unknown error"); + } + }; + + const boost::system::error_category & get_lib4_error_category() BOOST_SYSTEM_NOEXCEPT + { + static const lib4_error_category_imp l4ecat; + return l4ecat; + } + + const boost::system::error_code boo_boo( 456, lib4_error_category ); + const boost::system::error_code big_boo_boo( 789, lib4_error_category ); + +} + +// ------------------------------------------------------------------------ // + +// Chris Kolhoff's Test3, modified to work with error_code.hpp + +// Test3 +// ===== +// Define error classes to check for success, permission_denied and +// out_of_memory, but add additional mappings for a user-defined error category. +// + +//namespace test3 { + +// enum user_err +// { +// user_success = 0, +// user_permission_denied, +// user_out_of_memory +// }; +// +// class user_error_category_imp : public boost::system::error_category +// { +// public: +// const std::string & name() const +// { +// static std::string s( "test3" ); +// return s; +// } +// +// boost::system::error_code portable_error_code( int ev ) const +// { +// switch (ev) +// { +// case user_success: +// return boost::system::error_code(boost::system::errc::success, boost::system::generic_category()); +// case user_permission_denied: +// return boost::system::error_code(boost::system::errc::permission_denied, boost::system::generic_category()); +// case user_out_of_memory: +// return boost::system::error_code(boost::system::errc::not_enough_memory, boost::system::generic_category()); +// default: +// break; +// } +// return boost::system::error_code(boost::system::errc::no_posix_equivalent, boost::system::generic_category()); +// } +// +// }; +// +// const user_error_category_imp user_error_category_const; +// +// const boost::system::error_category & user_error_category +// = user_error_category_const; +// +// template<> inline boost::system::error_code make_error_code(user_err e) +// { +// return boost::system::error_code(e, user_error_category); +// } +// +// // test code +// +// void check_success(const boost::system::error_code& ec, bool expect) +// { +// BOOST_TEST( (ec == boost::system::errc::success) == expect ); +// if (ec == boost::system::errc::success) +// std::cout << "yes... " << (expect ? "ok" : "fail") << '\n'; +// else +// std::cout << "no... " << (expect ? "fail" : "ok") << '\n'; +// } +// +// void check_permission_denied(const boost::system::error_code& ec, bool expect) +// { +// BOOST_TEST( (ec == boost::system::errc::permission_denied) == expect ); +// if (ec == boost::system::errc::permission_denied) +// std::cout << "yes... " << (expect ? "ok" : "fail") << '\n'; +// else +// std::cout << "no... " << (expect ? "fail" : "ok") << '\n'; +// } +// +// void check_out_of_memory(const boost::system::error_code& ec, bool expect) +// { +// BOOST_TEST( (ec == boost::system::errc::not_enough_memory) == expect ); +// if (ec == boost::system::errc::not_enough_memory) +// std::cout << "yes... " << (expect ? "ok" : "fail") << '\n'; +// else +// std::cout << "no... " << (expect ? "fail" : "ok") << '\n'; +// } +// +// void run() +// { +// printf("Test3\n"); +// printf("=====\n"); +// boost::system::error_code ec; +// check_success(ec, true); +// check_success(boost::system::errc::success, true); +// check_success(boost::system::errc::permission_denied, false); +// check_success(boost::system::errc::not_enough_memory, false); +// check_success(user_success, true); +// check_success(user_permission_denied, false); +// check_success(user_out_of_memory, false); +// check_permission_denied(ec, false); +// check_permission_denied(boost::system::errc::success, false); +// check_permission_denied(boost::system::errc::permission_denied, true); +// check_permission_denied(boost::system::errc::not_enough_memory, false); +// check_permission_denied(user_success, false); +// check_permission_denied(user_permission_denied, true); +// check_permission_denied(user_out_of_memory, false); +// check_out_of_memory(ec, false); +// check_out_of_memory(boost::system::errc::success, false); +// check_out_of_memory(boost::system::errc::permission_denied, false); +// check_out_of_memory(boost::system::errc::not_enough_memory, true); +// check_out_of_memory(user_success, false); +// check_out_of_memory(user_permission_denied, false); +// check_out_of_memory(user_out_of_memory, true); +// +//# ifdef BOOST_WINDOWS_API +// check_success(boost::system::windows::success, true); +// check_success(boost::system::windows::access_denied, false); +// check_success(boost::system::windows::not_enough_memory, false); +// check_permission_denied(boost::system::windows::success, false); +// check_permission_denied(boost::system::windows::access_denied, true); +// check_permission_denied(boost::system::windows::not_enough_memory, false); +// check_out_of_memory(boost::system::windows::success, false); +// check_out_of_memory(boost::system::windows::access_denied, false); +// check_out_of_memory(boost::system::windows::not_enough_memory, true); +//# endif +// +// printf("\n"); +// } +// +//} // namespace test3 + + + +// ------------------------------------------------------------------------ // + +int main( int, char *[] ) +{ + boost::system::error_code ec; + + // Library 1 tests: + + ec = my_mkdir( "/no-such-file-or-directory/will-not-succeed" ); + std::cout << "ec.value() is " << ec.value() << '\n'; + + BOOST_TEST( ec ); + BOOST_TEST( ec == boost::system::errc::no_such_file_or_directory ); + BOOST_TEST( ec.category() == boost::system::system_category() ); + + // Library 2 tests: + + ec = my_remove( "/no-such-file-or-directory" ); + std::cout << "ec.value() is " << ec.value() << '\n'; + + BOOST_TEST( ec ); + BOOST_TEST( ec == boost::system::errc::no_such_file_or_directory ); + BOOST_TEST( ec.category() == boost::system::generic_category() ); + + // Library 3 tests: + + ec = boost::lib3::boo_boo; + std::cout << "ec.value() is " << ec.value() << '\n'; + + BOOST_TEST( ec ); + BOOST_TEST( ec == boost::lib3::boo_boo ); + BOOST_TEST( ec.value() == boost::lib3::boo_boo ); + BOOST_TEST( ec.category() == boost::lib3::lib3_error_category ); + + BOOST_TEST( ec == boost::system::errc::io_error ); + + boost::system::error_code ec3( boost::lib3::boo_boo+100, + boost::lib3::lib3_error_category ); + BOOST_TEST( ec3.category() == boost::lib3::lib3_error_category ); + BOOST_TEST( ec3.default_error_condition().category() + == boost::lib3::lib3_error_category ); + + // Library 4 tests: + + ec = lib4::boo_boo; + std::cout << "ec.value() is " << ec.value() << '\n'; + + BOOST_TEST( ec ); + BOOST_TEST( ec == lib4::boo_boo ); + BOOST_TEST( ec.value() == lib4::boo_boo.value() ); + BOOST_TEST( ec.category() == lib4::lib4_error_category ); + + BOOST_TEST( ec == boost::system::errc::io_error ); + + boost::system::error_code ec4( lib4::boo_boo.value()+100, + lib4::lib4_error_category ); + BOOST_TEST( ec4.default_error_condition().category() + == lib4::lib4_error_category ); + + // Test 3 + + //test3::run(); + + return ::boost::report_errors(); +} diff --git a/src/boost/libs/system/test/failed_constexpr_test.cpp b/src/boost/libs/system/test/failed_constexpr_test.cpp new file mode 100644 index 00000000..e9ccab5e --- /dev/null +++ b/src/boost/libs/system/test/failed_constexpr_test.cpp @@ -0,0 +1,58 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include <boost/system/error_code.hpp> +#include <boost/config/pragma_message.hpp> +#include <boost/static_assert.hpp> + +#if !defined(BOOST_SYSTEM_HAS_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Skipping constexpr test, BOOST_SYSTEM_HAS_CONSTEXPR isn't defined") +int main() {} + +#else + +using namespace boost::system; + +constexpr error_code ec1( 1, system_category() ); + +BOOST_STATIC_ASSERT( ec1.failed() ); +BOOST_STATIC_ASSERT( ec1 ); +BOOST_STATIC_ASSERT( !!ec1 ); + +constexpr error_code ec2( 2, generic_category() ); + +BOOST_STATIC_ASSERT( ec2.failed() ); +BOOST_STATIC_ASSERT( ec2 ); +BOOST_STATIC_ASSERT( !!ec2 ); + +constexpr error_code ec3; + +BOOST_STATIC_ASSERT( !ec3.failed() ); +BOOST_STATIC_ASSERT( ec3? false: true ); +BOOST_STATIC_ASSERT( !ec3 ); + +constexpr error_condition en1( 1, system_category() ); + +BOOST_STATIC_ASSERT( en1.failed() ); +BOOST_STATIC_ASSERT( en1 ); +BOOST_STATIC_ASSERT( !!en1 ); + +constexpr error_condition en2( 2, generic_category() ); + +BOOST_STATIC_ASSERT( en2.failed() ); +BOOST_STATIC_ASSERT( en2 ); +BOOST_STATIC_ASSERT( !!en2 ); + +constexpr error_condition en3; + +BOOST_STATIC_ASSERT( !en3.failed() ); +BOOST_STATIC_ASSERT( en3? false: true ); +BOOST_STATIC_ASSERT( !en3 ); + +int main() +{ +} + +#endif diff --git a/src/boost/libs/system/test/failed_test.cpp b/src/boost/libs/system/test/failed_test.cpp new file mode 100644 index 00000000..142d6ef8 --- /dev/null +++ b/src/boost/libs/system/test/failed_test.cpp @@ -0,0 +1,185 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +// Avoid spurious VC++ warnings +#define _CRT_SECURE_NO_WARNINGS + +#include <boost/system/error_code.hpp> +#include <boost/core/lightweight_test.hpp> +#include <cstdio> + +using namespace boost::system; + +struct http_category_impl: public error_category +{ + // clang++ 3.8 and below: initialization of const object + // requires a user-provided default constructor + BOOST_SYSTEM_CONSTEXPR http_category_impl() BOOST_NOEXCEPT + { + } + + char const * name() const BOOST_NOEXCEPT + { + return "http"; + } + + std::string message( int ev ) const + { + char buffer[ 32 ]; + + std::sprintf( buffer, "HTTP/1.0 %d", ev ); + return buffer; + } + + bool failed( int ev ) const BOOST_NOEXCEPT + { + return !( ev >= 200 && ev < 300 ); + } +}; + +error_category const & http_category() +{ + static const http_category_impl instance; + return instance; +} + +#define TEST_NOT_FAILED(ec) BOOST_TEST( !ec.failed() ); BOOST_TEST( ec? false: true ); BOOST_TEST( !ec ); +#define TEST_FAILED(ec) BOOST_TEST( ec.failed() ); BOOST_TEST( ec ); BOOST_TEST( !!ec ); + +template<class Ec> void test() +{ + { + Ec ec; + TEST_NOT_FAILED( ec ); + + ec.assign( 1, generic_category() ); + TEST_FAILED( ec ); + + ec.clear(); + TEST_NOT_FAILED( ec ); + + ec = Ec( 1, generic_category() ); + TEST_FAILED( ec ); + + ec = Ec(); + TEST_NOT_FAILED( ec ); + } + + { + Ec ec; + TEST_NOT_FAILED( ec ); + + ec.assign( 1, system_category() ); + TEST_FAILED( ec ); + + ec.clear(); + TEST_NOT_FAILED( ec ); + + ec = Ec( 1, system_category() ); + TEST_FAILED( ec ); + + ec = Ec(); + TEST_NOT_FAILED( ec ); + } + + { + Ec ec( 0, generic_category() ); + TEST_NOT_FAILED( ec ); + + ec.assign( 1, system_category() ); + TEST_FAILED( ec ); + + ec = Ec( 0, system_category() ); + TEST_NOT_FAILED( ec ); + } + + { + Ec ec( 1, generic_category() ); + TEST_FAILED( ec ); + + ec.assign( 0, system_category() ); + TEST_NOT_FAILED( ec ); + } + + { + Ec ec( 0, system_category() ); + TEST_NOT_FAILED( ec ); + + ec.assign( 1, generic_category() ); + TEST_FAILED( ec ); + + ec = Ec( 0, generic_category() ); + TEST_NOT_FAILED( ec ); + } + + { + Ec ec( 1, system_category() ); + TEST_FAILED( ec ); + + ec.assign( 0, generic_category() ); + TEST_NOT_FAILED( ec ); + } + + { + Ec ec( 0, http_category() ); + BOOST_TEST( ec.failed() ); + + ec.assign( 200, http_category() ); + BOOST_TEST( !ec.failed() ); + + ec = Ec( 404, http_category() ); + BOOST_TEST( ec.failed() ); + } + +} + +int main() +{ + BOOST_TEST( !generic_category().failed( 0 ) ); + BOOST_TEST( generic_category().failed( 7 ) ); + + BOOST_TEST( !system_category().failed( 0 ) ); + BOOST_TEST( system_category().failed( 7 ) ); + + BOOST_TEST( http_category().failed( 0 ) ); + BOOST_TEST( !http_category().failed( 200 ) ); + BOOST_TEST( http_category().failed( 404 ) ); + + test<error_code>(); + test<error_condition>(); + + { + error_condition ec( errc::success ); + TEST_NOT_FAILED( ec ); + + ec = errc::address_family_not_supported; + TEST_FAILED( ec ); + } + + { + error_condition ec( errc::address_family_not_supported ); + TEST_FAILED( ec ); + + ec = errc::success; + TEST_NOT_FAILED( ec ); + } + + { + error_code ec( make_error_code( errc::success ) ); + TEST_NOT_FAILED( ec ); + + ec = make_error_code( errc::address_family_not_supported ); + TEST_FAILED( ec ); + } + + { + error_code ec( make_error_code( errc::address_family_not_supported ) ); + TEST_FAILED( ec ); + + ec = make_error_code( errc::success ); + TEST_NOT_FAILED( ec ); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/system/test/generic_category_test.cpp b/src/boost/libs/system/test/generic_category_test.cpp new file mode 100644 index 00000000..0d538157 --- /dev/null +++ b/src/boost/libs/system/test/generic_category_test.cpp @@ -0,0 +1,41 @@ + +// Copyright 2018 Peter Dimov. +// +// Distributed under the Boost Software License, Version 1.0. +// +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + +// See library home page at http://www.boost.org/libs/system + +// Avoid spurious VC++ warnings +# define _CRT_SECURE_NO_WARNINGS + +#include <boost/system/error_code.hpp> +#include <boost/core/lightweight_test.hpp> +#include <cstring> + +// + +namespace sys = boost::system; + +int main() +{ + sys::error_category const & cat = sys::generic_category(); + + // message + + for( int i = -2; i < 1024; ++i ) + { + { + BOOST_TEST_CSTR_EQ( cat.message( i ).c_str(), std::strerror( i ) ); + } + + { + char buffer[ 256 ]; + BOOST_TEST_CSTR_EQ( cat.message( i, buffer, sizeof( buffer ) ), std::strerror( i ) ); + } + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/system/test/header_only_test.cpp b/src/boost/libs/system/test/header_only_test.cpp new file mode 100644 index 00000000..69dccae8 --- /dev/null +++ b/src/boost/libs/system/test/header_only_test.cpp @@ -0,0 +1,23 @@ +// header_only_test.cpp -----------------------------------------------------// + +// Copyright Beman Dawes 2007 + +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/system + +//----------------------------------------------------------------------------// + +#include <boost/config/warning_disable.hpp> + +#define BOOST_ERROR_CODE_HEADER_ONLY + +#include <boost/detail/lightweight_test.hpp> +#include <boost/system/error_code.hpp> + +int main( int, char*[] ) +{ + boost::system::error_code ec( 0, boost::system::system_category() ); + return ::boost::report_errors(); +} diff --git a/src/boost/libs/system/test/initialization_test.cpp b/src/boost/libs/system/test/initialization_test.cpp new file mode 100644 index 00000000..c5ea03c9 --- /dev/null +++ b/src/boost/libs/system/test/initialization_test.cpp @@ -0,0 +1,28 @@ +// initialization_test.cpp -------------------------------------------------// + +// Copyright Christoper Kohlhoff 2007 + +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/system + +// This test verifiies that the error_category vtable does not suffer from +// order-of-initialization problems. + +#include <boost/system/error_code.hpp> +#include <boost/core/lightweight_test.hpp> + +struct foo +{ + foo() + { + boost::system::error_code ec; + BOOST_TEST_NE( ec, boost::system::errc::permission_denied ); + } +} f; + +int main() +{ + return boost::report_errors(); +} diff --git a/src/boost/libs/system/test/msvc/common.props b/src/boost/libs/system/test/msvc/common.props new file mode 100644 index 00000000..345d38ea --- /dev/null +++ b/src/boost/libs/system/test/msvc/common.props @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ImportGroup Label="PropertySheets" /> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup /> + <ItemDefinitionGroup> + <ClCompile> + <AdditionalIncludeDirectories>../../../../..</AdditionalIncludeDirectories> + </ClCompile> + </ItemDefinitionGroup> + <ItemDefinitionGroup> + <ClCompile> + <WarningLevel>Level4</WarningLevel> + <PreprocessorDefinitions>BOOST_ALL_NO_LIB;BOOST_ALL_DYN_LINK;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ExceptionHandling>Async</ExceptionHandling> + </ClCompile> + <PostBuildEvent> + <Command>"$(TargetDir)\$(TargetName).exe"</Command> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemGroup /> +</Project>
\ No newline at end of file diff --git a/src/boost/libs/system/test/msvc/config_test/config_test.vcxproj b/src/boost/libs/system/test/msvc/config_test/config_test.vcxproj new file mode 100644 index 00000000..484ad8d4 --- /dev/null +++ b/src/boost/libs/system/test/msvc/config_test/config_test.vcxproj @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{E18C2B56-DCEC-438F-9C38-3C8B08B65247}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>config_test</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <SDLCheck>true</SDLCheck> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <SDLCheck>true</SDLCheck> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\..\config_test.cpp" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\..\..\include\boost\system\api_config.hpp" /> + <ClInclude Include="..\..\..\include\boost\system\config.hpp" /> + <ClInclude Include="..\..\..\include\boost\system\cygwin_error.hpp" /> + <ClInclude Include="..\..\..\include\boost\system\error_code.hpp" /> + <ClInclude Include="..\..\..\include\boost\system\linux_error.hpp" /> + <ClInclude Include="..\..\..\include\boost\system\system_error.hpp" /> + <ClInclude Include="..\..\..\include\boost\system\windows_error.hpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/src/boost/libs/system/test/msvc/error_code_test/error_code_test.vcxproj b/src/boost/libs/system/test/msvc/error_code_test/error_code_test.vcxproj new file mode 100644 index 00000000..2edf1bf0 --- /dev/null +++ b/src/boost/libs/system/test/msvc/error_code_test/error_code_test.vcxproj @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{E50C14DC-547D-4C33-83EA-653C0D0D4E64}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>error_code_test</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ProjectReference Include="..\system-dll\system-dll.vcxproj"> + <Project>{419402d4-f990-4b05-a459-655e2dc33dc2}</Project> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\..\error_code_test.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/src/boost/libs/system/test/msvc/header_only_error_code_test/header_only_error_code_test.vcxproj b/src/boost/libs/system/test/msvc/header_only_error_code_test/header_only_error_code_test.vcxproj new file mode 100644 index 00000000..2649e3a1 --- /dev/null +++ b/src/boost/libs/system/test/msvc/header_only_error_code_test/header_only_error_code_test.vcxproj @@ -0,0 +1,151 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <VCProjectVersion>15.0</VCProjectVersion> + <ProjectGuid>{C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>header_only_error_code_test</RootNamespace> + <WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="Shared"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BOOST_ERROR_CODE_HEADER_ONLY</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions);BOOST_ERROR_CODE_HEADER_ONLY</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);BOOST_ERROR_CODE_HEADER_ONLY</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions);BOOST_ERROR_CODE_HEADER_ONLY</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\..\error_code_test.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/src/boost/libs/system/test/msvc/header_only_test/header_only_test.vcxproj b/src/boost/libs/system/test/msvc/header_only_test/header_only_test.vcxproj new file mode 100644 index 00000000..5dd9e29a --- /dev/null +++ b/src/boost/libs/system/test/msvc/header_only_test/header_only_test.vcxproj @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{3773451B-A618-4A26-A7F2-85554F4BD21B}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>header_only_test</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\..\header_only_test.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/src/boost/libs/system/test/msvc/std_interop_test/std_interop_test.vcxproj b/src/boost/libs/system/test/msvc/std_interop_test/std_interop_test.vcxproj new file mode 100644 index 00000000..39fe49c9 --- /dev/null +++ b/src/boost/libs/system/test/msvc/std_interop_test/std_interop_test.vcxproj @@ -0,0 +1,156 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <VCProjectVersion>15.0</VCProjectVersion> + <ProjectGuid>{47B0A041-1EB5-4842-BD17-BA0DCC5E0313}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>std_interop_test</RootNamespace> + <WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="Shared"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\..\std_interop_test.cpp" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\system-dll\system-dll.vcxproj"> + <Project>{419402d4-f990-4b05-a459-655e2dc33dc2}</Project> + </ProjectReference> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/src/boost/libs/system/test/msvc/system-dll/system-dll.vcxproj b/src/boost/libs/system/test/msvc/system-dll/system-dll.vcxproj new file mode 100644 index 00000000..cd7174dd --- /dev/null +++ b/src/boost/libs/system/test/msvc/system-dll/system-dll.vcxproj @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{419402D4-F990-4B05-A459-655E2DC33DC2}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>systemdll</RootNamespace> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;SYSTEMDLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <LanguageStandard>stdcpplatest</LanguageStandard> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + <PostBuildEvent> + <Command /> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;SYSTEMDLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\..\..\src\error_code.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/src/boost/libs/system/test/msvc/system.sln b/src/boost/libs/system/test/msvc/system.sln new file mode 100644 index 00000000..25b44dba --- /dev/null +++ b/src/boost/libs/system/test/msvc/system.sln @@ -0,0 +1,83 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.6 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "system-dll", "system-dll\system-dll.vcxproj", "{419402D4-F990-4B05-A459-655E2DC33DC2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "error_code_test", "error_code_test\error_code_test.vcxproj", "{E50C14DC-547D-4C33-83EA-653C0D0D4E64}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "header_only_test", "header_only_test\header_only_test.vcxproj", "{3773451B-A618-4A26-A7F2-85554F4BD21B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "config_test", "config_test\config_test.vcxproj", "{E18C2B56-DCEC-438F-9C38-3C8B08B65247}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clang-system-dll", "clang-system-dll\clang-system-dll.vcxproj", "{30993F97-5E77-4B5A-B25F-B545C276077A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "std_interop_test", "std_interop_test\std_interop_test.vcxproj", "{47B0A041-1EB5-4842-BD17-BA0DCC5E0313}" + ProjectSection(ProjectDependencies) = postProject + {419402D4-F990-4B05-A459-655E2DC33DC2} = {419402D4-F990-4B05-A459-655E2DC33DC2} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "header_only_error_code_test", "header_only_error_code_test\header_only_error_code_test.vcxproj", "{C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {419402D4-F990-4B05-A459-655E2DC33DC2}.Debug|Win32.ActiveCfg = Debug|Win32 + {419402D4-F990-4B05-A459-655E2DC33DC2}.Debug|Win32.Build.0 = Debug|Win32 + {419402D4-F990-4B05-A459-655E2DC33DC2}.Debug|x64.ActiveCfg = Debug|Win32 + {419402D4-F990-4B05-A459-655E2DC33DC2}.Release|Win32.ActiveCfg = Release|Win32 + {419402D4-F990-4B05-A459-655E2DC33DC2}.Release|Win32.Build.0 = Release|Win32 + {419402D4-F990-4B05-A459-655E2DC33DC2}.Release|x64.ActiveCfg = Release|Win32 + {E50C14DC-547D-4C33-83EA-653C0D0D4E64}.Debug|Win32.ActiveCfg = Debug|Win32 + {E50C14DC-547D-4C33-83EA-653C0D0D4E64}.Debug|Win32.Build.0 = Debug|Win32 + {E50C14DC-547D-4C33-83EA-653C0D0D4E64}.Debug|x64.ActiveCfg = Debug|Win32 + {E50C14DC-547D-4C33-83EA-653C0D0D4E64}.Release|Win32.ActiveCfg = Release|Win32 + {E50C14DC-547D-4C33-83EA-653C0D0D4E64}.Release|Win32.Build.0 = Release|Win32 + {E50C14DC-547D-4C33-83EA-653C0D0D4E64}.Release|x64.ActiveCfg = Release|Win32 + {3773451B-A618-4A26-A7F2-85554F4BD21B}.Debug|Win32.ActiveCfg = Debug|Win32 + {3773451B-A618-4A26-A7F2-85554F4BD21B}.Debug|Win32.Build.0 = Debug|Win32 + {3773451B-A618-4A26-A7F2-85554F4BD21B}.Debug|x64.ActiveCfg = Debug|Win32 + {3773451B-A618-4A26-A7F2-85554F4BD21B}.Release|Win32.ActiveCfg = Release|Win32 + {3773451B-A618-4A26-A7F2-85554F4BD21B}.Release|Win32.Build.0 = Release|Win32 + {3773451B-A618-4A26-A7F2-85554F4BD21B}.Release|x64.ActiveCfg = Release|Win32 + {E18C2B56-DCEC-438F-9C38-3C8B08B65247}.Debug|Win32.ActiveCfg = Debug|Win32 + {E18C2B56-DCEC-438F-9C38-3C8B08B65247}.Debug|Win32.Build.0 = Debug|Win32 + {E18C2B56-DCEC-438F-9C38-3C8B08B65247}.Debug|x64.ActiveCfg = Debug|Win32 + {E18C2B56-DCEC-438F-9C38-3C8B08B65247}.Release|Win32.ActiveCfg = Release|Win32 + {E18C2B56-DCEC-438F-9C38-3C8B08B65247}.Release|Win32.Build.0 = Release|Win32 + {E18C2B56-DCEC-438F-9C38-3C8B08B65247}.Release|x64.ActiveCfg = Release|Win32 + {30993F97-5E77-4B5A-B25F-B545C276077A}.Debug|Win32.ActiveCfg = Debug|Win32 + {30993F97-5E77-4B5A-B25F-B545C276077A}.Debug|Win32.Build.0 = Debug|Win32 + {30993F97-5E77-4B5A-B25F-B545C276077A}.Debug|x64.ActiveCfg = Debug|x64 + {30993F97-5E77-4B5A-B25F-B545C276077A}.Debug|x64.Build.0 = Debug|x64 + {30993F97-5E77-4B5A-B25F-B545C276077A}.Release|Win32.ActiveCfg = Release|Win32 + {30993F97-5E77-4B5A-B25F-B545C276077A}.Release|Win32.Build.0 = Release|Win32 + {30993F97-5E77-4B5A-B25F-B545C276077A}.Release|x64.ActiveCfg = Release|x64 + {30993F97-5E77-4B5A-B25F-B545C276077A}.Release|x64.Build.0 = Release|x64 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Debug|Win32.ActiveCfg = Debug|Win32 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Debug|Win32.Build.0 = Debug|Win32 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Debug|x64.ActiveCfg = Debug|x64 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Debug|x64.Build.0 = Debug|x64 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Release|Win32.ActiveCfg = Release|Win32 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Release|Win32.Build.0 = Release|Win32 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Release|x64.ActiveCfg = Release|x64 + {47B0A041-1EB5-4842-BD17-BA0DCC5E0313}.Release|x64.Build.0 = Release|x64 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}.Debug|Win32.ActiveCfg = Debug|Win32 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}.Debug|Win32.Build.0 = Debug|Win32 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}.Debug|x64.ActiveCfg = Debug|x64 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}.Debug|x64.Build.0 = Debug|x64 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}.Release|Win32.ActiveCfg = Release|Win32 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}.Release|Win32.Build.0 = Release|Win32 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}.Release|x64.ActiveCfg = Release|x64 + {C25D7BD7-1B99-4DA9-A1A5-3034410CBEF7}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/boost/libs/system/test/quick.cpp b/src/boost/libs/system/test/quick.cpp new file mode 100644 index 00000000..ca669832 --- /dev/null +++ b/src/boost/libs/system/test/quick.cpp @@ -0,0 +1,36 @@ + +// Copyright 2017 Peter Dimov. +// +// Distributed under the Boost Software License, Version 1.0. +// +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + +// See library home page at http://www.boost.org/libs/system + +#include <boost/system/error_code.hpp> +#include <boost/core/lightweight_test.hpp> +#include <cerrno> + +int main() +{ + boost::system::error_category const & bt = boost::system::generic_category(); + + int ev = ENOENT; + + boost::system::error_code bc( ev, bt ); + + BOOST_TEST_EQ( bc.value(), ev ); + BOOST_TEST_EQ( &bc.category(), &bt ); + + boost::system::error_condition bn = bt.default_error_condition( ev ); + + BOOST_TEST_EQ( bn.value(), ev ); + BOOST_TEST_EQ( &bn.category(), &bt ); + + BOOST_TEST( bt.equivalent( ev, bn ) ); + + BOOST_TEST( bc == bn ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/system/test/single_instance_1.cpp b/src/boost/libs/system/test/single_instance_1.cpp new file mode 100644 index 00000000..7d6cd1b4 --- /dev/null +++ b/src/boost/libs/system/test/single_instance_1.cpp @@ -0,0 +1,29 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include <boost/config.hpp> + +#if defined(SINGLE_INSTANCE_DYN_LINK) +# define EXPORT BOOST_SYMBOL_EXPORT +#else +# define EXPORT +#endif + +#include <boost/system/error_code.hpp> +using namespace boost::system; + +namespace lib1 +{ + +EXPORT error_code get_system_code() +{ + return error_code( 0, system_category() ); +} + +EXPORT error_code get_generic_code() +{ + return error_code( 0, generic_category() ); +} + +} // namespace lib1 diff --git a/src/boost/libs/system/test/single_instance_2.cpp b/src/boost/libs/system/test/single_instance_2.cpp new file mode 100644 index 00000000..dba74a75 --- /dev/null +++ b/src/boost/libs/system/test/single_instance_2.cpp @@ -0,0 +1,29 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include <boost/config.hpp> + +#if defined(SINGLE_INSTANCE_DYN_LINK) +# define EXPORT BOOST_SYMBOL_EXPORT +#else +# define EXPORT +#endif + +#include <boost/system/error_code.hpp> +using namespace boost::system; + +namespace lib2 +{ + +EXPORT error_code get_system_code() +{ + return error_code( 0, system_category() ); +} + +EXPORT error_code get_generic_code() +{ + return error_code( 0, generic_category() ); +} + +} // namespace lib2 diff --git a/src/boost/libs/system/test/single_instance_test.cpp b/src/boost/libs/system/test/single_instance_test.cpp new file mode 100644 index 00000000..65de5a9b --- /dev/null +++ b/src/boost/libs/system/test/single_instance_test.cpp @@ -0,0 +1,47 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include <boost/system/error_code.hpp> +#include <boost/core/lightweight_test.hpp> + +using namespace boost::system; + +namespace lib1 +{ + +error_code get_system_code(); +error_code get_generic_code(); + +} // namespace lib1 + +namespace lib2 +{ + +error_code get_system_code(); +error_code get_generic_code(); + +} // namespace lib2 + +int main() +{ + { + error_code e1 = lib1::get_system_code(); + error_code e2 = lib2::get_system_code(); + + BOOST_TEST_EQ( e1, e2 ); + + BOOST_TEST_EQ( hash_value( e1 ), hash_value( e2 ) ); + } + + { + error_code e1 = lib1::get_generic_code(); + error_code e2 = lib2::get_generic_code(); + + BOOST_TEST_EQ( e1, e2 ); + + BOOST_TEST_EQ( hash_value( e1 ), hash_value( e2 ) ); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/system/test/std_interop_test.cpp b/src/boost/libs/system/test/std_interop_test.cpp new file mode 100644 index 00000000..94845d17 --- /dev/null +++ b/src/boost/libs/system/test/std_interop_test.cpp @@ -0,0 +1,373 @@ + +// Copyright 2017 Peter Dimov. +// +// Distributed under the Boost Software License, Version 1.0. +// +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + +// See library home page at http://www.boost.org/libs/system + +// Avoid spurious VC++ warnings +# define _CRT_SECURE_NO_WARNINGS + +#include <boost/system/error_code.hpp> +#include <boost/config.hpp> +#include <boost/config/pragma_message.hpp> +#include <iostream> + +#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) + +BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" ) + +int main() +{ + std::cout + << "The version of the C++ standard library being used does not" + " support header <system_error> so interoperation will not be tested.\n"; +} + +#else + +#include <boost/core/lightweight_test.hpp> +#include <system_error> +#include <cerrno> +#include <string> +#include <cstdio> + +static void test_generic_category() +{ + boost::system::error_category const & bt = boost::system::generic_category(); + std::error_category const & st = bt; + + BOOST_TEST_CSTR_EQ( bt.name(), st.name() ); + + int ev = ENOENT; + + BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); + + { + boost::system::error_code bc( ev, bt ); + + BOOST_TEST_EQ( bc.value(), ev ); + BOOST_TEST_EQ( &bc.category(), &bt ); + + std::error_code sc( bc ); + + BOOST_TEST_EQ( sc.value(), ev ); + BOOST_TEST_EQ( &sc.category(), &st ); + } + + { + boost::system::error_condition bn = bt.default_error_condition( ev ); + + BOOST_TEST_EQ( bn.value(), ev ); + BOOST_TEST_EQ( &bn.category(), &bt ); + + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + + BOOST_TEST_EQ( sn.value(), ev ); + BOOST_TEST_EQ( &sn.category(), &st ); + + BOOST_TEST( st.equivalent( ev, sn ) ); + } +} + +static void test_system_category() +{ + boost::system::error_category const & bt = boost::system::system_category(); + std::error_category const & st = bt; + + BOOST_TEST_CSTR_EQ( bt.name(), st.name() ); + + { + int ev = 5; + BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); + + { + boost::system::error_code bc( ev, bt ); + + BOOST_TEST_EQ( bc.value(), ev ); + BOOST_TEST_EQ( &bc.category(), &bt ); + + std::error_code sc( bc ); + + BOOST_TEST_EQ( sc.value(), ev ); + BOOST_TEST_EQ( &sc.category(), &st ); + } + + { + boost::system::error_condition bn = bt.default_error_condition( ev ); + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + BOOST_TEST( st.equivalent( ev, sn ) ); + } + } + + { + int ev = 4; + BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); + + { + boost::system::error_code bc( ev, bt ); + + BOOST_TEST_EQ( bc.value(), ev ); + BOOST_TEST_EQ( &bc.category(), &bt ); + + std::error_code sc( bc ); + + BOOST_TEST_EQ( sc.value(), ev ); + BOOST_TEST_EQ( &sc.category(), &st ); + } + + { + boost::system::error_condition bn = bt.default_error_condition( ev ); + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + BOOST_TEST( st.equivalent( ev, sn ) ); + } + } +} + +// test_user_category + +class user_category_impl: public boost::system::error_category +{ +public: + + virtual const char * name() const BOOST_NOEXCEPT + { + return "user"; + } + + virtual std::string message( int ev ) const + { + char buffer[ 256 ]; + std::sprintf( buffer, "user message %d", ev ); + + return buffer; + } + + virtual boost::system::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT + { + if( ev == 4 ) + { + return boost::system::error_condition( EMFILE, boost::system::generic_category() ); + } + else if( ev == 5 ) + { + return boost::system::error_condition( EACCES, boost::system::generic_category() ); + } + else + { + return boost::system::error_condition( ev, *this ); + } + } + + virtual bool equivalent( int code, const boost::system::error_condition & condition ) const BOOST_NOEXCEPT + { + if( code == 4 && condition == make_error_condition( boost::system::errc::too_many_files_open_in_system ) ) + { + return true; + } + + if( code == 4 && condition == make_error_condition( boost::system::errc::too_many_files_open ) ) + { + return true; + } + + return default_error_condition( code ) == condition; + } + + // virtual bool equivalent( const error_code & code, int condition ) const BOOST_NOEXCEPT; +}; + +boost::system::error_category const & user_category() +{ + static user_category_impl cat_; + return cat_; +} + +static void test_user_category() +{ + boost::system::error_category const & bt = user_category(); + std::error_category const & st = bt; + + BOOST_TEST_CSTR_EQ( bt.name(), st.name() ); + + { + int ev = 5; + BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); + + { + boost::system::error_code bc( ev, bt ); + + BOOST_TEST_EQ( bc.value(), ev ); + BOOST_TEST_EQ( &bc.category(), &bt ); + + std::error_code sc( bc ); + + BOOST_TEST_EQ( sc.value(), ev ); + BOOST_TEST_EQ( &sc.category(), &st ); + } + + { + boost::system::error_condition bn = bt.default_error_condition( ev ); + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + BOOST_TEST( st.equivalent( ev, sn ) ); + } + } + + { + int ev = 4; + BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) ); + + { + boost::system::error_code bc( ev, bt ); + + BOOST_TEST_EQ( bc.value(), ev ); + BOOST_TEST_EQ( &bc.category(), &bt ); + + std::error_code sc( bc ); + + BOOST_TEST_EQ( sc.value(), ev ); + BOOST_TEST_EQ( &sc.category(), &st ); + } + + { + boost::system::error_condition bn = bt.default_error_condition( ev ); + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + BOOST_TEST( st.equivalent( ev, sn ) ); + } + + { + boost::system::error_condition bn = make_error_condition( boost::system::errc::too_many_files_open_in_system ); + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + BOOST_TEST( st.equivalent( ev, sn ) ); + } + + { + boost::system::error_condition bn = make_error_condition( boost::system::errc::too_many_files_open ); + BOOST_TEST( bt.equivalent( ev, bn ) ); + + std::error_condition sn( bn ); + BOOST_TEST( st.equivalent( ev, sn ) ); + } + } +} + +// test_user2_category + +enum user2_errc +{ + my_enoent = 1, + my_einval, + my_other +}; + +class user2_category_impl: public boost::system::error_category +{ +public: + + virtual const char * name() const BOOST_NOEXCEPT + { + return "user2"; + } + + virtual std::string message( int ev ) const + { + char buffer[ 256 ]; + std::sprintf( buffer, "user2 message %d", ev ); + + return buffer; + } + + virtual boost::system::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT + { + return boost::system::error_condition( ev, *this ); + } + + virtual bool equivalent( int code, const boost::system::error_condition & condition ) const BOOST_NOEXCEPT + { + return default_error_condition( code ) == condition; + } + + virtual bool equivalent( const boost::system::error_code & code, int condition ) const BOOST_NOEXCEPT + { + if( code.category() == *this ) + { + return condition == code.value(); + } + else if( condition == my_enoent ) + { + return code == boost::system::errc::no_such_file_or_directory; + } + else if( condition == my_einval ) + { + return code == boost::system::errc::invalid_argument; + } + else + { + return false; + } + } +}; + +boost::system::error_category const & user2_category() +{ + static user2_category_impl cat_; + return cat_; +} + +static void test_user2_category() +{ + boost::system::error_category const & bt = user2_category(); + std::error_category const & st = bt; + + int ev = my_enoent; + + boost::system::error_condition bn( ev, bt ); + + BOOST_TEST_EQ( bn.value(), ev ); + BOOST_TEST_EQ( &bn.category(), &bt ); + + boost::system::error_code bc = make_error_code( boost::system::errc::no_such_file_or_directory ); + + BOOST_TEST( bc == bn ); + + std::error_condition sn( bn ); + + BOOST_TEST_EQ( sn.value(), ev ); + BOOST_TEST_EQ( &sn.category(), &st ); + + std::error_code sc( bc ); + + BOOST_TEST( sc == sn ); +} + +// + +int main() +{ + std::cout + << "The version of the C++ standard library being used" + " supports header <system_error> so interoperation will be tested.\n"; + test_generic_category(); + test_system_category(); + test_user_category(); + test_user2_category(); + + return boost::report_errors(); +} + +#endif diff --git a/src/boost/libs/system/test/std_mismatch_test.cpp b/src/boost/libs/system/test/std_mismatch_test.cpp new file mode 100644 index 00000000..3a34bb25 --- /dev/null +++ b/src/boost/libs/system/test/std_mismatch_test.cpp @@ -0,0 +1,66 @@ + +// Copyright 2017 Peter Dimov. +// +// Distributed under the Boost Software License, Version 1.0. +// +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + +// See library home page at http://www.boost.org/libs/system + +// Avoid spurious VC++ warnings +# define _CRT_SECURE_NO_WARNINGS + +#include <boost/system/error_code.hpp> +#include <boost/config.hpp> +#include <boost/config/pragma_message.hpp> +#include <iostream> + +#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) + +BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" ) + +int main() +{ + std::cout + << "The version of the C++ standard library being used does not" + " support header <system_error> so interoperation will not be tested.\n"; +} + +#else + +#include <boost/core/lightweight_test.hpp> +#include <system_error> +#include <cerrno> +#include <string> +#include <cstdio> + +static void test_generic_category() +{ + boost::system::error_category const & bt = boost::system::generic_category(); + std::error_category const & st = bt; + + BOOST_TEST_CSTR_EQ( bt.name(), st.name() ); +} + +static void test_system_category() +{ + boost::system::error_category const & bt = boost::system::system_category(); + std::error_category const & st = bt; + + BOOST_TEST_CSTR_EQ( bt.name(), st.name() ); +} + +int main() +{ + std::cout + << "The version of the C++ standard library being used" + " supports header <system_error> so interoperation will be tested.\n"; + + test_generic_category(); + test_system_category(); + + return boost::report_errors(); +} + +#endif diff --git a/src/boost/libs/system/test/std_single_instance_1.cpp b/src/boost/libs/system/test/std_single_instance_1.cpp new file mode 100644 index 00000000..69861460 --- /dev/null +++ b/src/boost/libs/system/test/std_single_instance_1.cpp @@ -0,0 +1,40 @@ + +// Copyright 2019 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include <boost/config.hpp> + +#if defined(STD_SINGLE_INSTANCE_DYN_LINK) +# define EXPORT BOOST_SYMBOL_EXPORT +#else +# define EXPORT +#endif + +#include <boost/system/error_code.hpp> + +#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) + +#include <system_error> + +namespace lib1 +{ + +EXPORT std::error_code get_system_code() +{ + return boost::system::error_code( 0, boost::system::system_category() ); +} + +EXPORT std::error_code get_generic_code() +{ + return boost::system::error_code( 0, boost::system::generic_category() ); +} + +} // namespace lib1 + +#else + +EXPORT void lib1_f() +{ +} + +#endif diff --git a/src/boost/libs/system/test/std_single_instance_2.cpp b/src/boost/libs/system/test/std_single_instance_2.cpp new file mode 100644 index 00000000..960b3caf --- /dev/null +++ b/src/boost/libs/system/test/std_single_instance_2.cpp @@ -0,0 +1,40 @@ + +// Copyright 2019 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include <boost/config.hpp> + +#if defined(STD_SINGLE_INSTANCE_DYN_LINK) +# define EXPORT BOOST_SYMBOL_EXPORT +#else +# define EXPORT +#endif + +#include <boost/system/error_code.hpp> + +#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) + +#include <system_error> + +namespace lib2 +{ + +EXPORT std::error_code get_system_code() +{ + return boost::system::error_code( 0, boost::system::system_category() ); +} + +EXPORT std::error_code get_generic_code() +{ + return boost::system::error_code( 0, boost::system::generic_category() ); +} + +} // namespace lib2 + +#else + +EXPORT void lib2_f() +{ +} + +#endif diff --git a/src/boost/libs/system/test/std_single_instance_test.cpp b/src/boost/libs/system/test/std_single_instance_test.cpp new file mode 100644 index 00000000..c5fe710e --- /dev/null +++ b/src/boost/libs/system/test/std_single_instance_test.cpp @@ -0,0 +1,76 @@ + +// Copyright 2019 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include <boost/system/error_code.hpp> +#include <boost/config/pragma_message.hpp> +#include <boost/config/helper_macros.hpp> + +#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) + +BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" ) +int main() {} + +#elif defined(STD_SINGLE_INSTANCE_SHARED) && defined(__CYGWIN__) + +BOOST_PRAGMA_MESSAGE( "Skipping Windows/DLL test, __CYGWIN__" ) +int main() {} + +#elif defined(STD_SINGLE_INSTANCE_SHARED) && defined(_WIN32) && !defined(_MSC_VER) + +BOOST_PRAGMA_MESSAGE( "Skipping Windows/DLL test, no _MSC_VER" ) +int main() {} + +#elif defined(STD_SINGLE_INSTANCE_SHARED) && defined(_WIN32) && !defined(_CPPLIB_VER) + +BOOST_PRAGMA_MESSAGE( "Skipping Windows/DLL test, no _CPPLIB_VER" ) +int main() {} + +#elif defined(STD_SINGLE_INSTANCE_SHARED) && defined(_WIN32) && (_MSC_VER < 1900 || _MSC_VER >= 2000) + +BOOST_PRAGMA_MESSAGE( "Skipping Windows/DLL test, _MSC_VER is " BOOST_STRINGIZE(_MSC_VER) ) +int main() {} + +#else + +#include <boost/core/lightweight_test.hpp> +#include <system_error> + +using namespace boost::system; + +namespace lib1 +{ + +std::error_code get_system_code(); +std::error_code get_generic_code(); + +} // namespace lib1 + +namespace lib2 +{ + +std::error_code get_system_code(); +std::error_code get_generic_code(); + +} // namespace lib2 + +int main() +{ + { + std::error_code e1 = lib1::get_system_code(); + std::error_code e2 = lib2::get_system_code(); + + BOOST_TEST_EQ( e1, e2 ); + } + + { + std::error_code e1 = lib1::get_generic_code(); + std::error_code e2 = lib2::get_generic_code(); + + BOOST_TEST_EQ( e1, e2 ); + } + + return boost::report_errors(); +} + +#endif diff --git a/src/boost/libs/system/test/system_category_test.cpp b/src/boost/libs/system/test/system_category_test.cpp new file mode 100644 index 00000000..5a77454c --- /dev/null +++ b/src/boost/libs/system/test/system_category_test.cpp @@ -0,0 +1,121 @@ + +// Copyright 2018 Peter Dimov. +// +// Distributed under the Boost Software License, Version 1.0. +// +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + +// See library home page at http://www.boost.org/libs/system + +// Avoid spurious VC++ warnings +# define _CRT_SECURE_NO_WARNINGS + +#include <boost/system/error_code.hpp> +#include <boost/core/lightweight_test.hpp> +#include <cstring> +#include <cstdio> + +// + +#if defined(BOOST_WINDOWS_API) && defined(BOOST_SYSTEM_USE_UTF8) + +#include <boost/config/pragma_message.hpp> + +BOOST_PRAGMA_MESSAGE( "Skipping test due to BOOST_WINDOWS_API && BOOST_SYSTEM_USE_UTF8" ) + +int main() {} + +#else + +#if defined(BOOST_WINDOWS_API) + +#include <windows.h> + +std::string sys_strerror( int ev ) +{ + void * lpMsgBuf = 0; + + DWORD retval = FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + ev, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR) &lpMsgBuf, + 0, + NULL + ); + + struct local_free + { + void * p_; + + ~local_free() + { + LocalFree( p_ ); + } + }; + + local_free lf_ = { lpMsgBuf }; + + if( retval == 0 ) + { + char buffer[ 38 ]; + + std::sprintf( buffer, "Unknown error (%d)", ev ); + return buffer; + } + + std::string str( static_cast<char const*>( lpMsgBuf ) ); + + while( !str.empty() && (str[str.size()-1] == '\n' || str[str.size()-1] == '\r') ) + { + str.erase( str.size()-1 ); + } + + if( !str.empty() && str[str.size()-1] == '.' ) + { + str.erase( str.size()-1 ); + } + + return str; +} + +#else + +std::string sys_strerror( int ev ) +{ + return std::strerror( ev ); +} + +#endif + +// + +namespace sys = boost::system; + +static void test_message( sys::error_category const & cat, int ev ) +{ + BOOST_TEST_EQ( cat.message( ev ), sys_strerror( ev ) ); + + char buffer[ 4096 ]; // yes, really + BOOST_TEST_CSTR_EQ( cat.message( ev, buffer, sizeof( buffer ) ), sys_strerror( ev ).c_str() ); +} + +int main() +{ + sys::error_category const & cat = sys::system_category(); + + // message + + for( int i = -2; i < 16000; ++i ) + { + test_message( cat, i ); + } + + return boost::report_errors(); +} + +#endif // #if defined(BOOST_WINDOWS_API) && defined(BOOST_SYSTEM_USE_UTF8) diff --git a/src/boost/libs/system/test/system_error_test.cpp b/src/boost/libs/system/test/system_error_test.cpp new file mode 100644 index 00000000..bb93ca53 --- /dev/null +++ b/src/boost/libs/system/test/system_error_test.cpp @@ -0,0 +1,106 @@ +// system_error_test.cpp ---------------------------------------------------// + +// Copyright Beman Dawes 2006 +// Copyright (c) Microsoft Corporation 2014 +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/system + +//----------------------------------------------------------------------------// + +#include <boost/config/warning_disable.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/system/system_error.hpp> +#include <iostream> +#include <string> + +#ifdef BOOST_WINDOWS_API +#include <windows.h> +#endif + +using boost::system::system_error; +using boost::system::error_code; +using boost::system::system_category; +using std::string; + +#define TEST(x,v,w) test(#x,x,v,w) + +namespace +{ + void test( const char * desc, const system_error & ex, + int v, const char * str ) + { + std::cout << "test " << desc << "\n what() returns \"" << ex.what() << "\"\n"; + BOOST_TEST( ex.code().value() == v ); + BOOST_TEST( ex.code().category() == system_category() ); +# ifdef BOOST_WINDOWS_API + LANGID language_id; +# if !BOOST_PLAT_WINDOWS_RUNTIME + language_id = ::GetUserDefaultUILanguage(); +# else + language_id = 0x0409; // Assume US English +# endif + // std::cout << "GetUserDefaultUILanguage() returns " << language_id << '\n'; + if ( language_id == 0x0409 ) // English (United States) + { + BOOST_TEST( std::string( ex.what() ) == str ); + if ( std::string( ex.what() ) != str ) + std::cout << "expected \"" << str << "\", but what() returned \"" + << ex.what() << "\"\n"; + } +# endif + } + + const boost::uint_least32_t uvalue = 2u; +} + +int main( int, char *[] ) +{ + // all constructors, in the same order as they appear in the header: + + system_error c1_0( error_code(0, system_category()) ); + system_error c1_1( error_code(1, system_category()) ); + system_error c1_2u( error_code(uvalue, system_category()) ); + + system_error c2_0( error_code(0, system_category()), string("c2_0") ); + system_error c2_1( error_code(1, system_category()), string("c2_1") ); + + system_error c3_0( error_code(0, system_category()), "c3_0" ); + system_error c3_1( error_code(1, system_category()), "c3_1" ); + + system_error c4_0( 0, system_category() ); + system_error c4_1( 1, system_category() ); + system_error c4_2u( uvalue, system_category() ); + + system_error c5_0( 0, system_category(), string("c5_0") ); + system_error c5_1( 1, system_category(), string("c5_1") ); + + system_error c6_0( 0, system_category(), "c6_0" ); + system_error c6_1( 1, system_category(), "c6_1" ); + + TEST( c1_0, 0, "The operation completed successfully" ); + TEST( c1_1, 1, "Incorrect function" ); + TEST( c1_2u, 2, "The system cannot find the file specified" ); + + TEST( c2_0, 0, "c2_0: The operation completed successfully" ); + TEST( c2_1, 1, "c2_1: Incorrect function" ); + + TEST( c3_0, 0, "c3_0: The operation completed successfully" ); + TEST( c3_1, 1, "c3_1: Incorrect function" ); + + TEST( c4_0, 0, "The operation completed successfully" ); + TEST( c4_1, 1, "Incorrect function" ); + TEST( c4_2u, 2, "The system cannot find the file specified" ); + + TEST( c5_0, 0, "c5_0: The operation completed successfully" ); + TEST( c5_1, 1, "c5_1: Incorrect function" ); + + TEST( c6_0, 0, "c6_0: The operation completed successfully" ); + TEST( c6_1, 1, "c6_1: Incorrect function" ); + + return ::boost::report_errors(); +} + + diff --git a/src/boost/libs/system/test/throw_test.cpp b/src/boost/libs/system/test/throw_test.cpp new file mode 100644 index 00000000..c7ae5173 --- /dev/null +++ b/src/boost/libs/system/test/throw_test.cpp @@ -0,0 +1,28 @@ +// throw_test.cpp --------------------------------------------------------===========-// + +// Copyright Beman Dawes 2010 + +// Distributed under the Boost Software License, Version 1.0. +// See www.boost.org/LICENSE_1_0.txt + +// Library home page is www.boost.org/libs/system + +//--------------------------------------------------------------------------------------// + +// See dynamic_link_test.cpp comments for use case. + +//--------------------------------------------------------------------------------------// + +#include <boost/system/system_error.hpp> +#include <boost/config.hpp> + +#if defined(THROW_DYN_LINK) +# define EXPORT BOOST_SYMBOL_EXPORT +#else +# define EXPORT +#endif + +EXPORT void throw_test() +{ + throw boost::system::system_error( 9999, boost::system::system_category(), "boo boo" ); +} diff --git a/src/boost/libs/system/test/throws_assign_fail.cpp b/src/boost/libs/system/test/throws_assign_fail.cpp new file mode 100644 index 00000000..8453577b --- /dev/null +++ b/src/boost/libs/system/test/throws_assign_fail.cpp @@ -0,0 +1,28 @@ + +// Copyright 2018 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include <boost/system/error_code.hpp> + +using namespace boost::system; + +static void f( error_code & ec ) +{ + ec = error_code(); +} + +#if defined(_WIN32) +# include <windows.h> // SetErrorMode +#endif + +int main() +{ +#if defined(_WIN32) + + SetErrorMode( SetErrorMode( 0 ) | SEM_NOGPFAULTERRORBOX ); + +#endif + + // this should crash + f( boost::throws() ); +} diff --git a/src/boost/libs/system/test/warnings_test.cpp b/src/boost/libs/system/test/warnings_test.cpp new file mode 100644 index 00000000..f7554e16 --- /dev/null +++ b/src/boost/libs/system/test/warnings_test.cpp @@ -0,0 +1,42 @@ + +// Copyright 2017, 2019 Peter Dimov. +// +// Distributed under the Boost Software License, Version 1.0. +// +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + +// See library home page at http://www.boost.org/libs/system + +#include <boost/config.hpp> + +#if defined( BOOST_GCC ) && BOOST_GCC < 40600 +#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" +#endif + +#include <boost/system/error_code.hpp> +#include <boost/core/lightweight_test.hpp> +#include <cerrno> + +int main() +{ + boost::system::error_category const & bt = boost::system::generic_category(); + + int ev = ENOENT; + + boost::system::error_code bc( ev, bt ); + + BOOST_TEST_EQ( bc.value(), ev ); + BOOST_TEST_EQ( &bc.category(), &bt ); + + boost::system::error_condition bn = bt.default_error_condition( ev ); + + BOOST_TEST_EQ( bn.value(), ev ); + BOOST_TEST_EQ( &bn.category(), &bt ); + + BOOST_TEST( bt.equivalent( ev, bn ) ); + + BOOST_TEST( bc == bn ); + + return boost::report_errors(); +} diff --git a/src/boost/libs/system/test/win32_hresult_test.cpp b/src/boost/libs/system/test/win32_hresult_test.cpp new file mode 100644 index 00000000..b79c51da --- /dev/null +++ b/src/boost/libs/system/test/win32_hresult_test.cpp @@ -0,0 +1,41 @@ + +// Copyright 2018 Peter Dimov. +// +// Distributed under the Boost Software License, Version 1.0. +// +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + +// See library home page at http://www.boost.org/libs/system + +#include <boost/system/error_code.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; + + HRESULT r = HRESULT_FROM_WIN32( ERROR_ACCESS_DENIED ); + + sys::error_code ec( r, sys::system_category() ); + sys::error_condition en = make_error_condition( sys::errc::permission_denied ); + + BOOST_TEST( ec == en ); + BOOST_TEST( ec.default_error_condition() == en ); + + BOOST_TEST_EQ( ec.default_error_condition().value(), en.value() ); + + return boost::report_errors(); +} + +#endif |