1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // <forward_list>
10
11 // template <class T, class Allocator>
12 // bool operator< (const forward_list<T, Allocator>& x,
13 // const forward_list<T, Allocator>& y);
14 //
15 // template <class T, class Allocator>
16 // bool operator> (const forward_list<T, Allocator>& x,
17 // const forward_list<T, Allocator>& y);
18 //
19 // template <class T, class Allocator>
20 // bool operator>=(const forward_list<T, Allocator>& x,
21 // const forward_list<T, Allocator>& y);
22 //
23 // template <class T, class Allocator>
24 // bool operator<=(const forward_list<T, Allocator>& x,
25 // const forward_list<T, Allocator>& y);
26
27 #include <forward_list>
28 #include <iterator>
29 #include <algorithm>
30 #include <cassert>
31
32 #include "test_macros.h"
33 #include "min_allocator.h"
34
35 template <class C>
test(int N,int M)36 void test(int N, int M)
37 {
38 C c1;
39 for (int i = 0; i < N; ++i)
40 c1.push_front(i);
41 C c2;
42 for (int i = 0; i < M; ++i)
43 c2.push_front(i);
44 if (N < M)
45 assert(c1 < c2);
46 if (N <= M)
47 assert(c1 <= c2);
48 if (N >= M)
49 assert(c1 >= c2);
50 if (N > M)
51 assert(c1 > c2);
52 }
53
main(int,char **)54 int main(int, char**)
55 {
56 for (int i = 0; i < 10; ++i)
57 for (int j = 0; j < 10; ++j)
58 test<std::forward_list<int> >(i, j);
59 #if TEST_STD_VER >= 11
60 for (int i = 0; i < 10; ++i)
61 for (int j = 0; j < 10; ++j)
62 test<std::forward_list<int, min_allocator<int>> >(i, j);
63 #endif
64
65 return 0;
66 }
67