]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/18_support/numeric_limits/max_digits10.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 18_support / numeric_limits / max_digits10.cc
1 // { dg-do run { target c++11 } }
2 // { dg-add-options ieee }
3
4 // 2010-02-25 Ed Smith-Rowland
5
6 // Copyright (C) 2010-2017 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 VERIFY( std::numeric_limits<bool>::max_digits10 == 0 );
33 VERIFY( std::numeric_limits<char>::max_digits10 == 0 );
34 VERIFY( std::numeric_limits<signed char>::max_digits10 == 0 );
35 VERIFY( std::numeric_limits<unsigned char>::max_digits10 == 0 );
36 VERIFY( std::numeric_limits<wchar_t>::max_digits10 == 0 );
37 VERIFY( std::numeric_limits<short>::max_digits10 == 0 );
38 VERIFY( std::numeric_limits<unsigned short>::max_digits10 == 0 );
39 VERIFY( std::numeric_limits<int>::max_digits10 == 0 );
40 VERIFY( std::numeric_limits<unsigned int>::max_digits10 == 0 );
41 VERIFY( std::numeric_limits<long>::max_digits10 == 0 );
42 VERIFY( std::numeric_limits<unsigned long>::max_digits10 == 0 );
43 VERIFY( std::numeric_limits<long long>::max_digits10 == 0 );
44 VERIFY( std::numeric_limits<unsigned long long>::max_digits10 == 0 );
45 VERIFY( std::numeric_limits<char16_t>::max_digits10 == 0 );
46 VERIFY( std::numeric_limits<char32_t>::max_digits10 == 0 );
47
48 // GNU Extensions.
49 #ifdef _GLIBCXX_USE_INT128
50 VERIFY( std::numeric_limits<__int128>::max_digits10 == 0 );
51 VERIFY( std::numeric_limits<unsigned __int128>::max_digits10 == 0 );
52 #endif
53
54 const int f_max_digits10 = (2 + std::numeric_limits<float>::digits
55 * 643 / 2136);
56 VERIFY( std::numeric_limits<float>::max_digits10 == f_max_digits10 );
57
58 const int d_max_digits10 = (2 + std::numeric_limits<double>::digits
59 * 643 / 2136);
60 VERIFY( std::numeric_limits<double>::max_digits10 == d_max_digits10 );
61
62 const int ld_max_digits10 = (2 + std::numeric_limits<long double>::digits
63 * 643 / 2136);
64 VERIFY( std::numeric_limits<long double>::max_digits10 == ld_max_digits10 );
65 }
66
67 int main()
68 {
69 test01();
70 return 0;
71 }