• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <sstream>
11 
12 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
13 // class basic_ostringstream
14 
15 // void str(const basic_string<charT,traits,Allocator>& s);
16 
17 #include <sstream>
18 #include <cassert>
19 
main()20 int main()
21 {
22     {
23         std::ostringstream ss(" 123 456");
24         assert(ss.rdbuf() != 0);
25         assert(ss.good());
26         assert(ss.str() == " 123 456");
27         int i = 0;
28         ss << i;
29         assert(ss.str() == "0123 456");
30         ss << 456;
31         assert(ss.str() == "0456 456");
32         ss.str(" 789");
33         assert(ss.str() == " 789");
34         ss << "abc";
35         assert(ss.str() == "abc9");
36     }
37     {
38         std::wostringstream ss(L" 123 456");
39         assert(ss.rdbuf() != 0);
40         assert(ss.good());
41         assert(ss.str() == L" 123 456");
42         int i = 0;
43         ss << i;
44         assert(ss.str() == L"0123 456");
45         ss << 456;
46         assert(ss.str() == L"0456 456");
47         ss.str(L" 789");
48         assert(ss.str() == L" 789");
49         ss << L"abc";
50         assert(ss.str() == L"abc9");
51     }
52 }
53