has_signaling_NaN.pass.cpp (1742B)
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 // has_signaling_NaN 13 14 #include <limits> 15 16 #include "test_macros.h" 17 18 template <class T, bool expected> 19 void 20 test() 21 { 22 static_assert(std::numeric_limits<T>::has_signaling_NaN == expected, "has_signaling_NaN test 1"); 23 static_assert(std::numeric_limits<const T>::has_signaling_NaN == expected, "has_signaling_NaN test 2"); 24 static_assert(std::numeric_limits<volatile T>::has_signaling_NaN == expected, "has_signaling_NaN test 3"); 25 static_assert(std::numeric_limits<const volatile T>::has_signaling_NaN == expected, "has_signaling_NaN test 4"); 26 } 27 28 int main() 29 { 30 test<bool, false>(); 31 test<char, false>(); 32 test<signed char, false>(); 33 test<unsigned char, false>(); 34 test<wchar_t, false>(); 35 #if TEST_STD_VER > 17 && defined(__cpp_char8_t) 36 test<char8_t, false>(); 37 #endif 38 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 39 test<char16_t, false>(); 40 test<char32_t, false>(); 41 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS 42 test<short, false>(); 43 test<unsigned short, false>(); 44 test<int, false>(); 45 test<unsigned int, false>(); 46 test<long, false>(); 47 test<unsigned long, false>(); 48 test<long long, false>(); 49 test<unsigned long long, false>(); 50 #ifndef _LIBCPP_HAS_NO_INT128 51 test<__int128_t, false>(); 52 test<__uint128_t, false>(); 53 #endif 54 test<float, true>(); 55 test<double, true>(); 56 test<long double, true>(); 57 }