Move test into test/std subdirectory.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2014-12-20 01:40:03 +00:00
parent 669a8a5a19
commit a90c6dd460
4817 changed files with 13 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<LessThanComparable T>
// const T&
// max(const T& a, const T& b);
#include <algorithm>
#include <cassert>
template <class T>
void
test(const T& a, const T& b, const T& x)
{
assert(&std::max(a, b) == &x);
}
int main()
{
{
int x = 0;
int y = 0;
test(x, y, x);
test(y, x, y);
}
{
int x = 0;
int y = 1;
test(x, y, y);
test(y, x, y);
}
{
int x = 1;
int y = 0;
test(x, y, x);
test(y, x, x);
}
#if _LIBCPP_STD_VER > 11
{
constexpr int x = 1;
constexpr int y = 0;
static_assert(std::max(x, y) == x, "" );
static_assert(std::max(y, x) == x, "" );
}
#endif
}

View File

@@ -0,0 +1,56 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<class T, StrictWeakOrder<auto, T> Compare>
// requires !SameType<T, Compare> && CopyConstructible<Compare>
// const T&
// max(const T& a, const T& b, Compare comp);
#include <algorithm>
#include <functional>
#include <cassert>
template <class T, class C>
void
test(const T& a, const T& b, C c, const T& x)
{
assert(&std::max(a, b, c) == &x);
}
int main()
{
{
int x = 0;
int y = 0;
test(x, y, std::greater<int>(), x);
test(y, x, std::greater<int>(), y);
}
{
int x = 0;
int y = 1;
test(x, y, std::greater<int>(), x);
test(y, x, std::greater<int>(), x);
}
{
int x = 1;
int y = 0;
test(x, y, std::greater<int>(), y);
test(y, x, std::greater<int>(), y);
}
#if _LIBCPP_STD_VER > 11
{
constexpr int x = 1;
constexpr int y = 0;
static_assert(std::max(x, y, std::greater<int>()) == y, "" );
static_assert(std::max(y, x, std::greater<int>()) == y, "" );
}
#endif
}

View File

@@ -0,0 +1,66 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<ForwardIterator Iter>
// requires LessThanComparable<Iter::value_type>
// Iter
// max_element(Iter first, Iter last);
#include <algorithm>
#include <cassert>
#include "test_iterators.h"
template <class Iter>
void
test(Iter first, Iter last)
{
Iter i = std::max_element(first, last);
if (first != last)
{
for (Iter j = first; j != last; ++j)
assert(!(*i < *j));
}
else
assert(i == last);
}
template <class Iter>
void
test(unsigned N)
{
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
std::random_shuffle(a, a+N);
test(Iter(a), Iter(a+N));
delete [] a;
}
template <class Iter>
void
test()
{
test<Iter>(0);
test<Iter>(1);
test<Iter>(2);
test<Iter>(3);
test<Iter>(10);
test<Iter>(1000);
}
int main()
{
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
}

View File

@@ -0,0 +1,85 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
// requires CopyConstructible<Compare>
// Iter
// max_element(Iter first, Iter last, Compare comp);
#include <algorithm>
#include <functional>
#include <cassert>
#include "test_iterators.h"
template <class Iter>
void
test(Iter first, Iter last)
{
Iter i = std::max_element(first, last, std::greater<int>());
if (first != last)
{
for (Iter j = first; j != last; ++j)
assert(!std::greater<int>()(*i, *j));
}
else
assert(i == last);
}
template <class Iter>
void
test(unsigned N)
{
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
std::random_shuffle(a, a+N);
test(Iter(a), Iter(a+N));
delete [] a;
}
template <class Iter>
void
test()
{
test<Iter>(0);
test<Iter>(1);
test<Iter>(2);
test<Iter>(3);
test<Iter>(10);
test<Iter>(1000);
}
template <class Iter, class Pred>
void test_eq0(Iter first, Iter last, Pred p)
{
assert(first == std::max_element(first, last, p));
}
void test_eq()
{
const size_t N = 10;
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = 10; // all the same
test_eq0(a, a+N, std::less<int>());
test_eq0(a, a+N, std::greater<int>());
delete [] a;
}
int main()
{
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
test_eq();
}

View File

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template <class T>
// T
// max(initializer_list<T> t);
#include <algorithm>
#include <cassert>
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
int i = std::max({2, 3, 1});
assert(i == 3);
i = std::max({2, 1, 3});
assert(i == 3);
i = std::max({3, 1, 2});
assert(i == 3);
i = std::max({3, 2, 1});
assert(i == 3);
i = std::max({1, 2, 3});
assert(i == 3);
i = std::max({1, 3, 2});
assert(i == 3);
#if _LIBCPP_STD_VER > 11
{
static_assert(std::max({1, 3, 2}) == 3, "");
static_assert(std::max({2, 1, 3}) == 3, "");
static_assert(std::max({3, 2, 1}) == 3, "");
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<class T, class Compare>
// T
// max(initializer_list<T> t, Compare comp);
#include <algorithm>
#include <functional>
#include <cassert>
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
int i = std::max({2, 3, 1}, std::greater<int>());
assert(i == 1);
i = std::max({2, 1, 3}, std::greater<int>());
assert(i == 1);
i = std::max({3, 1, 2}, std::greater<int>());
assert(i == 1);
i = std::max({3, 2, 1}, std::greater<int>());
assert(i == 1);
i = std::max({1, 2, 3}, std::greater<int>());
assert(i == 1);
i = std::max({1, 3, 2}, std::greater<int>());
assert(i == 1);
#if _LIBCPP_STD_VER > 11
{
static_assert(std::max({1, 3, 2}, std::greater<int>()) == 1, "");
static_assert(std::max({2, 1, 3}, std::greater<int>()) == 1, "");
static_assert(std::max({3, 2, 1}, std::greater<int>()) == 1, "");
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,54 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<LessThanComparable T>
// const T&
// min(const T& a, const T& b);
#include <algorithm>
#include <cassert>
template <class T>
void
test(const T& a, const T& b, const T& x)
{
assert(&std::min(a, b) == &x);
}
int main()
{
{
int x = 0;
int y = 0;
test(x, y, x);
test(y, x, y);
}
{
int x = 0;
int y = 1;
test(x, y, x);
test(y, x, x);
}
{
int x = 1;
int y = 0;
test(x, y, y);
test(y, x, y);
}
#if _LIBCPP_STD_VER > 11
{
constexpr int x = 1;
constexpr int y = 0;
static_assert(std::min(x, y) == y, "" );
static_assert(std::min(y, x) == y, "" );
}
#endif
}

View File

@@ -0,0 +1,56 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<class T, StrictWeakOrder<auto, T> Compare>
// requires !SameType<T, Compare> && CopyConstructible<Compare>
// const T&
// min(const T& a, const T& b, Compare comp);
#include <algorithm>
#include <functional>
#include <cassert>
template <class T, class C>
void
test(const T& a, const T& b, C c, const T& x)
{
assert(&std::min(a, b, c) == &x);
}
int main()
{
{
int x = 0;
int y = 0;
test(x, y, std::greater<int>(), x);
test(y, x, std::greater<int>(), y);
}
{
int x = 0;
int y = 1;
test(x, y, std::greater<int>(), y);
test(y, x, std::greater<int>(), y);
}
{
int x = 1;
int y = 0;
test(x, y, std::greater<int>(), x);
test(y, x, std::greater<int>(), x);
}
#if _LIBCPP_STD_VER > 11
{
constexpr int x = 1;
constexpr int y = 0;
static_assert(std::min(x, y, std::greater<int>()) == x, "" );
static_assert(std::min(y, x, std::greater<int>()) == x, "" );
}
#endif
}

View File

@@ -0,0 +1,66 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<ForwardIterator Iter>
// requires LessThanComparable<Iter::value_type>
// Iter
// min_element(Iter first, Iter last);
#include <algorithm>
#include <cassert>
#include "test_iterators.h"
template <class Iter>
void
test(Iter first, Iter last)
{
Iter i = std::min_element(first, last);
if (first != last)
{
for (Iter j = first; j != last; ++j)
assert(!(*j < *i));
}
else
assert(i == last);
}
template <class Iter>
void
test(unsigned N)
{
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
std::random_shuffle(a, a+N);
test(Iter(a), Iter(a+N));
delete [] a;
}
template <class Iter>
void
test()
{
test<Iter>(0);
test<Iter>(1);
test<Iter>(2);
test<Iter>(3);
test<Iter>(10);
test<Iter>(1000);
}
int main()
{
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
}

View File

@@ -0,0 +1,85 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
// requires CopyConstructible<Compare>
// Iter
// min_element(Iter first, Iter last, Compare comp);
#include <algorithm>
#include <functional>
#include <cassert>
#include "test_iterators.h"
template <class Iter>
void
test(Iter first, Iter last)
{
Iter i = std::min_element(first, last, std::greater<int>());
if (first != last)
{
for (Iter j = first; j != last; ++j)
assert(!std::greater<int>()(*j, *i));
}
else
assert(i == last);
}
template <class Iter>
void
test(unsigned N)
{
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
std::random_shuffle(a, a+N);
test(Iter(a), Iter(a+N));
delete [] a;
}
template <class Iter>
void
test()
{
test<Iter>(0);
test<Iter>(1);
test<Iter>(2);
test<Iter>(3);
test<Iter>(10);
test<Iter>(1000);
}
template <class Iter, class Pred>
void test_eq0(Iter first, Iter last, Pred p)
{
assert(first == std::min_element(first, last, p));
}
void test_eq()
{
const size_t N = 10;
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = 10; // all the same
test_eq0(a, a+N, std::less<int>());
test_eq0(a, a+N, std::greater<int>());
delete [] a;
}
int main()
{
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
test_eq();
}

View File

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<class T>
// T
// min(initializer_list<T> t);
#include <algorithm>
#include <cassert>
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
int i = std::min({2, 3, 1});
assert(i == 1);
i = std::min({2, 1, 3});
assert(i == 1);
i = std::min({3, 1, 2});
assert(i == 1);
i = std::min({3, 2, 1});
assert(i == 1);
i = std::min({1, 2, 3});
assert(i == 1);
i = std::min({1, 3, 2});
assert(i == 1);
#if _LIBCPP_STD_VER > 11
{
static_assert(std::min({1, 3, 2}) == 1, "");
static_assert(std::min({2, 1, 3}) == 1, "");
static_assert(std::min({3, 2, 1}) == 1, "");
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<class T, class Compare>
// T
// min(initializer_list<T> t, Compare comp);
#include <algorithm>
#include <functional>
#include <cassert>
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
int i = std::min({2, 3, 1}, std::greater<int>());
assert(i == 3);
i = std::min({2, 1, 3}, std::greater<int>());
assert(i == 3);
i = std::min({3, 1, 2}, std::greater<int>());
assert(i == 3);
i = std::min({3, 2, 1}, std::greater<int>());
assert(i == 3);
i = std::min({1, 2, 3}, std::greater<int>());
assert(i == 3);
i = std::min({1, 3, 2}, std::greater<int>());
assert(i == 3);
#if _LIBCPP_STD_VER > 11
{
static_assert(std::min({1, 3, 2}, std::greater<int>()) == 3, "");
static_assert(std::min({2, 1, 3}, std::greater<int>()) == 3, "");
static_assert(std::min({3, 2, 1}, std::greater<int>()) == 3, "");
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,62 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<LessThanComparable T>
// pair<const T&, const T&>
// minmax(const T& a, const T& b);
#include <algorithm>
#include <cassert>
template <class T>
void
test(const T& a, const T& b, const T& x, const T& y)
{
std::pair<const T&, const T&> p = std::minmax(a, b);
assert(&p.first == &x);
assert(&p.second == &y);
}
int main()
{
{
int x = 0;
int y = 0;
test(x, y, x, y);
test(y, x, y, x);
}
{
int x = 0;
int y = 1;
test(x, y, x, y);
test(y, x, x, y);
}
{
int x = 1;
int y = 0;
test(x, y, y, x);
test(y, x, y, x);
}
#if _LIBCPP_STD_VER > 11
{
// Note that you can't take a reference to a local var, since
// its address is not a compile-time constant.
constexpr static int x = 1;
constexpr static int y = 0;
constexpr auto p1 = std::minmax (x, y);
static_assert(p1.first == y, "");
static_assert(p1.second == x, "");
constexpr auto p2 = std::minmax (y, x);
static_assert(p2.first == y, "");
static_assert(p2.second == x, "");
}
#endif
}

View File

@@ -0,0 +1,65 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<class T, StrictWeakOrder<auto, T> Compare>
// requires !SameType<T, Compare> && CopyConstructible<Compare>
// pair<const T&, const T&>
// minmax(const T& a, const T& b, Compare comp);
#include <algorithm>
#include <functional>
#include <cassert>
template <class T, class C>
void
test(const T& a, const T& b, C c, const T& x, const T& y)
{
std::pair<const T&, const T&> p = std::minmax(a, b, c);
assert(&p.first == &x);
assert(&p.second == &y);
}
int main()
{
{
int x = 0;
int y = 0;
test(x, y, std::greater<int>(), x, y);
test(y, x, std::greater<int>(), y, x);
}
{
int x = 0;
int y = 1;
test(x, y, std::greater<int>(), y, x);
test(y, x, std::greater<int>(), y, x);
}
{
int x = 1;
int y = 0;
test(x, y, std::greater<int>(), x, y);
test(y, x, std::greater<int>(), x, y);
}
#if _LIBCPP_STD_VER > 11
{
// Note that you can't take a reference to a local var, since
// its address is not a compile-time constant.
constexpr static int x = 1;
constexpr static int y = 0;
constexpr auto p1 = std::minmax(x, y, std::greater<>());
static_assert(p1.first == x, "");
static_assert(p1.second == y, "");
constexpr auto p2 = std::minmax(y, x, std::greater<>());
static_assert(p2.first == x, "");
static_assert(p2.second == y, "");
}
#endif
}

View File

@@ -0,0 +1,83 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<ForwardIterator Iter>
// requires LessThanComparable<Iter::value_type>
// pair<Iter, Iter>
// minmax_element(Iter first, Iter last);
#include <algorithm>
#include <cassert>
#include "test_iterators.h"
template <class Iter>
void
test(Iter first, Iter last)
{
std::pair<Iter, Iter> p = std::minmax_element(first, last);
if (first != last)
{
for (Iter j = first; j != last; ++j)
{
assert(!(*j < *p.first));
assert(!(*p.second < *j));
}
}
else
{
assert(p.first == last);
assert(p.second == last);
}
}
template <class Iter>
void
test(unsigned N)
{
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
std::random_shuffle(a, a+N);
test(Iter(a), Iter(a+N));
delete [] a;
}
template <class Iter>
void
test()
{
test<Iter>(0);
test<Iter>(1);
test<Iter>(2);
test<Iter>(3);
test<Iter>(10);
test<Iter>(1000);
{
const unsigned N = 100;
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = 5;
std::random_shuffle(a, a+N);
std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N));
assert(base(p.first) == a);
assert(base(p.second) == a+N-1);
delete [] a;
}
}
int main()
{
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
}

View File

@@ -0,0 +1,88 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
// requires CopyConstructible<Compare>
// pair<Iter, Iter>
// minmax_element(Iter first, Iter last, Compare comp);
#include <algorithm>
#include <functional>
#include <cassert>
#include "test_iterators.h"
template <class Iter>
void
test(Iter first, Iter last)
{
typedef std::greater<int> Compare;
Compare comp;
std::pair<Iter, Iter> p = std::minmax_element(first, last, comp);
if (first != last)
{
for (Iter j = first; j != last; ++j)
{
assert(!comp(*j, *p.first));
assert(!comp(*p.second, *j));
}
}
else
{
assert(p.first == last);
assert(p.second == last);
}
}
template <class Iter>
void
test(unsigned N)
{
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = i;
std::random_shuffle(a, a+N);
test(Iter(a), Iter(a+N));
delete [] a;
}
template <class Iter>
void
test()
{
test<Iter>(0);
test<Iter>(1);
test<Iter>(2);
test<Iter>(3);
test<Iter>(10);
test<Iter>(1000);
{
const unsigned N = 100;
int* a = new int[N];
for (int i = 0; i < N; ++i)
a[i] = 5;
std::random_shuffle(a, a+N);
typedef std::greater<int> Compare;
Compare comp;
std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N), comp);
assert(base(p.first) == a);
assert(base(p.second) == a+N-1);
delete [] a;
}
}
int main()
{
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
}

View File

@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<class T>
// pair<T, T>
// minmax(initializer_list<T> t);
#include <algorithm>
#include <cassert>
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
assert((std::minmax({1, 2, 3}) == std::pair<int, int>(1, 3)));
assert((std::minmax({1, 3, 2}) == std::pair<int, int>(1, 3)));
assert((std::minmax({2, 1, 3}) == std::pair<int, int>(1, 3)));
assert((std::minmax({2, 3, 1}) == std::pair<int, int>(1, 3)));
assert((std::minmax({3, 1, 2}) == std::pair<int, int>(1, 3)));
assert((std::minmax({3, 2, 1}) == std::pair<int, int>(1, 3)));
#if _LIBCPP_STD_VER > 11
{
static_assert((std::minmax({1, 2, 3}) == std::pair<int, int>(1, 3)), "");
static_assert((std::minmax({1, 3, 2}) == std::pair<int, int>(1, 3)), "");
static_assert((std::minmax({2, 1, 3}) == std::pair<int, int>(1, 3)), "");
static_assert((std::minmax({2, 3, 1}) == std::pair<int, int>(1, 3)), "");
static_assert((std::minmax({3, 1, 2}) == std::pair<int, int>(1, 3)), "");
static_assert((std::minmax({3, 2, 1}) == std::pair<int, int>(1, 3)), "");
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<class T, class Compare>
// pair<T, T>
// minmax(initializer_list<T> t, Compare comp);
#include <algorithm>
#include <functional>
#include <cassert>
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
assert((std::minmax({1, 2, 3}, std::greater<int>()) == std::pair<int, int>(3, 1)));
assert((std::minmax({1, 3, 2}, std::greater<int>()) == std::pair<int, int>(3, 1)));
assert((std::minmax({2, 1, 3}, std::greater<int>()) == std::pair<int, int>(3, 1)));
assert((std::minmax({2, 3, 1}, std::greater<int>()) == std::pair<int, int>(3, 1)));
assert((std::minmax({3, 1, 2}, std::greater<int>()) == std::pair<int, int>(3, 1)));
assert((std::minmax({3, 2, 1}, std::greater<int>()) == std::pair<int, int>(3, 1)));
#if _LIBCPP_STD_VER > 11
{
static_assert((std::minmax({1, 2, 3}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
static_assert((std::minmax({1, 3, 2}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
static_assert((std::minmax({2, 1, 3}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
static_assert((std::minmax({2, 3, 1}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
static_assert((std::minmax({3, 1, 2}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
static_assert((std::minmax({3, 2, 1}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}