libcxx

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

radix.pass.cpp (1594B)


      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 // radix
     13 
     14 #include <limits>
     15 #include <cfloat>
     16 
     17 #include "test_macros.h"
     18 
     19 template <class T, int expected>
     20 void
     21 test()
     22 {
     23     static_assert(std::numeric_limits<T>::radix == expected, "radix test 1");
     24     static_assert(std::numeric_limits<const T>::radix == expected, "radix test 2");
     25     static_assert(std::numeric_limits<volatile T>::radix == expected, "radix test 3");
     26     static_assert(std::numeric_limits<const volatile T>::radix == expected, "radix test 4");
     27 }
     28 
     29 int main()
     30 {
     31     test<bool, 2>();
     32     test<char, 2>();
     33     test<signed char, 2>();
     34     test<unsigned char, 2>();
     35     test<wchar_t, 2>();
     36 #if TEST_STD_VER > 17 && defined(__cpp_char8_t)
     37     test<char8_t, 2>();
     38 #endif
     39 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
     40     test<char16_t, 2>();
     41     test<char32_t, 2>();
     42 #endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
     43     test<short, 2>();
     44     test<unsigned short, 2>();
     45     test<int, 2>();
     46     test<unsigned int, 2>();
     47     test<long, 2>();
     48     test<unsigned long, 2>();
     49     test<long long, 2>();
     50     test<unsigned long long, 2>();
     51 #ifndef _LIBCPP_HAS_NO_INT128
     52     test<__int128_t, 2>();
     53     test<__uint128_t, 2>();
     54 #endif
     55     test<float, FLT_RADIX>();
     56     test<double, FLT_RADIX>();
     57     test<long double, FLT_RADIX>();
     58 }