1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // bool operator==(const vector& lhs, const vector& rhs);
12 // bool operator!=(const vector& lhs, const vector& rhs);
13 // bool operator< (const vector& lhs, const vector& rhs);
14 // bool operator<=(const vector& lhs, const vector& rhs);
15 // bool operator> (const vector& lhs, const vector& rhs);
16 // bool operator>=(const vector& lhs, const vector& rhs);
21 #include "test_comparisons.h"
23 TEST_CONSTEXPR_CXX20
bool test() {
25 const std::vector
<int> c1
, c2
;
26 assert(testComparisons(c1
, c2
, true, false));
29 const std::vector
<int> c1(1, 1), c2(1, 2);
30 assert(testComparisons(c1
, c2
, false, true));
33 const std::vector
<int> c1
, c2(1, 2);
34 assert(testComparisons(c1
, c2
, false, true));
37 int items1
[3] = {1, 2, 1};
38 int items2
[3] = {1, 2, 2};
39 const std::vector
<int> c1(items1
, items1
+ 3);
40 const std::vector
<int> c2(items2
, items2
+ 3);
41 assert(testComparisons(c1
, c2
, false, true));
44 int items1
[3] = {3, 2, 3};
45 int items2
[3] = {3, 1, 3};
46 const std::vector
<int> c1(items1
, items1
+ 3);
47 const std::vector
<int> c2(items2
, items2
+ 3);
49 assert(testComparisons(c1
, c2
, false, false));
52 int items1
[2] = {1, 2};
53 int items2
[3] = {1, 2, 0};
54 const std::vector
<int> c1(items1
, items1
+ 2);
55 const std::vector
<int> c2(items2
, items2
+ 3);
56 assert(testComparisons(c1
, c2
, false, true));
59 int items1
[3] = {1, 2, 0};
60 const std::vector
<int> c1(items1
, items1
+ 3);
61 const std::vector
<int> c2(1, 3);
62 assert(testComparisons(c1
, c2
, false, true));
65 const std::vector
<LessAndEqComp
> c1
, c2
;
66 assert(testComparisons(c1
, c2
, true, false));
69 const std::vector
<LessAndEqComp
> c1(1, LessAndEqComp(1));
70 const std::vector
<LessAndEqComp
> c2(1, LessAndEqComp(1));
71 assert(testComparisons(c1
, c2
, true, false));
74 const std::vector
<LessAndEqComp
> c1(1, LessAndEqComp(1));
75 const std::vector
<LessAndEqComp
> c2(1, LessAndEqComp(2));
76 assert(testComparisons(c1
, c2
, false, true));
79 const std::vector
<LessAndEqComp
> c1
;
80 const std::vector
<LessAndEqComp
> c2(1, LessAndEqComp(2));
81 assert(testComparisons(c1
, c2
, false, true));
84 LessAndEqComp items1
[3] = {LessAndEqComp(1), LessAndEqComp(2), LessAndEqComp(2)};
85 LessAndEqComp items2
[3] = {LessAndEqComp(1), LessAndEqComp(2), LessAndEqComp(1)};
86 const std::vector
<LessAndEqComp
> c1(items1
, items1
+ 3);
87 const std::vector
<LessAndEqComp
> c2(items2
, items2
+ 3);
88 assert(testComparisons(c1
, c2
, false, false));
91 LessAndEqComp items1
[3] = {LessAndEqComp(3), LessAndEqComp(3), LessAndEqComp(3)};
92 LessAndEqComp items2
[3] = {LessAndEqComp(3), LessAndEqComp(2), LessAndEqComp(3)};
93 const std::vector
<LessAndEqComp
> c1(items1
, items1
+ 3);
94 const std::vector
<LessAndEqComp
> c2(items2
, items2
+ 3);
95 assert(testComparisons(c1
, c2
, false, false));
98 LessAndEqComp items1
[2] = {LessAndEqComp(1), LessAndEqComp(2)};
99 LessAndEqComp items2
[3] = {LessAndEqComp(1), LessAndEqComp(2), LessAndEqComp(0)};
100 const std::vector
<LessAndEqComp
> c1(items1
, items1
+ 2);
101 const std::vector
<LessAndEqComp
> c2(items2
, items2
+ 3);
102 assert(testComparisons(c1
, c2
, false, true));
105 LessAndEqComp items1
[3] = {LessAndEqComp(1), LessAndEqComp(2), LessAndEqComp(0)};
106 const std::vector
<LessAndEqComp
> c1(items1
, items1
+ 3);
107 const std::vector
<LessAndEqComp
> c2(1, LessAndEqComp(3));
108 assert(testComparisons(c1
, c2
, false, true));
111 assert((std::vector
<int>() == std::vector
<int>()));
112 assert(!(std::vector
<int>() != std::vector
<int>()));
113 assert(!(std::vector
<int>() < std::vector
<int>()));
114 assert((std::vector
<int>() <= std::vector
<int>()));
115 assert(!(std::vector
<int>() > std::vector
<int>()));
116 assert((std::vector
<int>() >= std::vector
<int>()));
122 int main(int, char**) {
124 #if TEST_STD_VER > 17
125 static_assert(test());