]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/18_support/numeric_limits/max_digits10.cc
Update copyright in libstdc++-v3.
[thirdparty/gcc.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-2013 Free Software Foundation, Inc.
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 // GNU Extensions.
51 #ifdef _GLIBCXX_USE_INT128
52 VERIFY( std::numeric_limits<__int128>::max_digits10 == 0 );
53 VERIFY( std::numeric_limits<unsigned __int128>::max_digits10 == 0 );
54 #endif
55
56 const int f_max_digits10 = (2 + std::numeric_limits<float>::digits
57 * 643 / 2136);
58 VERIFY( std::numeric_limits<float>::max_digits10 == f_max_digits10 );
59
60 const int d_max_digits10 = (2 + std::numeric_limits<double>::digits
61 * 643 / 2136);
62 VERIFY( std::numeric_limits<double>::max_digits10 == d_max_digits10 );
63
64 const int ld_max_digits10 = (2 + std::numeric_limits<long double>::digits
65 * 643 / 2136);
66 VERIFY( std::numeric_limits<long double>::max_digits10 == ld_max_digits10 );
67 }
68
69 int main()
70 {
71 test01();
72 return 0;
73 }