]>
Commit | Line | Data |
---|---|---|
8d9254fc | 1 | // Copyright (C) 2005-2020 Free Software Foundation, Inc. |
ba4b172f PC |
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 | |
748086b7 | 6 | // Free Software Foundation; either version 3, or (at your option) |
ba4b172f PC |
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 | |
748086b7 JJ |
15 | // with this library; see the file COPYING3. If not see |
16 | // <http://www.gnu.org/licenses/>. | |
ba4b172f PC |
17 | |
18 | // 27.6.2.5.4 basic_ostream character inserters | |
19 | ||
20 | #include <string> | |
21 | #include <ostream> | |
22 | #include <sstream> | |
23 | #include <testsuite_hooks.h> | |
24 | ||
25 | // ostringstream and large strings number 2 | |
26 | void | |
27 | test05() | |
28 | { | |
ba4b172f PC |
29 | std::wstring str05, str10; |
30 | ||
31 | typedef std::wostream::pos_type pos_type; | |
32 | typedef std::wostream::off_type off_type; | |
33 | std::wstring str01; | |
34 | const int size = 1000; | |
35 | ||
36 | // initialize string | |
37 | for(int i=0 ; i < size; i++) { | |
38 | str01 += L'1'; | |
39 | str01 += L'2'; | |
40 | str01 += L'3'; | |
41 | str01 += L'4'; | |
42 | str01 += L'5'; | |
43 | str01 += L'6'; | |
44 | str01 += L'7'; | |
45 | str01 += L'8'; | |
46 | str01 += L'9'; | |
47 | str01 += L'\n'; | |
48 | } | |
49 | ||
50 | // test 1: out | |
51 | std::wostringstream sstr01(str01, std::ios_base::out); | |
52 | std::wostringstream sstr02; | |
53 | sstr02 << str01; | |
54 | str05 = sstr01.str(); | |
55 | str10 = sstr02.str(); | |
56 | VERIFY( str05 == str01 ); | |
57 | VERIFY( str10 == str01 ); | |
58 | ||
59 | // test 2: in | out | |
60 | std::wostringstream sstr04(str01, std::ios_base::out | std::ios_base::in); | |
61 | std::wostringstream sstr05(std::ios_base::in | std::ios_base::out); | |
62 | sstr05 << str01; | |
63 | str05 = sstr04.str(); | |
64 | str10 = sstr05.str(); | |
65 | VERIFY( str05 == str01 ); | |
66 | VERIFY( str10 == str01 ); | |
67 | } | |
68 | ||
69 | int main() | |
70 | { | |
71 | test05(); | |
72 | return 0; | |
73 | } |