Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / input.output / stream.buffers / streambuf / streambuf.members / streambuf.pub.get / in_avail.pass.cpp
blobf8325c6de9f5e73969fb9eca0a725d06c59dd232
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 //===----------------------------------------------------------------------===//
9 // <streambuf>
11 // template <class charT, class traits = char_traits<charT> >
12 // class basic_streambuf;
14 // streamsize in_avail();
16 #include <streambuf>
17 #include <cassert>
19 #include "test_macros.h"
21 int showmanyc_called = 0;
23 template <class CharT>
24 struct test
25 : public std::basic_streambuf<CharT>
27 typedef std::basic_streambuf<CharT> base;
29 test() {}
31 void setg(CharT* gbeg, CharT* gnext, CharT* gend)
33 base::setg(gbeg, gnext, gend);
35 protected:
36 std::streamsize showmanyc()
38 ++showmanyc_called;
39 return 5;
43 int main(int, char**)
46 test<char> t;
47 assert(t.in_avail() == 5);
48 assert(showmanyc_called == 1);
49 char in[5];
50 t.setg(in, in+2, in+5);
51 assert(t.in_avail() == 3);
54 return 0;