]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/18_support/numeric_limits/specialization_default_values.cc
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 18_support / numeric_limits / specialization_default_values.cc
1 // { dg-add-options ieee }
2
3 // 1999-08-23 bkoz
4
5 // Copyright (C) 1999-2014 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 // 18.2.1.1 template class numeric_limits
23
24 #include <limits>
25 #include <limits.h>
26 #include <float.h>
27 #include <cwchar>
28 #include <testsuite_hooks.h>
29
30 template<typename T>
31 struct A
32 {
33 int key;
34 public:
35 A(int i = 0): key(i) { }
36 bool
37 operator==(int i) { return i == key; }
38 };
39
40 struct B
41 {
42 B(int = 0) { }
43 };
44
45
46 bool test01()
47 {
48 bool test __attribute__((unused)) = true;
49 std::numeric_limits< A<B> > obj;
50
51 VERIFY( !obj.is_specialized );
52 VERIFY( obj.min() == 0 );
53 VERIFY( obj.max() == 0 );
54 VERIFY( obj.digits == 0 );
55 VERIFY( obj.digits10 == 0 );
56 VERIFY( !obj.is_signed );
57 VERIFY( !obj.is_integer );
58 VERIFY( !obj.is_exact );
59 VERIFY( obj.radix == 0 );
60 VERIFY( obj.epsilon() == 0 );
61 VERIFY( obj.round_error() == 0 );
62 VERIFY( obj.min_exponent == 0 );
63 VERIFY( obj.min_exponent10 == 0 );
64 VERIFY( obj.max_exponent == 0 );
65 VERIFY( obj.max_exponent10 == 0 );
66 VERIFY( !obj.has_infinity );
67 VERIFY( !obj.has_quiet_NaN );
68 VERIFY( !obj.has_signaling_NaN );
69 VERIFY( !obj.has_denorm );
70 VERIFY( !obj.has_denorm_loss );
71 VERIFY( obj.infinity() == 0 );
72 VERIFY( obj.quiet_NaN() == 0 );
73 VERIFY( obj.signaling_NaN() == 0 );
74 VERIFY( obj.denorm_min() == 0 );
75 VERIFY( !obj.is_iec559 );
76 VERIFY( !obj.is_bounded );
77 VERIFY( !obj.is_modulo );
78 VERIFY( !obj.traps );
79 VERIFY( !obj.tinyness_before );
80 VERIFY( obj.round_style == std::round_toward_zero );
81 return test;
82 }
83
84 // test linkage of the generic bits
85 template struct std::numeric_limits<B>;
86
87 void test02()
88 {
89 typedef std::numeric_limits<B> b_nl_type;
90
91 // Should probably do all of them...
92 const int* __attribute__((unused)) pi1 = &b_nl_type::digits;
93 const int* __attribute__((unused)) pi2 = &b_nl_type::digits10;
94 const int* __attribute__((unused)) pi3 = &b_nl_type::max_exponent10;
95 const bool* __attribute__((unused)) pb1 = &b_nl_type::traps;
96 }
97
98
99 int main()
100 {
101 test01();
102 test02();
103
104 return 0;
105 }