1 2 // Copyright 2018 Daniel James 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6 #include "./config.hpp" 7 8 #ifndef BOOST_HASH_TEST_STD_INCLUDES 9 # include <boost/container_hash/hash.hpp> 10 #endif 11 #include <boost/config.hpp> 12 #include <boost/core/lightweight_test.hpp> 13 14 #if !defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) 15 16 #include <system_error> 17 test_error_code()18void test_error_code() 19 { 20 std::error_code err1a = std::make_error_code(std::errc::argument_list_too_long); 21 std::error_code err1b = std::make_error_code(std::errc::argument_list_too_long); 22 std::error_code err2 = std::make_error_code(std::errc::bad_file_descriptor); 23 24 boost::hash<std::error_code> hasher; 25 26 BOOST_TEST(hasher(err1a) == hasher(err1a)); 27 BOOST_TEST(hasher(err1a) == hasher(err1b)); 28 BOOST_TEST(hasher(err1a) != hasher(err2)); 29 } 30 test_error_condition()31void test_error_condition() 32 { 33 std::error_condition err1a = std::make_error_condition(std::errc::directory_not_empty); 34 std::error_condition err1b = std::make_error_condition(std::errc::directory_not_empty); 35 std::error_condition err2 = std::make_error_condition(std::errc::filename_too_long); 36 37 boost::hash<std::error_condition> hasher; 38 39 BOOST_TEST(hasher(err1a) == hasher(err1a)); 40 BOOST_TEST(hasher(err1a) == hasher(err1b)); 41 BOOST_TEST(hasher(err1a) != hasher(err2)); 42 } 43 44 #endif 45 main()46int main() 47 { 48 #if !defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) 49 test_error_code(); 50 test_error_condition(); 51 #else 52 BOOST_LIGHTWEIGHT_TEST_OSTREAM << "<system_error> not available." << std::endl; 53 #endif 54 return boost::report_errors(); 55 } 56