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 // <strstream>
10 
11 // class strstream
12 
13 // strstream();
14 
15 #include <strstream>
16 #include <cassert>
17 #include <cstring>
18 #include <string>
19 
20 #include "test_macros.h"
21 
main(int,char **)22 int main(int, char**)
23 {
24     std::strstream inout;
25     int i = 123;
26     double d = 4.5;
27     std::string s("dog");
28     inout << i << ' ' << d << ' ' << s << std::ends;
29     assert(inout.str() == std::string("123 4.5 dog"));
30     i = 0;
31     d = 0;
32     s = "";
33     inout >> i >> d >> s;
34     assert(i == 123);
35     assert(d == 4.5);
36     assert(std::strcmp(s.c_str(), "dog") == 0);
37     inout.freeze(false);
38 
39   return 0;
40 }
41