gcc/libstdc++-v3/testsuite/ext/stdio_filebuf/char/2.cc

62 lines
1.6 KiB
C++
Raw Normal View History

// 2003-04-12 Paolo Carlini <pcarlini at unitus dot it>
// Copyright (C) 2003-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// stdio_filebuf.h
libstdc++.exp (check_v3_target_fileio, [...]): New. * testsuite/lib/libstdc++.exp (check_v3_target_fileio, check_v3_target_time): New. * testsuite/lib/dg-options.exp (dg-require-fileio, dg-require-time): New. * testsuite/ext/stdio_sync_filebuf/char/12048-1.cc: Use it. * testsuite/ext/stdio_sync_filebuf/char/12048-2.cc: Use it. * testsuite/ext/stdio_sync_filebuf/char/12048-3.cc: Use it. * testsuite/ext/stdio_sync_filebuf/char/12048-4.cc: Use it. * testsuite/ext/stdio_sync_filebuf/char/1.cc: Use it. * testsuite/ext/stdio_filebuf/char/2.cc: Use it. * testsuite/ext/stdio_filebuf/char/10063-1.cc: Use it. * testsuite/ext/stdio_filebuf/char/10063-2.cc: Use it. * testsuite/ext/stdio_filebuf/char/10063-3.cc: Use it. * testsuite/22_locale/time_put/put/char/12439_1.cc: Use it. * testsuite/22_locale/time_put/put/char/12439_3.cc: Use it. * testsuite/27_io/basic_ofstream/open/char/1.cc: Use it. * testsuite/27_io/basic_ofstream/cons/char/2.cc: Use it. * testsuite/27_io/objects/char/12048-2.cc: Use it. * testsuite/27_io/objects/char/12048-4.cc: Use it. * testsuite/27_io/objects/char/12048-1.cc: Use it. * testsuite/27_io/objects/char/12048-3.cc: Use it. * testsuite/27_io/objects/char/10.cc: Use it. * testsuite/27_io/objects/char/12048-5.cc: Use it. * testsuite/27_io/basic_istream/get/char/2.cc: Use it. * testsuite/27_io/basic_istream/ignore/char/2.cc: Use it. * testsuite/27_io/basic_istream/ignore/char/3.cc: Use it. * testsuite/27_io/basic_istream/getline/char/5.cc: Use it. * testsuite/27_io/basic_istream/seekg/char/sstream.cc: Use it. * testsuite/27_io/basic_istream/seekg/char/fstream.cc: Use it. * testsuite/27_io/basic_istream/readsome/char/6746-2.cc: Use it. * testsuite/27_io/basic_istream/extractors_other/char/2.cc: Use it. * testsuite/27_io/basic_istream/tellg/char/sstream.cc: Use it. * testsuite/27_io/basic_istream/tellg/char/1.cc: Use it. * testsuite/27_io/basic_istream/tellg/char/fstream.cc: Use it. * testsuite/27_io/basic_istream/extractors_character/char/4.cc: Use it. * testsuite/27_io/basic_ostream/inserters_other/char/1.cc: Use it. * testsuite/27_io/basic_ostream/tellp/char/1.cc: Use it. * testsuite/27_io/basic_ostream/seekp/char/2346-fstream.cc: Use it. * testsuite/27_io/basic_ifstream/open/char/1.cc: Use it. * testsuite/27_io/basic_ifstream/cons/char/1.cc: Use it. * testsuite/27_io/basic_filebuf/sputbackc/char/1-in.cc: Use it. * testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Use it. * testsuite/27_io/basic_filebuf/sputbackc/char/2-in.cc: Use it. * testsuite/27_io/basic_filebuf/sputbackc/char/2-io.cc: Use it. * testsuite/27_io/basic_filebuf/sgetn/char/3.cc: Use it. * testsuite/27_io/basic_filebuf/sgetn/char/1-in.cc: Use it. * testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Use it. * testsuite/27_io/basic_filebuf/sgetn/char/2-in.cc: Use it. * testsuite/27_io/basic_filebuf/sgetn/char/2-io.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/12790-1.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/12790-2.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/12790-3.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/12790-4.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/char/1-in.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/char/1-io.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/char/1-out.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/char/2-in.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/char/2-io.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/char/2-out.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/char/3-in.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/char/3-out.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/char/11543.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/char/12790-1.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/char/12790-2.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/char/12790-3.cc: Use it. * testsuite/27_io/basic_filebuf/seekoff/char/12790-4.cc: Use it. * testsuite/27_io/basic_filebuf/in_avail/char/1.cc: Use it. * testsuite/27_io/basic_filebuf/in_avail/char/9701-3.cc: Use it. * testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Use it. * testsuite/27_io/basic_filebuf/setbuf/char/2.cc: Use it. * testsuite/27_io/basic_filebuf/setbuf/char/3.cc: Use it. * testsuite/27_io/basic_filebuf/setbuf/char/12875-1.cc: Use it. * testsuite/27_io/basic_filebuf/setbuf/char/12875-2.cc: Use it. * testsuite/27_io/basic_filebuf/sbumpc/char/1-in.cc: Use it. * testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Use it. * testsuite/27_io/basic_filebuf/sbumpc/char/2-in.cc: Use it. * testsuite/27_io/basic_filebuf/sbumpc/char/2-io.cc: Use it. * testsuite/27_io/basic_filebuf/sbumpc/char/9825.cc: Use it. * testsuite/27_io/basic_filebuf/is_open/char/1.cc: Use it. * testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Use it. * testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Use it. * testsuite/27_io/basic_filebuf/sputc/char/2-io.cc: Use it. * testsuite/27_io/basic_filebuf/sputc/char/2-out.cc: Use it. * testsuite/27_io/basic_filebuf/open/12790-1.cc: Use it. * testsuite/27_io/basic_filebuf/open/char/1.cc: Use it. * testsuite/27_io/basic_filebuf/open/char/2.cc: Use it. * testsuite/27_io/basic_filebuf/open/char/3.cc: Use it. * testsuite/27_io/basic_filebuf/overflow/char/2-unbuf.cc: Use it. * testsuite/27_io/basic_filebuf/overflow/char/2.cc: Use it. * testsuite/27_io/basic_filebuf/overflow/char/9988.cc: Use it. * testsuite/27_io/basic_filebuf/overflow/char/9182-2.cc: Use it. * testsuite/27_io/basic_filebuf/overflow/char/9169.cc: Use it. * testsuite/27_io/basic_filebuf/snextc/char/1-in.cc: Use it. * testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Use it. * testsuite/27_io/basic_filebuf/snextc/char/2-in.cc: Use it. * testsuite/27_io/basic_filebuf/snextc/char/2-io.cc: Use it. * testsuite/27_io/basic_filebuf/sgetc/char/1-in.cc: Use it. * testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Use it. * testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Use it. * testsuite/27_io/basic_filebuf/sgetc/char/2-in.cc: Use it. * testsuite/27_io/basic_filebuf/sgetc/char/2-io.cc: Use it. * testsuite/27_io/basic_filebuf/close/12790-1.cc: Use it. * testsuite/27_io/basic_filebuf/close/char/1.cc: Use it. * testsuite/27_io/basic_filebuf/close/char/12790-1.cc: Use it. * testsuite/27_io/basic_filebuf/close/char/12790-2.cc: Use it. * testsuite/27_io/basic_filebuf/close/char/2.cc: Use it. * testsuite/27_io/basic_filebuf/close/char/12790-3.cc: Use it. * testsuite/27_io/basic_filebuf/close/char/12790-4.cc: Use it. * testsuite/27_io/basic_filebuf/close/char/4.cc: Use it. * testsuite/27_io/basic_filebuf/underflow/10096.cc: Use it. * testsuite/27_io/basic_filebuf/underflow/char/2.cc: Use it. * testsuite/27_io/basic_filebuf/sungetc/char/1-in.cc: Use it. * testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Use it. * testsuite/27_io/basic_filebuf/sungetc/char/2-in.cc: Use it. * testsuite/27_io/basic_filebuf/sungetc/char/2-io.cc: Use it. * testsuite/27_io/basic_filebuf/seekpos/12790-1.cc: Use it. * testsuite/27_io/basic_filebuf/seekpos/12790-2.cc: Use it. * testsuite/27_io/basic_filebuf/seekpos/12790-3.cc: Use it. * testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc: Use it. * testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc: Use it. * testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc: Use it. * testsuite/27_io/basic_filebuf/seekpos/char/1-in.cc: Use it. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc: Use it. * testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Use it. * testsuite/27_io/basic_filebuf/seekpos/char/2-in.cc: Use it. * testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc: Use it. * testsuite/27_io/basic_filebuf/seekpos/char/2-out.cc: Use it. * testsuite/27_io/basic_filebuf/seekpos/char/3-in.cc: Use it. * testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Use it. * testsuite/27_io/basic_filebuf/seekpos/char/3-out.cc: Use it. * testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Use it. * testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Use it. * testsuite/27_io/basic_filebuf/sputn/char/2-io.cc: Use it. * testsuite/27_io/basic_filebuf/sputn/char/2-out.cc: Use it. * testsuite/27_io/basic_filebuf/sputn/char/9339.cc: Use it. * testsuite/27_io/basic_filebuf/pbackfail/char/9761.cc: Use it. * testsuite/27_io/basic_filebuf/sync/char/9182-1.cc: Use it. * testsuite/21_strings/basic_string/inserters_extractors/char/10.cc: Use it. * testsuite/21_strings/basic_string/inserters_extractors/char/11.cc: Use it. * testsuite/21_strings/basic_string/inserters_extractors/char/5.cc: Use it. From-SVN: r122913
2007-03-14 12:37:55 +01:00
// { dg-require-fileio "" }
#include <ext/stdio_filebuf.h>
#include <cstdio>
#include <fstream>
11.cc: Include <cstring>. 2007-05-10 Paolo Carlini <pcarlini@suse.de> * 27_io/objects/wchar_t/11.cc: Include <cstring>. * 27_io/objects/wchar_t/10.cc: Likewise. * 27_io/objects/wchar_t/12.cc: Likewise. * 27_io/basic_streambuf/sputbackc/char/9538.cc: Likewise. * 27_io/basic_streambuf/sgetn/char/1.cc: Likewise. * 27_io/basic_streambuf/overflow/char/1.cc: Likewise. * 27_io/basic_streambuf/sgetc/char/1.cc: Likewise. * 27_io/basic_streambuf/sputn/wchar_t/1.cc: Likewise. * 27_io/basic_streambuf/sputn/char/1.cc: Likewise. * 27_io/basic_ios/cons/char/3.cc: Likewise. * 27_io/basic_stringbuf/setbuf/char/2.cc: Likewise. * 27_io/basic_stringbuf/setbuf/char/3.cc: Likewise. * 27_io/basic_stringbuf/setbuf/char/4.cc: Likewise. * 27_io/basic_istream/extractors_character/char/4.cc: Likewise. * 27_io/fpos/mbstate_t/1.cc: Likewise. * 27_io/basic_filebuf/setbuf/char/2.cc: Likewise. * 27_io/basic_filebuf/setbuf/char/3.cc: Likewise. * 25_algorithms/copy/streambuf_iterators/char/2.cc: Likewise. * 25_algorithms/copy/streambuf_iterators/char/4.cc: Likewise. * 19_diagnostics/stdexceptions.cc: Likewise. * 21_strings/char_traits/requirements/short/1.cc: Likewise. * 21_strings/basic_string/compare/char/1.cc: Likewise. * 21_strings/basic_string/capacity/1.cc: Likewise. * ext/codecvt/char-1.cc: Likewise. * ext/codecvt/char-2.cc: Likewise. * ext/codecvt/1.cc: Likewise. * ext/stdio_sync_filebuf/wchar_t/1.cc: Likewise. * ext/stdio_sync_filebuf/char/1.cc: Likewise. * ext/stdio_filebuf/char/2.cc: Likewise. * ext/stdio_filebuf/char/10063-1.cc: Likewise. * 22_locale/ctype/narrow/char/19955.cc: Likewise. * 22_locale/codecvt/unshift/wchar_t/1.cc: Likewise. * 22_locale/codecvt/unshift/wchar_t/2.cc: Likewise. * 22_locale/codecvt/unshift/wchar_t/3.cc: Likewise. * 22_locale/codecvt/unshift/wchar_t/4.cc: Likewise. * 22_locale/codecvt/unshift/char/1.cc: Likewise. * 22_locale/codecvt/length/wchar_t/1.cc: Likewise. * 22_locale/codecvt/length/wchar_t/2.cc: Likewise. * 22_locale/codecvt/length/wchar_t/3.cc: Likewise. * 22_locale/codecvt/length/wchar_t/4.cc: Likewise. * 22_locale/codecvt/length/wchar_t/5.cc: Likewise. * 22_locale/codecvt/length/wchar_t/6.cc: Likewise. * 22_locale/codecvt/length/wchar_t/7.cc: Likewise. * 22_locale/codecvt/always_noconv/char/1.cc: Likewise. * 22_locale/codecvt/encoding/char/1.cc: Likewise. * 22_locale/codecvt/in/wchar_t/1.cc: Likewise. * 22_locale/codecvt/in/wchar_t/2.cc: Likewise. * 22_locale/codecvt/in/wchar_t/3.cc: Likewise. * 22_locale/codecvt/in/wchar_t/4.cc: Likewise. * 22_locale/codecvt/in/wchar_t/5.cc: Likewise. * 22_locale/codecvt/in/wchar_t/6.cc: Likewise. * 22_locale/codecvt/in/wchar_t/7.cc: Likewise. * 22_locale/codecvt/in/wchar_t/8.cc: Likewise. * 22_locale/codecvt/in/wchar_t/9.cc: Likewise. * 22_locale/codecvt/in/char/1.cc: Likewise. * 22_locale/codecvt/max_length/char/1.cc: Likewise. * 22_locale/codecvt/out/wchar_t/1.cc: Likewise. * 22_locale/codecvt/out/wchar_t/2.cc: Likewise. * 22_locale/codecvt/out/wchar_t/3.cc: Likewise. * 22_locale/codecvt/out/wchar_t/4.cc: Likewise. * 22_locale/codecvt/out/wchar_t/5.cc: Likewise. * 22_locale/codecvt/out/wchar_t/6.cc: Likewise. * 22_locale/codecvt/out/wchar_t/7.cc: Likewise. * 22_locale/codecvt/out/char/1.cc: Likewise. * 22_locale/locale/cons/5.cc: Likewise. * 22_locale/collate_byname/named_equivalence.cc: Likewise. From-SVN: r124610
2007-05-11 02:55:17 +02:00
#include <cstring>
#include <testsuite_hooks.h>
// Small stack-based buffers (i.e., using _M_unbuf) were not flushed
// out by _M_really_overflow upon overflow.
void test01()
{
using namespace std;
bool test __attribute__((unused)) = true;
const char* name = "tmp_file1";
FILE* file = fopen(name, "w");
{
using namespace __gnu_cxx;
stdio_filebuf<char> sbuf(file, ios_base::out, 2);
sbuf.sputc('T');
sbuf.sputc('S');
sbuf.sputc('P');
}
fclose(file);
filebuf fbuf;
fbuf.open(name, ios_base::in);
char buf[10];
streamsize n = fbuf.sgetn(buf, sizeof(buf));
fbuf.close();
VERIFY( n == 3 );
VERIFY( !memcmp(buf, "TSP", 3) );
}
int main()
{
test01();
}