Commit 23cac885 by Benjamin Kosnik Committed by Benjamin Kosnik

Reshuffle 27_io testsuite.


2003-04-09  Benjamin Kosnik  <bkoz@redhat.com>

	Reshuffle 27_io testsuite.  * testsuite/27_io/filebuf.cc,
	filebuf_members-1.tst, filebuf_members-1.txt, filebuf_members.cc,
	filebuf_virtuals-1.tst, filebuf_virtuals-1.txt,
	filebuf_virtuals-2.tst, filebuf_virtuals-3.tst,
	filebuf_virtuals.cc, fpos.cc, fstream.cc, fstream_members.cc,
	ifstream.cc, ifstream_members-1.tst, ifstream_members-1.txt,
	ifstream_members.cc, instantiations.cc, ios.cc,
	ios_base_callbacks.cc, ios_base_members_static-1.tst,
	ios_base_members_static.cc, ios_base_storage.cc,
	ios_base_types.cc, ios_ctor.cc, ios_init.cc,
	ios_manip_basefield.cc, ios_manip_fmtflags.cc, ios_members.cc,
	iostream.cc, iostream_members.cc, istream.cc,
	istream_exception.cc, istream_extractor_char.cc,
	istream_extractor_other-1.tst, istream_extractor_other-1.txt,
	istream_extractor_other-2.tst, istream_extractor_other.cc,
	istream_manip.cc, istream_seeks-1.tst, istream_seeks-1.txt,
	istream_seeks-2.tst, istream_seeks-3.tst, istream_seeks.cc,
	istream_sentry.cc, istream_unformatted-1.tst,
	istream_unformatted-1.txt, istream_unformatted.cc,
	istringstream.cc, istringstream_members.cc,
	narrow_stream_objects.cc, ofstream.cc, ofstream_members-1.tst,
	ofstream_members.cc, ostream.cc, ostream_exception.cc,
	ostream_fail.cc, ostream_inserter_arith.cc,
	ostream_inserter_char-1.tst, ostream_inserter_char-1.txt,
	ostream_inserter_char.cc, ostream_inserter_other-1.tst,
	ostream_inserter_other-2.tst, ostream_inserter_other.cc,
	ostream_manip.cc, ostream_seeks-1.tst, ostream_seeks.cc,
	ostream_sentry.cc, ostream_unformatted.cc, ostringstream.cc,
	ostringstream_members.cc, standard_manipulators.cc, streambuf.cc,
	streambuf_members.cc, stringbuf.cc, stringbuf_members.cc,
	stringbuf_virtuals.cc, stringstream.cc, stringstream_members.cc,
	wide_stream_objects.cc, istream_extractor_arith/01.cc,
	istream_extractor_arith/02.cc, istream_extractor_arith/03.cc,
	istream_extractor_arith/06.cc, istream_extractor_arith/07.cc,
	istream_extractor_arith/08.cc, istream_extractor_arith/09.cc,
	istream_extractor_arith/10.cc, istream_extractor_arith/11.cc,
	istream_extractor_arith/12.cc, istream_extractor_arith/13.cc:
	Split into...
	* 27_io/basic_filebuf/1.cc: New.
	* 27_io/basic_filebuf/2.cc: New.
	* 27_io/basic_filebuf/3.cc: New.
	* 27_io/basic_filebuf/4.cc: New.
	* 27_io/basic_filebuf/close/char/1.cc: New.
	* 27_io/basic_filebuf/close/char/2.cc: New.
	* 27_io/basic_filebuf/close/char/3.cc: New.
	* 27_io/basic_filebuf/close/char/4879.cc: New.
	* 27_io/basic_filebuf/close/char/9964.cc: New.
	* 27_io/basic_filebuf/imbue/char/1.cc: New.
	* 27_io/basic_filebuf/imbue/char/9322.cc: New.
	* 27_io/basic_filebuf/in_avail/char/1.cc: New.
	* 27_io/basic_filebuf/is_open/char/1.cc: New.
	* 27_io/basic_filebuf/open/char/1.cc: New.
	* 27_io/basic_filebuf/open/char/2.cc: New.
	* 27_io/basic_filebuf/open/char/3.cc: New.
	* 27_io/basic_filebuf/open/char/9507.cc: New.
	* 27_io/basic_filebuf/overflow/char/1.cc: New.
	* 27_io/basic_filebuf/overflow/char/3599.cc: New.
	* 27_io/basic_filebuf/overflow/char/9169.cc: New.
	* 27_io/basic_filebuf/overflow/char/9182-2.cc: New.
	* 27_io/basic_filebuf/overflow/char/9988.cc: New.
	* 27_io/basic_filebuf/sbumpc/char/1.cc: New.
	* 27_io/basic_filebuf/sbumpc/char/9825.cc: New.
	* 27_io/basic_filebuf/seekoff/char/1.cc: New.
	* 27_io/basic_filebuf/seekoff/char/2.cc: New.
	* 27_io/basic_filebuf/seekpos/char/1.cc: New.
	* 27_io/basic_filebuf/seekpos/char/2.cc: New.
	* 27_io/basic_filebuf/setbuf/char/1.cc: New.
	* 27_io/basic_filebuf/setbuf/char/2.cc: New.
	* 27_io/basic_filebuf/setbuf/char/3.cc: New.
	* 27_io/basic_filebuf/sgetc/char/1.cc: New.
	* 27_io/basic_filebuf/sgetn/char/1.cc: New.
	* 27_io/basic_filebuf/sgetn/char/2.cc: New.
	* 27_io/basic_filebuf/snextc/char/1.cc: New.
	* 27_io/basic_filebuf/sputbackc/char/1.cc: New.
	* 27_io/basic_filebuf/sputbackc/char/9425.cc: New.
	* 27_io/basic_filebuf/sputc/char/1.cc: New.
	* 27_io/basic_filebuf/sputc/char/1057.cc: New.
	* 27_io/basic_filebuf/sputc/char/9701-2.cc: New.
	* 27_io/basic_filebuf/sputn/char/1.cc: New.
	* 27_io/basic_filebuf/sputn/char/1057.cc: New.
	* 27_io/basic_filebuf/sputn/char/9701-1.cc: New.
	* 27_io/basic_filebuf/sungetc/char/1.cc: New.
	* 27_io/basic_filebuf/sync/char/1057.cc: New.
	* 27_io/basic_filebuf/sync/char/9182-1.cc: New.
	* 27_io/basic_filebuf/underflow/char/10097.cc: New.
	* 27_io/basic_fstream/1.cc: New.
	* 27_io/basic_fstream/2.cc: New.
	* 27_io/basic_fstream/3.cc: New.
	* 27_io/basic_fstream/4.cc: New.
	* 27_io/basic_fstream/rdbuf/char/2832.cc: New.
	* 27_io/basic_ifstream/1.cc: New.
	* 27_io/basic_ifstream/2.cc: New.
	* 27_io/basic_ifstream/3.cc: New.
	* 27_io/basic_ifstream/4.cc: New.
	* 27_io/basic_ifstream/cons/char/1.cc: New.
	* 27_io/basic_ifstream/open/char/1.cc: New.
	* 27_io/basic_ifstream/rdbuf/char/2832.cc: New.
	* 27_io/basic_ios/1.cc: New.
	* 27_io/basic_ios/2.cc: New.
	* 27_io/basic_ios/3.cc: New.
	* 27_io/basic_ios/4.cc: New.
	* 27_io/basic_ios/clear/char/1.cc: New.
	* 27_io/basic_ios/cons/char/1.cc: New.
	* 27_io/basic_ios/cons/char/2.cc: New.
	* 27_io/basic_ios/cons/char/3.cc: New.
	* 27_io/basic_ios/copyfmt/char/1.cc: New.
	* 27_io/basic_ios/copyfmt/char/2.cc: New.
	* 27_io/basic_ios/exceptions/char/1.cc: New.
	* 27_io/basic_ios/locales/char/1.cc: New.
	* 27_io/basic_iostream/1.cc: New.
	* 27_io/basic_iostream/2.cc: New.
	* 27_io/basic_iostream/3.cc: New.
	* 27_io/basic_iostream/4.cc: New.
	* 27_io/basic_istream/1.cc: New.
	* 27_io/basic_istream/2.cc: New.
	* 27_io/basic_istream/3.cc: New.
	* 27_io/basic_istream/4.cc: New.
	* 27_io/basic_istream/exceptions/char/9561.cc: New.
	* 27_io/basic_istream/extractors_arithmetic/char/01.cc: New.
	* 27_io/basic_istream/extractors_arithmetic/char/02.cc: New.
	* 27_io/basic_istream/extractors_arithmetic/char/03.cc: New.
	* 27_io/basic_istream/extractors_arithmetic/char/06.cc: New.
	* 27_io/basic_istream/extractors_arithmetic/char/07.cc: New.
	* 27_io/basic_istream/extractors_arithmetic/char/08.cc: New.
	* 27_io/basic_istream/extractors_arithmetic/char/09.cc: New.
	* 27_io/basic_istream/extractors_arithmetic/char/10.cc: New.
	* 27_io/basic_istream/extractors_arithmetic/char/11.cc: New.
	* 27_io/basic_istream/extractors_arithmetic/char/12.cc: New.
	* 27_io/basic_istream/extractors_arithmetic/char/13.cc: New.
	* 27_io/basic_istream/extractors_character/char/1.cc: New.
	* 27_io/basic_istream/extractors_character/char/2.cc: New.
	* 27_io/basic_istream/extractors_character/char/3.cc: New.
	* 27_io/basic_istream/extractors_character/char/9826.cc: New.
	* 27_io/basic_istream/extractors_other/char/1.cc: New.
	* 27_io/basic_istream/extractors_other/char/2.cc: New.
	* 27_io/basic_istream/extractors_other/char/3.cc: New.
	* 27_io/basic_istream/extractors_other/char/9318-in.cc: New.
	* 27_io/basic_istream/extractors_other/char/9424-in.cc: New.
	* 27_io/basic_istream/get/char/1.cc: New.
	* 27_io/basic_istream/get/char/2.cc: New.
	* 27_io/basic_istream/getline/char/1.cc: New.
	* 27_io/basic_istream/getline/char/2.cc: New.
	* 27_io/basic_istream/getline/char/3.cc: New.
	* 27_io/basic_istream/ignore/char/1.cc: New.
	* 27_io/basic_istream/ignore/char/6360.cc: New.
	* 27_io/basic_istream/ignore/char/7220.cc: New.
	* 27_io/basic_istream/peek/char/1.cc: New.
	* 27_io/basic_istream/peek/char/6414.cc: New.
	* 27_io/basic_istream/putback/char/1.cc: New.
	* 27_io/basic_istream/read/char/1.cc: New.
	* 27_io/basic_istream/read/char/2.cc: New.
	* 27_io/basic_istream/read/char/3.cc: New.
	* 27_io/basic_istream/readsome/char/6746-1.cc: New.
	* 27_io/basic_istream/readsome/char/6746-2.cc: New.
	* 27_io/basic_istream/readsome/char/8258.cc: New.
	* 27_io/basic_istream/seekg/char/2346-fstream.cc: New.
	* 27_io/basic_istream/seekg/char/2346-sstream.cc: New.
	* 27_io/basic_istream/seekg/char/8348-1.cc: New.
	* 27_io/basic_istream/seekg/char/8348-2.cc: New.
	* 27_io/basic_istream/seekg/char/fstream.cc: New.
	* 27_io/basic_istream/seekg/char/sstream.cc: New.
	* 27_io/basic_istream/sentry/char/1.cc: New.
	* 27_io/basic_istream/sentry/char/2.cc: New.
	* 27_io/basic_istream/sentry/char/3.cc: New.
	* 27_io/basic_istream/sentry/char/3983-fstream.cc: New.
	* 27_io/basic_istream/sentry/char/3983-sstream.cc: New.
	* 27_io/basic_istream/tellg/char/1.cc: New.
	* 27_io/basic_istream/tellg/char/8348.cc: New.
	* 27_io/basic_istream/tellg/char/fstream.cc: New.
	* 27_io/basic_istream/tellg/char/sstream.cc: New.
	* 27_io/basic_istream/ws/char/1.cc: New.
	* 27_io/basic_istringstream/1.cc: New.
	* 27_io/basic_istringstream/2.cc: New.
	* 27_io/basic_istringstream/3.cc: New.
	* 27_io/basic_istringstream/4.cc: New.
	* 27_io/basic_istringstream/rdbuf/char/2832.cc: New.
	* 27_io/basic_istringstream/str/char/1.cc: New.
	* 27_io/basic_ofstream/1.cc: New.
	* 27_io/basic_ofstream/2.cc: New.
	* 27_io/basic_ofstream/3.cc: New.
	* 27_io/basic_ofstream/4.cc: New.
	* 27_io/basic_ofstream/cons/char/2.cc: New.
	* 27_io/basic_ofstream/open/char/1.cc: New.
	* 27_io/basic_ofstream/rdbuf/char/2832.cc: New.
	* 27_io/basic_ostream/1.cc: New.
	* 27_io/basic_ostream/2.cc: New.
	* 27_io/basic_ostream/3.cc: New.
	* 27_io/basic_ostream/4.cc: New.
	* 27_io/basic_ostream/cons/char/9827.cc: New.
	* 27_io/basic_ostream/endl/char/1.cc: New.
	* 27_io/basic_ostream/ends/char/1.cc: New.
	* 27_io/basic_ostream/ends/char/2.cc: New.
	* 27_io/basic_ostream/exceptions/char/9561.cc: New.
	* 27_io/basic_ostream/flush/char/1.cc: New.
	* 27_io/basic_ostream/inserters_arithmetic/char/1.cc: New.
	* 27_io/basic_ostream/inserters_arithmetic/char/2.cc: New.
	* 27_io/basic_ostream/inserters_arithmetic/char/3.cc: New.
	* 27_io/basic_ostream/inserters_arithmetic/char/4.cc: New.
	* 27_io/basic_ostream/inserters_arithmetic/char/4402.cc: New.
	* 27_io/basic_ostream/inserters_arithmetic/char/5.cc: New.
	* 27_io/basic_ostream/inserters_arithmetic/char/6.cc: New.
	* 27_io/basic_ostream/inserters_arithmetic/wchar_t/1.cc: New.
	* 27_io/basic_ostream/inserters_character/char/1.cc: New.
	* 27_io/basic_ostream/inserters_character/char/2.cc: New.
	* 27_io/basic_ostream/inserters_character/char/3.cc: New.
	* 27_io/basic_ostream/inserters_character/char/4.cc: New.
	* 27_io/basic_ostream/inserters_character/char/5.cc: New.
	* 27_io/basic_ostream/inserters_character/char/6.cc: New.
	* 27_io/basic_ostream/inserters_character/char/8.cc: New.
	* 27_io/basic_ostream/inserters_character/wchar_t/7.cc: New.
	* 27_io/basic_ostream/inserters_character/wchar_t/8.cc: New.
	* 27_io/basic_ostream/inserters_other/char/1.cc: New.
	* 27_io/basic_ostream/inserters_other/char/2.cc: New.
	* 27_io/basic_ostream/inserters_other/char/3.cc: New.
	* 27_io/basic_ostream/inserters_other/char/4.cc: New.
	* 27_io/basic_ostream/inserters_other/char/9318-out.cc: New.
	* 27_io/basic_ostream/inserters_other/char/9424-out.cc: New.
	* 27_io/basic_ostream/sentry/char/1.cc: New.
	* 27_io/basic_ostream/sentry/char/2.cc: New.
	* 27_io/basic_ostream/sentry/char/3983-fstream.cc: New.
	* 27_io/basic_ostream/sentry/char/3983-sstream.cc: New.
	* 27_io/basic_ostream/tellp/char/1.cc: New.
	* 27_io/basic_ostream/tellp/char/2.cc: New.
	* 27_io/basic_ostringstream/1.cc: New.
	* 27_io/basic_ostringstream/2.cc: New.
	* 27_io/basic_ostringstream/3.cc: New.
	* 27_io/basic_ostringstream/4.cc: New.
	* 27_io/basic_ostringstream/cons/char/3.cc: New.
	* 27_io/basic_ostringstream/rdbuf/char/2832.cc: New.
	* 27_io/basic_ostringstream/str/char/1.cc: New.
	* 27_io/basic_ostringstream/str/char/2.cc: New.
	* 27_io/basic_streambuf/1.cc: New.
	* 27_io/basic_streambuf/2.cc: New.
	* 27_io/basic_streambuf/3.cc: New.
	* 27_io/basic_streambuf/cons/char/1.cc: New.
	* 27_io/basic_streambuf/imbue/char/1.cc: New.
	* 27_io/basic_streambuf/imbue/char/9322.cc: New.
	* 27_io/basic_streambuf/overflow/char/1.cc: New.
	* 27_io/basic_streambuf/overflow/char/2.cc: New.
	* 27_io/basic_streambuf/overflow/char/3599.cc: New.
	* 27_io/basic_streambuf/sgetc/char/1.cc: New.
	* 27_io/basic_streambuf/sgetn/char/1.cc: New.
	* 27_io/basic_streambuf/sputbackc/char/9538.cc: New.
	* 27_io/basic_streambuf/sputc/char/1057.cc: New.
	* 27_io/basic_streambuf/sputn/char/1.cc: New.
	* 27_io/basic_streambuf/sputn/char/1057.cc: New.
	* 27_io/basic_streambuf/sync/char/1057.cc: New.
	* 27_io/basic_stringbuf/1.cc: New.
	* 27_io/basic_stringbuf/2.cc: New.
	* 27_io/basic_stringbuf/3.cc: New.
	* 27_io/basic_stringbuf/4.cc: New.
	* 27_io/basic_stringbuf/5.cc: New.
	* 27_io/basic_stringbuf/imbue/char/1.cc: New.
	* 27_io/basic_stringbuf/imbue/char/9322.cc: New.
	* 27_io/basic_stringbuf/in_avail/char/1.cc: New.
	* 27_io/basic_stringbuf/overflow/char/2.cc: New.
	* 27_io/basic_stringbuf/overflow/char/3599.cc: New.
	* 27_io/basic_stringbuf/overflow/char/9988.cc: New.
	* 27_io/basic_stringbuf/sbumpc/char/1.cc: New.
	* 27_io/basic_stringbuf/sbumpc/char/9825.cc: New.
	* 27_io/basic_stringbuf/seekoff/char/1.cc: New.
	* 27_io/basic_stringbuf/seekoff/char/2.cc: New.
	* 27_io/basic_stringbuf/seekpos/char/1.cc: New.
	* 27_io/basic_stringbuf/seekpos/char/2.cc: New.
	* 27_io/basic_stringbuf/setbuf/char/1.cc: New.
	* 27_io/basic_stringbuf/setbuf/char/2.cc: New.
	* 27_io/basic_stringbuf/setbuf/char/3.cc: New.
	* 27_io/basic_stringbuf/sgetc/char/1.cc: New.
	* 27_io/basic_stringbuf/sgetn/char/1.cc: New.
	* 27_io/basic_stringbuf/snextc/char/1.cc: New.
	* 27_io/basic_stringbuf/sputbackc/char/1.cc: New.
	* 27_io/basic_stringbuf/sputbackc/char/9425.cc: New.
	* 27_io/basic_stringbuf/sputc/char/1.cc: New.
	* 27_io/basic_stringbuf/sputc/char/1057.cc: New.
	* 27_io/basic_stringbuf/sputc/char/9404-1.cc: New.
	* 27_io/basic_stringbuf/sputn/char/1.cc: New.
	* 27_io/basic_stringbuf/sputn/char/1057.cc: New.
	* 27_io/basic_stringbuf/sputn/char/9404-2.cc: New.
	* 27_io/basic_stringbuf/str/char/1.cc: New.
	* 27_io/basic_stringbuf/str/char/2.cc: New.
	* 27_io/basic_stringbuf/str/char/3.cc: New.
	* 27_io/basic_stringbuf/str/char/3955.cc: New.
	* 27_io/basic_stringbuf/sungetc/char/1.cc: New.
	* 27_io/basic_stringbuf/sync/char/1057.cc: New.
	* 27_io/basic_stringstream/1.cc: New.
	* 27_io/basic_stringstream/2.cc: New.
	* 27_io/basic_stringstream/3.cc: New.
	* 27_io/basic_stringstream/4.cc: New.
	* 27_io/basic_stringstream/rdbuf/char/2832.cc: New.
	* 27_io/basic_stringstream/str/char/1.cc: New.
	* 27_io/basic_stringstream/str/char/2.cc: New.
	* 27_io/basic_stringstream/str/char/3.cc: New.
	* 27_io/basic_stringstream/str/char/4.cc: New.
	* 27_io/fpos/1.cc: New.
	* 27_io/fpos/2.cc: New.
	* 27_io/fpos/3.cc: New.
	* 27_io/ios_base/callbacks/1.cc: New.
	* 27_io/ios_base/state/1.cc: New.
	* 27_io/ios_base/storage/1.cc: New.
	* 27_io/ios_base/storage/2.cc: New.
	* 27_io/ios_base/storage/3.cc: New.
	* 27_io/ios_base/sync_with_stdio/1.cc: New.
	* 27_io/ios_base/sync_with_stdio/2.cc: New.
	* 27_io/manipulators/adjustfield/char/1.cc: New.
	* 27_io/manipulators/adjustfield/char/2.cc: New.
	* 27_io/manipulators/basefield/char/1.cc: New.
	* 27_io/manipulators/standard/char/1.cc: New.
	* 27_io/manipulators/standard/char/2.cc: New.
	* 27_io/objects/char/1.cc: New.
	* 27_io/objects/char/2.cc: New.
	* 27_io/objects/char/2523-1_xin.cc: New.
	* 27_io/objects/char/2523-1_xin.in: New.
	* 27_io/objects/char/2523-2_xin.cc: New.
	* 27_io/objects/char/2523-2_xin.in: New.
	* 27_io/objects/char/3045.cc: New.
	* 27_io/objects/char/3647.cc: New.
	* 27_io/objects/char/3_xin.cc: New.
	* 27_io/objects/char/3_xin.in: New.
	* 27_io/objects/char/4_xin.cc: New.
	* 27_io/objects/char/4_xin.in: New.
	* 27_io/objects/char/5268.cc: New.
	* 27_io/objects/char/5280_xin.cc: New.
	* 27_io/objects/char/5280_xin.in: New.
	* 27_io/objects/char/6548_xin.cc: New.
	* 27_io/objects/char/6548_xin.in: New.
	* 27_io/objects/char/6648-1_xin.cc: New.
	* 27_io/objects/char/6648-1_xin.in: New.
	* 27_io/objects/char/6648-2_xin.cc: New.
	* 27_io/objects/char/6648-2_xin.in: New.
	* 27_io/objects/char/7744_xin.cc: New.
	* 27_io/objects/char/7744_xin.in: New.
	* 27_io/objects/wchar_t/1.cc: New.
	* 27_io/types/1.cc: New.
	* 27_io/types/2.cc: New.
	* data/filebuf_members-1.tst: New.
	* data/filebuf_members-1.txt: New.
	* data/filebuf_virtuals-1.tst: New.
	* data/filebuf_virtuals-1.txt: New.
	* data/filebuf_virtuals-2.tst: New.
	* data/filebuf_virtuals-3.tst: New.
	* data/ifstream_members-1.tst: New.
	* data/ifstream_members-1.txt: New.
	* data/ios_base_members_static-1.tst: New.
	* data/istream_extractor_other-1.tst: New.
	* data/istream_extractor_other-1.txt: New.
	* data/istream_extractor_other-2.tst: New.
	* data/istream_seeks-1.tst: New.
	* data/istream_seeks-1.txt: New.
	* data/istream_seeks-2.tst: New.
	* data/istream_seeks-3.tst: New.
	* data/istream_unformatted-1.tst: New.
	* data/istream_unformatted-1.txt: New.
	* data/ofstream_members-1.tst: New.
	* data/ostream_inserter_char-1.tst: New.
	* data/ostream_inserter_char-1.txt: New.
	* data/ostream_inserter_other-1.tst: New.
	* data/ostream_inserter_other-2.tst: New.
	* data/ostream_seeks-1.tst: New.

2003-04-09  Benjamin Kosnik  <bkoz@redhat.com>

	* include/bits/sstream.tcc (basic_stringbuf::seekpos): Remove
	requirement that __mode must be strict input or output.

	* include/std/std_streambuf.h (basic_streambuf::setp): Set
	_M_out_lim.

	* include/std/std_sstream.h (basic_strinbuf::str): Zero length
	output string shouldn't core.
	(basic_stringbuf::_M_really_sync): Add base argument. Remove rturn
	type.
	* include/bits/sstream.tcc: Adjust _M_really_sync bits here.

	* include/bits/istream.tcc (basic_istream::putback): Set gcount to
	zero.

2003-04-09  Benjamin Kosnik  <bkoz@redhat.com>

	* testsuite/data: New directory.
	* testsuite/lib/libstdc++-v3-dg.exp (libstdc++-v3-init): Modify
	to copy files from the testsuite data directory.
	(libstdc++-v3-list-sourcefiles): Add another test list filter, for
	testfiles containing _xin, which now means this is an interactive
	test and should be run with the interactive dejagnu hooks.
	* testsuite/Makefile.am: Remove testsuite_* files.
	* testsuite/Makefile.in: Regenerate.

From-SVN: r65421
parent a2cf38ee
...@@ -841,6 +841,7 @@ namespace std ...@@ -841,6 +841,7 @@ namespace std
basic_istream<_CharT, _Traits>:: basic_istream<_CharT, _Traits>::
putback(char_type __c) putback(char_type __c)
{ {
_M_gcount = 0;
sentry __cerb(*this, true); sentry __cerb(*this, true);
if (__cerb) if (__cerb)
{ {
......
...@@ -83,29 +83,30 @@ namespace std ...@@ -83,29 +83,30 @@ namespace std
bool __testout = this->_M_mode & ios_base::out; bool __testout = this->_M_mode & ios_base::out;
if (__builtin_expect(!__testout, false)) if (__builtin_expect(!__testout, false))
return traits_type::eof(); return traits_type::eof();
bool __testeof = traits_type::eq_int_type(__c, traits_type::eof()); bool __testeof = traits_type::eq_int_type(__c, traits_type::eof());
if (__builtin_expect(__testeof, false)) if (__builtin_expect(__testeof, false))
return traits_type::not_eof(__c); return traits_type::not_eof(__c);
// In virtue of DR 169 (TC) we are allowed to grow more than // In virtue of DR 169 (TC) we are allowed to grow more than
// one char the first time and also... // one char the first time and also...
__size_type __len = __size_type __len = std::max(__size_type(_M_string.capacity() + 1),
std::max(__size_type(_M_string.capacity() + 1), this->_M_buf_size_opt); this->_M_buf_size_opt);
bool __testput = this->_M_out_cur < this->_M_out_end;
bool __testwrite = this->_M_out_cur < this->_M_out_end; if (__builtin_expect(!__testput && __len > _M_string.max_size(), false))
if (__builtin_expect(!__testwrite && __len > _M_string.max_size(), false))
return traits_type::eof(); return traits_type::eof();
// Try to append __c into output sequence in one of two ways. // Try to append __c into output sequence in one of two ways.
// Order these tests done in is unspecified by the standard. // Order these tests done in is unspecified by the standard.
if (!__testwrite) if (!__testput)
{ {
// Force-allocate, re-sync. // Force-allocate, re-sync.
_M_string = this->str(); _M_string = this->str();
// ... the next times. That's easy to implement thanks to the // ... the next time. That's easy to implement thanks to the
// exponential growth policy builtin into basic_string. // exponential growth policy builtin into basic_string.
_M_string.reserve(__len); _M_string.reserve(__len);
_M_really_sync(this->_M_in_cur - this->_M_in_beg, _M_really_sync(const_cast<char_type*>(_M_string.data()),
this->_M_in_cur - this->_M_in_beg,
this->_M_out_cur - this->_M_out_beg); this->_M_out_cur - this->_M_out_beg);
} }
return this->sputc(traits_type::to_char_type(__c)); return this->sputc(traits_type::to_char_type(__c));
...@@ -187,21 +188,18 @@ namespace std ...@@ -187,21 +188,18 @@ namespace std
char_type* __end = NULL; char_type* __end = NULL;
bool __testin = (ios_base::in & this->_M_mode & __mode) != 0; bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
bool __testout = (ios_base::out & this->_M_mode & __mode) != 0; bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
bool __testboth = __testin && __testout;
__testin &= !(__mode & ios_base::out);
__testout &= !(__mode & ios_base::in);
// NB: Ordered. // NB: Ordered.
bool __testposi = false; bool __testposi = false;
bool __testposo = false; bool __testposo = false;
if (__testin || __testboth) if (__testin)
{ {
__beg = this->eback(); __beg = this->eback();
__end = this->egptr(); __end = this->egptr();
if (0 <= __pos && __pos <= __end - __beg) if (0 <= __pos && __pos <= __end - __beg)
__testposi = true; __testposi = true;
} }
if (__testout || __testboth) if (__testout)
{ {
__beg = this->pbase(); __beg = this->pbase();
__end = this->epptr(); __end = this->epptr();
......
...@@ -394,9 +394,7 @@ namespace std ...@@ -394,9 +394,7 @@ namespace std
*/ */
void void
_M_set_indeterminate(void) _M_set_indeterminate(void)
{ { _M_set_determinate(off_type(0)); }
_M_set_determinate(off_type(0));
}
/** /**
* @if maint * @if maint
......
...@@ -133,20 +133,23 @@ namespace std ...@@ -133,20 +133,23 @@ namespace std
__string_type __string_type
str() const str() const
{ {
__string_type __ret = _M_string;
if (this->_M_mode & ios_base::out) if (this->_M_mode & ios_base::out)
{ {
// This is the deal: _M_string.size() is a value that // This is the deal: _M_string.size() is a value that
// represents the size of the initial string that makes // represents the size of the initial string used to
// _M_string, and may not be the correct size of the // created the buffer, and may not be the correct size of
// current stringbuf internal buffer. // the current stringbuf internal buffer.
__size_type __len = _M_string.size(); __size_type __len = _M_string.size();
if (this->_M_out_lim > this->_M_out_beg) __size_type __nlen = this->_M_out_lim - this->_M_out_beg;
__len = std::max(__size_type(this->_M_out_lim if (__nlen)
- this->_M_out_beg), __len); {
return __string_type(this->_M_out_beg, this->_M_out_beg + __len); __len = std::max(__nlen, __len);
__ret = __string_type(this->_M_out_beg,
this->_M_out_beg + __len);
}
} }
else return __ret;
return _M_string;
} }
/** /**
...@@ -180,10 +183,11 @@ namespace std ...@@ -180,10 +183,11 @@ namespace std
// suit particular needs. // suit particular needs.
this->_M_buf_size_opt = 512; this->_M_buf_size_opt = 512;
this->_M_mode = __mode; this->_M_mode = __mode;
__size_type __len = 0;
if (this->_M_mode & (ios_base::ate | ios_base::app)) if (this->_M_mode & (ios_base::ate | ios_base::app))
_M_really_sync(0, _M_string.size()); __len = _M_string.size();
else _M_really_sync(const_cast<char_type*>(_M_string.data()), 0, __len);
_M_really_sync(0, 0);
} }
// Overridden virtual functions: // Overridden virtual functions:
...@@ -221,8 +225,18 @@ namespace std ...@@ -221,8 +225,18 @@ namespace std
{ {
if (__s && __n) if (__s && __n)
{ {
// This is implementation-defined behavior, and assumes
// that an external char_type array of length (__s + __n)
// exists and has been pre-allocated. If this is not the
// case, things will quickly blow up.
// Step 1: Destroy the current internal array.
_M_string = __string_type(__s, __n); _M_string = __string_type(__s, __n);
_M_really_sync(0, 0);
// Step 2: Use the external array.
this->_M_buf = __s;
this->_M_buf_size_opt = this->_M_buf_size = __n;
_M_really_sync(__s, 0, 0);
} }
return this; return this;
} }
...@@ -248,10 +262,9 @@ namespace std ...@@ -248,10 +262,9 @@ namespace std
* @doctodo * @doctodo
* @endif * @endif
*/ */
virtual int virtual void
_M_really_sync(__size_type __i, __size_type __o) _M_really_sync(char_type* __base, __size_type __i, __size_type __o)
{ {
char_type* __base = const_cast<char_type*>(_M_string.data());
bool __testin = this->_M_mode & ios_base::in; bool __testin = this->_M_mode & ios_base::in;
bool __testout = this->_M_mode & ios_base::out; bool __testout = this->_M_mode & ios_base::out;
__size_type __len = _M_string.size(); __size_type __len = _M_string.size();
...@@ -266,7 +279,6 @@ namespace std ...@@ -266,7 +279,6 @@ namespace std
this->_M_out_lim = __base + __len; this->_M_out_lim = __base + __len;
this->_M_out_cur += __o; this->_M_out_cur += __o;
} }
return 0;
} }
}; };
......
...@@ -210,7 +210,7 @@ namespace std ...@@ -210,7 +210,7 @@ namespace std
char_type* _M_out_cur; // Current put area. char_type* _M_out_cur; // Current put area.
char_type* _M_out_end; // End of put area. char_type* _M_out_end; // End of put area.
char_type* _M_out_lim; // Right limit of used put area. char_type* _M_out_lim; // End limit of used put area.
//@} //@}
...@@ -651,7 +651,7 @@ namespace std ...@@ -651,7 +651,7 @@ namespace std
setp(char_type* __pbeg, char_type* __pend) setp(char_type* __pbeg, char_type* __pend)
{ {
_M_out_beg = _M_out_cur = __pbeg; _M_out_beg = _M_out_cur = __pbeg;
_M_out_end = __pend; _M_out_end = _M_out_lim = __pend;
if (!(_M_mode & ios_base::out) && __pbeg && __pend) if (!(_M_mode & ios_base::out) && __pbeg && __pend)
_M_mode = _M_mode | ios_base::out; _M_mode = _M_mode | ios_base::out;
} }
......
// 1999-01-17 bkoz test functionality of basic_filebuf for char_type == char
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.1 - Template class basic_filebuf
// NB: This file is for testing basic_filebuf with NO OTHER INCLUDES.
#include <fstream>
// { dg-do compile }
// libstdc++/7216
void test01()
{
// Check for required typedefs
typedef std::filebuf test_type;
typedef test_type::char_type char_type;
typedef test_type::traits_type traits_type;
typedef test_type::int_type int_type;
typedef test_type::pos_type pos_type;
typedef test_type::off_type off_type;
}
// more surf!!!
// 1999-01-17 bkoz test functionality of basic_filebuf for char_type == char
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.1 - Template class basic_filebuf
// NB: This file is for testing basic_filebuf with NO OTHER INCLUDES.
#include <fstream>
#include <testsuite_hooks.h>
// { dg-do compile }
// test05
// libstdc++/1886
// should be able to instantiate basic_filebuf for non-standard types.
namespace test
{
using namespace std;
using __gnu_cxx_test::pod_char;
typedef short type_t;
template class basic_filebuf<type_t, char_traits<type_t> >;
template class basic_filebuf<pod_char, char_traits<pod_char> >;
} // test
// more surf!!!
...@@ -25,36 +25,8 @@ ...@@ -25,36 +25,8 @@
#include <fstream> #include <fstream>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
// { dg-do compile }
// libstdc++/7216
void test01()
{
// Check for required typedefs
typedef std::filebuf test_type;
typedef test_type::char_type char_type;
typedef test_type::traits_type traits_type;
typedef test_type::int_type int_type;
typedef test_type::pos_type pos_type;
typedef test_type::off_type off_type;
}
// test05
// libstdc++/1886
// should be able to instantiate basic_filebuf for non-standard types.
namespace test
{
using namespace std;
using __gnu_cxx_test::pod_char;
typedef short type_t;
template class basic_filebuf<type_t, char_traits<type_t> >;
template class basic_filebuf<pod_char, char_traits<pod_char> >;
} // test
// test07
// libstdc++/2020 // libstdc++/2020
// should be able to use custom char_type // should be able to use custom char_type, custom traits type
class gnu_char_type class gnu_char_type
{ {
unsigned long character; unsigned long character;
...@@ -79,10 +51,72 @@ public: ...@@ -79,10 +51,72 @@ public:
operator unsigned long() const { return character; } operator unsigned long() const { return character; }
}; };
// char_traits specialization
struct gnu_char_traits
{
typedef gnu_char_type char_type;
typedef long int_type;
typedef long pos_type;
typedef unsigned long off_type;
typedef long state_type;
static void
assign(char_type& __c1, const char_type& __c2) { }
static bool
eq(const char_type& __c1, const char_type& __c2) { return true; }
static bool
lt(const char_type& __c1, const char_type& __c2) { return true; }
static int
compare(const char_type* __s1, const char_type* __s2, size_t __n)
{ return 0; }
static size_t
length(const char_type* __s) { return 0; }
static const char_type*
find(const char_type* __s, size_t __n, const char_type& __a)
{ return __s; }
static char_type*
move(char_type* __s1, const char_type* __s2, size_t __n)
{ return __s1; }
static char_type*
copy(char_type* __s1, const char_type* __s2, size_t __n)
{ return __s1; }
static char_type*
assign(char_type* __s, size_t __n, char_type __a)
{ return __s; }
static char_type
to_char_type(const int_type& __c)
{ return char_type(); }
static int_type
to_int_type(const char_type& __c)
{ return int_type(); }
static bool
eq_int_type(const int_type& __c1, const int_type& __c2)
{ return true; }
static int_type
eof()
{ return int_type(); }
static int_type
not_eof(const int_type& __c)
{ return int_type(); }
};
void test07() void test07()
{ {
bool test = true; bool test = true;
typedef std::basic_filebuf<gnu_char_type> gnu_filebuf; typedef std::basic_filebuf<gnu_char_type, gnu_char_traits> gnu_filebuf;
try try
{ gnu_filebuf obj; } { gnu_filebuf obj; }
...@@ -102,7 +136,6 @@ template ...@@ -102,7 +136,6 @@ template
int main() int main()
{ {
test01();
test07(); test07();
return 0; return 0;
} }
...@@ -110,12 +143,3 @@ int main() ...@@ -110,12 +143,3 @@ int main()
// more surf!!! // more surf!!!
// 2003-03-26 B enjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.1 - Template class basic_filebuf
#include <fstream>
void test01()
{
// Check for required base class.
typedef std::filebuf test_type;
typedef std::streambuf base_type;
const test_type& obj = test_type();
const base_type* base = &obj;
}
int main()
{
test01();
return 0;
}
// more surf!!!
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.3 filebuf member functions
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %-*.txt
// various tests for filebuf::open() and filebuf::close() including
// the non-portable functionality in the libstdc++-v3 IO library
#include <fstream>
#include <testsuite_hooks.h>
const char name_01[] = "filebuf_members-1.tst";
const char name_02[] = "filebuf_members-1.txt";
// Test member functions.
void test_01()
{
bool test = true;
const char* name_03 = "filebuf_members-3"; // empty file, need to create
std::filebuf fb_01; // in
std::filebuf fb_02; // out
std::filebuf fb_03; // in | out
// bool is_open()
VERIFY( !fb_01.is_open() );
VERIFY( !fb_02.is_open() );
VERIFY( !fb_03.is_open() );
// filebuf_type* open(const char* __s, ios_base::openmode __mode)
fb_01.open(name_01, std::ios_base::in | std::ios_base::ate);
VERIFY( fb_01.is_open() );
// Try to open two different files without closing the first:
// Should keep the old file attached, and disregard attempt to overthrow.
fb_02.open(name_02, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
VERIFY( fb_02.is_open() );
fb_03.open(name_03, std::ios_base::out | std::ios_base::trunc);
VERIFY( fb_03.is_open() );
// filebuf_type* close()
std::filebuf* f;
f = fb_01.close();
VERIFY( f != NULL );
VERIFY( !fb_01.is_open() );
f = fb_02.close();
VERIFY( f != NULL );
VERIFY( !fb_02.is_open() );
f = fb_03.close();
VERIFY( f != NULL );
VERIFY( !fb_03.is_open() );
f = fb_03.close();
VERIFY( f == NULL );
VERIFY( !fb_03.is_open() );
}
int
main()
{
test_01();
return 0;
}
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.3 filebuf member functions
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %-*.txt
// various tests for filebuf::open() and filebuf::close() including
// the non-portable functionality in the libstdc++-v3 IO library
#include <fstream>
#include <ext/stdio_filebuf.h>
#include <testsuite_hooks.h>
// Verify that std::filebuf doesn't close files that it didn't open
// when using the following std::filebuf ctor:
//
// std::filebuf(__c_file_type* __f,
// ios_base::openmode __mode,
// int_type __s);
//
// Thanks to "George T. Talbot" <george@moberg.com> for uncovering
// this bug/situation.
const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
void test_02()
{
bool test = true;
int close_num;
// read (ext)
FILE* f2 = fopen(name_01, "r");
VERIFY( f2 != NULL );
if (f2)
{
__gnu_cxx::stdio_filebuf<char> fb(f2, std::ios_base::in, 512);
close_num = fclose(f2);
}
VERIFY( close_num == 0 );
// read (standard)
FILE* f = fopen(name_01, "r");
VERIFY( f != NULL );
if (f)
{
std::ifstream ifstream1(name_01);
VERIFY( ifstream1.is_open() );
std::ios_base::iostate st01 = ifstream1.rdstate();
VERIFY( st01 == std::ios_base::goodbit );
close_num = fclose(f);
}
VERIFY( close_num == 0 );
}
int
main()
{
test_02();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <locale>
#include <testsuite_hooks.h>
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %*.txt
// NB: This test assumes that _M_buf_size == 40, and not the usual
// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
// simulated a bit more readily.
// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
const int buffer_size = 8192;
//const int buffer_size = 40;
const char carray_01[] = "santa cruz or sandiego?";
const char carray_02[] = "memphis, new orleans, and savanah";
const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
const char name_04[] = "filebuf_virtuals-4.txt"; // empty file, need to create
const char name_05[] = "filebuf_virtuals-5.txt"; // empty file, need to create
const char name_06[] = "filebuf_virtuals-6.txt"; // empty file, need to create
const char name_07[] = "filebuf_virtuals-7.txt"; // empty file, need to create
const char name_08[] = "filebuf_virtuals-8.txt"; // empty file, need to create
class derived_filebuf: public std::filebuf
{
public:
void
set_size(int_type __size) { _M_buf_size_opt = __size; }
};
derived_filebuf fb_01; // in
derived_filebuf fb_02; // out
derived_filebuf fb_03; // in | out
// Initialize filebufs to be the same size regardless of platform.
void test03()
{
fb_01.set_size(buffer_size);
fb_02.set_size(buffer_size);
fb_03.set_size(buffer_size);
}
// Test overloaded virtual functions.
void test05()
{
typedef std::filebuf::int_type int_type;
typedef std::filebuf::traits_type traits_type;
typedef std::filebuf::pos_type pos_type;
typedef std::filebuf::off_type off_type;
typedef size_t size_type;
bool test = true;
std::filebuf f_tmp;
std::streamsize strmsz_1, strmsz_2;
std::streamoff strmof_1, strmof_2;
int i = 0, j = 0, k = 0;
fb_01.open(name_01, std::ios_base::in);
fb_02.open(name_02, std::ios_base::out | std::ios_base::trunc);
fb_03.open(name_03, std::ios_base::out | std::ios_base::in | std::ios_base::trunc);
// NB Have to close these suckers. . .
// filebuf_type* close()
fb_01.close();
fb_02.close();
fb_03.close();
VERIFY( !fb_01.is_open() );
VERIFY( !fb_02.is_open() );
VERIFY( !fb_03.is_open() );
}
main()
{
test03();
test05();
return 0;
}
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.3 filebuf member functions
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %-*.txt
// various tests for filebuf::open() and filebuf::close() including
// the non-portable functionality in the libstdc++-v3 IO library
#include <fstream>
#include <iostream>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <testsuite_hooks.h>
// libstdc++/2913, libstdc++/4879
// John Fardo <jfardo@laurelnetworks.com>, Brad Garcia <garsh@attbi.com>
void
test_04()
{
bool test = true;
const char* name = "tmp_fifo1";
signal(SIGPIPE, SIG_IGN);
unlink(name);
if (0 != mkfifo(name, S_IRWXU))
{
std::cerr << "failed to create fifo" << std::endl;
exit(-1);
}
int fval = fork();
if (fval == -1)
{
std::cerr << "failed to fork" << std::endl;
unlink(name);
exit(-1);
}
else if (fval == 0)
{
std::ifstream ifs(name);
sleep(1);
ifs.close();
exit(0);
}
std::ofstream ofs(name);
sleep(2);
ofs.put('t');
/*
* ISO/IED 14882:1998(E) 27.8.1.10.4
*
* void close();
*
* Effects: Calls rdbuf()->close() and, if that function fails
* (returns a null pointer), calls setstate(failbit)...
*/
ofs.close();
if (!(ofs.rdstate() & std::ios::failbit))
{
test = false;
VERIFY( test );
unlink(name);
exit(-1);
}
unlink(name);
}
int
main()
{
test_04();
return 0;
}
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.3 filebuf member functions
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %-*.txt
// various tests for filebuf::open() and filebuf::close() including
// the non-portable functionality in the libstdc++-v3 IO library
#include <fstream>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <testsuite_hooks.h>
// libstdc++/9964
void test_07()
{
using namespace std;
bool test = true;
const char* name = "tmp_fifo3";
signal(SIGPIPE, SIG_IGN);
unlink(name);
mkfifo(name, S_IRWXU);
int child = fork();
VERIFY( child != -1 );
if (child == 0)
{
filebuf fbin;
fbin.open(name, ios_base::in);
sleep(1);
fbin.close();
exit(0);
}
filebuf fb;
filebuf* ret = fb.open(name, ios_base::out | ios_base::trunc);
VERIFY( ret != NULL );
VERIFY( fb.is_open() );
sleep(2);
fb.sputc('a');
ret = fb.close();
VERIFY( ret == NULL );
VERIFY( !fb.is_open() );
}
int
main()
{
test_07();
return 0;
}
// 981208 bkoz test functionality of basic_stringbuf for char_type == char
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
#include <fstream>
#include <testsuite_hooks.h>
std::filebuf fbuf;
// test the filebuf locale settings
void test02()
{
std::locale loc_c = std::locale::classic();
loc_c = fbuf.getloc();
fbuf.pubimbue(loc_c); //This should initialize _M_init to true
std::locale loc_tmp = fbuf.getloc();
VERIFY( loc_tmp == loc_c );
}
int main()
{
test02();
return 0;
}
// more candy!!!
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <locale>
#include <testsuite_hooks.h>
// libstdc++/9322
void test07()
{
using std::locale;
bool test = true;
locale loc;
std::filebuf ob;
VERIFY( ob.getloc() == loc );
locale::global(locale("en_US"));
VERIFY( ob.getloc() == loc );
locale loc_de ("de_DE");
locale ret = ob.pubimbue(loc_de);
VERIFY( ob.getloc() == loc_de );
VERIFY( ret == loc );
locale::global(loc);
VERIFY( ob.getloc() == loc_de );
}
main()
{
__gnu_cxx_test::run_test_wrapped_generic_locale_exception_catcher(test07);
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <locale>
#include <testsuite_hooks.h>
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %*.txt
// NB: This test assumes that _M_buf_size == 40, and not the usual
// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
// simulated a bit more readily.
// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
const int buffer_size = 8192;
//const int buffer_size = 40;
const char carray_01[] = "santa cruz or sandiego?";
const char carray_02[] = "memphis, new orleans, and savanah";
const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
const char name_04[] = "filebuf_virtuals-4.txt"; // empty file, need to create
const char name_05[] = "filebuf_virtuals-5.txt"; // empty file, need to create
const char name_06[] = "filebuf_virtuals-6.txt"; // empty file, need to create
const char name_07[] = "filebuf_virtuals-7.txt"; // empty file, need to create
const char name_08[] = "filebuf_virtuals-8.txt"; // empty file, need to create
class derived_filebuf: public std::filebuf
{
public:
void
set_size(int_type __size) { _M_buf_size_opt = __size; }
};
derived_filebuf fb_01; // in
derived_filebuf fb_02; // out
derived_filebuf fb_03; // in | out
// Initialize filebufs to be the same size regardless of platform.
void test03()
{
fb_01.set_size(buffer_size);
fb_02.set_size(buffer_size);
fb_03.set_size(buffer_size);
}
// Test overloaded virtual functions.
void test05()
{
typedef std::filebuf::int_type int_type;
typedef std::filebuf::traits_type traits_type;
typedef std::filebuf::pos_type pos_type;
typedef std::filebuf::off_type off_type;
typedef size_t size_type;
bool test = true;
std::filebuf f_tmp;
std::streamsize strmsz_1, strmsz_2;
std::streamoff strmof_1, strmof_2;
int i = 0, j = 0, k = 0;
// GET
// int in_avail()
// if a read position is available, return _M_in_end - _M_in_cur.
// else return showmanyc.
strmof_1 = fb_01.in_avail();
strmof_2 = fb_02.in_avail();
VERIFY( strmof_1 == -1 );
VERIFY( strmof_1 == strmof_2 ); //fail because not open
strmof_1 = fb_03.in_avail();
VERIFY( strmof_1 == strmof_2 );
fb_01.open(name_01, std::ios_base::in);
fb_02.open(name_02, std::ios_base::out | std::ios_base::trunc);
fb_03.open(name_03, std::ios_base::out | std::ios_base::in | std::ios_base::trunc);
strmof_1 = fb_01.in_avail();
strmof_2 = fb_02.in_avail();
VERIFY( strmof_1 != strmof_2 );
VERIFY( strmof_1 >= 0 );
VERIFY( strmof_2 == -1 ); // empty file
strmof_1 = fb_03.in_avail();
VERIFY( strmof_1 == 0 ); // empty file
}
main()
{
test03();
test05();
return 0;
}
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.3 filebuf member functions
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %-*.txt
// various tests for filebuf::open() and filebuf::close() including
// the non-portable functionality in the libstdc++-v3 IO library
#include <fstream>
#include <testsuite_hooks.h>
const char name_01[] = "filebuf_members-1.tst";
const char name_02[] = "filebuf_members-1.txt";
// Test member functions.
void test_01()
{
bool test = true;
const char* name_03 = "filebuf_members-3"; // empty file, need to create
std::filebuf fb_01; // in
std::filebuf fb_02; // out
std::filebuf fb_03; // in | out
// bool is_open()
VERIFY( !fb_01.is_open() );
VERIFY( !fb_02.is_open() );
VERIFY( !fb_03.is_open() );
// filebuf_type* open(const char* __s, ios_base::openmode __mode)
fb_01.open(name_01, std::ios_base::in | std::ios_base::ate);
fb_02.open(name_02, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
fb_03.open(name_03, std::ios_base::out | std::ios_base::trunc);
VERIFY( fb_01.is_open() );
VERIFY( fb_02.is_open() );
VERIFY( fb_03.is_open() );
// filebuf_type* close()
fb_01.close();
fb_02.close();
fb_03.close();
VERIFY( !fb_01.is_open() );
VERIFY( !fb_02.is_open() );
VERIFY( !fb_03.is_open() );
}
int
main()
{
test_01();
return 0;
}
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.3 filebuf member functions
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %-*.txt
// various tests for filebuf::open() and filebuf::close() including
// the non-portable functionality in the libstdc++-v3 IO library
#include <fstream>
#include <testsuite_hooks.h>
const char name_01[] = "filebuf_members-1.tst";
const char name_02[] = "filebuf_members-1.txt";
// Test member functions.
void test_01()
{
bool test = true;
const char* name_03 = "filebuf_members-3"; // empty file, need to create
std::filebuf fb_01; // in
std::filebuf fb_02; // out
std::filebuf fb_03; // in | out
// bool is_open()
VERIFY( !fb_01.is_open() );
VERIFY( !fb_02.is_open() );
VERIFY( !fb_03.is_open() );
// filebuf_type* open(const char* __s, ios_base::openmode __mode)
fb_01.open(name_01, std::ios_base::in | std::ios_base::ate);
VERIFY( fb_01.is_open() );
// Try to open two different files without closing the first:
// Should keep the old file attached, and disregard attempt to overthrow.
std::filebuf* f = fb_02.open(name_02, std::ios_base::in | std::ios_base::out
| std::ios_base::trunc);
VERIFY( f != NULL );
VERIFY( fb_02.is_open() );
f = fb_02.open(name_03, std::ios_base::in | std::ios_base::out);
VERIFY( f == NULL );
VERIFY( fb_02.is_open() );
fb_03.open(name_03, std::ios_base::out | std::ios_base::trunc);
VERIFY( fb_03.is_open() );
}
int
main()
{
test_01();
return 0;
}
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.3 filebuf member functions
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %-*.txt
// various tests for filebuf::open() and filebuf::close() including
// the non-portable functionality in the libstdc++-v3 IO library
#include <fstream>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ext/stdio_filebuf.h>
#include <testsuite_hooks.h>
const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
void test_03()
{
bool test = true;
int first_fd = ::open(name_01, O_RDONLY);
VERIFY( first_fd != -1 );
FILE* first_file = ::fdopen(first_fd, "r");
VERIFY( first_file != NULL );
__gnu_cxx::stdio_filebuf<char> fb(first_file, std::ios_base::in);
int second_fd = fb.fd();
VERIFY( first_fd == second_fd );
}
int
main()
{
test_03();
return 0;
}
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.3 filebuf member functions
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %-*.txt
// various tests for filebuf::open() and filebuf::close() including
// the non-portable functionality in the libstdc++-v3 IO library
#include <fstream>
#include <testsuite_hooks.h>
// Charles Leggett <CGLeggett@lbl.gov>
void test_05()
{
bool test = true;
const char* name = "tmp_file5";
std::fstream scratch_file;
scratch_file.open(name, std::ios::out);
scratch_file.close();
scratch_file.open(name, std::ios::in);
if (!scratch_file)
VERIFY( false );
scratch_file.close();
}
int
main()
{
test_05();
return 0;
}
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.3 filebuf member functions
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %-*.txt
// various tests for filebuf::open() and filebuf::close() including
// the non-portable functionality in the libstdc++-v3 IO library
#include <fstream>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <testsuite_hooks.h>
// libstdc++/9507
void test_06()
{
bool test = true;
const char* name = "tmp_fifo2";
signal(SIGPIPE, SIG_IGN);
unlink(name);
mkfifo(name, S_IRWXU);
if (!fork())
{
std::filebuf fbuf;
fbuf.open(name, std::ios_base::in);
fbuf.sgetc();
fbuf.close();
exit(0);
}
std::filebuf fbuf;
std::filebuf* r = fbuf.open(name, std::ios_base::out | std::ios_base::ate);
VERIFY( !fbuf.is_open() );
VERIFY( r == NULL );
}
int
main()
{
test_06();
return 0;
}
// 1999-10-11 bkoz
// Copyright (C) 1999, 2000, 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <fstream>
#include <ostream>
#include <testsuite_hooks.h>
// test03
// http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00151.html
template<typename charT, typename traits = std::char_traits<charT> >
class basic_nullbuf : public std::basic_filebuf<charT, traits>
{
protected:
typedef typename
std::basic_filebuf<charT, traits>::int_type int_type;
virtual int_type
overflow(int_type c)
{ return traits::not_eof(c); }
};
typedef basic_nullbuf<char> nullbuf;
template<typename T>
char
print(const T& x)
{
nullbuf ob;
std::ostream out(&ob);
out << x << std::endl;
return (!out ? '0' : '1');
}
void test03()
{
bool test = true;
const std::string control01("11111");
std::string test01;
test01 += print(true);
test01 += print(3.14159);
test01 += print(10);
test01 += print('x');
test01 += print("pipo");
VERIFY( test01 == control01 );
}
int main()
{
test03();
return 0;
}
// 1999-10-11 bkoz
// Copyright (C) 1999, 2000, 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <fstream>
#include <ostream>
#include <testsuite_hooks.h>
// libstdc++/3599
class testbuf : public std::filebuf
{
public:
typedef std::filebuf::traits_type traits_type;
testbuf() : std::filebuf() { }
protected:
int_type
overflow(int_type c = traits_type::eof())
{ return traits_type::not_eof(0); }
};
void
test07()
{
bool test = true;
testbuf ob;
std::ostream out(&ob);
out << "gasp";
VERIFY(out.good());
out << std::endl;
VERIFY(out.good());
}
int main()
{
test07();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <locale>
#include <testsuite_hooks.h>
const char name_04[] = "filebuf_virtuals-4.txt"; // empty file, need to create
class Cvt_to_upper : public std::codecvt<char, char, mbstate_t>
{
bool do_always_noconv() const throw()
{
return false;
}
};
// libstdc++/9169
// filebuf output fails if codecvt<>::out returns noconv
void test10()
{
using namespace std;
bool test = true;
locale c_loc = locale::classic();
locale loc(c_loc, new Cvt_to_upper);
string str("abcdefghijklmnopqrstuvwxyz");
string tmp;
{
ofstream out;
out.imbue(loc);
out.open(name_04);
copy(str.begin(), str.end(), ostreambuf_iterator<char>(out));
}
{
ifstream in;
in.open(name_04);
copy(istreambuf_iterator<char>(in), istreambuf_iterator<char>(),
back_inserter(tmp));
}
VERIFY( tmp.size() == str.size() );
VERIFY( tmp == str );
}
main()
{
test10();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <locale>
#include <testsuite_hooks.h>
const char name_07[] = "filebuf_virtuals-7.txt"; // empty file, need to create
class errorcvt : public std::codecvt<char, char, mbstate_t>
{
protected:
std::codecvt_base::result
do_out(mbstate_t&, const char* from, const char*,
const char*& from_next, char* to, char*,
char*& to_next) const
{
from_next = from;
to_next = to;
return std::codecvt<char, char, mbstate_t>::error;
}
virtual bool do_always_noconv() const throw()
{
return false;
}
};
// libstdc++/9182
// basic_filebuf<>::sync and overflow do not write out any characters
// if codecvt<>::out returns error
void test14()
{
using namespace std;
bool test = true;
locale loc = locale::classic();
loc = locale(loc, new errorcvt);
filebuf fbuf1;
fbuf1.pubimbue(loc);
fbuf1.pubsetbuf(0, 0);
fbuf1.open(name_07, ios_base::out | ios_base::trunc);
streamsize n = fbuf1.sputn("onne", 4);
VERIFY( n == 0 );
fbuf1.close();
}
main()
{
test14();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <testsuite_hooks.h>
const char name_08[] = "filebuf_virtuals-8.txt"; // empty file, need to create
class OverBuf : public std::filebuf
{
public:
int_type pub_overflow(int_type c = traits_type::eof())
{ return std::filebuf::overflow(c); }
};
// libstdc++/9988
// filebuf::overflow writes EOF to file
void test15()
{
using namespace std;
bool test = true;
OverBuf fb;
fb.open(name_08, ios_base::out | ios_base::trunc);
fb.sputc('a');
fb.pub_overflow('b');
fb.pub_overflow();
fb.sputc('c');
fb.close();
filebuf fbin;
fbin.open(name_08, ios_base::in);
filebuf::int_type c;
c = fbin.sbumpc();
VERIFY( c == 'a' );
c = fbin.sbumpc();
VERIFY( c == 'b' );
c = fbin.sbumpc();
VERIFY( c == 'c' );
c = fbin.sbumpc();
VERIFY( c == filebuf::traits_type::eof() );
fbin.close();
}
main()
{
test15();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <testsuite_hooks.h>
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %*.txt
// NB: This test assumes that _M_buf_size == 40, and not the usual
// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
// simulated a bit more readily.
// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
const int buffer_size = 8192;
//const int buffer_size = 40;
const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
class derived_filebuf: public std::filebuf
{
public:
void
set_size(int_type __size) { _M_buf_size_opt = __size; }
};
derived_filebuf fb_01; // in
derived_filebuf fb_02; // out
derived_filebuf fb_03; // in | out
// Initialize filebufs to be the same size regardless of platform.
void test03()
{
fb_01.set_size(buffer_size);
fb_02.set_size(buffer_size);
fb_03.set_size(buffer_size);
}
// Test overloaded virtual functions.
void test05()
{
using namespace std;
typedef filebuf::int_type int_type;
typedef filebuf::traits_type traits_type;
typedef filebuf::pos_type pos_type;
typedef filebuf::off_type off_type;
typedef size_t size_type;
bool test = true;
filebuf f_tmp;
streamsize strmsz_1, strmsz_2;
streamoff strmof_1, strmof_2;
int i = 0, j = 0, k = 0;
// GET
fb_01.open(name_01, ios_base::in);
fb_02.open(name_02, ios_base::out | ios_base::trunc);
fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
strmof_1 = fb_01.in_avail();
strmof_2 = fb_02.in_avail();
strmof_1 = fb_03.in_avail();
// int_type sbumpc()
// if read_cur not avail returns uflow(), else return *read_cur & increment
int_type c1 = fb_01.sbumpc();
int_type c2 = fb_02.sbumpc();
VERIFY( c1 != c2 );
VERIFY( c1 == '/' );
VERIFY( c2 == -1 );
int_type c3 = fb_01.sbumpc();
int_type c4 = fb_02.sbumpc();
VERIFY( c3 != c4 );
VERIFY( c1 == c3 ); // fluke, both happen to be '/'
VERIFY( c2 == c4 );
int_type c5 = fb_03.sbumpc();
VERIFY( c5 == traits_type::eof() );
// XXX should do some kind of test to make sure that internal
// buffers point to the same thing, to check consistancy.
}
main()
{
test03();
test05();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <testsuite_hooks.h>
const char name_06[] = "filebuf_virtuals-6.txt"; // empty file, need to create
// libstdc++/9825
// filebuf::sputbackc breaks sbumpc
void test12()
{
using namespace std;
bool test = true;
filebuf fbuf;
fbuf.open(name_06, ios_base::in|ios_base::out|ios_base::trunc);
fbuf.sputn("crazy bees!", 11);
fbuf.pubseekoff(0, ios_base::beg);
fbuf.sbumpc();
fbuf.sputbackc('x');
filebuf::int_type c = fbuf.sbumpc();
VERIFY( c == 'x' );
c = fbuf.sbumpc();
VERIFY( c == 'r' );
c = fbuf.sbumpc();
VERIFY( c == 'a' );
fbuf.close();
}
main()
{
test12();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <testsuite_hooks.h>
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %*.txt
// NB: This test assumes that _M_buf_size == 40, and not the usual
// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
// simulated a bit more readily.
// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
const int buffer_size = 8192;
//const int buffer_size = 40;
const char name_01[] = "filebuf_virtuals-1.txt"; // empty file, need to create
class derived_filebuf: public std::filebuf
{
public:
void
set_size(int_type __size) { _M_buf_size_opt = __size; }
};
derived_filebuf fb_03; // in | out
// Initialize filebufs to be the same size regardless of platform.
void test03()
{
fb_03.set_size(buffer_size);
}
// Test overloaded virtual functions.
void test05()
{
using namespace std;
typedef filebuf::int_type int_type;
typedef filebuf::traits_type traits_type;
typedef filebuf::pos_type pos_type;
typedef filebuf::off_type off_type;
typedef size_t size_type;
bool test = true;
filebuf f_tmp;
streamsize strmsz_1, strmsz_2;
streamoff strmof_1, strmof_2;
int i = 0, j = 0, k = 0;
fb_03.open(name_01, ios_base::out | ios_base::in);
int_type c1;
int_type c2;
int_type c3;
// seekoff
// pubseekoff(off_type off, ios_base::seekdir way, ios_base::openmode which)
// alters the stream position to off
pos_type pt_1(off_type(-1));
pos_type pt_2(off_type(0));
off_type off_1 = 0;
off_type off_2 = 0;
//IN|OUT
// 27filebuf-3.txt = bd23456789:;<=>?...
//beg
strmsz_1 = fb_03.in_avail();
pt_1 = fb_03.pubseekoff(2, ios_base::beg);
strmsz_2 = fb_03.in_avail();
off_1 = pt_1;
VERIFY( off_1 > 0 );
c1 = fb_03.snextc(); //current in pointer +1
VERIFY( c1 == '9' );
c2 = fb_03.sputc('\n'); //current in pointer +1
c3 = fb_03.sgetc();
VERIFY( c2 != c3 );
VERIFY( c3 == '9' );
fb_03.pubsync();
c1 = fb_03.sgetc();
VERIFY( c1 == c3 );
//cur
// 27filebuf-3.txt = bd2\n456789:;<=>?...
pt_2 = fb_03.pubseekoff(2, ios_base::cur);
off_2 = pt_2;
VERIFY( (off_2 == (off_1 + 2 + 1 + 1)) );
c1 = fb_03.snextc(); //current in pointer +1
VERIFY( c1 == '1' );
c2 = fb_03.sputc('x'); //test current out pointer
c3 = fb_03.sputc('\n');
c1 = fb_03.sgetc();
fb_03.pubsync();
c3 = fb_03.sgetc();
VERIFY( c1 == c3 );
//end
// 27filebuf-3.txt = "bd2\n456x\n9"
pt_2 = fb_03.pubseekoff(0, ios_base::end, ios_base::in|ios_base::out);
off_1 = pt_2;
VERIFY( off_1 > off_2 ); //weak, but don't know exactly where it ends
c3 = fb_03.sputc('\n');
strmsz_1 = fb_03.sputn("because because because. . .", 28);
VERIFY( strmsz_1 == 28 );
c1 = fb_03.sungetc();
// Defect? retval of sungetc is not necessarily the character ungotten.
// So re-get it.
c1 = fb_03.sgetc();
fb_03.pubsync();
c3 = fb_03.sgetc();
VERIFY( c1 == c3 );
// IN
// OUT
}
main()
{
test03();
test05();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.7.1.3 Overridden virtual functions
#include <fstream>
#include <testsuite_hooks.h>
void test02(std::filebuf& in, bool pass)
{
bool test = true;
using namespace std;
typedef streambuf::pos_type pos_type;
typedef streambuf::off_type off_type;
pos_type bad = pos_type(off_type(-1));
pos_type p = 0;
// seekoff
p = in.pubseekoff(0, ios_base::beg, ios_base::in);
if (pass)
VERIFY( p != bad );
p = in.pubseekoff(0, ios_base::beg, ios_base::out);
VERIFY( p == bad );
p = in.pubseekoff(0, ios_base::beg);
if (pass)
VERIFY( p != bad );
}
const char name_01[] = "filebuf_virtuals-1.tst"; // file with data in it
const char name_03[] = "filebuf_members-1.tst"; // empty file
int main()
{
using namespace std;
// movie star, submarine scientist!
filebuf in1;
in1.open(name_01, ios_base::in);
filebuf in2;
filebuf in3;
in3.open(name_03, ios_base::in);
test02(in1, true);
test02(in2, false);
test02(in3, true);
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <testsuite_hooks.h>
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %*.txt
// NB: This test assumes that _M_buf_size == 40, and not the usual
// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
// simulated a bit more readily.
// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
const int buffer_size = 8192;
//const int buffer_size = 40;
const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
class derived_filebuf: public std::filebuf
{
public:
void
set_size(int_type __size) { _M_buf_size_opt = __size; }
};
derived_filebuf fb_03; // in | out
// Initialize filebufs to be the same size regardless of platform.
void test03()
{
fb_03.set_size(buffer_size);
}
// Test overloaded virtual functions.
void test05()
{
using namespace std;
typedef filebuf::int_type int_type;
typedef filebuf::traits_type traits_type;
typedef filebuf::pos_type pos_type;
typedef filebuf::off_type off_type;
typedef size_t size_type;
bool test = true;
filebuf f_tmp;
streamsize strmsz_1, strmsz_2;
streamoff strmof_1, strmof_2;
int i = 0, j = 0, k = 0;
fb_03.open(name_01, ios_base::out | ios_base::in);
int_type c1;
int_type c2;
int_type c3;
// seekpos
// pubseekpos(pos_type sp, ios_base::openmode)
// alters the stream position to sp
pos_type pt_1(off_type(-1));
pos_type pt_2(off_type(0));
off_type off_1 = 0;
off_type off_2 = 0;
//IN|OUT
//beg
pt_1 = fb_03.pubseekoff(78, ios_base::beg);
off_1 = pt_1;
VERIFY( off_1 > 0 );
c1 = fb_03.snextc(); //current in pointer +1
VERIFY( c1 == 't' );
c2 = fb_03.sputc('\n'); //test current out pointer
c3 = fb_03.sgetc();
fb_03.pubsync(); //resets pointers
pt_2 = fb_03.pubseekpos(pt_1);
off_2 = pt_2;
VERIFY( off_1 == off_2 );
c3 = fb_03.snextc(); //current in pointer +1
VERIFY( c2 == c3 );
pt_1 = fb_03.pubseekoff(0, ios_base::end);
off_1 = pt_1;
VERIFY( off_1 > off_2 );
fb_03.sputn("\nof the wonderful things he does!!\nok", 37);
fb_03.pubsync();
// IN
// OUT
// VIRTUALS (indirectly tested)
// underflow
// if read position avail, returns *gptr()
// pbackfail(int_type c)
// put c back into input sequence
// overflow
// appends c to output seq
// NB Have to close these suckers. . .
// filebuf_type* close()
fb_03.close();
VERIFY( !fb_03.is_open() );
}
main()
{
test03();
test05();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.7.1.3 Overridden virtual functions
#include <fstream>
#include <testsuite_hooks.h>
void test02(std::filebuf& in, bool pass)
{
bool test = true;
using namespace std;
typedef streambuf::pos_type pos_type;
typedef streambuf::off_type off_type;
pos_type bad = pos_type(off_type(-1));
pos_type p = 0;
// seekpos
p = in.pubseekpos(0, ios_base::in);
if (pass)
VERIFY( p != bad );
p = in.pubseekpos(0, ios_base::out);
VERIFY( p == bad );
p = in.pubseekpos(0);
if (pass)
VERIFY( p != bad );
}
const char name_01[] = "filebuf_virtuals-1.tst"; // file with data in it
const char name_03[] = "filebuf_members-1.tst"; // empty file
int main()
{
using namespace std;
// movie star, submarine scientist!
filebuf in1;
in1.open(name_01, ios_base::in);
filebuf in2;
filebuf in3;
in3.open(name_03, ios_base::in);
test02(in1, true);
test02(in2, false);
test02(in3, true);
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <testsuite_hooks.h>
class testbuf : public std::filebuf
{
public:
// Typedefs:
typedef std::filebuf base_type;
typedef base_type::traits_type traits_type;
typedef base_type::char_type char_type;
testbuf(): base_type()
{ _M_mode = (std::ios_base::in | std::ios_base::out); }
bool
check_pointers()
{
bool test = true;
test = (this->pbase() == NULL);
test &= (this->pptr() == NULL);
return test;
}
};
const char name_01[] = "filebuf_virtuals-1.txt";
// Test overloaded virtual functions.
void test05()
{
using namespace std;
typedef std::filebuf::int_type int_type;
typedef std::filebuf::traits_type traits_type;
typedef std::filebuf::pos_type pos_type;
typedef std::filebuf::off_type off_type;
typedef size_t size_type;
bool test = true;
int_type c1;
{
testbuf f_tmp;
// setbuf
// pubsetbuf(char_type* s, streamsize n)
f_tmp.pubsetbuf(0,0);
VERIFY( f_tmp.check_pointers() );
}
{
testbuf f_tmp;
f_tmp.open(name_01, ios_base::out | ios_base::in);
int_type c1 = f_tmp.sbumpc();
// setbuf
// pubsetbuf(char_type* s, streamsize n)
f_tmp.pubsetbuf(0, 0);
VERIFY( !f_tmp.check_pointers() );
}
}
main()
{
test05();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <testsuite_hooks.h>
void test01()
{
using namespace std;
bool test = true;
char buf[512];
const char* strlit = "how to tell a story and other essays: mark twain";
const size_t strlitsize = std::strlen(strlit);
filebuf fbuf;
fbuf.open("tmp_setbuf2", ios_base::out);
fbuf.pubsetbuf(buf, 512);
fbuf.sputn(strlit, strlitsize);
VERIFY( std::strncmp(strlit, buf, strlitsize) == 0 );
}
main()
{
test01();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <testsuite_hooks.h>
void test02()
{
using namespace std;
bool test = true;
char buf[512];
const char* strlit = "how to tell a story and other essays: mark twain";
const size_t strlitsize = std::strlen(strlit);
filebuf fbuf01;
fbuf01.open("tmp", ios_base::out);
fbuf01.pubsetbuf(buf, strlitsize);
fbuf01.sputn(strlit, strlitsize);
VERIFY( std::strncmp(strlit, buf, strlitsize) == 0 );
}
main()
{
test02();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <locale>
#include <testsuite_hooks.h>
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %*.txt
// NB: This test assumes that _M_buf_size == 40, and not the usual
// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
// simulated a bit more readily.
// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
const int buffer_size = 8192;
//const int buffer_size = 40;
const char carray_01[] = "santa cruz or sandiego?";
const char carray_02[] = "memphis, new orleans, and savanah";
const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
const char name_04[] = "filebuf_virtuals-4.txt"; // empty file, need to create
const char name_05[] = "filebuf_virtuals-5.txt"; // empty file, need to create
const char name_06[] = "filebuf_virtuals-6.txt"; // empty file, need to create
const char name_07[] = "filebuf_virtuals-7.txt"; // empty file, need to create
const char name_08[] = "filebuf_virtuals-8.txt"; // empty file, need to create
class derived_filebuf: public std::filebuf
{
public:
void
set_size(int_type __size) { _M_buf_size_opt = __size; }
};
derived_filebuf fb_01; // in
derived_filebuf fb_02; // out
derived_filebuf fb_03; // in | out
// Initialize filebufs to be the same size regardless of platform.
void test03()
{
fb_01.set_size(buffer_size);
fb_02.set_size(buffer_size);
fb_03.set_size(buffer_size);
}
// Test overloaded virtual functions.
void test05()
{
typedef std::filebuf::int_type int_type;
typedef std::filebuf::traits_type traits_type;
typedef std::filebuf::pos_type pos_type;
typedef std::filebuf::off_type off_type;
typedef size_t size_type;
bool test = true;
std::filebuf f_tmp;
std::streamsize strmsz_1, strmsz_2;
std::streamoff strmof_1, strmof_2;
int i = 0, j = 0, k = 0;
// GET
fb_01.open(name_01, std::ios_base::in);
fb_02.open(name_02, std::ios_base::out | std::ios_base::trunc);
fb_03.open(name_03, std::ios_base::out | std::ios_base::in | std::ios_base::trunc);
strmof_1 = fb_01.in_avail();
strmof_2 = fb_02.in_avail();
strmof_1 = fb_03.in_avail();
int_type c1 = fb_01.sbumpc();
int_type c2 = fb_02.sbumpc();
int_type c3 = fb_01.sbumpc();
int_type c4 = fb_02.sbumpc();
int_type c5 = fb_03.sbumpc();
// int_type sgetc()
// if read_cur not avail, return uflow(), else return *read_cur
int_type c6 = fb_01.sgetc();
int_type c7 = fb_02.sgetc();
VERIFY( c6 != c3 );
VERIFY( c7 == c4 ); // both -1
int_type c8 = fb_01.sgetc();
int_type c9 = fb_02.sgetc();
VERIFY( c6 == c8 );
VERIFY( c7 == c9 );
c5 = fb_03.sgetc();
VERIFY( c5 == traits_type::eof() );
}
main()
{
test03();
test05();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <testsuite_hooks.h>
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %*.txt
// NB: This test assumes that _M_buf_size == 40, and not the usual
// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
// simulated a bit more readily.
// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
const int buffer_size = 8192;
//const int buffer_size = 40;
const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
class derived_filebuf: public std::filebuf
{
public:
void
set_size(int_type __size) { _M_buf_size_opt = __size; }
};
derived_filebuf fb_01; // in
derived_filebuf fb_02; // out
derived_filebuf fb_03; // in | out
// Initialize filebufs to be the same size regardless of platform.
void test03()
{
fb_01.set_size(buffer_size);
fb_02.set_size(buffer_size);
fb_03.set_size(buffer_size);
}
// Test overloaded virtual functions.
void test05()
{
using namespace std;
typedef filebuf::int_type int_type;
typedef filebuf::traits_type traits_type;
typedef filebuf::pos_type pos_type;
typedef filebuf::off_type off_type;
typedef size_t size_type;
bool test = true;
filebuf f_tmp;
streamsize strmsz_1, strmsz_2;
streamoff strmof_1, strmof_2;
int i = 0, j = 0, k = 0;
// GET
fb_01.open(name_01, ios_base::in);
fb_02.open(name_02, ios_base::out | ios_base::trunc);
fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
strmof_1 = fb_01.in_avail();
strmof_2 = fb_02.in_avail();
strmof_1 = fb_03.in_avail();
int_type c1 = fb_01.sbumpc();
int_type c2 = fb_02.sbumpc();
int_type c3 = fb_01.sbumpc();
int_type c4 = fb_02.sbumpc();
int_type c5 = fb_03.sbumpc();
int_type c6 = fb_01.sgetc();
int_type c7 = fb_02.sgetc();
int_type c8 = fb_01.sgetc();
int_type c9 = fb_02.sgetc();
c5 = fb_03.sgetc();
// int_type snextc()
// calls sbumpc and if sbumpc != eof, return sgetc
c6 = fb_01.snextc();
c7 = fb_02.snextc();
c6 = fb_01.snextc();
c7 = fb_02.snextc();
c5 = fb_03.snextc();
// streamsize sgetn(char_type *s, streamsize n)
// streamsize xsgetn(char_type *s, streamsize n)
// assign up to n chars to s from input sequence, indexing in_cur as
// approp and returning the number of chars assigned
strmsz_1 = fb_01.in_avail();
strmsz_2 = fb_02.in_avail();
test = strmsz_1 != strmsz_2;
char carray1[13] = "";
strmsz_1 = fb_01.sgetn(carray1, 10);
char carray2[buffer_size] = "";
strmsz_2 = fb_02.sgetn(carray2, 10);
VERIFY( strmsz_1 != strmsz_2 );
VERIFY( strmsz_1 == 10 );
VERIFY( strmsz_2 == 0 );
c1 = fb_01.sgetc();
c2 = fb_02.sgetc();
VERIFY( c1 == '\n' );
VERIFY( c7 == c2 ); // n != i
strmsz_1 = fb_03.sgetn(carray1, 10);
VERIFY( !strmsz_1 ); //zero
strmsz_1 = fb_01.in_avail();
strmsz_2 = fb_01.sgetn(carray2, strmsz_1 + 5);
VERIFY( strmsz_1 == strmsz_2 - 5 );
c4 = fb_01.sgetc(); // buffer should have underflowed from above.
VERIFY( c4 == 'i' );
strmsz_1 = fb_01.in_avail();
VERIFY( strmsz_1 > 0 );
strmsz_2 = fb_01.sgetn(carray2, strmsz_1 + 5);
VERIFY( strmsz_1 == strmsz_2 ); //at the end of the actual file
strmsz_1 = fb_02.in_avail();
strmsz_2 = fb_02.sgetn(carray2, strmsz_1 + 5);
VERIFY( strmsz_1 == -1 );
VERIFY( strmsz_2 == 0 );
c4 = fb_02.sgetc(); // should be EOF
VERIFY( c4 == traits_type::eof() );
}
main()
{
test03();
test05();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <testsuite_hooks.h>
const char name_01[] = "filebuf_virtuals-1.tst"; // empty file, need to create
void test06()
{
using namespace std;
bool test = true;
char buffer[] = "xxxxxxxxxx";
typedef filebuf::int_type int_type;
filebuf fbuf01;
fbuf01.open(name_01, ios_base::in);
int_type len1 = fbuf01.sgetn(buffer, sizeof(buffer));
VERIFY( len1 == sizeof(buffer) );
VERIFY( buffer[0] == '/' );
}
main()
{
test06();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <testsuite_hooks.h>
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %*.txt
// NB: This test assumes that _M_buf_size == 40, and not the usual
// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
// simulated a bit more readily.
// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
const int buffer_size = 8192;
//const int buffer_size = 40;
const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
class derived_filebuf: public std::filebuf
{
public:
void
set_size(int_type __size) { _M_buf_size_opt = __size; }
};
derived_filebuf fb_01; // in
derived_filebuf fb_02; // out
derived_filebuf fb_03; // in | out
// Initialize filebufs to be the same size regardless of platform.
void test03()
{
fb_01.set_size(buffer_size);
fb_02.set_size(buffer_size);
fb_03.set_size(buffer_size);
}
// Test overloaded virtual functions.
void test05()
{
using namespace std;
typedef filebuf::int_type int_type;
typedef filebuf::traits_type traits_type;
typedef filebuf::pos_type pos_type;
typedef filebuf::off_type off_type;
typedef size_t size_type;
bool test = true;
filebuf f_tmp;
streamsize strmsz_1, strmsz_2;
streamoff strmof_1, strmof_2;
int i = 0, j = 0, k = 0;
// GET
fb_01.open(name_01, ios_base::in);
fb_02.open(name_02, ios_base::out | ios_base::trunc);
fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
strmof_1 = fb_01.in_avail();
strmof_2 = fb_02.in_avail();
strmof_1 = fb_03.in_avail();
int_type c1 = fb_01.sbumpc();
int_type c2 = fb_02.sbumpc();
int_type c3 = fb_01.sbumpc();
int_type c4 = fb_02.sbumpc();
int_type c5 = fb_03.sbumpc();
int_type c6 = fb_01.sgetc();
int_type c7 = fb_02.sgetc();
int_type c8 = fb_01.sgetc();
int_type c9 = fb_02.sgetc();
c5 = fb_03.sgetc();
// int_type snextc()
// calls sbumpc and if sbumpc != eof, return sgetc
c6 = fb_01.snextc();
c7 = fb_02.snextc();
VERIFY( c6 != c8 );
VERIFY( c7 == c9 ); // -1
VERIFY( c6 == '\n' );
c6 = fb_01.snextc();
c7 = fb_02.snextc();
VERIFY( c6 != c8 );
VERIFY( c7 == c9 ); // -1
VERIFY( c6 == '9' );
c5 = fb_03.snextc();
VERIFY( c5 == traits_type::eof() );
}
main()
{
test03();
test05();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <locale>
#include <testsuite_hooks.h>
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %*.txt
// NB: This test assumes that _M_buf_size == 40, and not the usual
// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
// simulated a bit more readily.
// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
const int buffer_size = 8192;
//const int buffer_size = 40;
const char carray_01[] = "santa cruz or sandiego?";
const char carray_02[] = "memphis, new orleans, and savanah";
const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
const char name_04[] = "filebuf_virtuals-4.txt"; // empty file, need to create
const char name_05[] = "filebuf_virtuals-5.txt"; // empty file, need to create
const char name_06[] = "filebuf_virtuals-6.txt"; // empty file, need to create
const char name_07[] = "filebuf_virtuals-7.txt"; // empty file, need to create
const char name_08[] = "filebuf_virtuals-8.txt"; // empty file, need to create
class derived_filebuf: public std::filebuf
{
public:
void
set_size(int_type __size) { _M_buf_size_opt = __size; }
};
derived_filebuf fb_01; // in
derived_filebuf fb_02; // out
derived_filebuf fb_03; // in | out
// Initialize filebufs to be the same size regardless of platform.
void test03()
{
fb_01.set_size(buffer_size);
fb_02.set_size(buffer_size);
fb_03.set_size(buffer_size);
}
// Test overloaded virtual functions.
void test05()
{
typedef std::filebuf::int_type int_type;
typedef std::filebuf::traits_type traits_type;
typedef std::filebuf::pos_type pos_type;
typedef std::filebuf::off_type off_type;
typedef size_t size_type;
bool test = true;
std::filebuf f_tmp;
std::streamsize strmsz_1, strmsz_2;
std::streamoff strmof_1, strmof_2;
int i = 0, j = 0, k = 0;
fb_01.open(name_01, std::ios_base::in);
fb_02.open(name_02, std::ios_base::out | std::ios_base::trunc);
fb_03.open(name_03, std::ios_base::out | std::ios_base::in | std::ios_base::trunc);
int_type c1 = fb_01.sbumpc();
int_type c2 = fb_02.sbumpc();
int_type c3 = fb_01.sbumpc();
int_type c4 = fb_02.sbumpc();
int_type c5 = fb_03.sbumpc();
int_type c6 = fb_01.sgetc();
int_type c7 = fb_02.sgetc();
int_type c8 = fb_01.sgetc();
int_type c9 = fb_02.sgetc();
// PUT
strmsz_1 = fb_03.sputn("racadabras", 10);//"abracadabras or what?"
strmsz_2 = fb_03.sputn(", i wanna reach out and", 10);
strmsz_1 = fb_02.sputn("racadabras", 10);
strmsz_1 = fb_01.sputn("racadabra", 10);
// PUTBACK
// int_type pbfail(int_type c)
// called when gptr() null, gptr() == eback(), or traits::eq(*gptr, c) false
// "pending sequence" is:
// 1) everything as defined in underflow
// 2) + if (traits::eq_int_type(c, traits::eof()), then input
// sequence is backed up one char before the pending sequence is
// determined.
// 3) + if (not 2) then c is prepended. Left unspecified is
// whether the input sequence is backedup or modified in any way
// returns traits::eof() for failure, unspecified other value for success
// int_type sputbackc(char_type c)
// if in_cur not avail || ! traits::eq(c, gptr() [-1]), return pbfail
// otherwise decrements in_cur and returns *gptr()
c1 = fb_03.sgetc(); // -1
c2 = fb_03.sputbackc('z');
strmsz_2 = fb_03.in_avail();
c3 = fb_03.sgetc();
VERIFY( c3 == c2 );
VERIFY( c1 != c3 );
VERIFY( 1 == strmsz_2 );
//test for _in_cur == _in_beg
// fb_03._M_out_beg = "bd23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZracada" etc
fb_03.pubseekoff(10, std::ios_base::beg,
std::ios_base::in | std::ios_base::out);
fb_03.sputc('m');
strmsz_1 = fb_03.in_avail();
c1 = fb_03.sgetc();
fb_03.snextc();
c2 = fb_03.sputbackc('z');
strmsz_2 = fb_03.in_avail();
c3 = fb_03.sgetc();
VERIFY( c1 != c2 );
VERIFY( c3 == c2 );
VERIFY( c1 != c3 );
VERIFY( c2 == 'z' );
// VERIFY( strmsz_1 == strmsz_2 );
// test for replacing char with identical one
fb_03.snextc();
fb_03.sputc('u');
fb_03.sputc('v');
fb_03.sputc('a');
strmsz_1 = fb_03.in_avail();
c2 = fb_03.sputbackc('a');
strmsz_2 = fb_03.in_avail();
c3 = fb_03.sgetc();
VERIFY( c3 == c2 );
VERIFY( strmsz_1 + 1 == strmsz_2 );
//test for ios_base::out
c1 = fb_02.sgetc(); // undefined
c2 = fb_02.sputbackc('a');
VERIFY( c1 == c2 );
VERIFY( c1 == -1 );
}
main()
{
test03();
test05();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <testsuite_hooks.h>
const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
// libstdc++/9439, libstdc++/9425
// basic_filebuf<>::pbackfail calls basic_filebuf<>::seekoff, but
// fails to check the return value
void test09()
{
using namespace std;
bool test = true;
filebuf fbuf;
fbuf.open(name_01, ios_base::in);
filebuf::int_type r = fbuf.sputbackc('a');
fbuf.close();
VERIFY( r == filebuf::traits_type::eof() );
}
main()
{
test09();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <locale>
#include <testsuite_hooks.h>
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %*.txt
// NB: This test assumes that _M_buf_size == 40, and not the usual
// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
// simulated a bit more readily.
// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
const int buffer_size = 8192;
//const int buffer_size = 40;
const char carray_01[] = "santa cruz or sandiego?";
const char carray_02[] = "memphis, new orleans, and savanah";
const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
const char name_04[] = "filebuf_virtuals-4.txt"; // empty file, need to create
const char name_05[] = "filebuf_virtuals-5.txt"; // empty file, need to create
const char name_06[] = "filebuf_virtuals-6.txt"; // empty file, need to create
const char name_07[] = "filebuf_virtuals-7.txt"; // empty file, need to create
const char name_08[] = "filebuf_virtuals-8.txt"; // empty file, need to create
class derived_filebuf: public std::filebuf
{
public:
void
set_size(int_type __size) { _M_buf_size_opt = __size; }
};
derived_filebuf fb_01; // in
derived_filebuf fb_02; // out
derived_filebuf fb_03; // in | out
// Initialize filebufs to be the same size regardless of platform.
void test03()
{
fb_01.set_size(buffer_size);
fb_02.set_size(buffer_size);
fb_03.set_size(buffer_size);
}
// Test overloaded virtual functions.
void test05()
{
typedef std::filebuf::int_type int_type;
typedef std::filebuf::traits_type traits_type;
typedef std::filebuf::pos_type pos_type;
typedef std::filebuf::off_type off_type;
typedef size_t size_type;
bool test = true;
std::filebuf f_tmp;
std::streamsize strmsz_1, strmsz_2;
std::streamoff strmof_1, strmof_2;
int i = 0, j = 0, k = 0;
fb_01.open(name_01, std::ios_base::in);
fb_02.open(name_02, std::ios_base::out | std::ios_base::trunc);
fb_03.open(name_03, std::ios_base::out | std::ios_base::in | std::ios_base::trunc);
int_type c1 = fb_01.sbumpc();
int_type c2 = fb_02.sbumpc();
int_type c3 = fb_01.sbumpc();
int_type c4 = fb_02.sbumpc();
int_type c5 = fb_03.sbumpc();
int_type c6 = fb_01.sgetc();
int_type c7 = fb_02.sgetc();
int_type c8 = fb_01.sgetc();
int_type c9 = fb_02.sgetc();
// PUT
// int_type sputc(char_type c)
// if out_cur not avail, return overflow(traits_type::to_int_type(c))
// else, stores c at out_cur,
// increments out_cur, and returns c as int_type
// strmsz_1 = fb_03.in_avail(); // XXX valid for in|out??
c1 = fb_02.sputc('a');
c2 = fb_03.sputc('b');
VERIFY( c1 != c2 );
c1 = fb_02.sputc('c');
c2 = fb_03.sputc('d');
VERIFY( c1 != c2 );
// strmsz_2 = fb_03.in_avail();
// VERIFY( strmsz_1 != strmsz_2 );
for (int i = 50; i <= 90; ++i)
c2 = fb_02.sputc(char(i));
// 27filebuf-2.txt == ac23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWX
// fb_02._M_out_cur = '2'
strmsz_1 = fb_03.in_avail();
for (int i = 50; i <= 90; ++i)
c2 = fb_03.sputc(char(i));
strmsz_2 = fb_03.in_avail();
// VERIFY( strmsz_1 != strmsz_2 );
// VERIFY( strmsz_1 > 0 );
// VERIFY( strmsz_2 > 0 );
// 27filebuf-2.txt == bd23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWX
// fb_02._M_out_cur = '2'
c3 = fb_01.sputc('a'); // should be EOF because this is read-only
VERIFY( c3 == traits_type::eof() );
}
main()
{
test03();
test05();
return 0;
}
// 1999-10-11 bkoz
// Copyright (C) 1999, 2000, 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// 27.5.2 template class basic_streambuf
#include <string>
#include <fstream>
#include <testsuite_hooks.h>
class nullsetpbuf : public std::filebuf
{
char foo[64];
public:
nullsetpbuf()
{
setp(foo, foo + 64);
setp(NULL, NULL);
}
};
// libstdc++/1057
void test05()
{
std::string text1 = "abcdefghijklmn";
nullsetpbuf nsp;
// Immediate crash as sputc writes to null pointer
nsp.sputc('a');
}
int main()
{
test05();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <testsuite_hooks.h>
const char name_05[] = "filebuf_virtuals-5.txt"; // empty file, need to create
bool over_called;
class Derived_filebuf : public std::filebuf
{
public:
int_type overflow(int_type c)
{
over_called = true;
return std::filebuf::overflow(c);
}
const char_type* pub_epptr() const
{ return epptr(); }
const char_type* pub_pptr() const
{ return pptr(); }
};
// libstdc++/9701 (partial)
void test11()
{
bool test = true;
bool over_expected;
// sputc
Derived_filebuf dfbuf_01;
dfbuf_01.open(name_05, std::ios_base::out);
over_called = false;
dfbuf_01.sputc('i');
VERIFY( !over_called );
over_expected = dfbuf_01.pub_epptr() == dfbuf_01.pub_pptr();
over_called = false;
dfbuf_01.sputc('v');
VERIFY( (!over_expected && !over_called)
|| (over_expected && over_called) );
dfbuf_01.close();
}
main()
{
test11();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <locale>
#include <testsuite_hooks.h>
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %*.txt
// NB: This test assumes that _M_buf_size == 40, and not the usual
// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
// simulated a bit more readily.
// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
const int buffer_size = 8192;
//const int buffer_size = 40;
const char carray_01[] = "santa cruz or sandiego?";
const char carray_02[] = "memphis, new orleans, and savanah";
const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
const char name_04[] = "filebuf_virtuals-4.txt"; // empty file, need to create
const char name_05[] = "filebuf_virtuals-5.txt"; // empty file, need to create
const char name_06[] = "filebuf_virtuals-6.txt"; // empty file, need to create
const char name_07[] = "filebuf_virtuals-7.txt"; // empty file, need to create
const char name_08[] = "filebuf_virtuals-8.txt"; // empty file, need to create
class derived_filebuf: public std::filebuf
{
public:
void
set_size(int_type __size) { _M_buf_size_opt = __size; }
};
derived_filebuf fb_01; // in
derived_filebuf fb_02; // out
derived_filebuf fb_03; // in | out
// Initialize filebufs to be the same size regardless of platform.
void test03()
{
fb_01.set_size(buffer_size);
fb_02.set_size(buffer_size);
fb_03.set_size(buffer_size);
}
// Test overloaded virtual functions.
void test05()
{
typedef std::filebuf::int_type int_type;
typedef std::filebuf::traits_type traits_type;
typedef std::filebuf::pos_type pos_type;
typedef std::filebuf::off_type off_type;
typedef size_t size_type;
bool test = true;
std::filebuf f_tmp;
std::streamsize strmsz_1, strmsz_2;
std::streamoff strmof_1, strmof_2;
int i = 0, j = 0, k = 0;
fb_01.open(name_01, std::ios_base::in);
fb_02.open(name_02, std::ios_base::out | std::ios_base::trunc);
fb_03.open(name_03, std::ios_base::out | std::ios_base::in | std::ios_base::trunc);
int_type c1 = fb_01.sbumpc();
int_type c2 = fb_02.sbumpc();
int_type c3 = fb_01.sbumpc();
int_type c4 = fb_02.sbumpc();
int_type c5 = fb_03.sbumpc();
int_type c6 = fb_01.sgetc();
int_type c7 = fb_02.sgetc();
int_type c8 = fb_01.sgetc();
int_type c9 = fb_02.sgetc();
// PUT
// streamsize sputn(const char_typs* s, streamsize n)
// write up to n chars to out_cur from s, returning number assigned
// NB *sputn will happily put '\0' into your stream if you give it a chance*
strmsz_1 = fb_03.sputn("racadabras", 10);//"abracadabras or what?"
VERIFY( strmsz_1 == 10 );
strmsz_2 = fb_03.sputn(", i wanna reach out and", 10);
VERIFY( strmsz_2 == 10 );
VERIFY( strmsz_1 == strmsz_2 );
// fb_03._M_out_beg = "YZracadabras, i wanna FGHIJKLMNOPQRSTUVW"
// fb_03._M_out_cur = "FGHIJKLMNOPQRSTUVW"
strmsz_1 = fb_02.sputn("racadabras", 10);
VERIFY( strmsz_1 == 10 );
// fb_02._M_out_beg = "YZracadabras<=>?@ABCDEFGHIJKLMNOPQRSTUVW"
// fb_02._M_out_cur = "<=>?@ABCDEFGHIJKLMNOPQRSTUVW"
strmsz_1 = fb_01.sputn("racadabra", 10);
VERIFY( strmsz_1 == 0 );
}
main()
{
test03();
test05();
return 0;
}
// 1999-10-11 bkoz
// Copyright (C) 1999, 2000, 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// 27.5.2 template class basic_streambuf
#include <string>
#include <fstream>
#include <testsuite_hooks.h>
class nullsetpbuf : public std::filebuf
{
char foo[64];
public:
nullsetpbuf()
{
setp(foo, foo + 64);
setp(NULL, NULL);
}
};
// libstdc++/1057
void test05()
{
std::string text1 = "abcdefghijklmn";
nullsetpbuf nsp;
// Immediate crash as xsputn writes to null pointer
nsp.sputn(text1.c_str(), text1.length());
}
int main()
{
test05();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <testsuite_hooks.h>
const char name_05[] = "filebuf_virtuals-5.txt"; // empty file, need to create
bool over_called;
class Derived_filebuf : public std::filebuf
{
public:
int_type overflow(int_type c)
{
over_called = true;
return std::filebuf::overflow(c);
}
const char_type* pub_epptr() const
{
return epptr();
}
const char_type* pub_pptr() const
{
return pptr();
}
};
// libstdc++/9701 (partial)
void test11()
{
bool test = true;
bool over_expected;
// sputn
Derived_filebuf dfbuf_02;
dfbuf_02.open(name_05, std::ios_base::out);
over_called = false;
dfbuf_02.sputn("sonne's", 7);
VERIFY( !over_called );
over_expected = dfbuf_02.pub_epptr() == dfbuf_02.pub_pptr();
over_called = false;
dfbuf_02.sputn(" peak", 5);
VERIFY( (!over_expected && !over_called)
|| (over_expected && over_called) );
dfbuf_02.close();
}
main()
{
test11();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <locale>
#include <testsuite_hooks.h>
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %*.txt
// NB: This test assumes that _M_buf_size == 40, and not the usual
// buffer_size length of BUFSIZ (8192), so that overflow/underflow can be
// simulated a bit more readily.
// NRB (Nota Really Bene): setting it to 40 breaks the test, as intended.
const int buffer_size = 8192;
//const int buffer_size = 40;
const char carray_01[] = "santa cruz or sandiego?";
const char carray_02[] = "memphis, new orleans, and savanah";
const char name_01[] = "filebuf_virtuals-1.txt"; // file with data in it
const char name_02[] = "filebuf_virtuals-2.txt"; // empty file, need to create
const char name_03[] = "filebuf_virtuals-3.txt"; // empty file, need to create
const char name_04[] = "filebuf_virtuals-4.txt"; // empty file, need to create
const char name_05[] = "filebuf_virtuals-5.txt"; // empty file, need to create
const char name_06[] = "filebuf_virtuals-6.txt"; // empty file, need to create
const char name_07[] = "filebuf_virtuals-7.txt"; // empty file, need to create
const char name_08[] = "filebuf_virtuals-8.txt"; // empty file, need to create
class derived_filebuf: public std::filebuf
{
public:
void
set_size(int_type __size) { _M_buf_size_opt = __size; }
};
derived_filebuf fb_01; // in
derived_filebuf fb_02; // out
derived_filebuf fb_03; // in | out
// Initialize filebufs to be the same size regardless of platform.
void test03()
{
fb_01.set_size(buffer_size);
fb_02.set_size(buffer_size);
fb_03.set_size(buffer_size);
}
// Test overloaded virtual functions.
void test05()
{
typedef std::filebuf::int_type int_type;
typedef std::filebuf::traits_type traits_type;
typedef std::filebuf::pos_type pos_type;
typedef std::filebuf::off_type off_type;
typedef size_t size_type;
bool test = true;
std::filebuf f_tmp;
std::streamsize strmsz_1, strmsz_2;
std::streamoff strmof_1, strmof_2;
int i = 0, j = 0, k = 0;
fb_01.open(name_01, std::ios_base::in);
fb_02.open(name_02, std::ios_base::out | std::ios_base::trunc);
fb_03.open(name_03, std::ios_base::out | std::ios_base::in | std::ios_base::trunc);
int_type c1 = fb_01.sbumpc();
int_type c2 = fb_02.sbumpc();
int_type c3 = fb_01.sbumpc();
int_type c4 = fb_02.sbumpc();
int_type c5 = fb_03.sbumpc();
int_type c6 = fb_01.sgetc();
int_type c7 = fb_02.sgetc();
int_type c8 = fb_01.sgetc();
int_type c9 = fb_02.sgetc();
// PUT
strmsz_1 = fb_03.sputn("racadabras", 10);//"abracadabras or what?"
strmsz_2 = fb_03.sputn(", i wanna reach out and", 10);
strmsz_1 = fb_02.sputn("racadabras", 10);
strmsz_1 = fb_01.sputn("racadabra", 10);
// PUTBACK
// int_type pbfail(int_type c)
// called when gptr() null, gptr() == eback(), or traits::eq(*gptr, c) false
// "pending sequence" is:
// 1) everything as defined in underflow
// 2) + if (traits::eq_int_type(c, traits::eof()), then input
// sequence is backed up one char before the pending sequence is
// determined.
// 3) + if (not 2) then c is prepended. Left unspecified is
// whether the input sequence is backedup or modified in any way
// returns traits::eof() for failure, unspecified other value for success
// int_type sputbackc(char_type c)
// if in_cur not avail || ! traits::eq(c, gptr() [-1]), return pbfail
// otherwise decrements in_cur and returns *gptr()
c1 = fb_03.sgetc(); // -1
c2 = fb_03.sputbackc('z');
strmsz_2 = fb_03.in_avail();
c3 = fb_03.sgetc();
//test for _in_cur == _in_beg
// fb_03._M_out_beg = "bd23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZracada" etc
fb_03.pubseekoff(10, std::ios_base::beg,
std::ios_base::in | std::ios_base::out);
fb_03.sputc('m');
strmsz_1 = fb_03.in_avail();
c1 = fb_03.sgetc();
fb_03.snextc();
c2 = fb_03.sputbackc('z');
strmsz_2 = fb_03.in_avail();
c3 = fb_03.sgetc();
fb_03.snextc();
fb_03.sputc('u');
fb_03.sputc('v');
fb_03.sputc('a');
strmsz_1 = fb_03.in_avail();
c2 = fb_03.sputbackc('a');
strmsz_2 = fb_03.in_avail();
c3 = fb_03.sgetc();
//test for ios_base::out
c1 = fb_02.sgetc(); // undefined
c2 = fb_02.sputbackc('a');
// int_type sungetc()
// if in_cur not avail, return pbackfail(), else decrement and
// return to_int_type(*gptr())
// fb_03._M_out_beg = "uvaacadabras, i wannaZ[\\]^_`abcdefghijkl"
// fb_03._M_out_cur = "aacadabras, i wannaZ[\\]^_`abcdefghijkl"
strmsz_1 = fb_03.in_avail();
c2 = fb_03.sungetc(); // delete the 'a'
strmsz_2 = fb_03.in_avail();
VERIFY( c2 == 'v' ); // VERIFY( c2 != traits_type::eof() );
VERIFY( strmsz_1 + 1 == strmsz_2 );
//test for _in_cur == _in_beg
for (int i = 50; i < 32 + 29; ++i)
fb_02.sputc(char(i));
fb_02.pubseekoff(0, std::ios_base::beg, std::ios_base::out);
c1 = fb_02.sgetc();
strmsz_1 = fb_02.in_avail();
c2 = fb_02.sungetc();
c3 = fb_02.sgetc();
strmsz_2 = fb_02.in_avail();
VERIFY( c1 == c2 );
VERIFY( c2 == c3 );
VERIFY( c1 == traits_type::eof() );
VERIFY( strmsz_1 == strmsz_2 );
//test for _in_cur == _in_end
fb_03.pubseekoff(0, std::ios_base::end);
strmsz_1 = fb_03.in_avail(); // -1 cuz at the end
c1 = fb_03.sgetc();
c2 = fb_03.sungetc();
strmsz_2 = fb_03.in_avail(); // 1
c3 = fb_03.sgetc();
VERIFY( c1 != c2 );
// VERIFY( c2 == c3 || c2 == traits_type::not_eof(int(c3)) );
VERIFY( strmsz_2 != strmsz_1 );
VERIFY( strmsz_2 == 1 );
//test for ios_base::out
}
main()
{
test03();
test05();
return 0;
}
// 1999-10-11 bkoz
// Copyright (C) 1999, 2000, 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// 27.5.2 template class basic_streambuf
#include <fstream>
#include <testsuite_hooks.h>
class setpbuf : public std::filebuf
{
char buffer[4];
std::string result;
public:
std::string&
get_result()
{ return result; }
setpbuf()
{
this->open("tmp_1057", std::ios_base::out | std::ios_base::trunc);
char foo [32];
setp(foo, foo + 32);
setp(buffer, buffer + 4);
}
~setpbuf()
{
sync();
close();
}
virtual int_type
overflow(int_type n)
{
if (sync() != 0)
return traits_type::eof();
result += traits_type::to_char_type(n);
return n;
}
virtual int
sync()
{
result.append(pbase(), pptr());
setp(buffer, buffer + 4);
return 0;
}
};
// libstdc++/1057
void test04()
{
bool test = true;
std::string text = "abcdefghijklmn";
// 01
setpbuf sp1;
// Here xsputn writes over sp1.result
sp1.sputn(text.c_str(), text.length());
// This crashes when result is accessed
sp1.pubsync();
VERIFY( sp1.get_result() == text );
// 02
setpbuf sp2;
for (std::string::size_type i = 0; i < text.length(); ++i)
{
// sputc also writes over result
sp2.sputc(text[i]);
}
// Crash here
sp2.pubsync();
VERIFY( sp2.get_result() == text );
}
int main()
{
test04();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <locale>
#include <testsuite_hooks.h>
const char name_07[] = "filebuf_virtuals-7.txt"; // empty file, need to create
class errorcvt : public std::codecvt<char, char, mbstate_t>
{
protected:
std::codecvt_base::result
do_out(mbstate_t&, const char* from, const char*,
const char*& from_next, char* to, char*,
char*& to_next) const
{
from_next = from;
to_next = to;
return std::codecvt<char, char, mbstate_t>::error;
}
virtual bool do_always_noconv() const throw()
{
return false;
}
};
// libstdc++/9182
// basic_filebuf<>::sync and overflow do not write out any characters
// if codecvt<>::out returns error
void test13()
{
using namespace std;
bool test = true;
locale loc = locale::classic();
loc = locale(loc, new errorcvt);
filebuf fbuf1;
fbuf1.pubimbue(loc);
fbuf1.open(name_07, ios_base::out | ios_base::trunc);
fbuf1.sputn("ison", 4);
int r = fbuf1.pubsync();
VERIFY( r == -1 );
fbuf1.close();
}
main()
{
test13();
return 0;
}
// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.4 Overridden virtual functions
#include <fstream>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <testsuite_hooks.h>
class UnderBuf : public std::filebuf
{
public:
int_type
pub_underflow()
{ return underflow(); }
std::streamsize
pub_showmanyc()
{ return showmanyc(); }
};
// libstdc++/10097
// filebuf::underflow drops characters.
void test16()
{
using namespace std;
bool test = true;
const char* name = "tmp_fifo1";
signal(SIGPIPE, SIG_IGN);
unlink(name);
if (0 != mkfifo(name, S_IRWXU))
{
VERIFY( false );
}
int fval = fork();
if (fval == -1)
{
unlink(name);
VERIFY( false );
}
else if (fval == 0)
{
filebuf fbout;
fbout.open(name, ios_base::out);
fbout.sputn("0123456789", 10);
fbout.pubsync();
sleep(2);
fbout.close();
exit(0);
}
UnderBuf fb;
fb.open(name, ios_base::in);
sleep(1);
fb.sgetc();
streamsize n = fb.pub_showmanyc();
while (n > 0)
{
--n;
UnderBuf::int_type c = fb.pub_underflow();
VERIFY( c != UnderBuf::traits_type::eof() );
fb.sbumpc();
}
fb.close();
}
main()
{
test16();
return 0;
}
...@@ -46,18 +46,3 @@ void test01() ...@@ -46,18 +46,3 @@ void test01()
typedef test_type::pos_type pos_type; typedef test_type::pos_type pos_type;
typedef test_type::off_type off_type; typedef test_type::off_type off_type;
} }
namespace test
{
using namespace std;
using __gnu_cxx_test::pod_char;
typedef short type_t;
template class basic_fstream<type_t, char_traits<type_t> >;
template class basic_fstream<pod_char, char_traits<pod_char> >;
} // test
int main()
{
test01();
return 0;
}
// 2002-07-25 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2002, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// 27.8.1.11 - Template class basic_fstream
// NB: This file is for testing basic_fstream with NO OTHER INCLUDES.
#include <fstream>
#include <testsuite_hooks.h>
// { dg-do compile }
namespace test
{
using namespace std;
using __gnu_cxx_test::pod_char;
typedef short type_t;
template class basic_fstream<type_t, char_traits<type_t> >;
template class basic_fstream<pod_char, char_traits<pod_char> >;
} // test
// 1999-01-17 bkoz test functionality of basic_filebuf for char_type == char
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.1 - Template class basic_filebuf
// NB: This file is for testing basic_filebuf with NO OTHER INCLUDES.
#include <fstream>
#include <testsuite_hooks.h>
// { dg-do compile }
// libstdc++/2020
// should be able to use custom char_type, custom traits type
class gnu_char_type
{
unsigned long character;
public:
// operator ==
bool
operator==(const gnu_char_type& __lhs)
{ return character == __lhs.character; }
// operator <
bool
operator<(const gnu_char_type& __lhs)
{ return character < __lhs.character; }
// default ctor
gnu_char_type() { }
// to_char_type
gnu_char_type(const unsigned long& __l) : character(__l) { }
// to_int_type
operator unsigned long() const { return character; }
};
// char_traits specialization
struct gnu_char_traits
{
typedef gnu_char_type char_type;
typedef long int_type;
typedef long pos_type;
typedef unsigned long off_type;
typedef long state_type;
static void
assign(char_type& __c1, const char_type& __c2) { }
static bool
eq(const char_type& __c1, const char_type& __c2) { return true; }
static bool
lt(const char_type& __c1, const char_type& __c2) { return true; }
static int
compare(const char_type* __s1, const char_type* __s2, size_t __n)
{ return 0; }
static size_t
length(const char_type* __s) { return 0; }
static const char_type*
find(const char_type* __s, size_t __n, const char_type& __a)
{ return __s; }
static char_type*
move(char_type* __s1, const char_type* __s2, size_t __n)
{ return __s1; }
static char_type*
copy(char_type* __s1, const char_type* __s2, size_t __n)
{ return __s1; }
static char_type*
assign(char_type* __s, size_t __n, char_type __a)
{ return __s; }
static char_type
to_char_type(const int_type& __c)
{ return char_type(); }
static int_type
to_int_type(const char_type& __c)
{ return int_type(); }
static bool
eq_int_type(const int_type& __c1, const int_type& __c2)
{ return true; }
static int_type
eof()
{ return int_type(); }
static int_type
not_eof(const int_type& __c)
{ return int_type(); }
};
void test07()
{
bool test = true;
typedef std::basic_fstream<gnu_char_type, gnu_char_traits> gnu_fstr;
try
{
gnu_fstr obj;
}
catch(std::exception& obj)
{
test = false;
VERIFY( test );
}
}
#if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support.
template
std::basic_streambuf<gnu_char_type>::int_type
std::basic_streambuf<gnu_char_type>::_S_pback_size;
#endif
int main()
{
test07();
return 0;
}
// more surf!!!
// 2003-03-26 B enjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.1 - Template class basic_filebuf
#include <iostream>
#include <fstream>
void test01()
{
// Check for required base class.
typedef std::fstream test_type;
typedef std::iostream base_type;
const test_type& obj = test_type();
const base_type* base = &obj;
}
int main()
{
test01();
return 0;
}
// more surf!!!
...@@ -45,16 +45,3 @@ void test01() ...@@ -45,16 +45,3 @@ void test01()
typedef test_type::pos_type pos_type; typedef test_type::pos_type pos_type;
typedef test_type::off_type off_type; typedef test_type::off_type off_type;
} }
namespace test
{
using namespace std;
typedef short type_t;
template class basic_ifstream<type_t, char_traits<type_t> >;
} // test
int main()
{
test01();
return 0;
}
// 2002-07-25 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2002 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
// 27.8.1.5 - Template class basic_ifstream
// NB: This file is for testing basic_ifstream with NO OTHER INCLUDES.
#include <fstream>
// { dg-do compile }
namespace test
{
using namespace std;
typedef short type_t;
template class basic_ifstream<type_t, char_traits<type_t> >;
} // test
// 1999-01-17 bkoz test functionality of basic_filebuf for char_type == char
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.1 - Template class basic_filebuf
// NB: This file is for testing basic_filebuf with NO OTHER INCLUDES.
#include <fstream>
#include <testsuite_hooks.h>
// { dg-do compile }
// libstdc++/2020
// should be able to use custom char_type, custom traits type
class gnu_char_type
{
unsigned long character;
public:
// operator ==
bool
operator==(const gnu_char_type& __lhs)
{ return character == __lhs.character; }
// operator <
bool
operator<(const gnu_char_type& __lhs)
{ return character < __lhs.character; }
// default ctor
gnu_char_type() { }
// to_char_type
gnu_char_type(const unsigned long& __l) : character(__l) { }
// to_int_type
operator unsigned long() const { return character; }
};
// char_traits specialization
struct gnu_char_traits
{
typedef gnu_char_type char_type;
typedef long int_type;
typedef long pos_type;
typedef unsigned long off_type;
typedef long state_type;
static void
assign(char_type& __c1, const char_type& __c2) { }
static bool
eq(const char_type& __c1, const char_type& __c2) { return true; }
static bool
lt(const char_type& __c1, const char_type& __c2) { return true; }
static int
compare(const char_type* __s1, const char_type* __s2, size_t __n)
{ return 0; }
static size_t
length(const char_type* __s) { return 0; }
static const char_type*
find(const char_type* __s, size_t __n, const char_type& __a)
{ return __s; }
static char_type*
move(char_type* __s1, const char_type* __s2, size_t __n)
{ return __s1; }
static char_type*
copy(char_type* __s1, const char_type* __s2, size_t __n)
{ return __s1; }
static char_type*
assign(char_type* __s, size_t __n, char_type __a)
{ return __s; }
static char_type
to_char_type(const int_type& __c)
{ return char_type(); }
static int_type
to_int_type(const char_type& __c)
{ return int_type(); }
static bool
eq_int_type(const int_type& __c1, const int_type& __c2)
{ return true; }
static int_type
eof()
{ return int_type(); }
static int_type
not_eof(const int_type& __c)
{ return int_type(); }
};
void test07()
{
bool test = true;
typedef std::basic_ifstream<gnu_char_type, gnu_char_traits> gnu_ifstr;
try
{
gnu_ifstr obj;
}
catch(std::exception& obj)
{
test = false;
VERIFY( test );
}
}
#if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support.
template
std::basic_streambuf<gnu_char_type>::int_type
std::basic_streambuf<gnu_char_type>::_S_pback_size;
#endif
int main()
{
test07();
return 0;
}
// more surf!!!
// 2003-03-26 B enjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.1 - Template class basic_filebuf
#include <istream>
#include <fstream>
void test01()
{
// Check for required base class.
typedef std::ifstream test_type;
typedef std::istream base_type;
const test_type& obj = test_type();
const base_type* base = &obj;
}
int main()
{
test01();
return 0;
}
// more surf!!!
// Copyright (C) 2000, 2001, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.7 ifstream member functions
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %-*.txt
#include <istream>
#include <fstream>
#include <testsuite_hooks.h>
const char name_01[] = "ifstream_members-1.tst";
// http://gcc.gnu.org/ml/libstdc++/2000-07/msg00004.html
void test02()
{
bool test = true;
const int more_than_max_open_files = 8200;
for (int i = 0; ++i < more_than_max_open_files;)
{
std::ifstream ifs(name_01);
VERIFY( static_cast<bool>(ifs) );
}
}
int main()
{
test02();
return 0;
}
// Copyright (C) 2000, 2001, 2003 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 2, 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 COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// 27.8.1.7 ifstream member functions
// @require@ %-*.tst %-*.txt
// @diff@ %-*.tst %-*.txt
#include <istream>
#include <fstream>
#include <testsuite_hooks.h>
const char name_01[] = "ifstream_members-1.tst";
// http://gcc.gnu.org/ml/libstdc++/2000-06/msg00136.html
void test01()
{
bool test = true;
std::ifstream ifs1;
ifs1.close();
// false as expected:
VERIFY( !ifs1.is_open() );
// this is now true:
VERIFY( !(ifs1) );
ifs1.open(name_01);
VERIFY( ifs1.is_open() );
// fail bit still true
VERIFY( !(ifs1) );
VERIFY( ifs1.rdstate() == std::ios_base::failbit );
ifs1.close();
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2000, 2001 Free Software Foundation, Inc. // Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -27,52 +27,6 @@ ...@@ -27,52 +27,6 @@
const char name_01[] = "ifstream_members-1.tst"; const char name_01[] = "ifstream_members-1.tst";
const char name_02[] = "ifstream_members-1.txt"; const char name_02[] = "ifstream_members-1.txt";
// http://gcc.gnu.org/ml/libstdc++/2000-06/msg00136.html
bool test00()
{
bool test = true;
std::ifstream ifs1;
ifs1.close();
// false as expected:
VERIFY( !ifs1.is_open() );
// this is now true:
VERIFY( !(ifs1) );
ifs1.open(name_01);
VERIFY( ifs1.is_open() );
// fail bit still true
VERIFY( !(ifs1) );
VERIFY( ifs1.rdstate() == std::ios_base::failbit );
ifs1.close();
#ifdef DEBUG_ASSERT
assert(test);
#endif
return test;
}
// http://gcc.gnu.org/ml/libstdc++/2000-07/msg00004.html
bool test01()
{
bool test = true;
const int more_than_max_open_files = 8200;
for(int i = 0; ++i < more_than_max_open_files;)
{
std::ifstream ifs(name_01);
VERIFY( static_cast<bool>(ifs) );
}
#ifdef DEBUG_ASSERT
assert(test);
#endif
return test;
}
void void
redirect_buffer(std::ios& stream, std::streambuf* new_buf) redirect_buffer(std::ios& stream, std::streambuf* new_buf)
{ stream.rdbuf(new_buf); } { stream.rdbuf(new_buf); }
...@@ -82,7 +36,7 @@ active_buffer(std::ios& stream) ...@@ -82,7 +36,7 @@ active_buffer(std::ios& stream)
{ return stream.rdbuf(); } { return stream.rdbuf(); }
// libstdc++/2832 // libstdc++/2832
void test02() void test03()
{ {
bool test = true; bool test = true;
const char* strlit01 = "fuck war"; const char* strlit01 = "fuck war";
...@@ -112,10 +66,7 @@ void test02() ...@@ -112,10 +66,7 @@ void test02()
int main() int main()
{ {
test00(); test03();
test01();
test02();
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment