3 // Copyright (C) 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23 #include <testsuite_hooks.h>
27 bool test
__attribute__((unused
)) = true;
29 const int& x
= std::max(1, 2);
30 const int& y
= std::max(4, 3);
34 const int& xc
= std::max(1, 2, std::greater
<int>());
35 const int& yc
= std::max(4, 3, std::greater
<int>());
39 const int& z
= std::min(1, 2);
40 const int& w
= std::min(4, 3);
44 const int& zc
= std::min(1, 2, std::greater
<int>());
45 const int& wc
= std::min(4, 3, std::greater
<int>());
51 struct A
{ static const T a
; };
54 const T A
<T
>::a
= T(3);
58 bool test
__attribute__((unused
)) = true;
60 VERIFY( 2 == std::min(A
<int>::a
, 2) );
61 VERIFY( 3 == std::min(A
<int>::a
, 4) );
63 VERIFY( 2u == std::min(A
<unsigned int>::a
, 2u) );
64 VERIFY( 3u == std::min(A
<unsigned int>::a
, 4u) );
66 VERIFY( 2l == std::min(A
<long>::a
, 2l) );
67 VERIFY( 3l == std::min(A
<long>::a
, 4l) );
69 VERIFY( 2ul == std::min(A
<unsigned long>::a
, 2ul) );
70 VERIFY( 3ul == std::min(A
<unsigned long>::a
, 4ul) );
72 #ifdef _GLIBCXX_USE_LONG_LONG
73 VERIFY( 2ll == std::min(A
<long long>::a
, 2ll) );
74 VERIFY( 3ll == std::min(A
<long long>::a
, 4ll) );
76 VERIFY( 2ull == std::min(A
<unsigned long long>::a
, 2ull) );
77 VERIFY( 3ull == std::min(A
<unsigned long long>::a
, 4ull) );
80 VERIFY( short(2) == std::min(A
<short>::a
, short(2)) );
81 VERIFY( short(3) == std::min(A
<short>::a
, short(4)) );
83 VERIFY( (unsigned short)2 == std::min(A
<unsigned short>::a
, (unsigned short)2) );
84 VERIFY( (unsigned short)3 == std::min(A
<unsigned short>::a
, (unsigned short)4) );
86 VERIFY( (char)2 == std::min(A
<char>::a
, (char)2) );
87 VERIFY( (char)3 == std::min(A
<char>::a
, (char)4) );
89 VERIFY( (signed char)2 == std::min(A
<signed char>::a
, (signed char)2) );
90 VERIFY( (signed char)3 == std::min(A
<signed char>::a
, (signed char)4) );
92 VERIFY( (unsigned char)2 == std::min(A
<unsigned char>::a
, (unsigned char)2) );
93 VERIFY( (unsigned char)3 == std::min(A
<unsigned char>::a
, (unsigned char)4) );
95 VERIFY( (wchar_t)2 == std::min(A
<wchar_t>::a
, (wchar_t)2) );
96 VERIFY( (wchar_t)3 == std::min(A
<wchar_t>::a
, (wchar_t)4) );
98 VERIFY( 2.0 == std::min(A
<double>::a
, 2.0) );
99 VERIFY( 3.0 == std::min(A
<double>::a
, 4.0) );
101 VERIFY( float(2) == std::min(A
<float>::a
, float(2)) );
102 VERIFY( float(3) == std::min(A
<float>::a
, float(4)) );
104 VERIFY( (long double)2 == std::min(A
<long double>::a
, (long double)2) );
105 VERIFY( (long double)3 == std::min(A
<long double>::a
, (long double)4) );
108 VERIFY( 3 == std::max(A
<int>::a
, 2) );
109 VERIFY( 4 == std::max(A
<int>::a
, 4) );
111 VERIFY( 3u == std::max(A
<unsigned int>::a
, 2u) );
112 VERIFY( 4u == std::max(A
<unsigned int>::a
, 4u) );
114 VERIFY( 3l == std::max(A
<long>::a
, 2l) );
115 VERIFY( 4l == std::max(A
<long>::a
, 4l) );
117 VERIFY( 3ul == std::max(A
<unsigned long>::a
, 2ul) );
118 VERIFY( 4ul == std::max(A
<unsigned long>::a
, 4ul) );
120 #ifdef _GLIBCXX_USE_LONG_LONG
121 VERIFY( 3ll == std::max(A
<long long>::a
, 2ll) );
122 VERIFY( 4ll == std::max(A
<long long>::a
, 4ll) );
124 VERIFY( 3ull == std::max(A
<unsigned long long>::a
, 2ull) );
125 VERIFY( 4ull == std::max(A
<unsigned long long>::a
, 4ull) );
128 VERIFY( short(3) == std::max(A
<short>::a
, short(2)) );
129 VERIFY( short(4) == std::max(A
<short>::a
, short(4)) );
131 VERIFY( (unsigned short)3 == std::max(A
<unsigned short>::a
, (unsigned short)2) );
132 VERIFY( (unsigned short)4 == std::max(A
<unsigned short>::a
, (unsigned short)4) );
134 VERIFY( (char)3 == std::max(A
<char>::a
, (char)2) );
135 VERIFY( (char)4 == std::max(A
<char>::a
, (char)4) );
137 VERIFY( (signed char)3 == std::max(A
<signed char>::a
, (signed char)2) );
138 VERIFY( (signed char)4 == std::max(A
<signed char>::a
, (signed char)4) );
140 VERIFY( (unsigned char)3 == std::max(A
<unsigned char>::a
, (unsigned char)2) );
141 VERIFY( (unsigned char)4 == std::max(A
<unsigned char>::a
, (unsigned char)4) );
143 VERIFY( (wchar_t)3 == std::max(A
<wchar_t>::a
, (wchar_t)2) );
144 VERIFY( (wchar_t)4 == std::max(A
<wchar_t>::a
, (wchar_t)4) );