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