blob: af93e78c0e915005ea31e98d0e192ab4313d565b [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// test numeric_limits
11
12// traps
13
14#include <limits>
15
Dan Albert1d4a1ed2016-05-25 22:36:09 -070016#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__)
Marshall Clow13fbe9d2014-02-03 23:26:56 +000017static const bool integral_types_trap = true;
18#else
19static const bool integral_types_trap = false;
20#endif
21
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000022template <class T, bool expected>
23void
24test()
25{
26 static_assert(std::numeric_limits<T>::traps == expected, "traps test 1");
27 static_assert(std::numeric_limits<const T>::traps == expected, "traps test 2");
28 static_assert(std::numeric_limits<volatile T>::traps == expected, "traps test 3");
29 static_assert(std::numeric_limits<const volatile T>::traps == expected, "traps test 4");
30}
31
32int main()
33{
34 test<bool, false>();
Marshall Clow13fbe9d2014-02-03 23:26:56 +000035 test<char, integral_types_trap>();
36 test<signed char, integral_types_trap>();
37 test<unsigned char, integral_types_trap>();
38 test<wchar_t, integral_types_trap>();
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000039#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
Marshall Clow13fbe9d2014-02-03 23:26:56 +000040 test<char16_t, integral_types_trap>();
41 test<char32_t, integral_types_trap>();
Howard Hinnantcf6dcc32010-08-22 00:31:12 +000042#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
Marshall Clow13fbe9d2014-02-03 23:26:56 +000043 test<short, integral_types_trap>();
44 test<unsigned short, integral_types_trap>();
45 test<int, integral_types_trap>();
46 test<unsigned int, integral_types_trap>();
47 test<long, integral_types_trap>();
48 test<unsigned long, integral_types_trap>();
49 test<long long, integral_types_trap>();
50 test<unsigned long long, integral_types_trap>();
Stephan Tolksdorf8a71d232014-03-26 19:45:52 +000051#ifndef _LIBCPP_HAS_NO_INT128
52 test<__int128_t, integral_types_trap>();
53 test<__uint128_t, integral_types_trap>();
54#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000055 test<float, false>();
56 test<double, false>();
57 test<long double, false>();
58}