136108Sjb// Copyright (C) 2005 Free Software Foundation
250472Speter//
336108Sjb// This file is part of the GNU ISO C++ Library.  This library is free
436108Sjb// software; you can redistribute it and/or modify it under the
543818Swes// terms of the GNU General Public License as published by the
643818Swes// Free Software Foundation; either version 2, or (at your option)
750177Shoek// any later version.
843818Swes
943818Swes// This library is distributed in the hope that it will be useful,
1043818Swes// but WITHOUT ANY WARRANTY; without even the implied warranty of
1143818Swes// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1243818Swes// GNU General Public License for more details.
1350177Shoek
1443818Swes// You should have received a copy of the GNU General Public License along
1543818Swes// with this library; see the file COPYING.  If not, write to the Free
1643818Swes// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
1750177Shoek// USA.
1894929Sgerald
1994929Sgerald// 27.6.2.5.4 basic_ostream character inserters
2094929Sgerald
2194929Sgerald#include <string>
2250177Shoek#include <ostream>
2350177Shoek#include <sstream>
2443818Swes#include <testsuite_hooks.h>
2543818Swes
2650177Shoek// ostringstream and large strings number 2
2750177Shoekvoid
2843818Swestest05()
2936108Sjb{
3036108Sjb  bool test __attribute__((unused)) = true;
3150177Shoek  std::wstring str05, str10;
3250177Shoek
3356805Sobrien  typedef std::wostream::pos_type	pos_type;
3436108Sjb  typedef std::wostream::off_type	off_type;
3556805Sobrien  std::wstring str01;
3636108Sjb  const int size = 1000;
3736108Sjb
3836108Sjb  // initialize string
3948558Sdes  for(int i=0 ; i < size; i++) {
4048558Sdes    str01 += L'1';
4148558Sdes    str01 += L'2';
4248558Sdes    str01 += L'3';
4348558Sdes    str01 += L'4';
44170088Sdougb    str01 += L'5';
4536108Sjb    str01 += L'6';
4636108Sjb    str01 += L'7';
47180487Sed    str01 += L'8';
48180487Sed    str01 += L'9';
49180487Sed    str01 += L'\n';
50180487Sed  }
51121468Ssimokawa
52121468Ssimokawa  // test 1: out
5336108Sjb  std::wostringstream sstr01(str01, std::ios_base::out);
5436108Sjb  std::wostringstream sstr02;
5536108Sjb  sstr02 << str01;
5636108Sjb  str05 = sstr01.str();
5736108Sjb  str10 = sstr02.str();
5836108Sjb  VERIFY( str05 == str01 );
5936108Sjb  VERIFY( str10 == str01 );
6036108Sjb
6136108Sjb  // test 2: in | out
6236108Sjb  std::wostringstream sstr04(str01,  std::ios_base::out | std::ios_base::in);
6336108Sjb  std::wostringstream sstr05(std::ios_base::in | std::ios_base::out);
6436108Sjb  sstr05 << str01;
6536108Sjb  str05 = sstr04.str();
6636108Sjb  str10 = sstr05.str();
6736108Sjb  VERIFY( str05 == str01 );
6836108Sjb  VERIFY( str10 == str01 );
6936108Sjb}
7036108Sjb
7136108Sjbint main()
7236108Sjb{
7336108Sjb  test05();
7436108Sjb  return 0;
7536108Sjb}
7636108Sjb