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 // void pbump(int n);
15 
16 #include <streambuf>
17 #include <cassert>
18 
19 template <class CharT>
20 struct test
21     : public std::basic_streambuf<CharT>
22 {
23     typedef std::basic_streambuf<CharT> base;
24 
25     test() {}
26 
27     void setp(CharT* pbeg, CharT* pend)
28     {
29         base::setp(pbeg, pend);
30     }
31 
32     void pbump(int n)
33     {
34         CharT* pbeg = base::pbase();
35         CharT* pnext = base::pptr();
36         CharT* pend = base::epptr();
37         base::pbump(n);
38         assert(base::pbase() == pbeg);
39         assert(base::pptr() == pnext+n);
40         assert(base::epptr() == pend);
41     }
42 };
43 
44 int main(int, char**)
45 {
46     {
47         test<char> t;
48         char in[] = "ABCDE";
49         t.setp(in, in+sizeof(in)/sizeof(in[0]));
50         t.pbump(2);
51         t.pbump(1);
52     }
53     {
54         test<wchar_t> t;
55         wchar_t in[] = L"ABCDE";
56         t.setp(in, in+sizeof(in)/sizeof(in[0]));
57         t.pbump(3);
58         t.pbump(1);
59     }
60 
61   return 0;
62 }
63