summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/18_support/numeric_limits/dr559.cc
blob: 150db95880720f5d95492f2f7e6d0bd2ba655857 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// { dg-do run { target c++11 } }

// 2010-02-17  Paolo Carlini  <paolo.carlini@oracle.com>
//
// Copyright (C) 2010-2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3.  If not see
// <http://www.gnu.org/licenses/>.

#include <limits>
#include <type_traits>
#include <testsuite_hooks.h>

template<typename T>
  void do_test_aux()
  {
    typedef std::numeric_limits<T> cv_limits;
    typedef std::numeric_limits<typename std::remove_cv<T>::type> limits;

    VERIFY( cv_limits::is_specialized == limits::is_specialized );
    VERIFY( cv_limits::min() == limits::min() );
    VERIFY( cv_limits::max() == limits::max() );
    VERIFY( cv_limits::lowest() == limits::lowest() );
    VERIFY( cv_limits::digits == limits::digits );
    VERIFY( cv_limits::digits10 == limits::digits10 );
    VERIFY( cv_limits::max_digits10 == limits::max_digits10 );
    VERIFY( cv_limits::is_signed == limits::is_signed );
    VERIFY( cv_limits::is_integer == limits::is_integer );
    VERIFY( cv_limits::is_exact == limits::is_exact );
    VERIFY( cv_limits::radix == limits::radix );
    VERIFY( cv_limits::epsilon() == limits::epsilon() );
    VERIFY( cv_limits::round_error() == limits::round_error() );
    VERIFY( cv_limits::min_exponent == limits::min_exponent );
    VERIFY( cv_limits::min_exponent10 == limits::min_exponent10 );
    VERIFY( cv_limits::max_exponent == limits::max_exponent );
    VERIFY( cv_limits::max_exponent10 == limits::max_exponent10 );
    VERIFY( cv_limits::has_infinity == limits::has_infinity );
    VERIFY( cv_limits::has_quiet_NaN == limits::has_quiet_NaN );
    VERIFY( cv_limits::has_signaling_NaN == limits::has_signaling_NaN );
    VERIFY( cv_limits::has_denorm == limits::has_denorm );
    VERIFY( cv_limits::has_denorm_loss == limits::has_denorm_loss );
    VERIFY( cv_limits::infinity() == limits::infinity() );
    if (!std::is_floating_point<T>::value)
      {
	VERIFY( cv_limits::quiet_NaN() == limits::quiet_NaN() );
	VERIFY( cv_limits::signaling_NaN() == limits::signaling_NaN() );
      }
    VERIFY( cv_limits::denorm_min() == limits::denorm_min() );
    VERIFY( cv_limits::is_iec559 == limits::is_iec559 );
    VERIFY( cv_limits::is_bounded == limits::is_bounded );
    VERIFY( cv_limits::is_modulo == limits::is_modulo );
    VERIFY( cv_limits::traps == limits::traps );
    VERIFY( cv_limits::tinyness_before == limits::tinyness_before );
    VERIFY( cv_limits::round_style == limits::round_style );
  }

template<typename T>
  void
  do_test()
  {
    do_test_aux<T>();
    do_test_aux<const T>();
    do_test_aux<volatile T>();
    do_test_aux<const volatile T>();
  }

// DR 559.
int main()
{
  do_test<bool>();
  do_test<char>();
  do_test<signed char>();
  do_test<unsigned char>();
  do_test<wchar_t>();
  do_test<char16_t>();
  do_test<char32_t>();
  do_test<short>();
  do_test<unsigned short>();
  do_test<int>();
  do_test<unsigned int>();
  do_test<long>();
  do_test<unsigned long>();
  do_test<long long>();
  do_test<unsigned long long>();
  // GNU Extensions.
#ifdef _GLIBCXX_USE_INT128
  do_test<__int128>();
  do_test<unsigned __int128>();
#endif
  do_test<float>();
  do_test<double>();
  do_test<long double>();
  return 0;
}