| 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 | // <streambuf> |
| 10 | |
| 11 | // template <class charT, class traits = char_traits<charT> > |
| 12 | // class basic_streambuf; |
| 13 | |
| 14 | // streamsize xsputn(const char_type* s, streamsize n); |
| 15 | |
| 16 | #include <streambuf> |
| 17 | #include <cassert> |
| 18 | #include <cstring> |
| 19 | |
| 20 | #include "test_macros.h" |
| 21 | |
| 22 | struct test |
| 23 | : public std::basic_streambuf<char> |
| 24 | { |
| 25 | typedef std::basic_streambuf<char> base; |
| 26 | |
| 27 | test() {} |
| 28 | |
| 29 | void setp(char* pbeg, char* pend) |
| 30 | { |
| 31 | base::setp(pbeg: pbeg, pend: pend); |
| 32 | } |
| 33 | }; |
| 34 | |
| 35 | int main(int, char**) |
| 36 | { |
| 37 | { |
| 38 | test t; |
| 39 | char in[] = "123456" ; |
| 40 | assert(t.sputn(in, sizeof(in)) == 0); |
| 41 | char out[sizeof(in)] = {0}; |
| 42 | t.setp(pbeg: out, pend: out+sizeof(out)); |
| 43 | assert(t.sputn(in, sizeof(in)) == sizeof(in)); |
| 44 | assert(std::strcmp(in, out) == 0); |
| 45 | } |
| 46 | |
| 47 | return 0; |
| 48 | } |
| 49 | |