]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/char/16956.cc
1 // 2004-08-12 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2004-2017 Free Software Foundation, Inc.
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)
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.
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/>.
20 // 27.7.1.3 Overridden virtual functions
23 #include <testsuite_hooks.h>
30 typedef stringbuf::int_type int_type
;
31 typedef stringbuf::traits_type traits_type
;
32 typedef stringbuf::pos_type pos_type
;
33 typedef stringbuf::off_type off_type
;
35 stringbuf
strb_01("lara's place", ios_base::in
);
36 pos_type pt_1
= strb_01
.pubseekoff(5, ios_base::cur
, ios_base::in
);
37 int_type c1
= strb_01
.sgetc();
38 VERIFY( c1
!= traits_type::eof() );
39 pos_type pt_2
= strb_01
.pubseekoff(2, ios_base::cur
, ios_base::in
);
40 pos_type pt_3
= strb_01
.pubseekpos(pt_1
, ios_base::in
);
41 int_type c2
= strb_01
.sbumpc();
42 VERIFY( off_type(pt_3
) == off_type(pt_2
) - 2 );
45 stringbuf
strb_02("-", ios_base::out
);
46 pos_type pt_4
= strb_02
.pubseekoff(0, ios_base::cur
, ios_base::out
);
47 strb_02
.sputn("red", 3);
48 pos_type pt_5
= strb_02
.pubseekoff(-3, ios_base::cur
, ios_base::out
);
49 strb_02
.pubseekpos(pt_5
, ios_base::out
);
50 VERIFY( off_type(pt_5
) == off_type(pt_4
) );
51 strb_02
.sputn("blu", 3);
52 VERIFY( strb_02
.str() == "blu" );