brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 57ab447 Raw
55 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// UNSUPPORTED: no-localization11// UNSUPPORTED: libcpp-has-no-experimental-syncstream12 13// <syncstream>14 15// template <class charT, class traits, class Allocator>16// class basic_syncbuf;17 18// ~basic_syncbuf();19 20#include <syncstream>21#include <cassert>22 23#include "../helpers.h"24#include "test_macros.h"25 26template <class CharT>27void test() {28  // We do this because we want to be able to use CharT29  CharT arr[3] = {'a', 'b', 'c'};30  CharT* ptr   = arr;31 32  test_buf<CharT> base;33  const std::allocator<CharT> alloc;34  {35    test_syncbuf<CharT> buf(&base, alloc);36 37    buf._setp(ptr, ptr + 3);38    assert(base._pptr() == nullptr);39    // The destructor calls buf.emit();40  }41  CharT* pptr = base._pptr();42  while (pptr) {43    assert(*pptr++ == *ptr++);44  }45}46 47int main(int, char**) {48  test<char>();49#ifndef TEST_HAS_NO_WIDE_CHARACTERS50  test<wchar_t>();51#endif52 53  return 0;54}55