1 // { dg-do run { target c++11 } }
2 
3 // 2010-02-17  Paolo Carlini  <paolo.carlini@oracle.com>
4 //
5 // Copyright (C) 2010-2021 Free Software Foundation, Inc.
6 //
7 // This file is part of the GNU ISO C++ Library.  This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
11 // any later version.
12 
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING3.  If not see
20 // <http://www.gnu.org/licenses/>.
21 
22 #include <limits>
23 #include <type_traits>
24 #include <testsuite_hooks.h>
25 
26 template<typename T>
do_test_aux()27   void do_test_aux()
28   {
29     typedef std::numeric_limits<T> cv_limits;
30     typedef std::numeric_limits<typename std::remove_cv<T>::type> limits;
31 
32     VERIFY( cv_limits::is_specialized == limits::is_specialized );
33     VERIFY( cv_limits::min() == limits::min() );
34     VERIFY( cv_limits::max() == limits::max() );
35     VERIFY( cv_limits::lowest() == limits::lowest() );
36     VERIFY( cv_limits::digits == limits::digits );
37     VERIFY( cv_limits::digits10 == limits::digits10 );
38     VERIFY( cv_limits::max_digits10 == limits::max_digits10 );
39     VERIFY( cv_limits::is_signed == limits::is_signed );
40     VERIFY( cv_limits::is_integer == limits::is_integer );
41     VERIFY( cv_limits::is_exact == limits::is_exact );
42     VERIFY( cv_limits::radix == limits::radix );
43     VERIFY( cv_limits::epsilon() == limits::epsilon() );
44     VERIFY( cv_limits::round_error() == limits::round_error() );
45     VERIFY( cv_limits::min_exponent == limits::min_exponent );
46     VERIFY( cv_limits::min_exponent10 == limits::min_exponent10 );
47     VERIFY( cv_limits::max_exponent == limits::max_exponent );
48     VERIFY( cv_limits::max_exponent10 == limits::max_exponent10 );
49     VERIFY( cv_limits::has_infinity == limits::has_infinity );
50     VERIFY( cv_limits::has_quiet_NaN == limits::has_quiet_NaN );
51     VERIFY( cv_limits::has_signaling_NaN == limits::has_signaling_NaN );
52     VERIFY( cv_limits::has_denorm == limits::has_denorm );
53     VERIFY( cv_limits::has_denorm_loss == limits::has_denorm_loss );
54     VERIFY( cv_limits::infinity() == limits::infinity() );
55     if (!std::is_floating_point<T>::value)
56       {
57 	VERIFY( cv_limits::quiet_NaN() == limits::quiet_NaN() );
58 	VERIFY( cv_limits::signaling_NaN() == limits::signaling_NaN() );
59       }
60     VERIFY( cv_limits::denorm_min() == limits::denorm_min() );
61     VERIFY( cv_limits::is_iec559 == limits::is_iec559 );
62     VERIFY( cv_limits::is_bounded == limits::is_bounded );
63     VERIFY( cv_limits::is_modulo == limits::is_modulo );
64     VERIFY( cv_limits::traps == limits::traps );
65     VERIFY( cv_limits::tinyness_before == limits::tinyness_before );
66     VERIFY( cv_limits::round_style == limits::round_style );
67   }
68 
69 template<typename T>
70   void
do_test()71   do_test()
72   {
73     do_test_aux<T>();
74     do_test_aux<const T>();
75     do_test_aux<volatile T>();
76     do_test_aux<const volatile T>();
77   }
78 
79 // DR 559.
main()80 int main()
81 {
82   do_test<bool>();
83   do_test<char>();
84   do_test<signed char>();
85   do_test<unsigned char>();
86   do_test<wchar_t>();
87 #ifdef _GLIBCXX_USE_CHAR8_T
88   do_test<char8_t>();
89 #endif
90   do_test<char16_t>();
91   do_test<char32_t>();
92   do_test<short>();
93   do_test<unsigned short>();
94   do_test<int>();
95   do_test<unsigned int>();
96   do_test<long>();
97   do_test<unsigned long>();
98   do_test<long long>();
99   do_test<unsigned long long>();
100   // GNU Extensions.
101 #ifdef _GLIBCXX_USE_INT128
102   do_test<__int128>();
103   do_test<unsigned __int128>();
104 #endif
105   do_test<float>();
106   do_test<double>();
107   do_test<long double>();
108   return 0;
109 }
110