Reverting merge from trunk
[official-gcc.git] / libstdc++-v3 / testsuite / 27_io / basic_ostream / inserters_character / wchar_t / 6.cc
blob4de6c6a62579e034a859feedbef13166684fd0d7
1 // Copyright (C) 2005-2013 Free Software Foundation, Inc.
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 3, or (at your option)
7 // any later version.
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.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // 27.6.2.5.4 basic_ostream character inserters
20 #include <string>
21 #include <ostream>
22 #include <sstream>
23 #include <testsuite_hooks.h>
25 // ostringstream and positioning, multiple writes
26 // http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00326.html
27 void test06()
29 bool test __attribute__((unused)) = true;
30 const wchar_t carray01[] = L"mos def & talib kweli are black star";
32 // normal
33 std::wostringstream ostr1(L"mos def");
34 VERIFY( ostr1.str() == L"mos def" );
35 ostr1 << L" & talib kweli"; // should overwrite first part of buffer
36 VERIFY( ostr1.str() == L" & talib kweli" );
37 ostr1 << L" are black star"; // should append to string from above
38 VERIFY( ostr1.str() != carray01 );
39 VERIFY( ostr1.str() == L" & talib kweli are black star" );
41 // appending
42 std::wostringstream ostr2(L"blackalicious",
43 std::ios_base::out | std::ios_base::ate);
44 VERIFY( ostr2.str() == L"blackalicious" );
45 ostr2 << L" NIA "; // should not overwrite first part of buffer
46 VERIFY( ostr2.str() == L"blackalicious NIA " );
47 ostr2 << L"4: deception (5:19)"; // should append to full string from above
48 VERIFY( ostr2.str() == L"blackalicious NIA 4: deception (5:19)" );
51 int main()
53 test06();
54 return 0;