58 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: no-localization10// UNSUPPORTED: c++03, c++11, c++14, c++1711 12// friend bool operator==(const iterator& x, default_sentinel_t);13 14#include <cassert>15#include <ranges>16#include <sstream>17 18#include "test_macros.h"19#include "../utils.h"20 21template <class CharT>22void test() {23 // fail to read24 {25 auto iss = make_string_stream<CharT>("a123 4");26 std::ranges::basic_istream_view<int, CharT> isv{iss};27 auto it = isv.begin();28 assert(it == std::default_sentinel);29 }30 31 // iterate through the end32 {33 auto iss = make_string_stream<CharT>("123 ");34 std::ranges::basic_istream_view<int, CharT> isv{iss};35 auto it = isv.begin();36 assert(it != std::default_sentinel);37 ++it;38 assert(it == std::default_sentinel);39 }40 41 // empty stream42 {43 auto iss = make_string_stream<CharT>("");44 std::ranges::basic_istream_view<int, CharT> isv{iss};45 auto it = isv.begin();46 assert(it == std::default_sentinel);47 }48}49 50int main(int, char**) {51 test<char>();52#ifndef TEST_HAS_NO_WIDE_CHARACTERS53 test<wchar_t>();54#endif55 56 return 0;57}58