1// Copyright (C) 2005 Free Software Foundation
2//
3// This file is part of the GNU ISO C++ Library.  This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
6// Free Software Foundation; either version 2, or (at your option)
7// any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License along
15// with this library; see the file COPYING.  If not, write to the Free
16// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17// USA.
18
19// 27.6.2.5.4 basic_ostream character inserters
20
21#include <string>
22#include <ostream>
23#include <sstream>
24#include <testsuite_hooks.h>
25
26// ostringstream and large strings number 2
27void
28test05()
29{
30  bool test __attribute__((unused)) = true;
31  std::wstring str05, str10;
32
33  typedef std::wostream::pos_type	pos_type;
34  typedef std::wostream::off_type	off_type;
35  std::wstring str01;
36  const int size = 1000;
37
38  // initialize string
39  for(int i=0 ; i < size; i++) {
40    str01 += L'1';
41    str01 += L'2';
42    str01 += L'3';
43    str01 += L'4';
44    str01 += L'5';
45    str01 += L'6';
46    str01 += L'7';
47    str01 += L'8';
48    str01 += L'9';
49    str01 += L'\n';
50  }
51
52  // test 1: out
53  std::wostringstream sstr01(str01, std::ios_base::out);
54  std::wostringstream sstr02;
55  sstr02 << str01;
56  str05 = sstr01.str();
57  str10 = sstr02.str();
58  VERIFY( str05 == str01 );
59  VERIFY( str10 == str01 );
60
61  // test 2: in | out
62  std::wostringstream sstr04(str01,  std::ios_base::out | std::ios_base::in);
63  std::wostringstream sstr05(std::ios_base::in | std::ios_base::out);
64  sstr05 << str01;
65  str05 = sstr04.str();
66  str10 = sstr05.str();
67  VERIFY( str05 == str01 );
68  VERIFY( str10 == str01 );
69}
70
71int main()
72{
73  test05();
74  return 0;
75}
76