aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/basic_istream
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2010-11-18 17:21:35 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2010-11-18 17:21:35 +0000
commit2ca2a8990ac14844436402836221016c47a86dcb (patch)
treed06e9b1040ed5ba9967d91587e69b61545eafad5 /libstdc++-v3/testsuite/27_io/basic_istream
parent275853ab387d1912647c4f367a7f7f33f47d0526 (diff)
downloadgcc-2ca2a8990ac14844436402836221016c47a86dcb.zip
gcc-2ca2a8990ac14844436402836221016c47a86dcb.tar.gz
gcc-2ca2a8990ac14844436402836221016c47a86dcb.tar.bz2
PR libstdc++/26211 + N3168
2010-11-18 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/26211 + N3168 * include/bits/istream.tcc (basic_istream<>::tellg, seekg(pos_type), seekg(off_type, ios_base::seekdir)): Construct a sentry. (basic_istream<>::tellg, seekg(pos_type), seekg(off_type, ios_base::seekdir, putback, unget)): Clear eofbit first, per N3168. * testsuite/27_io/basic_istream/seekg/char/26211.cc: New. * testsuite/27_io/basic_istream/seekg/wchar_t/26211.cc: Likewise. * testsuite/27_io/basic_istream/tellg/char/26211.cc: Likewise. * testsuite/27_io/basic_istream/tellg/wchar_t/26211.cc: Likewise. * testsuite/27_io/basic_istream/tellg/char/8348.cc: Tweak. * testsuite/27_io/basic_istream/tellg/wchar_t/8348.cc: Likewise. From-SVN: r166911
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_istream')
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/26211.cc63
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/26211.cc63
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/26211.cc49
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/8348.cc1
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/26211.cc49
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/8348.cc1
6 files changed, 226 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/26211.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/26211.cc
new file mode 100644
index 0000000..be28650
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/26211.cc
@@ -0,0 +1,63 @@
+// 2010-11-18 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/26211
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ typedef istringstream::pos_type pos_type;
+
+ istringstream iss("Duos for Doris");
+ ostringstream oss;
+
+ const pos_type p0 = iss.tellg();
+ VERIFY( p0 == pos_type(0) );
+
+ iss >> oss.rdbuf();
+ VERIFY( iss.rdstate() == iss.eofbit );
+
+ iss.seekg(0, ios_base::beg);
+ VERIFY( iss.good() );
+
+ iss.seekg(0, ios_base::beg);
+ VERIFY( !iss.fail() );
+ VERIFY( iss.tellg() == p0 );
+
+ iss >> oss.rdbuf();
+ VERIFY( iss.rdstate() == iss.eofbit );
+
+ iss.seekg(p0);
+ VERIFY( iss.good() );
+
+ iss.seekg(p0);
+ VERIFY( !iss.fail() );
+ VERIFY( iss.tellg() == p0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/26211.cc b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/26211.cc
new file mode 100644
index 0000000..2a73e1e
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/26211.cc
@@ -0,0 +1,63 @@
+// 2010-11-18 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/26211
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ typedef wistringstream::pos_type pos_type;
+
+ wistringstream iss(L"Duos for Doris");
+ wostringstream oss;
+
+ const pos_type p0 = iss.tellg();
+ VERIFY( p0 == pos_type(0) );
+
+ iss >> oss.rdbuf();
+ VERIFY( iss.rdstate() == iss.eofbit );
+
+ iss.seekg(0, ios_base::beg);
+ VERIFY( iss.good() );
+
+ iss.seekg(0, ios_base::beg);
+ VERIFY( !iss.fail() );
+ VERIFY( iss.tellg() == p0 );
+
+ iss >> oss.rdbuf();
+ VERIFY( iss.rdstate() == iss.eofbit );
+
+ iss.seekg(p0);
+ VERIFY( iss.good() );
+
+ iss.seekg(p0);
+ VERIFY( !iss.fail() );
+ VERIFY( iss.tellg() == p0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/26211.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/26211.cc
new file mode 100644
index 0000000..6677f94
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/26211.cc
@@ -0,0 +1,49 @@
+// 2010-11-18 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/26211
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ typedef istringstream::pos_type pos_type;
+
+ istringstream iss("Duos for Doris");
+ ostringstream oss;
+
+ VERIFY( iss.tellg() == pos_type(0) );
+
+ iss >> oss.rdbuf();
+ VERIFY( iss.rdstate() == iss.eofbit );
+ VERIFY( iss.tellg() == pos_type(-1) );
+
+ iss.clear();
+ VERIFY( iss.tellg() == pos_type(14) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/8348.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/8348.cc
index e4b4914..62bdd50 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/8348.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/8348.cc
@@ -40,6 +40,7 @@ void test06(void)
iss >> asNum;
VERIFY( test = iss.eof() );
VERIFY( test = !iss.fail() );
+ iss.clear();
iss.tellg();
VERIFY( test = !iss.fail() );
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/26211.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/26211.cc
new file mode 100644
index 0000000..7d88d5c
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/26211.cc
@@ -0,0 +1,49 @@
+// 2010-11-18 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <istream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/26211
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ typedef wistringstream::pos_type pos_type;
+
+ wistringstream iss(L"Duos for Doris");
+ wostringstream oss;
+
+ VERIFY( iss.tellg() == pos_type(0) );
+
+ iss >> oss.rdbuf();
+ VERIFY( iss.rdstate() == iss.eofbit );
+ VERIFY( iss.tellg() == pos_type(-1) );
+
+ iss.clear();
+ VERIFY( iss.tellg() == pos_type(14) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/8348.cc b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/8348.cc
index 6161381..6979b9c 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/8348.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/8348.cc
@@ -37,6 +37,7 @@ void test06(void)
iss >> asNum;
VERIFY( test = iss.eof() );
VERIFY( test = !iss.fail() );
+ iss.clear();
iss.tellg();
VERIFY( test = !iss.fail() );
}