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 // void gbump(int n);
16 
17 #include <streambuf>
18 #include <cassert>
19 
20 template <class CharT>
21 struct test
22     : public std::basic_streambuf<CharT>
23 {
24     typedef std::basic_streambuf<CharT> base;
25 
testtest26     test() {}
27 
setgtest28     void setg(CharT* gbeg, CharT* gnext, CharT* gend)
29     {
30         base::setg(gbeg, gnext, gend);
31     }
32 
gbumptest33     void gbump(int n)
34     {
35         CharT* gbeg = base::eback();
36         CharT* gnext = base::gptr();
37         CharT* gend = base::egptr();
38         base::gbump(n);
39         assert(base::eback() == gbeg);
40         assert(base::gptr() == gnext+n);
41         assert(base::egptr() == gend);
42     }
43 };
44 
main()45 int main()
46 {
47     {
48         test<char> t;
49         char in[] = "ABCDE";
50         t.setg(in, in+1, in+sizeof(in)/sizeof(in[0]));
51         t.gbump(2);
52     }
53     {
54         test<wchar_t> t;
55         wchar_t in[] = L"ABCDE";
56         t.setg(in, in+1, in+sizeof(in)/sizeof(in[0]));
57         t.gbump(3);
58     }
59 }
60