1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <streambuf>
11
12// template <class charT, class traits = char_traits<charT> >
13// class basic_streambuf;
14
15// streamsize xsputn(const char_type* s, streamsize n);
16
17#include <streambuf>
18#include <cassert>
19
20struct test
21    : public std::basic_streambuf<char>
22{
23    typedef std::basic_streambuf<char> base;
24
25    test() {}
26
27    void setp(char* pbeg, char* pend)
28    {
29        base::setp(pbeg, pend);
30    }
31};
32
33int main()
34{
35    {
36        test t;
37        char in[] = "123456";
38        assert(t.sputn(in, sizeof(in)) == 0);
39        char out[sizeof(in)] = {0};
40        t.setp(out, out+sizeof(out));
41        assert(t.sputn(in, sizeof(in)) == sizeof(in));
42        assert(strcmp(in, out) == 0);
43    }
44}
45