+2004-07-09 Paolo Carlini <pcarlini@suse.de>
+
+ Add wchar_t counterparts of the basic_stringbuf<char> tests.
+ * testsuite/27_io/basic_stringbuf/imbue/wchar_t/1.cc, 9322.cc: New.
+ * testsuite/27_io/basic_stringbuf/in_avail/wchar_t/1.cc: Likewise.
+ * testsuite/27_io/basic_stringbuf/overflow/wchar_t/1.cc, 2.cc,
+ 3599.cc, 9988.cc: Likewise.
+ * testsuite/27_io/basic_stringbuf/sbumpc/wchar_t/1.cc, 9825.cc:
+ Likewise.
+ * testsuite/27_io/basic_stringbuf/seekoff/wchar_t/1.cc, 2.cc:
+ Likewise.
+ * testsuite/27_io/basic_stringbuf/seekoff/wchar_t/1.cc, 2.cc, 3.cc:
+ Likewise.
+ * testsuite/27_io/basic_stringbuf/setbuf/wchar_t/1.cc, 2.cc, 3.cc:
+ Likewise.
+ * testsuite/27_io/basic_stringbuf/sgetc/wchar_t/1.cc: Likewise.
+ * testsuite/27_io/basic_stringbuf/sgetn/wchar_t/1.cc: Likewise.
+ * testsuite/27_io/basic_stringbuf/snextc/wchar_t/1.cc: Likewise.
+ * testsuite/27_io/basic_stringbuf/sputbackc/wchar_t/1.cc, 9425.cc:
+ Likewise.
+ * testsuite/27_io/basic_stringbuf/sputc/wchar_t/1.cc, 1057.cc,
+ 9404-1.cc: Likewise.
+ * testsuite/27_io/basic_stringbuf/sputn/wchar_t/1.cc, 1057.cc,
+ 9404-2.cc: Likewise.
+ * testsuite/27_io/basic_stringbuf/str/wchar_t/1.cc, 2.cc, 3.cc,
+ 3955.cc: Likewise.
+ * testsuite/27_io/basic_stringbuf/sungetc/wchar_t/1.cc: Likewise.
+ * testsuite/27_io/basic_stringbuf/sync/wchar_t/1057.cc: Likewise.
+
2004-07-08 Paolo Carlini <pcarlini@suse.de>
* include/bits/gslice.h: Trivial formatting fixes.
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+std::wstring str_01(L"mykonos. . . or what?");
+std::wstringbuf strb_01(str_01);
+
+// test the streambuf/stringbuf locale settings
+void test02()
+{
+ std::locale loc_c = std::locale::classic();
+ loc_c = strb_01.getloc();
+ strb_01.pubimbue(loc_c); //This should initialize _M_init to true
+ std::locale loc_tmp = strb_01.getloc();
+ VERIFY( loc_tmp == loc_c );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 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++/9322
+void test03()
+{
+ using std::locale;
+ bool test __attribute__((unused)) = true;
+
+ locale loc = std::locale::classic();
+ std::wstringbuf ob;
+ VERIFY( ob.getloc() == loc );
+
+ locale::global(__gnu_test::try_named_locale("en_US"));
+ VERIFY( ob.getloc() == loc );
+
+ locale loc_de = __gnu_test::try_named_locale("de_DE");
+ locale ret = ob.pubimbue(loc_de);
+ VERIFY( ob.getloc() == loc_de );
+ VERIFY( ret == loc );
+
+ locale::global(loc);
+ VERIFY( ob.getloc() == loc_de );
+}
+
+int main()
+{
+ using namespace std;
+ test03();
+ return 0;
+}
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#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::streamoff strmof_1(-1), strmof_2;
+ typedef std::wstringbuf::int_type int_type;
+ typedef std::wstringbuf::traits_type traits_type;
+ typedef std::wstringbuf::pos_type pos_type;
+ typedef std::wstringbuf::off_type off_type;
+
+ // GET
+ // int in_avail()
+ strmof_1 = strb_01.in_avail();
+ strmof_2 = strb_02.in_avail();
+ VERIFY( strmof_1 != strmof_2 );
+ VERIFY( strmof_1 == static_cast<std::streamoff>(str_01.length()) );
+ VERIFY( strmof_2 == static_cast<std::streamoff>(str_02.length()) );
+ strmof_1 = strb_03.in_avail();
+ // zero cuz write-only, or eof()? zero, from showmany
+ VERIFY( strmof_1 == 0 );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 2004-07-07 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 basic_stringbuf overridden virtual functions.
+
+#include <sstream>
+#include <cstdlib>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+wstring
+data(unsigned len)
+{
+ wstring ret;
+ for (unsigned i = 0; i < len; ++i)
+ ret.push_back(L'a' + rand() % 26);
+ return ret;
+}
+
+void
+test01(unsigned iter)
+{
+ bool test __attribute__((unused)) = true;
+
+ for (unsigned n = 1; n <= iter; n *= 10)
+ {
+ const wstring str = data(n);
+ wstringbuf sstr;
+ for (unsigned i = 0; i < n; ++i)
+ sstr.sputc(str[i]);
+ VERIFY( str == sstr.str() );
+ }
+}
+
+int main()
+{
+ test01(10000000);
+ return 0;
+}
--- /dev/null
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.
+
+// 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 <sstream>
+#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_stringbuf<charT, traits>
+ {
+ protected:
+ typedef typename
+ std::basic_stringbuf<charT, traits>::int_type int_type;
+ virtual int_type
+ overflow(int_type c)
+ { return traits::not_eof(c); }
+ };
+
+typedef basic_nullbuf<wchar_t> nullbuf;
+
+template<typename T>
+ wchar_t
+ print(const T& x)
+ {
+ nullbuf ob;
+ std::wostream out(&ob);
+ out << x << std::endl;
+ return (!out ? L'0' : L'1');
+ }
+
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+ const std::wstring control01(L"11111");
+ std::wstring test01;
+
+ test01 += print(true);
+ test01 += print(3.14159);
+ test01 += print(10);
+ test01 += print(L'x');
+ test01 += print(L"pipo");
+
+ VERIFY( test01 == control01 );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
--- /dev/null
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.
+
+// 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 <sstream>
+#include <ostream>
+#include <testsuite_hooks.h>
+
+// libstdc++/3599
+class testbuf : public std::wstringbuf
+{
+public:
+ typedef std::wstringbuf::traits_type traits_type;
+
+ testbuf() : std::wstringbuf() { }
+
+protected:
+ int_type
+ overflow(int_type c __attribute__((unused)) = traits_type::eof())
+ { return traits_type::not_eof(0); }
+};
+
+void
+test07()
+{
+ bool test __attribute__((unused)) = true;
+ testbuf ob;
+ std::wostream out(&ob);
+
+ out << L"gasp";
+ VERIFY(out.good());
+
+ out << std::endl;
+ VERIFY(out.good());
+}
+
+int main()
+{
+ test07();
+ return 0;
+}
--- /dev/null
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 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.8.1.4 Overridden virtual functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+class OverBuf : public std::wstringbuf
+{
+public:
+ int_type pub_overflow(int_type c = traits_type::eof())
+ { return std::wstringbuf::overflow(c); }
+};
+
+// libstdc++/9988
+// filebuf::overflow writes EOF to file
+void test15()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ OverBuf sb;
+
+ sb.sputc(L'a');
+ sb.pub_overflow(L'b');
+ sb.pub_overflow();
+ sb.sputc(L'c');
+
+ wstringbuf sbin(sb.str(), ios_base::in);
+ wstringbuf::int_type c;
+ c = sbin.sbumpc();
+ VERIFY( c == L'a' );
+ c = sbin.sbumpc();
+ VERIFY( c == L'b' );
+ c = sbin.sbumpc();
+ VERIFY( c == L'c' );
+ c = sbin.sbumpc();
+ VERIFY( c == wstringbuf::traits_type::eof() );
+}
+
+int main()
+{
+ test15();
+ return 0;
+}
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#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::streamoff strmof_1(-1), strmof_2;
+ typedef std::wstringbuf::int_type int_type;
+ typedef std::wstringbuf::traits_type traits_type;
+ typedef std::wstringbuf::pos_type pos_type;
+ typedef std::wstringbuf::off_type off_type;
+
+ // GET
+ strmof_1 = strb_01.in_avail();
+ strmof_2 = strb_02.in_avail();
+ strmof_1 = strb_03.in_avail();
+
+ // int_type sbumpc()
+ // if read_cur not avail, return uflow(), else return *read_cur & increment
+ int_type c1 = strb_01.sbumpc();
+ int_type c2 = strb_02.sbumpc();
+ VERIFY( c1 != c2 );
+ VERIFY( c1 == str_01[0] );
+ VERIFY( c2 == str_02[0] ); //should equal first letter at this point
+ int_type c3 = strb_01.sbumpc();
+ int_type c4 = strb_02.sbumpc();
+ VERIFY( c1 != c2 );
+ VERIFY( c1 != c3 );
+ VERIFY( c2 != c4 );
+ int_type c5 = strb_03.sbumpc();
+ VERIFY( c5 == traits_type::eof() );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 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.8.1.4 Overridden virtual functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/9825
+// filebuf::sputbackc breaks sbumpc
+void test12()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wstringbuf sbuf;
+ sbuf.sputn(L"crazy bees!", 11);
+ sbuf.pubseekoff(0, ios_base::beg);
+ sbuf.sbumpc();
+ sbuf.sputbackc(L'x');
+ stringbuf::int_type c = sbuf.sbumpc();
+ VERIFY( c == L'x' );
+ c = sbuf.sbumpc();
+ VERIFY( c == L'r' );
+ c = sbuf.sbumpc();
+ VERIFY( c == L'a' );
+}
+
+int main()
+{
+ test12();
+ return 0;
+}
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#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;
+ typedef std::wstringbuf::pos_type pos_type;
+ 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
+
+ // BUFFER MANAGEMENT & POSITIONING
+
+ // 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;
+ 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);
+ off_1 = off_type(pt_1);
+ VERIFY( off_1 >= 0 );
+ c1 = strb_01.snextc(); //current in pointer +1
+ VERIFY( c1 == L'o' );
+ c2 = strb_01.sputc(L'x'); //test current out pointer
+ str_tmp = std::wstring(L"myxonos. . . or what?");
+ VERIFY( strb_01.str() == str_tmp );
+ //cur
+ pt_1 = strb_01.pubseekoff(2, std::ios_base::cur);
+ off_1 = off_type(pt_1);
+ VERIFY( off_1 == -1 ); // can't seekoff for in and out + cur in sstreams
+ pt_1 = strb_01.pubseekoff(2, std::ios_base::cur, std::ios_base::in);
+ off_1 = off_type(pt_1);
+ pt_2 = strb_01.pubseekoff(2, std::ios_base::cur, std::ios_base::in);
+ off_2 = off_type(pt_2);
+ VERIFY( off_2 == off_1 + 2 );
+ c1 = strb_01.snextc(); //current in pointer + 1
+ VERIFY( c1 == L' ' );
+ c2 = strb_01.sputc(L'x'); //test current out pointer
+ str_tmp = std::wstring(L"myxxnos. . . or what?");
+ VERIFY( strb_01.str() == str_tmp );
+ //end
+ pt_2 = strb_01.pubseekoff(2, std::ios_base::end);
+ off_1 = off_type(pt_2);
+ VERIFY( off_1 == -1 ); // not a valid position
+ VERIFY( strb_01.str() == str_tmp );
+ // end part two (from the filebuf tests)
+ strb_01.pubseekoff(0, std::ios_base::end);
+ strmsz_1 = strb_01.in_avail(); // 0 cuz at the end
+ c1 = strb_01.sgetc();
+ c2 = strb_01.sungetc();
+ strmsz_2 = strb_01.in_avail(); // 1
+ c3 = strb_01.sgetc();
+ VERIFY( c1 != c2 );
+ VERIFY( strmsz_2 != strmsz_1 );
+ VERIFY( strmsz_2 == 1 );
+ // end part three
+ strmsz_1 = strb_01.str().size();
+ strmsz_2 = strb_01.sputn(L" ravi shankar meets carlos santana in LoHa", 90);
+ strb_01.pubseekoff(0, std::ios_base::end);
+ strb_01.sputc(L'<');
+ str_tmp = strb_01.str();
+ VERIFY(static_cast<std::streamsize>(str_tmp.size()) == strmsz_1 + strmsz_2 + 1);
+ // IN
+ // OUT
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 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>
+
+void test02(std::wstringbuf& in, bool pass)
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+ typedef wstreambuf::pos_type pos_type;
+ typedef wstreambuf::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);
+ VERIFY( p == bad );
+}
+
+int main()
+{
+ using namespace std;
+
+ // movie star, submarine scientist!
+ wstringbuf in1(L"Hedy Lamarr", ios_base::in);
+ wstringbuf in2(ios_base::in);
+ wstringbuf in3(L"", ios_base::in);
+ test02(in1, true);
+ test02(in2, false);
+ test02(in3, false);
+ return 0;
+}
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#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;
+ typedef std::wstringbuf::int_type int_type;
+ typedef std::wstringbuf::traits_type traits_type;
+ typedef std::wstringbuf::pos_type pos_type;
+ 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();
+
+ pos_type pt_1(off_type(-1));
+ pos_type pt_2(off_type(0));
+ off_type off_1 = 0;
+ off_type off_2 = 0;
+
+ // PUT
+ strb_03.str(str_01); //reset
+
+ // BUFFER MANAGEMENT & POSITIONING
+
+ // seekpos
+ // pubseekpos(pos_type sp, ios_base::openmode)
+ // alters the stream position to sp
+ 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);
+ off_1 = off_type(pt_1);
+ VERIFY( off_1 >= 0 );
+ pt_1 = strb_01.pubseekoff(0, std::ios_base::cur, std::ios_base::out);
+ off_1 = off_type(pt_1);
+ c1 = strb_01.snextc(); //current in pointer +1
+ VERIFY( c1 == L'o' );
+ c2 = strb_01.sputc(L'x'); //test current out pointer
+ str_tmp = std::wstring(L"myxonos. . . or what?");
+ VERIFY( strb_01.str() == str_tmp );
+ strb_01.pubsync(); //resets pointers
+ pt_2 = strb_01.pubseekpos(pt_1, std::ios_base::in|std::ios_base::out);
+ off_2 = off_type(pt_2);
+ VERIFY( off_1 == off_2 );
+ c3 = strb_01.snextc(); //current in pointer +1
+ VERIFY( c1 == c3 );
+ c2 = strb_01.sputc(L'x'); //test current out pointer
+ str_tmp = std::wstring(L"myxonos. . . or what?");
+ VERIFY( strb_01.str() == str_tmp );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 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>
+
+void test02(std::wstringbuf& in, bool pass)
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+ typedef wstreambuf::pos_type pos_type;
+ typedef wstreambuf::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 );
+}
+
+int main()
+{
+ using namespace std;
+
+ // movie star, submarine scientist!
+ wstringbuf in1(L"Hedy Lamarr", ios_base::in);
+ wstringbuf in2(ios_base::in);
+ wstringbuf in3(L"", ios_base::in);
+ test02(in1, true);
+ test02(in2, false);
+ test02(in3, false);
+ return 0;
+}
--- /dev/null
+// 2003-05-30 Paolo Carlini <pcarlini@unitus.it>
+
+// Copyright (C) 2003, 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.
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+ typedef wstringbuf::pos_type pos_type;
+ typedef wstringbuf::off_type off_type;
+
+ wstringbuf strb_01(ios_base::out);
+
+ strb_01.sputn(L"broken peak", 11);
+ pos_type pt_1 = strb_01.pubseekoff(0, ios_base::end, ios_base::out);
+
+ // In general, according to 27.7.1.3,14, the below has undefined
+ // behaviour since pt_1 + off_type(1) doesn't come from a
+ // previous pubseekpos or pubseekoff. However, given v3 implementation,
+ // this was useful to expose a bug in pubseekpos checks.
+ pos_type pt_2 = strb_01.pubseekpos(pt_1 + off_type(1), ios_base::out);
+ VERIFY( pt_2 == pos_type(off_type(-1)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#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;
+ typedef std::wstringbuf::int_type int_type;
+ typedef std::wstringbuf::traits_type traits_type;
+ typedef std::wstringbuf::pos_type pos_type;
+ typedef std::wstringbuf::off_type off_type;
+
+ // PUT
+ strb_03.str(str_01); //reset
+
+ // BUFFER MANAGEMENT & POSITIONING
+ // setbuf
+ // pubsetbuf(char_type* s, streamsize n)
+ str_tmp = std::wstring(L"naaaah, go to cebu");
+ strb_01.pubsetbuf(const_cast<wchar_t*> (str_tmp.c_str()), str_tmp.size());
+ VERIFY( strb_01.str() == str_tmp );
+ strb_01.pubsetbuf(0,0);
+ VERIFY( strb_01.str() == str_tmp );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 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.8.1.4 Overridden virtual functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+
+ bool test __attribute__((unused)) = true;
+ wchar_t buf[512];
+ const wchar_t* strlit = L"how to tell a story and other essays: mark twain";
+ const size_t strlitsize = std::wcslen(strlit);
+ wstringbuf sbuf;
+
+ sbuf.pubsetbuf(buf, 512);
+ sbuf.sputn(strlit, strlitsize);
+ VERIFY( std::wcsncmp(strlit, buf, strlitsize) == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 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.8.1.4 Overridden virtual functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test02()
+{
+ using namespace std;
+
+ bool test __attribute__((unused)) = true;
+ wchar_t buf[512];
+ const wchar_t* strlit = L"how to tell a story and other essays: mark twain";
+ const size_t strlitsize = std::wcslen(strlit);
+ wstring s(L"tmp");
+ wstringbuf sbuf(s, ios_base::out);
+ sbuf.pubsetbuf(buf, strlitsize);
+ sbuf.sputn(strlit, strlitsize);
+ VERIFY( std::wcsncmp(strlit, buf, strlitsize) == 0 );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#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::streamoff strmof_1(-1), strmof_2;
+ typedef std::wstringbuf::int_type int_type;
+ typedef std::wstringbuf::traits_type traits_type;
+ typedef std::wstringbuf::pos_type pos_type;
+ typedef std::wstringbuf::off_type off_type;
+
+ // GET
+ strmof_1 = strb_01.in_avail();
+ strmof_2 = strb_02.in_avail();
+ strmof_1 = strb_03.in_avail();
+
+ int_type c3 = strb_01.sbumpc();
+ int_type c4 = strb_02.sbumpc();
+ int_type c5 = strb_03.sbumpc();
+
+ // int_type sgetc()
+ // if read_cur not avail, return uflow(), else return *read_cur
+ int_type c6 = strb_01.sgetc();
+ int_type c7 = strb_02.sgetc();
+ VERIFY( c6 != c3 );
+ VERIFY( c7 != c4 );
+ int_type c8 = strb_01.sgetc();
+ int_type c9 = strb_02.sgetc();
+ VERIFY( c6 == c8 );
+ VERIFY( c7 == c9 );
+ c5 = strb_03.sgetc();
+ VERIFY( c5 == traits_type::eof() );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#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;
+ std::streamoff strmof_1(-1), strmof_2;
+ typedef std::wstringbuf::int_type int_type;
+ typedef std::wstringbuf::traits_type traits_type;
+ typedef std::wstringbuf::pos_type pos_type;
+ typedef std::wstringbuf::off_type off_type;
+
+ // GET
+ strmof_1 = strb_01.in_avail();
+ strmof_2 = strb_02.in_avail();
+ strmof_1 = strb_03.in_avail();
+
+ int_type c1 = strb_01.sbumpc();
+ int_type c2 = strb_02.sbumpc();
+ strb_01.sbumpc();
+ int_type c4 = strb_02.sbumpc();
+ int_type c5 = strb_03.sbumpc();
+
+ // int_type sgetc()
+ // if read_cur not avail, return uflow(), else return *read_cur
+ int_type c6 = strb_01.sgetc();
+ int_type c7 = strb_02.sgetc();
+ strb_01.sgetc();
+ strb_02.sgetc();
+ c5 = strb_03.sgetc();
+
+ // int_type snextc()
+ // calls sbumpc and if sbumpc != eof, return sgetc
+ c6 = strb_01.snextc();
+ c7 = strb_02.snextc();
+ c5 = strb_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 = strb_01.in_avail();
+ strmsz_2 = strb_02.in_avail();
+ test = strmsz_1 != strmsz_2;
+ VERIFY( strmsz_1 != static_cast<std::streamsize>(str_01.length()) );
+ // because now we've moved into string
+ VERIFY( strmsz_2 != static_cast<std::streamsize>(str_02.length()) );
+ wchar_t carray1[11] = L"";
+ strmsz_1 = strb_01.sgetn(carray1, 10);
+ wchar_t carray2[20] = L"";
+ strmsz_2 = strb_02.sgetn(carray2, 10);
+ VERIFY( strmsz_1 == strmsz_2 );
+ VERIFY( strmsz_1 == 10 );
+ c1 = strb_01.sgetc();
+ c2 = strb_02.sgetc();
+ VERIFY( c6 == c1 ); //just by co-incidence both o's
+ VERIFY( c7 != c2 ); // n != i
+ VERIFY( c1 == str_01[13] );
+ VERIFY( c2 == str_02[13] ); //should equal fourteenth letter at this point
+ strmsz_1 = strb_03.sgetn(carray1, 10);
+ VERIFY( !strmsz_1 ); //zero
+ strmsz_1 = strb_02.in_avail();
+ strmsz_2 = strb_02.sgetn(carray2, strmsz_1 + 5);
+ VERIFY( strmsz_1 == strmsz_2 ); //write off the end
+ c4 = strb_02.sgetc(); // should be EOF
+ VERIFY( c4 == traits_type::eof() );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#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::streamoff strmof_1(-1), strmof_2;
+ typedef std::wstringbuf::int_type int_type;
+ typedef std::wstringbuf::traits_type traits_type;
+ typedef std::wstringbuf::pos_type pos_type;
+ typedef std::wstringbuf::off_type off_type;
+
+ // GET
+ strmof_1 = strb_01.in_avail();
+ strmof_2 = strb_02.in_avail();
+ strmof_1 = strb_03.in_avail();
+
+ strb_01.sbumpc();
+ strb_02.sbumpc();
+ strb_01.sbumpc();
+ strb_02.sbumpc();
+ int_type c5 = strb_03.sbumpc();
+
+ // int_type sgetc()
+ // if read_cur not avail, return uflow(), else return *read_cur
+ int_type c6 = strb_01.sgetc();
+ int_type c7 = strb_02.sgetc();
+ int_type c8 = strb_01.sgetc();
+ int_type c9 = strb_02.sgetc();
+ c5 = strb_03.sgetc();
+
+ // int_type snextc()
+ // calls sbumpc and if sbumpc != eof, return sgetc
+ c6 = strb_01.snextc();
+ c7 = strb_02.snextc();
+ VERIFY( c6 != c8 );
+ VERIFY( c7 != c9 );
+ VERIFY( c6 == str_01[3] );
+ VERIFY( c7 == str_02[3] ); //should equal fourth letter at this point
+ c5 = strb_03.snextc();
+ VERIFY( c5 == traits_type::eof() );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#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, str_tmp2;
+ std::wstringbuf strb_tmp;
+ std::streamsize strmsz_1, strmsz_2;
+ typedef std::wstringbuf::int_type int_type;
+ typedef std::wstringbuf::traits_type traits_type;
+ typedef std::wstringbuf::pos_type pos_type;
+ 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();
+ int_type c4 = strb_02.sbumpc();
+
+ // PUT
+ strb_03.str(str_01); //reset
+ std::wstring::size_type sz1 = strb_03.str().length();
+ std::wstring::size_type sz2 = strb_03.str().length();
+
+ // 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*
+ str_tmp = strb_03.str();
+ sz1 = str_tmp.length();
+ strmsz_1 = strb_03.sputn(L"racadabras", 10);//"abracadabras or what?"
+ sz2 = strb_03.str().length();
+ strmsz_2 = strb_03.sputn(L", i wanna reach out and", 10);
+ sz2 = strb_03.str().length();
+ str_tmp = strb_02.str();
+ strmsz_1 = strb_02.sputn(L"racadabra", 10);
+
+ // PUTBACK
+
+ // 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()
+ strmsz_1 = strb_01.in_avail();
+ str_tmp = strb_01.str();
+ c1 = strb_01.sgetc(); //"mykonos. . . 'o'r what?"
+ c2 = strb_01.sputbackc(L'z');//"mykonos. . .zor what?"
+ c3 = strb_01.sgetc();
+ str_tmp2 = strb_01.str();
+ VERIFY( c1 != c2 );
+ VERIFY( c3 == c2 );
+ VERIFY( str_tmp2 == std::wstring(L"mzkonos. . . or what?") );
+ VERIFY( str_tmp.size() == str_tmp2.size() );
+ //test for _in_cur == _in_beg
+ strb_01.str(str_tmp);
+ strmsz_1 = strb_01.in_avail();
+ c1 = strb_01.sgetc(); //"'m'ykonos. . . or what?"
+ c2 = strb_01.sputbackc(L'z');//"mykonos. . . or what?"
+ c3 = strb_01.sgetc();
+ VERIFY( c1 != c2 );
+ VERIFY( c3 != c2 );
+ VERIFY( c1 == c3 );
+ VERIFY( c2 == traits_type::eof() );
+ VERIFY( strb_01.str() == str_tmp );
+ VERIFY( str_tmp.size() == strb_01.str().size() );
+ // test for replacing char with identical one
+ strb_01.str(str_01); //reset
+ strmsz_1 = strb_01.in_avail();
+ strb_01.sbumpc();
+ strb_01.sbumpc();
+ c1 = strb_01.sgetc(); //"my'k'onos. . . or what?"
+ c2 = strb_01.sputbackc(L'y');//"mykonos. . . or what?"
+ c3 = strb_01.sgetc();
+ VERIFY( c1 != c2 );
+ VERIFY( c3 == c2 );
+ VERIFY( c1 != c3 );
+ VERIFY( strb_01.str() == str_01 );
+ VERIFY( str_01.size() == strb_01.str().size() );
+ //test for ios_base::out
+ strmsz_2 = strb_03.in_avail();
+ c4 = strb_03.sputbackc(L'x');
+ VERIFY( c4 == traits_type::eof() );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 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.8.1.4 Overridden virtual functions
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// 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 __attribute__((unused)) = true;
+
+ wstringbuf sbuf;
+ wstringbuf::int_type r = sbuf.sputbackc(L'a');
+ VERIFY( r == wstringbuf::traits_type::eof() );
+}
+
+int main()
+{
+ test09();
+ return 0;
+}
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#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;
+ typedef std::wstringbuf::int_type int_type;
+ typedef std::wstringbuf::traits_type traits_type;
+ typedef std::wstringbuf::pos_type pos_type;
+ 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
+ // int_type sputc(char_type c)
+ // if out_cur not avail, return overflow. Else, stores c at out_cur,
+ // increments out_cur, and returns c as int_type
+ strb_03.str(str_01); //reset
+ std::wstring::size_type sz1 = strb_03.str().length();
+ c1 = strb_03.sputc(L'a');
+ std::wstring::size_type sz2 = strb_03.str().length();
+ VERIFY( sz1 == sz2 ); //cuz inserting at out_cur, which is at beg to start
+ c2 = strb_03.sputc(L'b');
+ VERIFY( c1 != c2 );
+ VERIFY( strb_03.str() != str_01 );
+ c3 = strb_02.sputc(L'a'); // should be EOF because this is read-only
+ VERIFY( c3 == traits_type::eof() );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.
+
+// 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 <sstream>
+#include <testsuite_hooks.h>
+
+class nullsetpbuf : public std::wstringbuf
+{
+ wchar_t foo[64];
+public:
+ nullsetpbuf()
+ {
+ setp(foo, foo + 64);
+ setp(NULL, NULL);
+ }
+};
+
+// libstdc++/1057
+void test05()
+{
+ std::wstring text1 = L"abcdefghijklmn";
+
+ nullsetpbuf nsp;
+ // Immediate crash as sputc writes to null pointer
+ nsp.sputc(L'a');
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
--- /dev/null
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 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>
+
+bool over_called;
+
+class Derived_stringbuf : public std::wstringbuf
+{
+public:
+ int_type overflow(int_type c)
+ {
+ over_called = true;
+ return std::wstringbuf::overflow(c);
+ }
+
+ const char_type* pub_epptr() const
+ {
+ return epptr();
+ }
+
+ const char_type* pub_pptr() const
+ {
+ return pptr();
+ }
+};
+
+// libstdc++/9404
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+
+ bool over_expected;
+
+ // sputc
+ Derived_stringbuf dsbuf_01;
+ over_called = false;
+ dsbuf_01.sputc(L'i');
+ VERIFY( over_called );
+ over_expected = dsbuf_01.pub_epptr() == dsbuf_01.pub_pptr();
+ over_called = false;
+ dsbuf_01.sputc(L'v');
+ VERIFY( (!over_expected && !over_called)
+ || (over_expected && over_called) );
+ dsbuf_01.sputc(L'i');
+ VERIFY( dsbuf_01.str() == L"ivi" ); // Sanity check.
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#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;
+ typedef std::wstringbuf::pos_type pos_type;
+ typedef std::wstringbuf::off_type off_type;
+
+ // PUT
+ strb_03.str(str_01); //reset
+ std::wstring::size_type sz1 = strb_03.str().length();
+ std::wstring::size_type sz2 = strb_03.str().length();
+
+ // streamsize sputn(const char_type* 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*
+ str_tmp = strb_03.str();
+ sz1 = str_tmp.length();
+ strmsz_1 = strb_03.sputn(L"racadabras", 10);//"abracadabras or what?"
+ sz2 = strb_03.str().length();
+ VERIFY( sz1 == sz2 ); //shouldn't have changed length
+ VERIFY( strmsz_1 == 10 );
+ VERIFY( str_tmp != strb_03.str() );
+ strmsz_2 = strb_03.sputn(L", i wanna reach out and", 23);
+ VERIFY( strmsz_1 != strmsz_2 ); // should re-allocate, copy 10 chars.
+ VERIFY( strmsz_1 == 10 );
+ VERIFY( strmsz_2 == 23 );
+ sz2 = strb_03.str().length();
+ VERIFY( sz1 != sz2 ); // need to change length
+ VERIFY( str_tmp != strb_03.str() );
+ str_tmp = strb_02.str();
+ strmsz_1 = strb_02.sputn(L"racadabra", 10);
+ VERIFY( strmsz_1 == 0 );
+ VERIFY( str_tmp == strb_02.str() );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.
+
+// 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 <sstream>
+#include <testsuite_hooks.h>
+
+class nullsetpbuf : public std::wstringbuf
+{
+ wchar_t foo[64];
+public:
+ nullsetpbuf()
+ {
+ setp(foo, foo + 64);
+ setp(NULL, NULL);
+ }
+};
+
+// libstdc++/1057
+void test05()
+{
+ std::wstring text1 = L"abcdefghijklmn";
+
+ nullsetpbuf nsp;
+ // Immediate crash as xsputn writes to null pointer
+ nsp.sputn(text1.c_str(), text1.length());
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
--- /dev/null
+// 2001-05-21 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2003, 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>
+
+bool over_called;
+
+class Derived_stringbuf : public std::wstringbuf
+{
+public:
+ int_type overflow(int_type c)
+ {
+ over_called = true;
+ return std::wstringbuf::overflow(c);
+ }
+
+ const char_type* pub_epptr() const
+ {
+ return epptr();
+ }
+
+ const char_type* pub_pptr() const
+ {
+ return pptr();
+ }
+};
+
+// libstdc++/9404
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+
+ bool over_expected;
+ Derived_stringbuf dsbuf_01;
+
+ // sputn
+ Derived_stringbuf dsbuf_02;
+ over_called = false;
+ dsbuf_02.sputn(L"sonne's", 7);
+ VERIFY( over_called );
+ over_expected = dsbuf_02.pub_epptr() == dsbuf_02.pub_pptr();
+ over_called = false;
+ dsbuf_02.sputn(L" peak", 5);
+ VERIFY( (!over_expected && !over_called)
+ || (over_expected && over_called) );
+ VERIFY( dsbuf_02.str() == L"sonne's peak" ); // Sanity check.
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#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 member functions
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ // stringbuf::str()
+ VERIFY( strb_01.str() == str_01 );
+ VERIFY( strb_02.str() == str_02 );
+ VERIFY( strb_03.str() == str_03 );
+
+ // stringbuf::str(string&)
+ strb_03.str(L"none of the above, go to the oberoi in cairo, egypt.");
+ strb_03.str(str_01);
+ std::streamsize d1 = strb_01.in_avail();
+ std::streamsize d2 = strb_03.in_avail();
+ VERIFY( d1 ); // non-zero
+ VERIFY( !d2 ); // zero, cuz ios_base::out
+ VERIFY( d1 != d2 ); //these should be the same
+ VERIFY( static_cast<std::streamsize>(str_01.length()) == d1 );
+ VERIFY( strb_01.str() == strb_03.str() ); //ditto
+
+ // stringbuf::str(string&) and stringbuf::stringbuf(string&), where the
+ // string in question contains embedded NUL characters. Note that in this
+ // embedded-NUL situation, the size must be passed to the string ctor.
+ std::wstring str_nulls(L"eschew \0 obfuscation", 20); // tested in 21_strings
+ std::wstringbuf strb_normal(str_01);
+ std::wstringbuf strb_nulls(str_nulls);
+ strb_normal.str(str_nulls); // tried using 'strb_01' rather than declaring
+ // another variable, but then test04 broke!
+ VERIFY( strb_nulls.in_avail() == static_cast<std::streamsize>(str_nulls.size()) );
+ VERIFY( strb_nulls.str().size() == 20 );
+ VERIFY( strb_normal.in_avail() == static_cast<std::streamsize>(str_nulls.size()) );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// http://gcc.gnu.org/ml/libstdc++/2003-02/msg00269.html
+// Growing and then seeking to ios_base::beg triggered a bug in str(),
+// which didn't notice the grow.
+void test07()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wstringbuf strb_01;
+ strb_01.sputc(L's');
+ strb_01.pubseekoff(0, std::ios_base::beg);
+ std::wstring tmp = strb_01.str();
+ VERIFY( tmp == L"s" );
+
+ std::wstring str(L"strivi,");
+ std::wstringbuf strb_02(str);
+ strb_02.pubseekoff(0, std::ios_base::end);
+ strb_02.sputn(L" no better!", 11);
+ strb_02.pubseekoff(0, std::ios_base::beg);
+ tmp = strb_02.str();
+ VERIFY( tmp == L"strivi, no better!" );
+}
+
+int main()
+{
+ test07();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void test06()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wostringstream os (L"foo", std::ios_base::app);
+ os << L"bar";
+
+ VERIFY( os.str() == L"foobar" );
+}
+
+int main()
+{
+ test06();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// libstdc++/3955 -- ios_base::app overwrites from the beginning
+void test05()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wostringstream os (L"foo");
+ os << L"bar";
+
+ VERIFY( os.str() == L"bar" );
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 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.
+
+#include <sstream>
+#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;
+ typedef std::wstringbuf::pos_type pos_type;
+ 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();
+ int_type c4 = strb_02.sbumpc();
+
+ // PUT
+ strb_03.str(str_01); //reset
+ std::wstring::size_type sz1 = strb_03.str().length();
+ std::wstring::size_type sz2 = strb_03.str().length();
+
+ // 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*
+ str_tmp = strb_03.str();
+ sz1 = str_tmp.length();
+ strmsz_1 = strb_03.sputn(L"racadabras", 10);//"abracadabras or what?"
+ sz2 = strb_03.str().length();
+ strmsz_2 = strb_03.sputn(L", i wanna reach out and", 10);
+ sz2 = strb_03.str().length();
+ str_tmp = strb_02.str();
+ strmsz_1 = strb_02.sputn(L"racadabra", 10);
+
+ // PUTBACK
+
+ // 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()
+ strmsz_1 = strb_01.in_avail();
+ str_tmp = strb_01.str();
+ c1 = strb_01.sgetc(); //"mykonos. . . 'o'r what?"
+ c2 = strb_01.sputbackc('z');//"mykonos. . .zor what?"
+ c3 = strb_01.sgetc();
+ //test for _in_cur == _in_beg
+ strb_01.str(str_tmp);
+ strmsz_1 = strb_01.in_avail();
+ c1 = strb_01.sgetc(); //"'m'ykonos. . . or what?"
+ c2 = strb_01.sputbackc(L'z');//"mykonos. . . or what?"
+ c3 = strb_01.sgetc();
+ // test for replacing char with identical one
+ strb_01.str(str_01); //reset
+ strmsz_1 = strb_01.in_avail();
+ strb_01.sbumpc();
+ strb_01.sbumpc();
+ c1 = strb_01.sgetc(); //"my'k'onos. . . or what?"
+ c2 = strb_01.sputbackc(L'y');//"mykonos. . . or what?"
+ c3 = strb_01.sgetc();
+ //test for ios_base::out
+ strmsz_2 = strb_03.in_avail();
+ c4 = strb_03.sputbackc(L'x');
+
+ // int_type sungetc()
+ // if in_cur not avail, return pbackfail(), else decrement and
+ // return to_int_type(*gptr())
+ for (int i = 0; i<12; ++i)
+ strb_01.sbumpc();
+ strmsz_1 = strb_01.in_avail();
+ str_tmp = strb_01.str();
+ c1 = strb_01.sgetc(); //"mykonos. . . 'o'r what?"
+ c2 = strb_01.sungetc();//"mykonos. . . or what?"
+ c3 = strb_01.sgetc();
+ VERIFY( c1 != c2 );
+ VERIFY( c3 == c2 );
+ VERIFY( c1 != c3 );
+ VERIFY( c2 == L' ' );
+ VERIFY( strb_01.str() == str_01 );
+ VERIFY( str_01.size() == strb_01.str().size() );
+ //test for _in_cur == _in_beg
+ strb_01.str(str_tmp);
+ strmsz_1 = strb_01.in_avail();
+ c1 = strb_01.sgetc(); //"'m'ykonos. . . or what?"
+ c2 = strb_01.sungetc();//"mykonos. . . or what?"
+ c3 = strb_01.sgetc();
+ VERIFY( c1 != c2 );
+ VERIFY( c3 != c2 );
+ VERIFY( c1 == c3 );
+ VERIFY( c2 == traits_type::eof() );
+ VERIFY( strb_01.str() == str_01 );
+ VERIFY( str_01.size() == strb_01.str().size() );
+ // test for replacing char with identical one
+ strb_01.str(str_01); //reset
+ strmsz_1 = strb_01.in_avail();
+ strb_01.sbumpc();
+ strb_01.sbumpc();
+ c1 = strb_01.sgetc(); //"my'k'onos. . . or what?"
+ c2 = strb_01.sungetc();//"mykonos. . . or what?"
+ c3 = strb_01.sgetc();
+ VERIFY( c1 != c2 );
+ VERIFY( c3 == c2 );
+ VERIFY( c1 != c3 );
+ VERIFY( strb_01.str() == str_01 );
+ VERIFY( str_01.size() == strb_01.str().size() );
+ //test for ios_base::out
+ strmsz_2 = strb_03.in_avail();
+ c4 = strb_03.sungetc();
+ VERIFY( c4 == traits_type::eof() );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
+
+
+
+// more candy!!!
--- /dev/null
+// 1999-10-11 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 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.
+
+// 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 <sstream>
+#include <testsuite_hooks.h>
+
+class setpbuf : public std::wstringbuf
+{
+ wchar_t buffer[4];
+ std::wstring result;
+
+public:
+
+ std::wstring&
+ get_result()
+ { return result; }
+
+ setpbuf()
+ {
+ wchar_t foo [32];
+ setp(foo, foo + 32);
+ setp(buffer, buffer + 4);
+ }
+
+ ~setpbuf()
+ { sync(); }
+
+ 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 __attribute__((unused)) = true;
+ std::wstring text = L"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::wstring::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;
+}