OSDN Git Service

2010-02-25 Ed Smith-Rowland <3dw4rd@verizon.net>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / testsuite / 18_support / numeric_limits / max_digits10.cc
1 // { dg-options "-std=gnu++0x" }
2 // { dg-add-options ieee }
3
4 // 2010-02-25  Ed Smith-Rowland
5
6 // Copyright (C) 2010 Free Software Foundation
7 //
8 // This file is part of the GNU ISO C++ Library.  This library is free
9 // software; you can redistribute it and/or modify it under the
10 // terms of the GNU General Public License as published by the
11 // Free Software Foundation; either version 3, or (at your option)
12 // any later version.
13
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 // GNU General Public License for more details.
18
19 // You should have received a copy of the GNU General Public License along
20 // with this library; see the file COPYING3.  If not see
21 // <http://www.gnu.org/licenses/>.
22
23 // 18.2.1.1 template class numeric_limits
24
25 #include <limits>
26 #include <cmath>
27 #include <testsuite_hooks.h>
28
29 void
30 test01()
31 {
32   bool test __attribute__((unused)) = true;
33
34   VERIFY( std::numeric_limits<bool>::max_digits10 == 0 );
35   VERIFY( std::numeric_limits<char>::max_digits10 == 0 );
36   VERIFY( std::numeric_limits<signed char>::max_digits10 == 0 );
37   VERIFY( std::numeric_limits<unsigned char>::max_digits10 == 0 );
38   VERIFY( std::numeric_limits<wchar_t>::max_digits10 == 0 );
39   VERIFY( std::numeric_limits<short>::max_digits10 == 0 );
40   VERIFY( std::numeric_limits<unsigned short>::max_digits10 == 0 );
41   VERIFY( std::numeric_limits<int>::max_digits10 == 0 );
42   VERIFY( std::numeric_limits<unsigned int>::max_digits10 == 0 );
43   VERIFY( std::numeric_limits<long>::max_digits10 == 0 );
44   VERIFY( std::numeric_limits<unsigned long>::max_digits10 == 0 );
45   VERIFY( std::numeric_limits<long long>::max_digits10 == 0 );
46   VERIFY( std::numeric_limits<unsigned long long>::max_digits10 == 0 );
47   VERIFY( std::numeric_limits<char16_t>::max_digits10 == 0 );
48   VERIFY( std::numeric_limits<char32_t>::max_digits10 == 0 );
49
50   const int f_max_digits10 = (2 + std::numeric_limits<float>::digits
51                               * 643 / 2136);
52   VERIFY( std::numeric_limits<float>::max_digits10 == f_max_digits10 );
53
54   const int d_max_digits10 = (2 + std::numeric_limits<double>::digits
55                               * 643 / 2136);
56   VERIFY( std::numeric_limits<double>::max_digits10 == d_max_digits10 );
57
58   const int ld_max_digits10 = (2 + std::numeric_limits<long double>::digits
59                                * 643 / 2136);
60   VERIFY( std::numeric_limits<long double>::max_digits10 == ld_max_digits10 );
61 }
62
63 int main()
64 {
65   test01();
66   return 0;
67 }