+2007-09-09 Benjamin Kosnik <bkoz@redhat.com>
+
+ * testsuite/25_algorithms/binary_search.cc: Move...
+ * testsuite/25_algorithms/binary_search/2.cc: ...here.
+
+ * testsuite/25_algorithms/sort.cc: Move...
+ * testsuite/25_algorithms/sort/1.cc: ...here.
+ * testsuite/25_algorithms/partial_sort_copy/2.cc: ...here.
+ * testsuite/25_algorithms/nth_element/3.cc: ...here.
+ * testsuite/25_algorithms/partial_sort/2.cc: ...here.
+ * testsuite/25_algorithms/stable_sort/2.cc: ...here.
+
+ * testsuite/25_algorithms/min_max.cc: Move...
+ * testsuite/25_algorithms/min/1.cc: ...here.
+ * testsuite/25_algorithms/min/2.cc: ...here.
+ * testsuite/25_algorithms/max/1.cc: ...here.
+ * testsuite/25_algorithms/max/2.cc: ...here.
+
2007-09-09 Joseph Myers <joseph@codesourcery.com>
* testsuite/lib/libstdc++.exp (v3-build-support): Specify output
+++ /dev/null
-// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
-// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 25.3.3 [lib.alg.binary.search] Binary search algorithms.
-
-#include <algorithm>
-#include <testsuite_hooks.h>
-
-bool test __attribute__((unused)) = true;
-
-const int A[] = {1, 2, 3, 3, 3, 5, 8};
-const int C[] = {8, 5, 3, 3, 3, 2, 1};
-const int N = sizeof(A) / sizeof(int);
-
-// A comparison, equalivalent to std::greater<int> without the
-// dependency on <functional>.
-
-struct gt
-{
- bool
- operator()(const int& x, const int& y) const
- { return x > y; }
-};
-
-// Each test performs general-case, bookend, not-found condition,
-// and predicate functional checks.
-
-// 25.3.3.1 lower_bound, with and without comparison predicate
-void
-test01()
-{
- using std::lower_bound;
-
- const int first = A[0];
- const int last = A[N - 1];
-
- const int* p = lower_bound(A, A + N, 3);
- VERIFY(p == A + 2);
-
- const int* q = lower_bound(A, A + N, first);
- VERIFY(q == A + 0);
-
- const int* r = lower_bound(A, A + N, last);
- VERIFY(r == A + N - 1);
-
- const int* s = lower_bound(A, A + N, 4);
- VERIFY(s == A + 5);
-
- const int* t = lower_bound(C, C + N, 3, gt());
- VERIFY(t == C + 2);
-
- const int* u = lower_bound(C, C + N, first, gt());
- VERIFY(u == C + N - 1);
-
- const int* v = lower_bound(C, C + N, last, gt());
- VERIFY(v == C + 0);
-
- const int* w = lower_bound(C, C + N, 4, gt());
- VERIFY(w == C + 2);
-}
-
-// 25.3.3.2 upper_bound, with and without comparison predicate
-void
-test02()
-{
- using std::upper_bound;
-
- const int first = A[0];
- const int last = A[N - 1];
-
- const int* p = upper_bound(A, A + N, 3);
- VERIFY(p == A + 5);
-
- const int* q = upper_bound(A, A + N, first);
- VERIFY(q == A + 1);
-
- const int* r = upper_bound(A, A + N, last);
- VERIFY(r == A + N);
-
- const int* s = upper_bound(A, A + N, 4);
- VERIFY(s == A + 5);
-
- const int* t = upper_bound(C, C + N, 3, gt());
- VERIFY(t == C + 5);
-
- const int* u = upper_bound(C, C + N, first, gt());
- VERIFY(u == C + N);
-
- const int* v = upper_bound(C, C + N, last, gt());
- VERIFY(v == C + 1);
-
- const int* w = upper_bound(C, C + N, 4, gt());
- VERIFY(w == C + 2);
-}
-
-// 25.3.3.3 equal_range, with and without comparison predicate
-void
-test03()
-{
- using std::equal_range;
- typedef std::pair<const int*, const int*> Ipair;
-
- const int first = A[0];
- const int last = A[N - 1];
-
- Ipair p = equal_range(A, A + N, 3);
- VERIFY(p.first == A + 2);
- VERIFY(p.second == A + 5);
-
- Ipair q = equal_range(A, A + N, first);
- VERIFY(q.first == A + 0);
- VERIFY(q.second == A + 1);
-
- Ipair r = equal_range(A, A + N, last);
- VERIFY(r.first == A + N - 1);
- VERIFY(r.second == A + N);
-
- Ipair s = equal_range(A, A + N, 4);
- VERIFY(s.first == A + 5);
- VERIFY(s.second == A + 5);
-
- Ipair t = equal_range(C, C + N, 3, gt());
- VERIFY(t.first == C + 2);
- VERIFY(t.second == C + 5);
-
- Ipair u = equal_range(C, C + N, first, gt());
- VERIFY(u.first == C + N - 1);
- VERIFY(u.second == C + N);
-
- Ipair v = equal_range(C, C + N, last, gt());
- VERIFY(v.first == C + 0);
- VERIFY(v.second == C + 1);
-
- Ipair w = equal_range(C, C + N, 4, gt());
- VERIFY(w.first == C + 2);
- VERIFY(w.second == C + 2);
-}
-
-// 25.3.3.4 binary_search, with and without comparison predicate
-void
-test04()
-{
- using std::binary_search;
-
- const int first = A[0];
- const int last = A[N - 1];
-
- VERIFY(binary_search(A, A + N, 5));
- VERIFY(binary_search(A, A + N, first));
- VERIFY(binary_search(A, A + N, last));
- VERIFY(!binary_search(A, A + N, 4));
-
- VERIFY(binary_search(C, C + N, 5, gt()));
- VERIFY(binary_search(C, C + N, first, gt()));
- VERIFY(binary_search(C, C + N, last, gt()));
- VERIFY(!binary_search(C, C + N, 4, gt()));
-}
-
-int
-main()
-{
- test01();
- test02();
- test03();
- test04();
-
- return 0;
-}
--- /dev/null
+// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 25.3.3 [lib.alg.binary.search] Binary search algorithms.
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+
+bool test __attribute__((unused)) = true;
+
+const int A[] = {1, 2, 3, 3, 3, 5, 8};
+const int C[] = {8, 5, 3, 3, 3, 2, 1};
+const int N = sizeof(A) / sizeof(int);
+
+// A comparison, equalivalent to std::greater<int> without the
+// dependency on <functional>.
+struct gt
+{
+ bool
+ operator()(const int& x, const int& y) const
+ { return x > y; }
+};
+
+// Each test performs general-case, bookend, not-found condition,
+// and predicate functional checks.
+
+// 25.3.3.1 lower_bound, with and without comparison predicate
+void
+test01()
+{
+ using std::lower_bound;
+
+ const int first = A[0];
+ const int last = A[N - 1];
+
+ const int* p = lower_bound(A, A + N, 3);
+ VERIFY(p == A + 2);
+
+ const int* q = lower_bound(A, A + N, first);
+ VERIFY(q == A + 0);
+
+ const int* r = lower_bound(A, A + N, last);
+ VERIFY(r == A + N - 1);
+
+ const int* s = lower_bound(A, A + N, 4);
+ VERIFY(s == A + 5);
+
+ const int* t = lower_bound(C, C + N, 3, gt());
+ VERIFY(t == C + 2);
+
+ const int* u = lower_bound(C, C + N, first, gt());
+ VERIFY(u == C + N - 1);
+
+ const int* v = lower_bound(C, C + N, last, gt());
+ VERIFY(v == C + 0);
+
+ const int* w = lower_bound(C, C + N, 4, gt());
+ VERIFY(w == C + 2);
+}
+
+// 25.3.3.2 upper_bound, with and without comparison predicate
+void
+test02()
+{
+ using std::upper_bound;
+
+ const int first = A[0];
+ const int last = A[N - 1];
+
+ const int* p = upper_bound(A, A + N, 3);
+ VERIFY(p == A + 5);
+
+ const int* q = upper_bound(A, A + N, first);
+ VERIFY(q == A + 1);
+
+ const int* r = upper_bound(A, A + N, last);
+ VERIFY(r == A + N);
+
+ const int* s = upper_bound(A, A + N, 4);
+ VERIFY(s == A + 5);
+
+ const int* t = upper_bound(C, C + N, 3, gt());
+ VERIFY(t == C + 5);
+
+ const int* u = upper_bound(C, C + N, first, gt());
+ VERIFY(u == C + N);
+
+ const int* v = upper_bound(C, C + N, last, gt());
+ VERIFY(v == C + 1);
+
+ const int* w = upper_bound(C, C + N, 4, gt());
+ VERIFY(w == C + 2);
+}
+
+// 25.3.3.3 equal_range, with and without comparison predicate
+void
+test03()
+{
+ using std::equal_range;
+ typedef std::pair<const int*, const int*> Ipair;
+
+ const int first = A[0];
+ const int last = A[N - 1];
+
+ Ipair p = equal_range(A, A + N, 3);
+ VERIFY(p.first == A + 2);
+ VERIFY(p.second == A + 5);
+
+ Ipair q = equal_range(A, A + N, first);
+ VERIFY(q.first == A + 0);
+ VERIFY(q.second == A + 1);
+
+ Ipair r = equal_range(A, A + N, last);
+ VERIFY(r.first == A + N - 1);
+ VERIFY(r.second == A + N);
+
+ Ipair s = equal_range(A, A + N, 4);
+ VERIFY(s.first == A + 5);
+ VERIFY(s.second == A + 5);
+
+ Ipair t = equal_range(C, C + N, 3, gt());
+ VERIFY(t.first == C + 2);
+ VERIFY(t.second == C + 5);
+
+ Ipair u = equal_range(C, C + N, first, gt());
+ VERIFY(u.first == C + N - 1);
+ VERIFY(u.second == C + N);
+
+ Ipair v = equal_range(C, C + N, last, gt());
+ VERIFY(v.first == C + 0);
+ VERIFY(v.second == C + 1);
+
+ Ipair w = equal_range(C, C + N, 4, gt());
+ VERIFY(w.first == C + 2);
+ VERIFY(w.second == C + 2);
+}
+
+// 25.3.3.4 binary_search, with and without comparison predicate
+void
+test04()
+{
+ using std::binary_search;
+
+ const int first = A[0];
+ const int last = A[N - 1];
+
+ VERIFY(binary_search(A, A + N, 5));
+ VERIFY(binary_search(A, A + N, first));
+ VERIFY(binary_search(A, A + N, last));
+ VERIFY(!binary_search(A, A + N, 4));
+
+ VERIFY(binary_search(C, C + N, 5, gt()));
+ VERIFY(binary_search(C, C + N, first, gt()));
+ VERIFY(binary_search(C, C + N, last, gt()));
+ VERIFY(!binary_search(C, C + N, 4, gt()));
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+
+ return 0;
+}
--- /dev/null
+// 2000-03-29 sss/bkoz
+
+// Copyright (C) 2000, 2003, 2004, 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <algorithm>
+#include <functional>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const int& x = std::max(1, 2);
+ const int& y = std::max(4, 3);
+ VERIFY( x == 2 );
+ VERIFY( y == 4 );
+
+ const int& xc = std::max(1, 2, std::greater<int>());
+ const int& yc = std::max(4, 3, std::greater<int>());
+ VERIFY( xc == 1 );
+ VERIFY( yc == 3 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2000-03-29 sss/bkoz
+
+// Copyright (C) 2000, 2003, 2004, 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <algorithm>
+#include <functional>
+#include <testsuite_hooks.h>
+
+template<typename T>
+ struct A { static const T a; };
+
+template<typename T>
+const T A<T>::a = T(3);
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ VERIFY( 3 == std::max(A<int>::a, 2) );
+ VERIFY( 4 == std::max(A<int>::a, 4) );
+
+ VERIFY( 3u == std::max(A<unsigned int>::a, 2u) );
+ VERIFY( 4u == std::max(A<unsigned int>::a, 4u) );
+
+ VERIFY( 3l == std::max(A<long>::a, 2l) );
+ VERIFY( 4l == std::max(A<long>::a, 4l) );
+
+ VERIFY( 3ul == std::max(A<unsigned long>::a, 2ul) );
+ VERIFY( 4ul == std::max(A<unsigned long>::a, 4ul) );
+
+#ifdef _GLIBCXX_USE_LONG_LONG
+ VERIFY( 3ll == std::max(A<long long>::a, 2ll) );
+ VERIFY( 4ll == std::max(A<long long>::a, 4ll) );
+
+ VERIFY( 3ull == std::max(A<unsigned long long>::a, 2ull) );
+ VERIFY( 4ull == std::max(A<unsigned long long>::a, 4ull) );
+#endif
+
+ VERIFY( short(3) == std::max(A<short>::a, short(2)) );
+ VERIFY( short(4) == std::max(A<short>::a, short(4)) );
+
+ VERIFY( (unsigned short)3 == std::max(A<unsigned short>::a, (unsigned short)2) );
+ VERIFY( (unsigned short)4 == std::max(A<unsigned short>::a, (unsigned short)4) );
+
+ VERIFY( (char)3 == std::max(A<char>::a, (char)2) );
+ VERIFY( (char)4 == std::max(A<char>::a, (char)4) );
+
+ VERIFY( (signed char)3 == std::max(A<signed char>::a, (signed char)2) );
+ VERIFY( (signed char)4 == std::max(A<signed char>::a, (signed char)4) );
+
+ VERIFY( (unsigned char)3 == std::max(A<unsigned char>::a, (unsigned char)2) );
+ VERIFY( (unsigned char)4 == std::max(A<unsigned char>::a, (unsigned char)4) );
+
+ VERIFY( (wchar_t)3 == std::max(A<wchar_t>::a, (wchar_t)2) );
+ VERIFY( (wchar_t)4 == std::max(A<wchar_t>::a, (wchar_t)4) );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
--- /dev/null
+// 2000-03-29 sss/bkoz
+
+// Copyright (C) 2000, 2003, 2004, 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <algorithm>
+#include <functional>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const int& z = std::min(1, 2);
+ const int& w = std::min(4, 3);
+ VERIFY( z == 1 );
+ VERIFY( w == 3 );
+
+ const int& zc = std::min(1, 2, std::greater<int>());
+ const int& wc = std::min(4, 3, std::greater<int>());
+ VERIFY( zc == 2 );
+ VERIFY( wc == 4 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2000-03-29 sss/bkoz
+
+// Copyright (C) 2000, 2003, 2004, 2005 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <algorithm>
+#include <functional>
+#include <testsuite_hooks.h>
+
+template<typename T>
+ struct A { static const T a; };
+
+template<typename T>
+const T A<T>::a = T(3);
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ VERIFY( 2 == std::min(A<int>::a, 2) );
+ VERIFY( 3 == std::min(A<int>::a, 4) );
+
+ VERIFY( 2u == std::min(A<unsigned int>::a, 2u) );
+ VERIFY( 3u == std::min(A<unsigned int>::a, 4u) );
+
+ VERIFY( 2l == std::min(A<long>::a, 2l) );
+ VERIFY( 3l == std::min(A<long>::a, 4l) );
+
+ VERIFY( 2ul == std::min(A<unsigned long>::a, 2ul) );
+ VERIFY( 3ul == std::min(A<unsigned long>::a, 4ul) );
+
+#ifdef _GLIBCXX_USE_LONG_LONG
+ VERIFY( 2ll == std::min(A<long long>::a, 2ll) );
+ VERIFY( 3ll == std::min(A<long long>::a, 4ll) );
+
+ VERIFY( 2ull == std::min(A<unsigned long long>::a, 2ull) );
+ VERIFY( 3ull == std::min(A<unsigned long long>::a, 4ull) );
+#endif
+
+ VERIFY( short(2) == std::min(A<short>::a, short(2)) );
+ VERIFY( short(3) == std::min(A<short>::a, short(4)) );
+
+ VERIFY( (unsigned short)2 == std::min(A<unsigned short>::a, (unsigned short)2) );
+ VERIFY( (unsigned short)3 == std::min(A<unsigned short>::a, (unsigned short)4) );
+
+ VERIFY( (char)2 == std::min(A<char>::a, (char)2) );
+ VERIFY( (char)3 == std::min(A<char>::a, (char)4) );
+
+ VERIFY( (signed char)2 == std::min(A<signed char>::a, (signed char)2) );
+ VERIFY( (signed char)3 == std::min(A<signed char>::a, (signed char)4) );
+
+ VERIFY( (unsigned char)2 == std::min(A<unsigned char>::a, (unsigned char)2) );
+ VERIFY( (unsigned char)3 == std::min(A<unsigned char>::a, (unsigned char)4) );
+
+ VERIFY( (wchar_t)2 == std::min(A<wchar_t>::a, (wchar_t)2) );
+ VERIFY( (wchar_t)3 == std::min(A<wchar_t>::a, (wchar_t)4) );
+
+ VERIFY( 2.0 == std::min(A<double>::a, 2.0) );
+ VERIFY( 3.0 == std::min(A<double>::a, 4.0) );
+
+ VERIFY( float(2) == std::min(A<float>::a, float(2)) );
+ VERIFY( float(3) == std::min(A<float>::a, float(4)) );
+
+ VERIFY( (long double)2 == std::min(A<long double>::a, (long double)2) );
+ VERIFY( (long double)3 == std::min(A<long double>::a, (long double)4) );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
+++ /dev/null
-// 2000-03-29 sss/bkoz
-
-// Copyright (C) 2000, 2003, 2004, 2005 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 2, 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 COPYING. If not, write to the Free
-// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-#include <algorithm>
-#include <functional>
-#include <testsuite_hooks.h>
-
-void test01()
-{
- bool test __attribute__((unused)) = true;
-
- const int& x = std::max(1, 2);
- const int& y = std::max(4, 3);
- VERIFY( x == 2 );
- VERIFY( y == 4 );
-
- const int& xc = std::max(1, 2, std::greater<int>());
- const int& yc = std::max(4, 3, std::greater<int>());
- VERIFY( xc == 1 );
- VERIFY( yc == 3 );
-
- const int& z = std::min(1, 2);
- const int& w = std::min(4, 3);
- VERIFY( z == 1 );
- VERIFY( w == 3 );
-
- const int& zc = std::min(1, 2, std::greater<int>());
- const int& wc = std::min(4, 3, std::greater<int>());
- VERIFY( zc == 2 );
- VERIFY( wc == 4 );
-}
-
-template<typename T>
- struct A { static const T a; };
-
-template<typename T>
-const T A<T>::a = T(3);
-
-void test02()
-{
- bool test __attribute__((unused)) = true;
-
- VERIFY( 2 == std::min(A<int>::a, 2) );
- VERIFY( 3 == std::min(A<int>::a, 4) );
-
- VERIFY( 2u == std::min(A<unsigned int>::a, 2u) );
- VERIFY( 3u == std::min(A<unsigned int>::a, 4u) );
-
- VERIFY( 2l == std::min(A<long>::a, 2l) );
- VERIFY( 3l == std::min(A<long>::a, 4l) );
-
- VERIFY( 2ul == std::min(A<unsigned long>::a, 2ul) );
- VERIFY( 3ul == std::min(A<unsigned long>::a, 4ul) );
-
-#ifdef _GLIBCXX_USE_LONG_LONG
- VERIFY( 2ll == std::min(A<long long>::a, 2ll) );
- VERIFY( 3ll == std::min(A<long long>::a, 4ll) );
-
- VERIFY( 2ull == std::min(A<unsigned long long>::a, 2ull) );
- VERIFY( 3ull == std::min(A<unsigned long long>::a, 4ull) );
-#endif
-
- VERIFY( short(2) == std::min(A<short>::a, short(2)) );
- VERIFY( short(3) == std::min(A<short>::a, short(4)) );
-
- VERIFY( (unsigned short)2 == std::min(A<unsigned short>::a, (unsigned short)2) );
- VERIFY( (unsigned short)3 == std::min(A<unsigned short>::a, (unsigned short)4) );
-
- VERIFY( (char)2 == std::min(A<char>::a, (char)2) );
- VERIFY( (char)3 == std::min(A<char>::a, (char)4) );
-
- VERIFY( (signed char)2 == std::min(A<signed char>::a, (signed char)2) );
- VERIFY( (signed char)3 == std::min(A<signed char>::a, (signed char)4) );
-
- VERIFY( (unsigned char)2 == std::min(A<unsigned char>::a, (unsigned char)2) );
- VERIFY( (unsigned char)3 == std::min(A<unsigned char>::a, (unsigned char)4) );
-
- VERIFY( (wchar_t)2 == std::min(A<wchar_t>::a, (wchar_t)2) );
- VERIFY( (wchar_t)3 == std::min(A<wchar_t>::a, (wchar_t)4) );
-
- VERIFY( 2.0 == std::min(A<double>::a, 2.0) );
- VERIFY( 3.0 == std::min(A<double>::a, 4.0) );
-
- VERIFY( float(2) == std::min(A<float>::a, float(2)) );
- VERIFY( float(3) == std::min(A<float>::a, float(4)) );
-
- VERIFY( (long double)2 == std::min(A<long double>::a, (long double)2) );
- VERIFY( (long double)3 == std::min(A<long double>::a, (long double)4) );
-
-
- VERIFY( 3 == std::max(A<int>::a, 2) );
- VERIFY( 4 == std::max(A<int>::a, 4) );
-
- VERIFY( 3u == std::max(A<unsigned int>::a, 2u) );
- VERIFY( 4u == std::max(A<unsigned int>::a, 4u) );
-
- VERIFY( 3l == std::max(A<long>::a, 2l) );
- VERIFY( 4l == std::max(A<long>::a, 4l) );
-
- VERIFY( 3ul == std::max(A<unsigned long>::a, 2ul) );
- VERIFY( 4ul == std::max(A<unsigned long>::a, 4ul) );
-
-#ifdef _GLIBCXX_USE_LONG_LONG
- VERIFY( 3ll == std::max(A<long long>::a, 2ll) );
- VERIFY( 4ll == std::max(A<long long>::a, 4ll) );
-
- VERIFY( 3ull == std::max(A<unsigned long long>::a, 2ull) );
- VERIFY( 4ull == std::max(A<unsigned long long>::a, 4ull) );
-#endif
-
- VERIFY( short(3) == std::max(A<short>::a, short(2)) );
- VERIFY( short(4) == std::max(A<short>::a, short(4)) );
-
- VERIFY( (unsigned short)3 == std::max(A<unsigned short>::a, (unsigned short)2) );
- VERIFY( (unsigned short)4 == std::max(A<unsigned short>::a, (unsigned short)4) );
-
- VERIFY( (char)3 == std::max(A<char>::a, (char)2) );
- VERIFY( (char)4 == std::max(A<char>::a, (char)4) );
-
- VERIFY( (signed char)3 == std::max(A<signed char>::a, (signed char)2) );
- VERIFY( (signed char)4 == std::max(A<signed char>::a, (signed char)4) );
-
- VERIFY( (unsigned char)3 == std::max(A<unsigned char>::a, (unsigned char)2) );
- VERIFY( (unsigned char)4 == std::max(A<unsigned char>::a, (unsigned char)4) );
-
- VERIFY( (wchar_t)3 == std::max(A<wchar_t>::a, (wchar_t)2) );
- VERIFY( (wchar_t)4 == std::max(A<wchar_t>::a, (wchar_t)4) );
-}
-
-int main()
-{
- test01();
- test02();
- return 0;
-}
--- /dev/null
+// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 25.3.1 algorithms, sort()
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+
+bool test __attribute__((unused)) = true;
+
+const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
+const int B[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19};
+const int C[] = {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
+const int N = sizeof(A) / sizeof(int);
+const int logN = 3; // ln(N) rounded up
+const int P = 7;
+
+// comparison predicate for stable_sort: order by rightmost digit
+struct CompLast
+{
+ bool
+ operator()(const int x, const int y)
+ { return x % 10 < y % 10; }
+};
+
+// This functor has the equivalent functionality of std::geater<>,
+// but there is no dependency on <functional> and it also tracks the
+// number of invocations since creation.
+class Gt
+{
+public:
+ static int count() { return itsCount; }
+ static void reset() { itsCount = 0; }
+
+ bool
+ operator()(const int& x, const int& y)
+ {
+ ++itsCount;
+ return x > y;
+ }
+
+private:
+ static int itsCount;
+};
+
+int Gt::itsCount = 0;
+
+// 25.3.2 nth_element()
+void
+test05()
+{
+ using std::nth_element;
+
+ int s1[N];
+ std::copy(B, B + N, s1);
+ VERIFY(std::equal(s1, s1 + N, B));
+
+ int* pn = s1 + (N / 2) - 1;
+ nth_element(s1, pn, s1 + N);
+ for (const int* i = pn; i < s1 + N; ++i) VERIFY(!(*i < *pn));
+
+ CompLast pred;
+ nth_element(s1, pn, s1 + N, pred);
+ for (const int* i = pn; i < s1 + N; ++i) VERIFY(!pred(*i, *pn));
+}
+
+int
+main()
+{
+ test05();
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 25.3.1 algorithms, sort()
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+
+bool test __attribute__((unused)) = true;
+
+const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
+const int B[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19};
+const int C[] = {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
+const int N = sizeof(A) / sizeof(int);
+const int logN = 3; // ln(N) rounded up
+const int P = 7;
+
+// comparison predicate for stable_sort: order by rightmost digit
+struct CompLast
+{
+ bool
+ operator()(const int x, const int y)
+ { return x % 10 < y % 10; }
+};
+
+// This functor has the equivalent functionality of std::geater<>,
+// but there is no dependency on <functional> and it also tracks the
+// number of invocations since creation.
+class Gt
+{
+public:
+ static int count() { return itsCount; }
+ static void reset() { itsCount = 0; }
+
+ bool
+ operator()(const int& x, const int& y)
+ {
+ ++itsCount;
+ return x > y;
+ }
+
+private:
+ static int itsCount;
+};
+
+int Gt::itsCount = 0;
+
+// 25.3.1.3 partial_sort()
+void
+test03()
+{
+ int s1[N];
+ std::copy(B, B + N, s1);
+ VERIFY(std::equal(s1, s1 + N, B));
+
+ std::partial_sort(s1, s1 + P, s1 + N);
+ VERIFY(std::equal(s1, s1 + P, A));
+
+ Gt gt;
+ gt.reset();
+ std::partial_sort(s1, s1 + P, s1 + N, gt);
+ VERIFY(std::equal(s1, s1 + P, C));
+}
+
+int
+main()
+{
+ test03();
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 25.3.1 algorithms, sort()
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+
+bool test __attribute__((unused)) = true;
+
+const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
+const int B[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19};
+const int C[] = {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
+const int N = sizeof(A) / sizeof(int);
+const int logN = 3; // ln(N) rounded up
+const int P = 7;
+
+// comparison predicate for stable_sort: order by rightmost digit
+struct CompLast
+{
+ bool
+ operator()(const int x, const int y)
+ { return x % 10 < y % 10; }
+};
+
+// This functor has the equivalent functionality of std::geater<>,
+// but there is no dependency on <functional> and it also tracks the
+// number of invocations since creation.
+class Gt
+{
+public:
+ static int count() { return itsCount; }
+ static void reset() { itsCount = 0; }
+
+ bool
+ operator()(const int& x, const int& y)
+ {
+ ++itsCount;
+ return x > y;
+ }
+
+private:
+ static int itsCount;
+};
+
+int Gt::itsCount = 0;
+
+
+// 25.3.1.4 partial_sort_copy()
+void
+test04()
+{
+ using std::partial_sort_copy;
+
+ int s1[N];
+ std::copy(B, B + N, s1);
+ VERIFY(std::equal(s1, s1 + N, B));
+
+ int s2[2*N];
+
+ partial_sort_copy(s1, s1 + N, s2, s2 + P);
+ VERIFY(std::equal(s2, s2 + P, A));
+
+ Gt gt;
+ gt.reset();
+ partial_sort_copy(s1, s1 + N, s2, s2 + P, gt);
+ VERIFY(std::equal(s2, s2 + P, C));
+
+ VERIFY(std::equal(s2, partial_sort_copy(s1, s1 + N, s2, s2 + 2*N), A));
+}
+
+int
+main()
+{
+ test04();
+ return 0;
+}
+++ /dev/null
-// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
-// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-// USA.
-
-// 25.3.1 algorithms, sort()
-
-#include <algorithm>
-#include <testsuite_hooks.h>
-
-bool test __attribute__((unused)) = true;
-
-const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
-const int B[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19};
-const int C[] = {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
-const int N = sizeof(A) / sizeof(int);
-const int logN = 3; // ln(N) rounded up
-const int P = 7;
-
-// comparison predicate for stable_sort: order by rightmost digit
-struct CompLast
-{
- bool
- operator()(const int x, const int y)
- { return x % 10 < y % 10; }
-};
-
-// This functor has the equivalent functionality of std::geater<>,
-// but there is no dependency on <functional> and it also tracks the
-// number of invocations since creation.
-class Gt
-{
-public:
- static int count() { return itsCount; }
- static void reset() { itsCount = 0; }
-
- bool
- operator()(const int& x, const int& y)
- {
- ++itsCount;
- return x > y;
- }
-
-private:
- static int itsCount;
-};
-
-int Gt::itsCount = 0;
-
-
-// 25.3.1.1 sort()
-void
-test01()
-{
- int s1[N];
- std::copy(B, B + N, s1);
- VERIFY(std::equal(s1, s1 + N, B));
-
- std::sort(s1, s1 + N);
- VERIFY(std::equal(s1, s1 + N, A));
-
- Gt gt;
- gt.reset();
- std::sort(s1, s1 + N, gt);
- VERIFY(std::equal(s1, s1 + N, C));
-}
-
-// 25.3.1.2 stable_sort()
-void
-test02()
-{
- int s1[N];
- std::copy(A, A + N, s1);
- VERIFY(std::equal(s1, s1 + N, A));
-
- std::stable_sort(s1, s1 + N, CompLast());
- VERIFY(std::equal(s1, s1 + N, B));
-
- std::stable_sort(s1, s1 + N);
- VERIFY(std::equal(s1, s1 + N, A));
-
- Gt gt;
- gt.reset();
- std::stable_sort(s1, s1 + N, gt);
- VERIFY(std::equal(s1, s1 + N, C));
- VERIFY(gt.count() <= N * logN * logN);
-}
-
-// 25.3.1.3 partial_sort()
-void
-test03()
-{
- int s1[N];
- std::copy(B, B + N, s1);
- VERIFY(std::equal(s1, s1 + N, B));
-
- std::partial_sort(s1, s1 + P, s1 + N);
- VERIFY(std::equal(s1, s1 + P, A));
-
- Gt gt;
- gt.reset();
- std::partial_sort(s1, s1 + P, s1 + N, gt);
- VERIFY(std::equal(s1, s1 + P, C));
-}
-
-// 25.3.1.4 partial_sort_copy()
-void
-test04()
-{
- using std::partial_sort_copy;
-
- int s1[N];
- std::copy(B, B + N, s1);
- VERIFY(std::equal(s1, s1 + N, B));
-
- int s2[2*N];
-
- partial_sort_copy(s1, s1 + N, s2, s2 + P);
- VERIFY(std::equal(s2, s2 + P, A));
-
- Gt gt;
- gt.reset();
- partial_sort_copy(s1, s1 + N, s2, s2 + P, gt);
- VERIFY(std::equal(s2, s2 + P, C));
-
- VERIFY(std::equal(s2, partial_sort_copy(s1, s1 + N, s2, s2 + 2*N), A));
-}
-
-// 25.3.2 nth_element()
-void
-test05()
-{
- using std::nth_element;
-
- int s1[N];
- std::copy(B, B + N, s1);
- VERIFY(std::equal(s1, s1 + N, B));
-
- int* pn = s1 + (N / 2) - 1;
- nth_element(s1, pn, s1 + N);
- for (const int* i = pn; i < s1 + N; ++i) VERIFY(!(*i < *pn));
-
- CompLast pred;
- nth_element(s1, pn, s1 + N, pred);
- for (const int* i = pn; i < s1 + N; ++i) VERIFY(!pred(*i, *pn));
-}
-
-int
-main()
-{
- test01();
- test02();
- test03();
- test04();
- test05();
-
- return 0;
-}
--- /dev/null
+// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 25.3.1 algorithms, sort()
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+
+bool test __attribute__((unused)) = true;
+
+const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
+const int B[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19};
+const int C[] = {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
+const int N = sizeof(A) / sizeof(int);
+const int logN = 3; // ln(N) rounded up
+const int P = 7;
+
+// comparison predicate for stable_sort: order by rightmost digit
+struct CompLast
+{
+ bool
+ operator()(const int x, const int y)
+ { return x % 10 < y % 10; }
+};
+
+// This functor has the equivalent functionality of std::geater<>,
+// but there is no dependency on <functional> and it also tracks the
+// number of invocations since creation.
+class Gt
+{
+public:
+ static int count() { return itsCount; }
+ static void reset() { itsCount = 0; }
+
+ bool
+ operator()(const int& x, const int& y)
+ {
+ ++itsCount;
+ return x > y;
+ }
+
+private:
+ static int itsCount;
+};
+
+int Gt::itsCount = 0;
+
+
+// 25.3.1.1 sort()
+void
+test01()
+{
+ int s1[N];
+ std::copy(B, B + N, s1);
+ VERIFY(std::equal(s1, s1 + N, B));
+
+ std::sort(s1, s1 + N);
+ VERIFY(std::equal(s1, s1 + N, A));
+
+ Gt gt;
+ gt.reset();
+ std::sort(s1, s1 + N, gt);
+ VERIFY(std::equal(s1, s1 + N, C));
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2001 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 25.3.1 algorithms, sort()
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+
+bool test __attribute__((unused)) = true;
+
+const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
+const int B[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19};
+const int C[] = {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
+const int N = sizeof(A) / sizeof(int);
+const int logN = 3; // ln(N) rounded up
+const int P = 7;
+
+// comparison predicate for stable_sort: order by rightmost digit
+struct CompLast
+{
+ bool
+ operator()(const int x, const int y)
+ { return x % 10 < y % 10; }
+};
+
+// This functor has the equivalent functionality of std::geater<>,
+// but there is no dependency on <functional> and it also tracks the
+// number of invocations since creation.
+class Gt
+{
+public:
+ static int count() { return itsCount; }
+ static void reset() { itsCount = 0; }
+
+ bool
+ operator()(const int& x, const int& y)
+ {
+ ++itsCount;
+ return x > y;
+ }
+
+private:
+ static int itsCount;
+};
+
+int Gt::itsCount = 0;
+
+// 25.3.1.2 stable_sort()
+void
+test02()
+{
+ int s1[N];
+ std::copy(A, A + N, s1);
+ VERIFY(std::equal(s1, s1 + N, A));
+
+ std::stable_sort(s1, s1 + N, CompLast());
+ VERIFY(std::equal(s1, s1 + N, B));
+
+ std::stable_sort(s1, s1 + N);
+ VERIFY(std::equal(s1, s1 + N, A));
+
+ Gt gt;
+ gt.reset();
+ std::stable_sort(s1, s1 + N, gt);
+ VERIFY(std::equal(s1, s1 + N, C));
+ VERIFY(gt.count() <= N * logN * logN);
+}
+
+int
+main()
+{
+ test02();
+ return 0;
+}