1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // XFAIL: with_system_cxx_lib=macosx10.12 11 // XFAIL: with_system_cxx_lib=macosx10.11 12 // XFAIL: with_system_cxx_lib=macosx10.10 13 // XFAIL: with_system_cxx_lib=macosx10.9 14 // XFAIL: with_system_cxx_lib=macosx10.7 15 // XFAIL: with_system_cxx_lib=macosx10.8 16 17 // <system_error> 18 19 // class error_category 20 21 // const error_category& generic_category(); 22 23 #include <system_error> 24 #include <cassert> 25 #include <string> 26 #include <cerrno> 27 28 #include "test_macros.h" 29 30 void test_message_for_bad_value() { 31 errno = E2BIG; // something that message will never generate 32 const std::error_category& e_cat1 = std::generic_category(); 33 const std::string msg = e_cat1.message(-1); 34 // Exact message format varies by platform. 35 LIBCPP_ASSERT(msg == "Unknown error -1" || msg == "Unknown error" || 36 msg == "Unknown error: -1"); 37 assert(errno == E2BIG); 38 } 39 40 int main() 41 { 42 const std::error_category& e_cat1 = std::generic_category(); 43 std::string m1 = e_cat1.name(); 44 assert(m1 == "generic"); 45 { 46 test_message_for_bad_value(); 47 } 48 } 49