libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

generic_category.pass.cpp (1357B)


      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: suse-linux-enterprise-server-11
     11 // XFAIL: with_system_cxx_lib=macosx10.12
     12 // XFAIL: with_system_cxx_lib=macosx10.11
     13 // XFAIL: with_system_cxx_lib=macosx10.10
     14 // XFAIL: with_system_cxx_lib=macosx10.9
     15 // XFAIL: with_system_cxx_lib=macosx10.7
     16 // XFAIL: with_system_cxx_lib=macosx10.8
     17 
     18 // <system_error>
     19 
     20 // class error_category
     21 
     22 // const error_category& generic_category();
     23 
     24 #include <system_error>
     25 #include <cassert>
     26 #include <string>
     27 #include <cerrno>
     28 
     29 #include "test_macros.h"
     30 
     31 void test_message_for_bad_value() {
     32     errno = E2BIG; // something that message will never generate
     33     const std::error_category& e_cat1 = std::generic_category();
     34     const std::string msg = e_cat1.message(-1);
     35     LIBCPP_ASSERT(msg == "Unknown error -1" || msg == "Unknown error");
     36     assert(errno == E2BIG);
     37 }
     38 
     39 int main()
     40 {
     41     const std::error_category& e_cat1 = std::generic_category();
     42     std::string m1 = e_cat1.name();
     43     assert(m1 == "generic");
     44     {
     45         test_message_for_bad_value();
     46     }
     47 }