brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · 142589e Raw
97 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// UNSUPPORTED: c++03, c++11, c++14, c++179 10// <vector>11 12// class vector<bool, Allocator>13 14// template<class T, class Allocator>15//   constexpr synth-three-way-result<T> operator<=>(const vector<T, Allocator>& x,16//                                                   const vector<T, Allocator>& y);17 18#include <cassert>19#include <vector>20 21#include "test_comparisons.h"22 23constexpr bool test_sequence_container_spaceship_vectorbool() {24  // Empty containers25  {26    std::vector<bool> l1;27    std::vector<bool> l2;28    assert(testOrder(l1, l2, std::strong_ordering::equivalent));29  }30  // Identical contents31  {32    std::vector<bool> t1{true, true};33    std::vector<bool> t2{true, true};34    assert(testOrder(t1, t2, std::strong_ordering::equivalent));35 36    std::vector<bool> f1{false, false};37    std::vector<bool> f2{false, false};38    assert(testOrder(f1, f2, std::strong_ordering::equivalent));39  }40  // Less, due to contained values41  {42    std::vector<bool> l1{true, false};43    std::vector<bool> l2{true, true};44    assert(testOrder(l1, l2, std::strong_ordering::less));45  }46  // Greater, due to contained values47  {48    std::vector<bool> l1{true, true};49    std::vector<bool> l2{true, false};50    assert(testOrder(l1, l2, std::strong_ordering::greater));51  }52  // Shorter list53  {54    std::vector<bool> l1{true};55    std::vector<bool> l2{true, false};56    assert(testOrder(l1, l2, std::strong_ordering::less));57 58    std::vector<bool> t1{true};59    std::vector<bool> t2{true, true};60    assert(testOrder(t1, t2, std::strong_ordering::less));61 62    std::vector<bool> f1{false};63    std::vector<bool> f2{false, false};64    assert(testOrder(f1, f2, std::strong_ordering::less));65 66    std::vector<bool> e;67    assert(testOrder(e, t1, std::strong_ordering::less));68    assert(testOrder(e, f1, std::strong_ordering::less));69  }70  // Longer list71  {72    std::vector<bool> l1{true, false};73    std::vector<bool> l2{true};74    assert(testOrder(l1, l2, std::strong_ordering::greater));75 76    std::vector<bool> t1{true, true};77    std::vector<bool> t2{true};78    assert(testOrder(t1, t2, std::strong_ordering::greater));79 80    std::vector<bool> f1{false, false};81    std::vector<bool> f2{false};82    assert(testOrder(f1, f2, std::strong_ordering::greater));83 84    std::vector<bool> e;85    assert(testOrder(t2, e, std::strong_ordering::greater));86    assert(testOrder(f2, e, std::strong_ordering::greater));87  }88 89  return true;90}91 92int main(int, char**) {93  assert(test_sequence_container_spaceship_vectorbool());94  static_assert(test_sequence_container_spaceship_vectorbool());95  return 0;96}97