128 lines · cpp
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-exception6//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 ); // constexpr since C++2614 15// template< class T, class Alloc >16// bool operator!=( const std::list<T,Alloc>& lhs,17// const std::list<T,Alloc>& rhs ); // constexpr since C++2618 19// template< class T, class Alloc >20// bool operator<( const std::list<T,Alloc>& lhs,21// const std::list<T,Alloc>& rhs ); // constexpr since C++2622 23// template< class T, class Alloc >24// bool operator<=( const std::list<T,Alloc>& lhs,25// const std::list<T,Alloc>& rhs ); // constexpr since C++2626 27// template< class T, class Alloc >28// bool operator>( const std::list<T,Alloc>& lhs,29// const std::list<T,Alloc>& rhs ); // constexpr since C++2630 31// template< class T, class Alloc >32// bool operator>=( const std::list<T,Alloc>& lhs,33// const std::list<T,Alloc>& rhs ); // constexpr since C++2634 35#include <list>36#include <cassert>37 38#include "test_comparisons.h"39 40TEST_CONSTEXPR_CXX26 bool test() {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 117 return true;118}119 120int main(int, char**) {121 assert(test());122#if TEST_STD_VER >= 26123 static_assert(test());124#endif125 126 return 0;127}128