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 #include "test_macros.h"
19 template <class T, int expected>
23 static_assert(std::numeric_limits<T>::digits10 == expected, "digits10 test 1");
24 static_assert(std::numeric_limits<T>::is_bounded, "digits10 test 5");
25 static_assert(std::numeric_limits<const T>::digits10 == expected, "digits10 test 2");
26 static_assert(std::numeric_limits<const T>::is_bounded, "digits10 test 6");
27 static_assert(std::numeric_limits<volatile T>::digits10 == expected, "digits10 test 3");
28 static_assert(std::numeric_limits<volatile T>::is_bounded, "digits10 test 7");
29 static_assert(std::numeric_limits<const volatile T>::digits10 == expected, "digits10 test 4");
30 static_assert(std::numeric_limits<const volatile T>::is_bounded, "digits10 test 8");
37 test<signed char, 2>();
38 test<unsigned char, 2>();
39 test<wchar_t, 5*sizeof(wchar_t)/2-1>(); // 4 -> 9 and 2 -> 4
40 #if TEST_STD_VER > 17 && defined(__cpp_char8_t)
43 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
46 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
48 test<unsigned short, 4>();
50 test<unsigned int, 9>();
51 test<long, sizeof(long) == 4 ? 9 : 18>();
52 test<unsigned long, sizeof(long) == 4 ? 9 : 19>();
53 test<long long, 18>();
54 test<unsigned long long, 19>();
55 #ifndef _LIBCPP_HAS_NO_INT128
56 test<__int128_t, 38>();
57 test<__uint128_t, 38>();
59 test<float, FLT_DIG>();
60 test<double, DBL_DIG>();
61 test<long double, LDBL_DIG>();