| 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 |
// <vector> |
| 10 |
|
| 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 ); |
| 17 |
|
| 18 |
#include <vector> |
| 19 |
#include <cassert> |
| 20 |
|
| 21 |
#include "test_comparisons.h" |
| 22 |
|
| 23 |
TEST_CONSTEXPR_CXX20 bool test() { |
| 24 |
typedef std::vector<bool> VB; |
| 25 |
{ |
| 26 |
const VB v1, v2; |
| 27 |
assert(testComparisons(v1, v2, true, false)); |
| 28 |
} |
| 29 |
{ |
| 30 |
const VB v1(1, true); |
| 31 |
const VB v2(1, true); |
| 32 |
assert(testComparisons(v1, v2, true, false)); |
| 33 |
} |
| 34 |
{ |
| 35 |
const VB v1(1, false); |
| 36 |
const VB v2(1, true); |
| 37 |
assert(testComparisons(v1, v2, false, true)); |
| 38 |
} |
| 39 |
{ |
| 40 |
const VB v1, v2(1, true); |
| 41 |
assert(testComparisons(v1, v2, false, true)); |
| 42 |
} |
| 43 |
{ |
| 44 |
bool items1[3] = {false, true, false}; |
| 45 |
bool items2[3] = {false, true, true}; |
| 46 |
const VB v1(items1, items1 + 3); |
| 47 |
const VB v2(items2, items2 + 3); |
| 48 |
assert(testComparisons(v1, v2, false, true)); |
| 49 |
} |
| 50 |
{ |
| 51 |
bool items1[3] = {false, false, false}; |
| 52 |
bool items2[3] = {false, true, false}; |
| 53 |
const VB v1(items1, items1 + 3); |
| 54 |
const VB v2(items2, items2 + 3); |
| 55 |
assert(testComparisons(v1, v2, false, true)); |
| 56 |
} |
| 57 |
{ |
| 58 |
bool items1[2] = {false, true}; |
| 59 |
bool items2[3] = {false, true, false}; |
| 60 |
const VB v1(items1, items1 + 2); |
| 61 |
const VB v2(items2, items2 + 3); |
| 62 |
assert(testComparisons(v1, v2, false, true)); |
| 63 |
} |
| 64 |
{ |
| 65 |
bool items[3] = {false, true, false}; |
| 66 |
const VB v1(items, items + 3); |
| 67 |
const VB v2(1, true); |
| 68 |
assert(testComparisons(v1, v2, false, true)); |
| 69 |
} |
| 70 |
{ |
| 71 |
assert( (std::vector<bool>() == std::vector<bool>())); |
| 72 |
assert(!(std::vector<bool>() != std::vector<bool>())); |
| 73 |
assert(!(std::vector<bool>() < std::vector<bool>())); |
| 74 |
assert( (std::vector<bool>() <= std::vector<bool>())); |
| 75 |
assert(!(std::vector<bool>() > std::vector<bool>())); |
| 76 |
assert( (std::vector<bool>() >= std::vector<bool>())); |
| 77 |
} |
| 78 |
|
| 79 |
return true; |
| 80 |
} |
| 81 |
|
| 82 |
int main(int, char**) { |
| 83 |
test(); |
| 84 |
#if TEST_STD_VER > 17 |
| 85 |
static_assert(test()); |
| 86 |
#endif |
| 87 |
|
| 88 |
return 0; |
| 89 |
} |