1// 2004-08-12  Paolo Carlini  <pcarlini@suse.de>
2
3// Copyright (C) 2004, 2009 Free Software Foundation, Inc.
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
8// Free Software Foundation; either version 3, or (at your option)
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
17// with this library; see the file COPYING3.  If not see
18// <http://www.gnu.org/licenses/>.
19
20// 27.7.1.3 Overridden virtual functions
21
22#include <sstream>
23#include <testsuite_hooks.h>
24
25// libstdc++/16956
26void test01()
27{
28  bool test __attribute__((unused)) = true;
29  using namespace std;
30
31  typedef wstringbuf::int_type int_type;
32  typedef wstringbuf::traits_type traits_type;
33  typedef wstringbuf::pos_type pos_type;
34  typedef wstringbuf::off_type off_type;
35
36  wstringbuf strb_01(L"lara's place", ios_base::in);
37  pos_type pt_1 = strb_01.pubseekoff(5, ios_base::cur, ios_base::in);
38  int_type c1 = strb_01.sgetc();
39  VERIFY( c1 != traits_type::eof() );
40  pos_type pt_2 = strb_01.pubseekoff(2, ios_base::cur, ios_base::in);
41  pos_type pt_3 = strb_01.pubseekpos(pt_1, ios_base::in);
42  int_type c2 = strb_01.sbumpc();
43  VERIFY( off_type(pt_3) == off_type(pt_2) - 2 );
44  VERIFY( c2 == c1 );
45
46  wstringbuf strb_02(L"-", ios_base::out);
47  pos_type pt_4 = strb_02.pubseekoff(0, ios_base::cur, ios_base::out);
48  strb_02.sputn(L"red", 3);
49  pos_type pt_5 = strb_02.pubseekoff(-3, ios_base::cur, ios_base::out);
50  strb_02.pubseekpos(pt_5, ios_base::out);
51  VERIFY( off_type(pt_5) == off_type(pt_4) );
52  strb_02.sputn(L"blu", 3);
53  VERIFY( strb_02.str() == L"blu" );
54}
55
56int main()
57{
58  test01();
59  return 0;
60}
61