xref: /llvm-project/libcxx/test/std/containers/sequences/deque/compare.pass.cpp (revision 984f5f3f6249ffac6a238da2d23ae20a433a0e99)
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 // <deque>
10 
11 // template<class T, class Alloc>
12 // bool operator==(const std::deque<T, Alloc>& lhs,
13 //                 const std::deque<T,Alloc>& rhs);
14 
15 // template<class T, class Alloc>
16 // bool operator!=(const std::deque<T,Alloc>& lhs,
17 //                 const std::deque<T,Alloc>& rhs);
18 
19 // template<class T, class Alloc>
20 // bool operator<(const std::deque<T,Alloc>& lhs,
21 //                const std::deque<T,Alloc>& rhs);
22 
23 // template<class T, class Alloc>
24 // bool operator<=(const std::deque<T,Alloc>& lhs,
25 //                 const std::deque<T,Alloc>& rhs);
26 
27 // template<class T, class Alloc>
28 // bool operator>(const std::deque<T,Alloc>& lhs,
29 //                const std::deque<T,Alloc>& rhs);
30 
31 // template<class T, class Alloc>
32 // bool operator>=(const std::deque<T,Alloc>& lhs,
33 //                 const std::deque<T,Alloc>& rhs);
34 
35 #include <deque>
36 #include <cassert>
37 
38 #include "test_comparisons.h"
39 
main(int,char **)40 int main(int, char**)
41 {
42     {
43         const std::deque<int> d1, d2;
44         assert(testComparisons(d1, d2, true, false));
45     }
46     {
47         const std::deque<int> d1(1, 1), d2(1, 1);
48         assert(testComparisons(d1, d2, true, false));
49     }
50     {
51         int items[3] = {1, 2, 3};
52         const std::deque<int> d1(items, items + 3);
53         const std::deque<int> d2(items, items + 3);
54         assert(testComparisons(d1, d2, true, false));
55     }
56     {
57         const std::deque<int> d1(1, 1), d2;
58         assert(testComparisons(d1, d2, false, false));
59     }
60     {
61         const std::deque<int> d1(1, 1), d2(1, 2);
62         assert(testComparisons(d1, d2, false, true));
63     }
64     {
65         int items1[2] = {1, 2};
66         int items2[2] = {1, 3};
67         const std::deque<int> d1(items1, items1 + 2);
68         const std::deque<int> d2(items2, items2 + 2);
69         assert(testComparisons(d1, d2, false, true));
70     }
71     {
72         int items1[2] = {2, 2};
73         int items2[2] = {1, 3};
74         const std::deque<int> d1(items1, items1 + 2);
75         const std::deque<int> d2(items2, items2 + 2);
76         assert(testComparisons(d1, d2, false, false));
77     }
78     {
79         const std::deque<LessAndEqComp> d1, d2;
80         assert(testComparisons(d1, d2, true, false));
81     }
82     {
83         const std::deque<LessAndEqComp> d1(1, LessAndEqComp(1));
84         const std::deque<LessAndEqComp> d2(1, LessAndEqComp(1));
85         assert(testComparisons(d1, d2, true, false));
86     }
87     {
88         LessAndEqComp items[3] = {LessAndEqComp(1), LessAndEqComp(2), LessAndEqComp(3)};
89         const std::deque<LessAndEqComp> d1(items, items + 3);
90         const std::deque<LessAndEqComp> d2(items, items + 3);
91         assert(testComparisons(d1, d2, true, false));
92     }
93     {
94         const std::deque<LessAndEqComp> d1(1, LessAndEqComp(1));
95         const std::deque<LessAndEqComp> d2;
96         assert(testComparisons(d1, d2, false, false));
97     }
98     {
99         const std::deque<LessAndEqComp> d1(1, LessAndEqComp(1));
100         const std::deque<LessAndEqComp> d2(1, LessAndEqComp(2));
101         assert(testComparisons(d1, d2, false, true));
102     }
103     {
104         LessAndEqComp items1[2] = {LessAndEqComp(1), LessAndEqComp(2)};
105         LessAndEqComp items2[2] = {LessAndEqComp(1), LessAndEqComp(3)};
106         const std::deque<LessAndEqComp> d1(items1, items1 + 2);
107         const std::deque<LessAndEqComp> d2(items2, items2 + 2);
108         assert(testComparisons(d1, d2, false, true));
109     }
110     {
111         LessAndEqComp items1[2] = {LessAndEqComp(2), LessAndEqComp(2)};
112         LessAndEqComp items2[2] = {LessAndEqComp(1), LessAndEqComp(3)};
113         const std::deque<LessAndEqComp> d1(items1, items1 + 2);
114         const std::deque<LessAndEqComp> d2(items2, items2 + 2);
115         assert(testComparisons(d1, d2, false, false));
116     }
117 
118     return 0;
119 }
120