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 xsgetn(char_type* s, streamsize n);
15 
16 #include <streambuf>
17 #include <cassert>
18 #include <cstring>
19 
20 struct test
21     : public std::basic_streambuf<char>
22 {
23     typedef std::basic_streambuf<char> base;
24 
25     test() {}
26 
27     void setg(char* gbeg, char* gnext, char* gend)
28     {
29         base::setg(gbeg, gnext, gend);
30     }
31 };
32 
33 int main(int, char**)
34 {
35     test t;
36     char input[7] = "123456";
37     t.setg(input, input, input+7);
38     char output[sizeof(input)] = {0};
39     assert(t.sgetn(output, 10) == 7);
40     assert(std::strcmp(input, output) == 0);
41 
42   return 0;
43 }
44