]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp
Vendor import of libc++ trunk r290819:
[FreeBSD/FreeBSD.git] / test / std / algorithms / alg.sorting / alg.min.max / min_init_list_comp.pass.cpp
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // UNSUPPORTED: c++98, c++03
11
12 // <algorithm>
13
14 // template<class T, class Compare>
15 //   T
16 //   min(initializer_list<T> t, Compare comp);
17
18 #include <algorithm>
19 #include <functional>
20 #include <cassert>
21
22 #include "test_macros.h"
23
24 int main()
25 {
26     int i = std::min({2, 3, 1}, std::greater<int>());
27     assert(i == 3);
28     i = std::min({2, 1, 3}, std::greater<int>());
29     assert(i == 3);
30     i = std::min({3, 1, 2}, std::greater<int>());
31     assert(i == 3);
32     i = std::min({3, 2, 1}, std::greater<int>());
33     assert(i == 3);
34     i = std::min({1, 2, 3}, std::greater<int>());
35     assert(i == 3);
36     i = std::min({1, 3, 2}, std::greater<int>());
37     assert(i == 3);
38 #if TEST_STD_VER >= 14
39     {
40     static_assert(std::min({1, 3, 2}, std::greater<int>()) == 3, "");
41     static_assert(std::min({2, 1, 3}, std::greater<int>()) == 3, "");
42     static_assert(std::min({3, 2, 1}, std::greater<int>()) == 3, "");
43     }
44 #endif
45 }