From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../27_io/basic_filebuf/seekpos/char/1-in.cc | 103 ++++++++++++++++++++ .../27_io/basic_filebuf/seekpos/char/1-io.cc | 103 ++++++++++++++++++++ .../27_io/basic_filebuf/seekpos/char/1-out.cc | 105 +++++++++++++++++++++ .../27_io/basic_filebuf/seekpos/char/12790-1.cc | 81 ++++++++++++++++ .../27_io/basic_filebuf/seekpos/char/12790-2.cc | 82 ++++++++++++++++ .../27_io/basic_filebuf/seekpos/char/12790-3.cc | 79 ++++++++++++++++ .../27_io/basic_filebuf/seekpos/char/12790-4.cc | 82 ++++++++++++++++ .../27_io/basic_filebuf/seekpos/char/2-in.cc | 104 ++++++++++++++++++++ .../27_io/basic_filebuf/seekpos/char/2-io.cc | 102 ++++++++++++++++++++ .../27_io/basic_filebuf/seekpos/char/2-out.cc | 104 ++++++++++++++++++++ .../27_io/basic_filebuf/seekpos/char/3-in.cc | 63 +++++++++++++ .../27_io/basic_filebuf/seekpos/char/3-io.cc | 66 +++++++++++++ .../27_io/basic_filebuf/seekpos/char/3-out.cc | 63 +++++++++++++ 13 files changed, 1137 insertions(+) create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-in.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-in.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-out.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-in.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc create mode 100644 libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-out.cc (limited to 'libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char') diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-in.cc new file mode 100644 index 000000000..da5a80b4b --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-in.cc @@ -0,0 +1,103 @@ +// 2001-05-21 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.8.1.4 Overridden virtual functions + +// { dg-require-fileio "" } + +#include +#include +#include + +// @require@ %-*.tst %-*.txt +// @diff@ %-*.tst %*.txt + +const char name_01[] = "seekpos.txt"; // file with data in it + +void test05() +{ + using namespace std; + using namespace __gnu_test; + + typedef filebuf::int_type int_type; + typedef filebuf::pos_type pos_type; + typedef filebuf::off_type off_type; + typedef filebuf::traits_type traits_type; + + bool test __attribute__((unused)) = true; + + int_type c1; + int_type c2; + int_type c3; + + pos_type pt_1(off_type(-1)); + pos_type pt_2(off_type(0)); + pos_type pt_3; + off_type off_1 = 0; + off_type off_2 = 0; + + // seekpos + // pubseekpos(pos_type sp, ios_base::openmode) + // alters the stream position to sp + + // in + { + constraint_filebuf fb; + fb.open(name_01, ios_base::in); + VERIFY( !fb.write_position() ); + + // beg + pt_1 = fb.pubseekoff(78, ios_base::beg); + off_1 = off_type(pt_1); + VERIFY( off_1 > 0 ); + c1 = fb.snextc(); //current in pointer +1 + VERIFY( c1 == 't' ); + + // cur + pt_3 = fb.pubseekoff(0, ios_base::cur); + fb.pubseekpos(pt_3); + c2 = fb.sputc('\n'); //test current out pointer + pt_3 = fb.pubseekoff(0, ios_base::cur); + fb.pubseekpos(pt_3); + c3 = fb.sgetc(); + fb.pubsync(); //resets pointers + pt_2 = fb.pubseekpos(pt_1); + off_2 = off_type(pt_2); + VERIFY( off_1 == off_2 ); + c3 = fb.snextc(); //current in pointer +1 + VERIFY( c2 == traits_type::eof() ); + VERIFY( c2 != c3 ); + + // end + pt_1 = fb.pubseekoff(0, ios_base::end); + off_1 = off_type(pt_1); + VERIFY( off_1 > off_2 ); + fb.sputn("\nof the wonderful things he does!!\nok", 37); + fb.pubsync(); + VERIFY( !fb.write_position() ); + fb.close(); + VERIFY( !fb.is_open() ); + } +} + +int main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc new file mode 100644 index 000000000..c90de5e31 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc @@ -0,0 +1,103 @@ +// 2001-05-21 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.8.1.4 Overridden virtual functions + +// { dg-require-fileio "" } + +#include +#include +#include + +// @require@ %-*.tst %-*.txt +// @diff@ %-*.tst %*.txt + +const char name_01[] = "seekpos-1io.tst"; // file with data in it + +void test05() +{ + using namespace std; + using namespace __gnu_test; + + typedef filebuf::int_type int_type; + typedef filebuf::pos_type pos_type; + typedef filebuf::off_type off_type; + + bool test __attribute__((unused)) = true; + + int_type c1; + int_type c2; + int_type c3; + + pos_type pt_1(off_type(-1)); + pos_type pt_2(off_type(0)); + pos_type pt_3; + off_type off_1 = 0; + off_type off_2 = 0; + + // seekpos + // pubseekpos(pos_type sp, ios_base::openmode) + // alters the stream position to sp + + // in | out + { + constraint_filebuf fb; + fb.open(name_01, ios_base::out | ios_base::in); + VERIFY( !fb.write_position() ); + VERIFY( !fb.read_position() ); + + // beg + pt_1 = fb.pubseekoff(78, ios_base::beg); + off_1 = off_type(pt_1); + VERIFY( off_1 > 0 ); + c1 = fb.snextc(); //current in pointer +1 + VERIFY( c1 == 't' ); + + // cur + pt_3 = fb.pubseekoff(0, ios_base::cur); + fb.pubseekpos(pt_3); + c2 = fb.sputc('\n'); //test current out pointer + pt_3 = fb.pubseekoff(0, ios_base::cur); + fb.pubseekpos(pt_3); + c3 = fb.sgetc(); + fb.pubsync(); //resets pointers + pt_2 = fb.pubseekpos(pt_1); + off_2 = off_type(pt_2); + VERIFY( off_1 == off_2 ); + c3 = fb.snextc(); //current in pointer +1 + VERIFY( c2 == c3 ); + + // end + pt_1 = fb.pubseekoff(0, ios_base::end); + off_1 = off_type(pt_1); + VERIFY( off_1 > off_2 ); + fb.sputn("\nof the wonderful things he does!!\nok", 37); + fb.pubsync(); + VERIFY( fb.write_position() ); + VERIFY( !fb.read_position() ); + fb.close(); + VERIFY( !fb.is_open() ); + } +} + +int main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc new file mode 100644 index 000000000..0b596a451 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc @@ -0,0 +1,105 @@ +// 2001-05-21 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.8.1.4 Overridden virtual functions + +// { dg-require-fileio "" } + +#include +#include +#include + +// @require@ %-*.tst %-*.txt +// @diff@ %-*.tst %*.txt + +const char name_01[] = "seekpos-1out.tst"; // file with data in it + +void test05() +{ + using namespace std; + using namespace __gnu_test; + + typedef filebuf::int_type int_type; + typedef filebuf::pos_type pos_type; + typedef filebuf::off_type off_type; + typedef filebuf::traits_type traits_type; + + bool test __attribute__((unused)) = true; + + int_type c1; + int_type c2; + int_type c3; + + pos_type pt_1(off_type(-1)); + pos_type pt_2(off_type(0)); + pos_type pt_3; + off_type off_1 = 0; + off_type off_2 = 0; + + // seekpos + // pubseekpos(pos_type sp, ios_base::openmode) + // alters the stream position to sp + + // out + { + constraint_filebuf fb; + fb.open(name_01, ios_base::out); + VERIFY( !fb.write_position() ); + VERIFY( !fb.read_position() ); + + // beg + pt_1 = fb.pubseekoff(78, ios_base::beg); + off_1 = off_type(pt_1); + VERIFY( off_1 > 0 ); + c1 = fb.snextc(); //current in pointer +1 + VERIFY( c1 == traits_type::eof() ); + + // cur + pt_3 = fb.pubseekoff(0, ios_base::cur); + fb.pubseekpos(pt_3); + c2 = fb.sputc('\n'); //test current out pointer + pt_3 = fb.pubseekoff(0, ios_base::cur); + fb.pubseekpos(pt_3); + c3 = fb.sgetc(); + fb.pubsync(); //resets pointers + pt_2 = fb.pubseekpos(pt_1); + off_2 = off_type(pt_2); + VERIFY( off_1 == off_2 ); + c3 = fb.snextc(); //current in pointer +1 + VERIFY( c2 != c3 ); + VERIFY( c3 == traits_type::eof() ); + + // end + pt_1 = fb.pubseekoff(0, ios_base::end); + off_1 = off_type(pt_1); + VERIFY( off_1 > off_2 ); + fb.sputn("\nof the wonderful things he does!!\nok", 37); + fb.pubsync(); + VERIFY( fb.write_position() ); + VERIFY( !fb.read_position() ); + fb.close(); + VERIFY( !fb.is_open() ); + } +} + +int main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc new file mode 100644 index 000000000..1a024941f --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/12790-1.cc @@ -0,0 +1,81 @@ +// Copyright (C) 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.8.1.4 Overridden virtual functions + +// { dg-require-fileio "" } + +#include +#include +#include + +class Cvt : public std::codecvt +{ +public: + mutable bool unshift_called; + + Cvt() + : unshift_called(false) + { } + +protected: + bool + do_always_noconv() const throw() + { return false; } + + int + do_encoding() const throw() + { return -1; } + + std::codecvt_base::result + do_unshift(std::mbstate_t&, char* to, char*, char*& to_next) const + { + unshift_called = true; + to_next = to; + return std::codecvt_base::ok; + } +}; + +// libstdc++/12790 +// basic_filebuf::seekpos() should call codecvt::unshift() +void test01() +{ + using namespace std; + + bool test __attribute__((unused)) = true; + const char* name = "tmp_seekpos_12790"; + + Cvt* cvt = new Cvt; + locale loc(locale::classic(), cvt); + + filebuf fb; + fb.pubimbue(loc); + + fb.open(name, ios_base::out); + streampos pos = fb.pubseekoff(0, ios_base::beg); + fb.sputc('a'); + + VERIFY( !cvt->unshift_called ); + fb.pubseekpos(pos); + VERIFY( cvt->unshift_called ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc new file mode 100644 index 000000000..b0085e29e --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/12790-2.cc @@ -0,0 +1,82 @@ +// Copyright (C) 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.8.1.4 Overridden virtual functions + +// { dg-require-fileio "" } + +#include +#include +#include + +class Cvt : public std::codecvt +{ +public: + mutable bool unshift_called; + + Cvt() + : unshift_called(false) + { } + +protected: + bool + do_always_noconv() const throw() + { return false; } + + int + do_encoding() const throw() + { return -1; } + + std::codecvt_base::result + do_unshift(std::mbstate_t&, char* to, char*, char*& to_next) const + { + unshift_called = true; + to_next = to; + return std::codecvt_base::ok; + } +}; + +// libstdc++/12790 +// basic_filebuf::seekpos() should call codecvt::unshift() +void test01() +{ + using namespace std; + + bool test __attribute__((unused)) = true; + const char* name = "tmp_seekpos_12790"; + + Cvt* cvt = new Cvt; + locale loc(locale::classic(), cvt); + + filebuf fb; + fb.pubsetbuf(0, 0); + fb.pubimbue(loc); + + fb.open(name, ios_base::out); + streampos pos = fb.pubseekoff(0, ios_base::beg); + fb.sputc('a'); + + VERIFY( !cvt->unshift_called ); + fb.pubseekpos(pos); + VERIFY( cvt->unshift_called ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc new file mode 100644 index 000000000..0eb3ecf80 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/12790-3.cc @@ -0,0 +1,79 @@ +// Copyright (C) 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.8.1.4 Overridden virtual functions + +#include +#include +#include + +class Cvt : public std::codecvt +{ +public: + mutable bool unshift_called; + + Cvt() + : unshift_called(false) + { } + +protected: + bool + do_always_noconv() const throw() + { return false; } + + int + do_encoding() const throw() + { return -1; } + + std::codecvt_base::result + do_unshift(std::mbstate_t&, char* to, char*, char*& to_next) const + { + unshift_called = true; + to_next = to; + return std::codecvt_base::ok; + } +}; + +// libstdc++/12790 +// basic_filebuf::seekpos() should call codecvt::unshift(), +// but only if writing +void test01() +{ + using namespace std; + + bool test __attribute__((unused)) = true; + const char* name = "tmp_seekpos_12790"; + + Cvt* cvt = new Cvt; + locale loc(locale::classic(), cvt); + + filebuf fb; + fb.pubimbue(loc); + + fb.open(name, ios_base::out); + streampos pos = fb.pubseekoff(0, ios_base::beg); + + VERIFY( !cvt->unshift_called ); + fb.pubseekpos(pos); + VERIFY( !cvt->unshift_called ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc new file mode 100644 index 000000000..506482bd6 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/12790-4.cc @@ -0,0 +1,82 @@ +// Copyright (C) 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.8.1.4 Overridden virtual functions + +// { dg-require-fileio "" } + +#include +#include +#include + +class Cvt : public std::codecvt +{ +public: + mutable bool unshift_called; + + Cvt() + : unshift_called(false) + { } + +protected: + bool + do_always_noconv() const throw() + { return false; } + + int + do_encoding() const throw() + { return -1; } + + std::codecvt_base::result + do_unshift(std::mbstate_t&, char* to, char*, char*& to_next) const + { + unshift_called = true; + to_next = to; + return std::codecvt_base::ok; + } +}; + +// libstdc++/12790 +// basic_filebuf::seekpos() should call codecvt::unshift() +void test01() +{ + using namespace std; + + bool test __attribute__((unused)) = true; + const char* name = "tmp_seekpos_12790"; + + Cvt* cvt = new Cvt; + locale loc(locale::classic(), cvt); + + filebuf fb; + fb.pubimbue(loc); + + fb.open(name, ios_base::out); + streampos pos = fb.pubseekoff(0, ios_base::beg); + fb.sputc('a'); + fb.pubsync(); // Does not call unshift() + + VERIFY( !cvt->unshift_called ); + fb.pubseekpos(pos); + VERIFY( cvt->unshift_called ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-in.cc new file mode 100644 index 000000000..782fb6bb8 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-in.cc @@ -0,0 +1,104 @@ +// 2001-05-21 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.8.1.4 Overridden virtual functions + +// { dg-require-fileio "" } + +#include +#include +#include + +// @require@ %-*.tst %-*.txt +// @diff@ %-*.tst %*.txt + +const char name_01[] = "seekpos.txt"; // file with data in it + +void test05() +{ + using namespace std; + using namespace __gnu_test; + + typedef filebuf::int_type int_type; + typedef filebuf::pos_type pos_type; + typedef filebuf::off_type off_type; + typedef filebuf::traits_type traits_type; + + bool test __attribute__((unused)) = true; + + int_type c1; + int_type c2; + int_type c3; + + pos_type pt_1(off_type(-1)); + pos_type pt_2(off_type(0)); + pos_type pt_3; + off_type off_1 = 0; + off_type off_2 = 0; + + // seekpos + // pubseekpos(pos_type sp, ios_base::openmode) + // alters the stream position to sp + + // in + { + constraint_filebuf fb; + fb.pubsetbuf(0, 0); + fb.open(name_01, ios_base::in); + VERIFY( fb.unbuffered() ); + + // beg + pt_1 = fb.pubseekoff(78, ios_base::beg); + off_1 = off_type(pt_1); + VERIFY( off_1 > 0 ); + c1 = fb.snextc(); //current in pointer +1 + VERIFY( c1 == 't' ); + + // cur + pt_3 = fb.pubseekoff(0, ios_base::cur); + fb.pubseekpos(pt_3); + c2 = fb.sputc('\n'); //test current out pointer + pt_3 = fb.pubseekoff(0, ios_base::cur); + fb.pubseekpos(pt_3); + c3 = fb.sgetc(); + fb.pubsync(); //resets pointers + pt_2 = fb.pubseekpos(pt_1); + off_2 = off_type(pt_2); + VERIFY( off_1 == off_2 ); + c3 = fb.snextc(); //current in pointer +1 + VERIFY( c2 == traits_type::eof() ); + VERIFY( c2 != c3 ); + + // end + pt_1 = fb.pubseekoff(0, ios_base::end); + off_1 = off_type(pt_1); + VERIFY( off_1 > off_2 ); + fb.sputn("\nof the wonderful things he does!!\nok", 37); + fb.pubsync(); + VERIFY( fb.unbuffered() ); + fb.close(); + VERIFY( !fb.is_open() ); + } +} + +int main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc new file mode 100644 index 000000000..4916d6059 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc @@ -0,0 +1,102 @@ +// 2001-05-21 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.8.1.4 Overridden virtual functions + +// { dg-require-fileio "" } + +#include +#include +#include + +// @require@ %-*.tst %-*.txt +// @diff@ %-*.tst %*.txt + +const char name_01[] = "seekpos-2io.tst"; // file with data in it + +void test05() +{ + using namespace std; + using namespace __gnu_test; + + typedef filebuf::int_type int_type; + typedef filebuf::pos_type pos_type; + typedef filebuf::off_type off_type; + + bool test __attribute__((unused)) = true; + + int_type c1; + int_type c2; + int_type c3; + + pos_type pt_1(off_type(-1)); + pos_type pt_2(off_type(0)); + pos_type pt_3; + off_type off_1 = 0; + off_type off_2 = 0; + + // seekpos + // pubseekpos(pos_type sp, ios_base::openmode) + // alters the stream position to sp + + // in | out + { + constraint_filebuf fb; + fb.pubsetbuf(0, 0); + fb.open(name_01, ios_base::out | ios_base::in); + VERIFY( fb.unbuffered() ); + + // beg + pt_1 = fb.pubseekoff(78, ios_base::beg); + off_1 = off_type(pt_1); + VERIFY( off_1 > 0 ); + c1 = fb.snextc(); //current in pointer +1 + VERIFY( c1 == 't' ); + + // cur + pt_3 = fb.pubseekoff(0, ios_base::cur); + fb.pubseekpos(pt_3); + c2 = fb.sputc('\n'); //test current out pointer + pt_3 = fb.pubseekoff(0, ios_base::cur); + fb.pubseekpos(pt_3); + c3 = fb.sgetc(); + fb.pubsync(); //resets pointers + pt_2 = fb.pubseekpos(pt_1); + off_2 = off_type(pt_2); + VERIFY( off_1 == off_2 ); + c3 = fb.snextc(); //current in pointer +1 + VERIFY( c2 == c3 ); + + // end + pt_1 = fb.pubseekoff(0, ios_base::end); + off_1 = off_type(pt_1); + VERIFY( off_1 > off_2 ); + fb.sputn("\nof the wonderful things he does!!\nok", 37); + fb.pubsync(); + VERIFY( fb.unbuffered() ); + fb.close(); + VERIFY( !fb.is_open() ); + } +} + +int main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-out.cc new file mode 100644 index 000000000..9031bca6c --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-out.cc @@ -0,0 +1,104 @@ +// 2001-05-21 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.8.1.4 Overridden virtual functions + +// { dg-require-fileio "" } + +#include +#include +#include + +// @require@ %-*.tst %-*.txt +// @diff@ %-*.tst %*.txt + +const char name_01[] = "seekpos-2out.tst"; // file with data in it + +void test05() +{ + using namespace std; + using namespace __gnu_test; + + typedef filebuf::int_type int_type; + typedef filebuf::pos_type pos_type; + typedef filebuf::off_type off_type; + typedef filebuf::traits_type traits_type; + + bool test __attribute__((unused)) = true; + + int_type c1; + int_type c2; + int_type c3; + + pos_type pt_1(off_type(-1)); + pos_type pt_2(off_type(0)); + pos_type pt_3; + off_type off_1 = 0; + off_type off_2 = 0; + + // seekpos + // pubseekpos(pos_type sp, ios_base::openmode) + // alters the stream position to sp + + // out + { + constraint_filebuf fb; + fb.pubsetbuf(0, 0); + fb.open(name_01, ios_base::out); + VERIFY( fb.unbuffered() ); + + // beg + pt_1 = fb.pubseekoff(78, ios_base::beg); + off_1 = off_type(pt_1); + VERIFY( off_1 > 0 ); + c1 = fb.snextc(); //current in pointer +1 + VERIFY( c1 == traits_type::eof() ); + + // cur + pt_3 = fb.pubseekoff(0, ios_base::cur); + fb.pubseekpos(pt_3); + c2 = fb.sputc('\n'); //test current out pointer + pt_3 = fb.pubseekoff(0, ios_base::cur); + fb.pubseekpos(pt_3); + c3 = fb.sgetc(); + fb.pubsync(); //resets pointers + pt_2 = fb.pubseekpos(pt_1); + off_2 = off_type(pt_2); + VERIFY( off_1 == off_2 ); + c3 = fb.snextc(); //current in pointer +1 + VERIFY( c2 != c3 ); + VERIFY( c3 == traits_type::eof() ); + + // end + pt_1 = fb.pubseekoff(0, ios_base::end); + off_1 = off_type(pt_1); + VERIFY( off_1 > off_2 ); + fb.sputn("\nof the wonderful things he does!!\nok", 37); + fb.pubsync(); + VERIFY( fb.unbuffered() ); + fb.close(); + VERIFY( !fb.is_open() ); + } +} + +int main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-in.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-in.cc new file mode 100644 index 000000000..278d39e72 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-in.cc @@ -0,0 +1,63 @@ +// 2001-05-21 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.3 Overridden virtual functions + +// { dg-require-fileio "" } + +#include +#include + +void test02(std::filebuf& in, bool pass) +{ + bool test __attribute__((unused)) = 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); + VERIFY( pass == (p != bad) ); + + p = in.pubseekpos(0, ios_base::out); + VERIFY( pass == (p != bad) ); // See libstdc++/12232 + + p = in.pubseekpos(0); + VERIFY( pass == (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; + + 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; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc new file mode 100644 index 000000000..3f37a266a --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc @@ -0,0 +1,66 @@ +// 2001-05-21 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.3 Overridden virtual functions + +// { dg-require-fileio "" } + +#include +#include + +void test02(std::filebuf& in, bool pass) +{ + bool test __attribute__((unused)) = 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); + if (pass) + 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; + + filebuf in1; + in1.open(name_01, ios_base::in | ios_base::out); + filebuf in2; + filebuf in3; + in3.open(name_03, ios_base::in | ios_base::out); + test02(in1, true); + test02(in2, false); + test02(in3, true); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-out.cc new file mode 100644 index 000000000..07bdc0cae --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-out.cc @@ -0,0 +1,63 @@ +// 2001-05-21 Benjamin Kosnik + +// Copyright (C) 2001, 2002, 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 27.7.1.3 Overridden virtual functions + +// { dg-require-fileio "" } + +#include +#include + +void test02(std::filebuf& in, bool pass) +{ + bool test __attribute__((unused)) = 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); + VERIFY( pass == (p != bad) ); // See libstdc++/12232 + + p = in.pubseekpos(0, ios_base::out); + VERIFY( pass == (p != bad) ); + + p = in.pubseekpos(0); + VERIFY( pass == (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; + + filebuf out1; + out1.open(name_01, ios_base::out); + filebuf out2; + filebuf out3; + out3.open(name_03, ios_base::out); + test02(out1, true); + test02(out2, false); + test02(out3, true); + return 0; +} -- cgit v1.2.3