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// <ostream>
10
11// template <class charT, class traits = char_traits<charT> >
12// class basic_ostream;
13
14// explicit basic_ostream(basic_streambuf<charT,traits>* sb);
15
16#include <ostream>
17#include <cassert>
18
19#include "test_macros.h"
20
21template <class CharT>
22struct testbuf
23 : public std::basic_streambuf<CharT>
24{
25 testbuf() {}
26};
27
28int main(int, char**)
29{
30 {
31 testbuf<char> sb;
32 std::basic_ostream<char> os(&sb);
33 assert(os.rdbuf() == &sb);
34 assert(os.tie() == 0);
35 assert(os.fill() == ' ');
36 assert(os.rdstate() == os.goodbit);
37 assert(os.exceptions() == os.goodbit);
38 assert(os.flags() == (os.skipws | os.dec));
39 assert(os.precision() == 6);
40 assert(os.getloc().name() == "C");
41 }
42#ifndef TEST_HAS_NO_WIDE_CHARACTERS
43 {
44 testbuf<wchar_t> sb;
45 std::basic_ostream<wchar_t> os(&sb);
46 assert(os.rdbuf() == &sb);
47 assert(os.tie() == 0);
48 assert(os.fill() == L' ');
49 assert(os.rdstate() == os.goodbit);
50 assert(os.exceptions() == os.goodbit);
51 assert(os.flags() == (os.skipws | os.dec));
52 assert(os.precision() == 6);
53 assert(os.getloc().name() == "C");
54 }
55#endif
56
57 return 0;
58}
59

source code of libcxx/test/std/input.output/iostream.format/output.streams/ostream.cons/streambuf.pass.cpp