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