]>
Commit | Line | Data |
---|---|---|
0a162bde PC |
1 | // 2004-08-12 Paolo Carlini <pcarlini@suse.de> |
2 | ||
818ab71a | 3 | // Copyright (C) 2004-2016 Free Software Foundation, Inc. |
0a162bde PC |
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 | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
0a162bde PC |
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 | |
748086b7 JJ |
17 | // with this library; see the file COPYING3. If not see |
18 | // <http://www.gnu.org/licenses/>. | |
0a162bde PC |
19 | |
20 | // 27.7.1.3 Overridden virtual functions | |
21 | ||
22 | #include <sstream> | |
23 | #include <testsuite_hooks.h> | |
24 | ||
25 | // libstdc++/16956 | |
26 | void test01() | |
27 | { | |
0a162bde PC |
28 | using namespace std; |
29 | ||
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; | |
34 | ||
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 ); | |
43 | VERIFY( c2 == c1 ); | |
44 | ||
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" ); | |
53 | } | |
54 | ||
55 | int main() | |
56 | { | |
57 | test01(); | |
58 | return 0; | |
59 | } |