1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <sstream>
10 
11 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
12 // class basic_ostringstream
13 
14 // void str(const basic_string<charT,traits,Allocator>& s);
15 
16 #include <sstream>
17 #include <cassert>
18 
19 #include "test_macros.h"
20 
main(int,char **)21 int main(int, char**)
22 {
23     {
24         std::ostringstream ss(" 123 456");
25         assert(ss.rdbuf() != 0);
26         assert(ss.good());
27         assert(ss.str() == " 123 456");
28         int i = 0;
29         ss << i;
30         assert(ss.str() == "0123 456");
31         ss << 456;
32         assert(ss.str() == "0456 456");
33         ss.str(" 789");
34         assert(ss.str() == " 789");
35         ss << "abc";
36         assert(ss.str() == "abc9");
37     }
38     {
39         std::wostringstream ss(L" 123 456");
40         assert(ss.rdbuf() != 0);
41         assert(ss.good());
42         assert(ss.str() == L" 123 456");
43         int i = 0;
44         ss << i;
45         assert(ss.str() == L"0123 456");
46         ss << 456;
47         assert(ss.str() == L"0456 456");
48         ss.str(L" 789");
49         assert(ss.str() == L" 789");
50         ss << L"abc";
51         assert(ss.str() == L"abc9");
52     }
53 
54   return 0;
55 }
56