summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2004-08-12 22:26:32 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2004-08-12 22:26:32 +0000
commit0a162bde464b45ccfdc3045d0c6e515981cc76d1 (patch)
tree3ffbfad7e0c608bace637fa9c73d9c009e271eb8 /libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t
parentc5443745bd596fa6f7a9d5a6e6e90b03abb28463 (diff)
downloadgcc-0a162bde464b45ccfdc3045d0c6e515981cc76d1.tar.gz
re PR libstdc++/16956 ([3.4 only] std::stringbuf::seekoff return wrong position value)
2004-08-12 Paolo Carlini <pcarlini@suse.de> PR libstdc++/16956 * include/bits/sstream.tcc (basic_stringbuf<>::seekoff): Add __off to the returned value, reorganize a bit. * testsuite/27_io/basic_stringbuf/seekoff/char/16956.cc: New. * testsuite/27_io/basic_stringbuf/seekoff/wchar_t/16956.cc: New. * testsuite/27_io/basic_stringbuf/seekoff/char/1.cc: Remove junk. * testsuite/27_io/basic_stringbuf/seekoff/wchar_t/1.cc: Likewise. * testsuite/27_io/basic_stringbuf/seekpos/char/1.cc: Likewise. * testsuite/27_io/basic_stringbuf/seekpos/wchar_t/1.cc: Likewise. From-SVN: r85910
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t')
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t/1.cc14
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t/16956.cc61
2 files changed, 63 insertions, 12 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t/1.cc
index c1a659e6be1..6177140c803 100644
--- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t/1.cc
@@ -23,18 +23,13 @@
#include <testsuite_hooks.h>
std::wstring str_01(L"mykonos. . . or what?");
-std::wstring str_02(L"paris, or sainte-maxime?");
-std::wstring str_03;
std::wstringbuf strb_01(str_01);
-std::wstringbuf strb_02(str_02, std::ios_base::in);
-std::wstringbuf strb_03(str_03, std::ios_base::out);
// test overloaded virtual functions
void test04()
{
bool test __attribute__((unused)) = true;
std::wstring str_tmp;
- std::wstringbuf strb_tmp;
std::streamsize strmsz_1, strmsz_2;
typedef std::wstringbuf::int_type int_type;
typedef std::wstringbuf::traits_type traits_type;
@@ -42,11 +37,7 @@ void test04()
typedef std::wstringbuf::off_type off_type;
int_type c1 = strb_01.sbumpc();
- int_type c2 = strb_02.sbumpc();
- int_type c3 = strb_01.sbumpc();
-
- // PUT
- strb_03.str(str_01); //reset
+ int_type c2, c3;
// BUFFER MANAGEMENT & POSITIONING
@@ -58,8 +49,7 @@ void test04()
off_type off_1 = 0;
off_type off_2 = 0;
strb_01.str(str_01); //in|out ("mykonos. . . or what?");
- strb_02.str(str_02); //in ("paris, or sainte-maxime?");
- strb_03.str(str_03); //out ("")
+
//IN|OUT
//beg
pt_1 = strb_01.pubseekoff(2, std::ios_base::beg);
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t/16956.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t/16956.cc
new file mode 100644
index 00000000000..6b43b385cd1
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/seekoff/wchar_t/16956.cc
@@ -0,0 +1,61 @@
+// 2004-08-12 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004 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 <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/16956
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ typedef wstringbuf::int_type int_type;
+ typedef wstringbuf::traits_type traits_type;
+ typedef wstringbuf::pos_type pos_type;
+ typedef wstringbuf::off_type off_type;
+
+ wstringbuf strb_01(L"lara's place", ios_base::in);
+ pos_type pt_1 = strb_01.pubseekoff(5, ios_base::cur, ios_base::in);
+ int_type c1 = strb_01.sgetc();
+ VERIFY( c1 != traits_type::eof() );
+ pos_type pt_2 = strb_01.pubseekoff(2, ios_base::cur, ios_base::in);
+ pos_type pt_3 = strb_01.pubseekpos(pt_1, ios_base::in);
+ int_type c2 = strb_01.sbumpc();
+ VERIFY( off_type(pt_3) == off_type(pt_2) - 2 );
+ VERIFY( c2 == c1 );
+
+ wstringbuf strb_02(L"-", ios_base::out);
+ pos_type pt_4 = strb_02.pubseekoff(0, ios_base::cur, ios_base::out);
+ strb_02.sputn(L"red", 3);
+ pos_type pt_5 = strb_02.pubseekoff(-3, ios_base::cur, ios_base::out);
+ strb_02.pubseekpos(pt_5, ios_base::out);
+ VERIFY( off_type(pt_5) == off_type(pt_4) );
+ strb_02.sputn(L"blu", 3);
+ VERIFY( strb_02.str() == L"blu" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}