1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // test numeric_limits
17 template <class T, int expected>
21 static_assert(std::numeric_limits<T>::digits10 == expected, "digits10 test 1");
22 static_assert(std::numeric_limits<T>::is_bounded, "digits10 test 5");
23 static_assert(std::numeric_limits<const T>::digits10 == expected, "digits10 test 2");
24 static_assert(std::numeric_limits<const T>::is_bounded, "digits10 test 6");
25 static_assert(std::numeric_limits<volatile T>::digits10 == expected, "digits10 test 3");
26 static_assert(std::numeric_limits<volatile T>::is_bounded, "digits10 test 7");
27 static_assert(std::numeric_limits<const volatile T>::digits10 == expected, "digits10 test 4");
28 static_assert(std::numeric_limits<const volatile T>::is_bounded, "digits10 test 8");
35 test<signed char, 2>();
36 test<unsigned char, 2>();
37 test<wchar_t, 5*sizeof(wchar_t)/2-1>(); // 4 -> 9 and 2 -> 4
38 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
41 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
43 test<unsigned short, 4>();
45 test<unsigned int, 9>();
46 test<long, sizeof(long) == 4 ? 9 : 18>();
47 test<unsigned long, sizeof(long) == 4 ? 9 : 19>();
48 test<long long, 18>();
49 test<unsigned long long, 19>();
50 #ifndef _LIBCPP_HAS_NO_INT128
51 test<__int128_t, 38>();
52 test<__uint128_t, 38>();
54 test<float, FLT_DIG>();
55 test<double, DBL_DIG>();
56 test<long double, LDBL_DIG>();