Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / libstdc++-v3 / testsuite / 18_support / numeric_limits / dr559.cc
1 // { dg-options "-std=gnu++0x" }
2
3 // 2010-02-17  Paolo Carlini  <paolo.carlini@oracle.com>
4 //
5 // Copyright (C) 2010-2013 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>
27   void do_test_aux()
28   {
29     bool test __attribute__((unused)) = true;
30     typedef std::numeric_limits<T> cv_limits;
31     typedef std::numeric_limits<typename std::remove_cv<T>::type> limits;
32
33     VERIFY( cv_limits::is_specialized == limits::is_specialized );
34     VERIFY( cv_limits::min() == limits::min() );
35     VERIFY( cv_limits::max() == limits::max() );
36     VERIFY( cv_limits::lowest() == limits::lowest() );
37     VERIFY( cv_limits::digits == limits::digits );
38     VERIFY( cv_limits::digits10 == limits::digits10 );
39     VERIFY( cv_limits::max_digits10 == limits::max_digits10 );
40     VERIFY( cv_limits::is_signed == limits::is_signed );
41     VERIFY( cv_limits::is_integer == limits::is_integer );
42     VERIFY( cv_limits::is_exact == limits::is_exact );
43     VERIFY( cv_limits::radix == limits::radix );
44     VERIFY( cv_limits::epsilon() == limits::epsilon() );
45     VERIFY( cv_limits::round_error() == limits::round_error() );
46     VERIFY( cv_limits::min_exponent == limits::min_exponent );
47     VERIFY( cv_limits::min_exponent10 == limits::min_exponent10 );
48     VERIFY( cv_limits::max_exponent == limits::max_exponent );
49     VERIFY( cv_limits::max_exponent10 == limits::max_exponent10 );
50     VERIFY( cv_limits::has_infinity == limits::has_infinity );
51     VERIFY( cv_limits::has_quiet_NaN == limits::has_quiet_NaN );
52     VERIFY( cv_limits::has_signaling_NaN == limits::has_signaling_NaN );
53     VERIFY( cv_limits::has_denorm == limits::has_denorm );
54     VERIFY( cv_limits::has_denorm_loss == limits::has_denorm_loss );
55     VERIFY( cv_limits::infinity() == limits::infinity() );
56     if (!std::is_floating_point<T>::value)
57       {
58         VERIFY( cv_limits::quiet_NaN() == limits::quiet_NaN() );
59         VERIFY( cv_limits::signaling_NaN() == limits::signaling_NaN() );
60       }
61     VERIFY( cv_limits::denorm_min() == limits::denorm_min() );
62     VERIFY( cv_limits::is_iec559 == limits::is_iec559 );
63     VERIFY( cv_limits::is_bounded == limits::is_bounded );
64     VERIFY( cv_limits::is_modulo == limits::is_modulo );
65     VERIFY( cv_limits::traps == limits::traps );
66     VERIFY( cv_limits::tinyness_before == limits::tinyness_before );
67     VERIFY( cv_limits::round_style == limits::round_style );
68   }
69
70 template<typename T>
71   void
72   do_test()
73   {
74     do_test_aux<T>();
75     do_test_aux<const T>();
76     do_test_aux<volatile T>();
77     do_test_aux<const volatile T>();
78   }
79
80 // DR 559.
81 int main()
82 {
83   do_test<bool>();
84   do_test<char>();
85   do_test<signed char>();
86   do_test<unsigned char>();
87   do_test<wchar_t>();
88   do_test<char16_t>();
89   do_test<char32_t>();
90   do_test<short>();
91   do_test<unsigned short>();
92   do_test<int>();
93   do_test<unsigned int>();
94   do_test<long>();
95   do_test<unsigned long>();
96   do_test<long long>();
97   do_test<unsigned long long>();
98   // GNU Extensions.
99 #ifdef _GLIBCXX_USE_INT128
100   do_test<__int128>();
101   do_test<unsigned __int128>();
102 #endif
103   do_test<float>();
104   do_test<double>();
105   do_test<long double>();
106   return 0;
107 }