44 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++11, c++14, c++1710 11// <sstream>12 13// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>14// class basic_stringbuf15 16// template <class SAlloc>17// explicit basic_stringbuf(const basic_string<charT, traits, SAlloc>& s,18// ios_base::openmode which = ios_base::in | ios_base::out);19 20#include <sstream>21#include <cassert>22 23#include "make_string.h"24#include "test_allocator.h"25#include "test_macros.h"26 27#define STR(S) MAKE_STRING(CharT, S)28#define SV(S) MAKE_STRING_VIEW(CharT, S)29 30template <class CharT>31static void test() {32 const std::basic_string<CharT, std::char_traits<CharT>, test_allocator<CharT>> s(STR("testing"));33 const std::basic_stringbuf<CharT> buf(s, std::ios_base::in);34 assert(buf.view() == SV("testing"));35}36 37int main(int, char**) {38 test<char>();39#ifndef TEST_HAS_NO_WIDE_CHARACTERS40 test<wchar_t>();41#endif42 return 0;43}44