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
25 #include <testsuite_hooks.h>
30 bool test __attribute__((unused)) = true;
32 typedef wfilebuf::pos_type pos_type;
33 const char name[] = "tmp_seekoff-4.tst";
35 const size_t size = 12;
40 fb.open(name, ios_base::in | ios_base::out | ios_base::trunc);
42 n = fb.sputn(L"abcd", 4);
45 fb.pubseekoff(0, ios_base::beg);
48 VERIFY( !wmemcmp(buf, L"abc", 3) );
50 // Check read => write without pubseekoff(0, ios_base::cur)
52 n = fb.sputn(L"ef", 2);
55 fb.pubseekoff(0, ios_base::beg);
57 n = fb.sgetn(buf, size);
59 VERIFY( !wmemcmp(buf, L"abcef", 5) );
61 fb.pubseekoff(0, ios_base::beg);
62 n = fb.sputn(L"gh", 2);
65 // Check write => read without pubseekoff(0, ios_base::cur)
67 n = fb.sgetn( buf, 3 );
68 VERIFY( !memcmp(buf, L"cef", 3) );
70 n = fb.sputn(L"ijkl", 4);
73 fb.pubseekoff(0, ios_base::beg);
76 VERIFY( !wmemcmp(buf, L"gh", 2) );
78 fb.pubseekoff(0, ios_base::end);
79 n = fb.sputn(L"mno", 3);
82 fb.pubseekoff(0, ios_base::beg);
83 n = fb.sgetn(buf, size);
85 VERIFY( !wmemcmp(buf, L"ghcefijklmno", 12) );