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 | #include <forward_list> |
20 | #include <iterator> |
21 | #include <algorithm> |
22 | #include <cassert> |
23 | |
24 | #include "test_macros.h" |
25 | #include "min_allocator.h" |
26 | |
27 | template <class C> |
28 | void test(int N, int M) |
29 | { |
30 | C c1; |
31 | for (int i = 0; i < N; ++i) |
32 | c1.push_front(i); |
33 | C c2; |
34 | for (int i = 0; i < M; ++i) |
35 | c2.push_front(i); |
36 | if (N == M) |
37 | assert(c1 == c2); |
38 | else |
39 | assert(c1 != c2); |
40 | c2 = c1; |
41 | assert(c1 == c2); |
42 | if (N > 0) |
43 | { |
44 | c2.front() = N+1; |
45 | assert(c1 != c2); |
46 | } |
47 | } |
48 | |
49 | int main(int, char**) |
50 | { |
51 | for (int i = 0; i < 10; ++i) |
52 | for (int j = 0; j < 10; ++j) |
53 | test<std::forward_list<int> >(N: i, M: j); |
54 | #if TEST_STD_VER >= 11 |
55 | for (int i = 0; i < 10; ++i) |
56 | for (int j = 0; j < 10; ++j) |
57 | test<std::forward_list<int, min_allocator<int>> >(i, j); |
58 | #endif |
59 | |
60 | return 0; |
61 | } |
62 | |