brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · f44ca0b Raw
84 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// UNSUPPORTED: c++03, c++1110 11// <string>12 13// iterator       begin(); // constexpr since C++2014// iterator       end(); // constexpr since C++2015// const_iterator begin()  const; // constexpr since C++2016// const_iterator end()    const; // constexpr since C++2017// const_iterator cbegin() const; // constexpr since C++2018// const_iterator cend()   const; // constexpr since C++2019 20#include <string>21#include <cassert>22 23#include "test_macros.h"24 25template <class C>26TEST_CONSTEXPR_CXX20 void test() {27  { // N3644 testing28    typename C::iterator ii1{}, ii2{};29    typename C::iterator ii4 = ii1;30    typename C::const_iterator cii{};31 32    assert(ii1 == ii2);33    assert(ii1 == ii4);34 35    assert(!(ii1 != ii2));36 37    assert((ii1 == cii));38    assert((cii == ii1));39    assert(!(ii1 != cii));40    assert(!(cii != ii1));41    assert(!(ii1 < cii));42    assert(!(cii < ii1));43    assert((ii1 <= cii));44    assert((cii <= ii1));45    assert(!(ii1 > cii));46    assert(!(cii > ii1));47    assert((ii1 >= cii));48    assert((cii >= ii1));49    assert(cii - ii1 == 0);50    assert(ii1 - cii == 0);51  }52  {53    C a;54    typename C::iterator i1 = a.begin();55    typename C::iterator i2;56    i2 = i1;57    assert(i1 == i2);58  }59}60 61TEST_CONSTEXPR_CXX20 bool test() {62  test<std::string>();63#ifndef TEST_HAS_NO_WIDE_CHARACTERS64  test<std::wstring>();65#endif66 67#ifndef TEST_HAS_NO_CHAR8_T68  test<std::u8string>();69#endif70 71  test<std::u16string>();72  test<std::u32string>();73 74  return true;75}76 77int main(int, char**) {78  test();79#if TEST_STD_VER > 1780  static_assert(test());81#endif82  return 0;83}84