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