brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · f640a13 Raw
47 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// void str(const basic_string<charT, traits, SAlloc>& s);18 19#include <sstream>20#include <cassert>21 22#include "make_string.h"23#include "test_allocator.h"24#include "test_macros.h"25 26#define STR(S) MAKE_STRING(CharT, S)27#define SV(S) MAKE_STRING_VIEW(CharT, S)28 29template <class CharT>30static void test() {31  {32    const test_allocator<CharT> a(6);33    const std::basic_string<CharT, std::char_traits<CharT>, test_allocator<CharT>> s(STR("testing"), a);34    std::basic_stringbuf<CharT> buf;35    buf.str(s);36    assert(buf.view() == SV("testing"));37  }38}39 40int main(int, char**) {41  test<char>();42#ifndef TEST_HAS_NO_WIDE_CHARACTERS43  test<wchar_t>();44#endif45  return 0;46}47