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 // lowest() 13 14 #include <limits> 15 #include <climits> 16 #include <cwchar> 17 #include <cfloat> 18 #include <cassert> 19 20 template <class T> 21 void 22 test(T expected) 23 { 24 assert(std::numeric_limits<T>::lowest() == expected); 25 assert(std::numeric_limits<T>::is_bounded); 26 assert(std::numeric_limits<const T>::lowest() == expected); 27 assert(std::numeric_limits<const T>::is_bounded); 28 assert(std::numeric_limits<volatile T>::lowest() == expected); 29 assert(std::numeric_limits<volatile T>::is_bounded); 30 assert(std::numeric_limits<const volatile T>::lowest() == expected); 31 assert(std::numeric_limits<const volatile T>::is_bounded); 32 } 33 34 int main() 35 { 36 test<bool>(false); 37 test<char>(CHAR_MIN); 38 test<signed char>(SCHAR_MIN); 39 test<unsigned char>(0); 40 test<wchar_t>(WCHAR_MIN); 41 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 42 test<char16_t>(0); 43 test<char32_t>(0); 44 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS 45 test<short>(SHRT_MIN); 46 test<unsigned short>(0); 47 test<int>(INT_MIN); 48 test<unsigned int>(0); 49 test<long>(LONG_MIN); 50 test<unsigned long>(0); 51 test<long long>(LLONG_MIN); 52 test<unsigned long long>(0); 53 test<float>(-FLT_MAX); 54 test<double>(-DBL_MAX); 55 test<long double>(-LDBL_MAX); 56 } 57