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// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM
10
11// <strstream>
12
13// class strstreambuf
14
15// int_type underflow();
16
17#include <strstream>
18#include <cassert>
19
20#include "test_macros.h"
21
22struct test
23 : public std::strstreambuf
24{
25 typedef std::strstreambuf base;
26 test(char* gnext_arg, std::streamsize n, char* pbeg_arg = 0)
27 : base(gnext_arg, n, pbeg_arg) {}
28 test(const char* gnext_arg, std::streamsize n)
29 : base(gnext_arg, n) {}
30
31 base::int_type underflow() {return base::underflow();}
32};
33
34int main(int, char**)
35{
36 {
37 char buf[10] = "123";
38 test sb(buf, 0, buf + 3);
39 assert(sb.underflow() == '1');
40 assert(sb.underflow() == '1');
41 assert(sb.snextc() == '2');
42 assert(sb.underflow() == '2');
43 assert(sb.underflow() == '2');
44 assert(sb.snextc() == '3');
45 assert(sb.underflow() == '3');
46 assert(sb.underflow() == '3');
47 assert(sb.snextc() == EOF);
48 assert(sb.underflow() == EOF);
49 assert(sb.underflow() == EOF);
50 sb.sputc(c: '4');
51 assert(sb.underflow() == '4');
52 assert(sb.underflow() == '4');
53 }
54
55 return 0;
56}
57

source code of libcxx/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/underflow.pass.cpp