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 setg(char_type* gbeg, char_type* gnext, char_type* gend);
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 setg(CharT* gbeg, CharT* gnext, CharT* gend)
30 {
31 base::setg(gbeg, gnext, gend);
32 assert(base::eback() == gbeg);
33 assert(base::gptr() == gnext);
34 assert(base::egptr() == gend);
35 }
36};
37
38int main(int, char**)
39{
40 {
41 test<char> t;
42 char in[] = "ABC";
43 t.setg(gbeg: in, gnext: in+1, gend: in+sizeof(in)/sizeof(in[0]));
44 }
45#ifndef TEST_HAS_NO_WIDE_CHARACTERS
46 {
47 test<wchar_t> t;
48 wchar_t in[] = L"ABC";
49 t.setg(gbeg: in, gnext: in+1, gend: in+sizeof(in)/sizeof(in[0]));
50 }
51#endif
52
53 return 0;
54}
55

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