• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 xsgetn(char_type* s, streamsize n);
16 
17 #include <streambuf>
18 #include <cassert>
19 
20 struct test
21     : public std::basic_streambuf<char>
22 {
23     typedef std::basic_streambuf<char> base;
24 
testtest25     test() {}
26 
setgtest27     void setg(char* gbeg, char* gnext, char* gend)
28     {
29         base::setg(gbeg, gnext, gend);
30     }
31 };
32 
main()33 int main()
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(strcmp(input, output) == 0);
41 }
42