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