1 // { dg-require-fileio "" }
3 // Copyright (C) 2010-2013 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.8.1.4 Overridden virtual functions
24 #include <testsuite_hooks.h>
29 bool test __attribute__((unused)) = true;
31 typedef filebuf::pos_type pos_type;
32 const char name[] = "tmp_seekoff-4.tst";
34 const size_t size = 12;
39 fb.open(name, ios_base::in | ios_base::out | ios_base::trunc);
41 n = fb.sputn("abcd", 4);
44 fb.pubseekoff(0, ios_base::beg);
47 VERIFY( !memcmp(buf, "abc", 3) );
49 // Check read => write without pubseekoff(0, ios_base::cur)
51 n = fb.sputn("ef", 2);
54 fb.pubseekoff(0, ios_base::beg);
56 n = fb.sgetn(buf, size);
58 VERIFY( !memcmp(buf, "abcef", 5) );
60 fb.pubseekoff(0, ios_base::beg);
61 n = fb.sputn("gh", 2);
64 // Check write => read without pubseekoff(0, ios_base::cur)
66 n = fb.sgetn( buf, 3 );
67 VERIFY( !memcmp(buf, "cef", 3) );
69 n = fb.sputn("ijkl", 4);
72 fb.pubseekoff(0, ios_base::beg);
75 VERIFY( !memcmp(buf, "gh", 2) );
77 fb.pubseekoff(0, ios_base::end);
78 n = fb.sputn("mno", 3);
81 fb.pubseekoff(0, ios_base::beg);
82 n = fb.sgetn(buf, size);
84 VERIFY( !memcmp(buf, "ghcefijklmno", 12) );