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