]> git.ipfire.org Git - thirdparty/gcc.git/blame - 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
CommitLineData
52066eae 1// { dg-do run { target c++11 } }
018afad3
ESR
2// { dg-add-options ieee }
3
4// 2010-02-25 Ed Smith-Rowland
5
7adcbafe 6// Copyright (C) 2010-2022 Free Software Foundation, Inc.
018afad3
ESR
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
29void
30test01()
31{
018afad3
ESR
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 );
59019b42
TH
45#ifdef _GLIBCXX_USE_CHAR8_T
46 VERIFY( std::numeric_limits<char8_t>::max_digits10 == 0 );
47#endif
018afad3
ESR
48 VERIFY( std::numeric_limits<char16_t>::max_digits10 == 0 );
49 VERIFY( std::numeric_limits<char32_t>::max_digits10 == 0 );
50
12bfa8bd 51 // GNU Extensions.
29a9de9b 52#ifdef __SIZEOF_INT128__
fd1e62c2
PC
53 VERIFY( std::numeric_limits<__int128>::max_digits10 == 0 );
54 VERIFY( std::numeric_limits<unsigned __int128>::max_digits10 == 0 );
12bfa8bd
PC
55#endif
56
018afad3
ESR
57 const int f_max_digits10 = (2 + std::numeric_limits<float>::digits
58 * 643 / 2136);
59 VERIFY( std::numeric_limits<float>::max_digits10 == f_max_digits10 );
60
61 const int d_max_digits10 = (2 + std::numeric_limits<double>::digits
62 * 643 / 2136);
63 VERIFY( std::numeric_limits<double>::max_digits10 == d_max_digits10 );
64
65 const int ld_max_digits10 = (2 + std::numeric_limits<long double>::digits
66 * 643 / 2136);
67 VERIFY( std::numeric_limits<long double>::max_digits10 == ld_max_digits10 );
68}
69
70int main()
71{
72 test01();
73 return 0;
74}