Home | History | Annotate | Download | only in numeric.limits.members
      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 // test numeric_limits
     11 
     12 // traps
     13 
     14 #include <limits>
     15 
     16 #if (defined(__i386__) || defined(__x86_64__))
     17 static const bool integral_types_trap = true;
     18 #else
     19 static const bool integral_types_trap = false;
     20 #endif
     21 
     22 template <class T, bool expected>
     23 void
     24 test()
     25 {
     26     static_assert(std::numeric_limits<T>::traps == expected, "traps test 1");
     27     static_assert(std::numeric_limits<const T>::traps == expected, "traps test 2");
     28     static_assert(std::numeric_limits<volatile T>::traps == expected, "traps test 3");
     29     static_assert(std::numeric_limits<const volatile T>::traps == expected, "traps test 4");
     30 }
     31 
     32 int main()
     33 {
     34     test<bool, false>();
     35     test<char, integral_types_trap>();
     36     test<signed char, integral_types_trap>();
     37     test<unsigned char, integral_types_trap>();
     38     test<wchar_t, integral_types_trap>();
     39 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
     40     test<char16_t, integral_types_trap>();
     41     test<char32_t, integral_types_trap>();
     42 #endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
     43     test<short, integral_types_trap>();
     44     test<unsigned short, integral_types_trap>();
     45     test<int, integral_types_trap>();
     46     test<unsigned int, integral_types_trap>();
     47     test<long, integral_types_trap>();
     48     test<unsigned long, integral_types_trap>();
     49     test<long long, integral_types_trap>();
     50     test<unsigned long long, integral_types_trap>();
     51 #ifndef _LIBCPP_HAS_NO_INT128
     52     test<__int128_t, integral_types_trap>();
     53     test<__uint128_t, integral_types_trap>();
     54 #endif
     55     test<float, false>();
     56     test<double, false>();
     57     test<long double, false>();
     58 }
     59