OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [18_support/] [numeric_limits/] [min_max.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jlechner
// { dg-options "-mieee" { target alpha*-*-* } }
2
// { dg-options "-mieee" { target sh*-*-* } }
3
 
4
// 1999-08-23 bkoz
5
 
6
// Copyright (C) 1999, 2001, 2002, 2003, 2004 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 2, 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 COPYING.  If not, write to the Free
21
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22
// USA.
23
 
24
// 18.2.1.1 template class numeric_limits
25
 
26
#include <limits>
27
#include <limits.h>
28
#include <float.h>
29
#include <cwchar>
30
#include <testsuite_hooks.h>
31
 
32
template<typename T>
33
struct extrema {
34
  static T min;
35
  static T max;
36
};
37
 
38
 
39
#define DEFINE_EXTREMA(T, m, M) \
40
  template<> T extrema<T>::min = m; \
41
  template<> T extrema<T>::max = M
42
 
43
DEFINE_EXTREMA(char, CHAR_MIN, CHAR_MAX);
44
DEFINE_EXTREMA(signed char, SCHAR_MIN, SCHAR_MAX);
45
DEFINE_EXTREMA(unsigned char, 0, UCHAR_MAX);
46
DEFINE_EXTREMA(short, SHRT_MIN, SHRT_MAX);
47
DEFINE_EXTREMA(unsigned short, 0, USHRT_MAX);
48
DEFINE_EXTREMA(int, INT_MIN, INT_MAX);
49
DEFINE_EXTREMA(unsigned, 0U, UINT_MAX);
50
DEFINE_EXTREMA(long, LONG_MIN, LONG_MAX);
51
DEFINE_EXTREMA(unsigned long, 0UL, ULONG_MAX);
52
 
53
#if _GLIBCXX_USE_WCHAR_T
54
DEFINE_EXTREMA(wchar_t, WCHAR_MIN, WCHAR_MAX);
55
#endif //_GLIBCXX_USE_WCHAR_T
56
 
57
DEFINE_EXTREMA(float, FLT_MIN, FLT_MAX);
58
DEFINE_EXTREMA(double, DBL_MIN, DBL_MAX);
59
DEFINE_EXTREMA(long double, LDBL_MIN, LDBL_MAX);
60
 
61
#undef DEFINE_EXTREMA
62
 
63
template<typename T>
64
void test_extrema()
65
{
66
  bool test __attribute__((unused)) = true;
67
  T limits_min = std::numeric_limits<T>::min();
68
  T limits_max = std::numeric_limits<T>::max();
69
  T extrema_min = extrema<T>::min;
70
  T extrema_max = extrema<T>::max;
71
  VERIFY( extrema_min == limits_min );
72
  VERIFY( extrema_max == limits_max );
73
}
74
 
75
int main()
76
{
77
  test_extrema<char>();
78
  test_extrema<signed char>();
79
  test_extrema<unsigned char>();
80
 
81
  test_extrema<short>();
82
  test_extrema<unsigned short>();
83
 
84
  test_extrema<int>();
85
  test_extrema<unsigned>();
86
 
87
  test_extrema<long>();
88
  test_extrema<unsigned long>();
89
 
90
  test_extrema<float>();
91
  test_extrema<double>();
92
  test_extrema<long double>();
93
 
94
  return 0;
95
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.