From 96321beb88947c81c44ab23f38c48459e59811f6 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 27 Aug 2020 15:45:07 +0300 Subject: [PATCH] Add error_condition.hpp --- include/boost/system/error_condition.hpp | 13 ++++++++++ test/Jamfile.v2 | 1 + test/error_condition_test.cpp | 31 ++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 include/boost/system/error_condition.hpp create mode 100644 test/error_condition_test.cpp diff --git a/include/boost/system/error_condition.hpp b/include/boost/system/error_condition.hpp new file mode 100644 index 0000000..2a8cec1 --- /dev/null +++ b/include/boost/system/error_condition.hpp @@ -0,0 +1,13 @@ +#ifndef BOOST_SYSTEM_ERROR_CONDITION_HPP_INCLUDED +#define BOOST_SYSTEM_ERROR_CONDITION_HPP_INCLUDED + +// Copyright 2020 Peter Dimov +// Distributed under the Boost Software License, Version 1.0 +// http://www.boost.org/LICENSE_1_0.txt +// +// See library home page at http://www.boost.org/libs/system + +#include +#include + +#endif // #ifndef BOOST_SYSTEM_ERROR_CONDITION_HPP_INCLUDED diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 8d7d5f5..780e0c2 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -78,3 +78,4 @@ run is_error_code_enum_test.cpp ; run is_error_condition_enum_test.cpp ; run errc_test.cpp ; run error_category_test2.cpp ; +run error_condition_test.cpp ; diff --git a/test/error_condition_test.cpp b/test/error_condition_test.cpp new file mode 100644 index 0000000..1ebe447 --- /dev/null +++ b/test/error_condition_test.cpp @@ -0,0 +1,31 @@ +// Copyright 2020 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// http://www.boost.org/LICENSE_1_0.txt + +#include +#include + +namespace sys = boost::system; + +int main() +{ + sys::error_condition en; + + BOOST_TEST_EQ( en.value(), 0 ); + BOOST_TEST( !en ); + + sys::error_condition en2( en ); + + BOOST_TEST( en == en2 ); + BOOST_TEST_NOT( en != en2 ); + + en2.assign( 1, en.category() ); + + BOOST_TEST_EQ( en2.value(), 1 ); + BOOST_TEST( en2 ); + + BOOST_TEST_NOT( en == en2 ); + BOOST_TEST( en != en2 ); + + return boost::report_errors(); +}