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-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // UNSUPPORTED: c++03, c++11, c++14, c++17 |
10 | // UNSUPPORTED: no-localization |
11 | // UNSUPPORTED: libcpp-has-no-experimental-syncstream |
12 | |
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 | |
26 | template <class CharT> |
27 | void test() { |
28 | // We do this because we want to be able to use CharT |
29 | 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 | |
47 | int main(int, char**) { |
48 | test<char>(); |
49 | #ifndef TEST_HAS_NO_WIDE_CHARACTERS |
50 | test<wchar_t>(); |
51 | #endif |
52 | |
53 | return 0; |
54 | } |
55 | |