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

source code of libcxx/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.cpp