]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/27_io/basic_streambuf/sputbackc/char/9538.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_streambuf / sputbackc / char / 9538.cc
CommitLineData
a2febbfb 1// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
efc2753a 2
fbd26352 3// Copyright (C) 2001-2019 Free Software Foundation, Inc.
efc2753a 4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
6bc9506f 8// Free Software Foundation; either version 3, or (at your option)
efc2753a 9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License along
6bc9506f 17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
efc2753a 19
a2febbfb 20// 27.8.1.4 Overridden virtual functions
21
efc2753a 22#include <streambuf>
a2febbfb 23#include <locale>
1f3fc4aa 24#include <cstring>
efc2753a 25#include <testsuite_hooks.h>
26
a2febbfb 27class MyTraits : public std::char_traits<char>
efc2753a 28{
a2febbfb 29public:
30 static bool eq(char c1, char c2)
31 {
a2febbfb 32 VERIFY( c1 != 'X' );
33 VERIFY( c2 != 'X' );
34 return std::char_traits<char>::eq(c1, c2);
35 }
efc2753a 36};
37
a2febbfb 38class MyBuf : public std::basic_streambuf<char, MyTraits>
efc2753a 39{
a2febbfb 40 char buffer[8];
efc2753a 41
a2febbfb 42public:
43 MyBuf()
44 {
45 std::memset(buffer, 'X', sizeof(buffer));
46 std::memset(buffer + 2, 'f', 4);
47 setg(buffer + 2, buffer + 2, buffer + 6);
efc2753a 48 }
a2febbfb 49};
efc2753a 50
a2febbfb 51// libstdc++/9538
52void test08()
53{
a2febbfb 54 MyBuf mb;
55 mb.sputbackc('a');
56}
efc2753a 57
f8ef786c 58int main()
efc2753a 59{
a2febbfb 60 test08();
efc2753a 61 return 0;
62}