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 // bool emit();
19
20 #include <syncstream>
21 #include <cassert>
22
23 #include "../helpers.h"
24 #include "test_macros.h"
25
26 template <class CharT>
test()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 test_syncbuf<CharT> buff(&base, alloc);
35
36 buff._setp(ptr, ptr + 3);
37 assert(base._pptr() == nullptr);
38 buff.emit();
39 CharT* pptr = base._pptr();
40 while (pptr) {
41 assert(*pptr++ == *ptr++);
42 }
43 }
44
main(int,char **)45 int main(int, char**) {
46 test<char>();
47 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
48 test<wchar_t>();
49 #endif
50
51 return 0;
52 }
53