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 // UNSUPPORTED: c++03
10 
11 // <sstream>
12 
13 // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
14 // class basic_istringstream
15 
16 // basic_istringstream& operator=(basic_istringstream&& rhs);
17 
18 #include <sstream>
19 #include <cassert>
20 
21 #include "test_macros.h"
22 
23 int main(int, char**)
24 {
25     {
26         std::istringstream ss0(" 123 456");
27         std::istringstream ss;
28         ss = std::move(ss0);
29         assert(ss.rdbuf() != 0);
30         assert(ss.good());
31         assert(ss.str() == " 123 456");
32         int i = 0;
33         ss >> i;
34         assert(i == 123);
35         ss >> i;
36         assert(i == 456);
37     }
38     {
39         std::istringstream s1("Aaaaa Bbbbb Cccccccccc Dddddddddddddddddd");
40         std::string s;
41         s1 >> s;
42 
43         std::istringstream s2 = std::move(s1);
44         s2 >> s;
45         assert(s == "Bbbbb");
46 
47         std::istringstream s3;
48         s3 = std::move(s2);
49         s3 >> s;
50         assert(s == "Cccccccccc");
51 
52         s1 = std::move(s3);
53         s1 >> s;
54         assert(s == "Dddddddddddddddddd");
55     }
56     {
57         std::wistringstream ss0(L" 123 456");
58         std::wistringstream ss;
59         ss = std::move(ss0);
60         assert(ss.rdbuf() != 0);
61         assert(ss.good());
62         assert(ss.str() == L" 123 456");
63         int i = 0;
64         ss >> i;
65         assert(i == 123);
66         ss >> i;
67         assert(i == 456);
68     }
69     {
70         std::wistringstream s1(L"Aaaaa Bbbbb Cccccccccc Dddddddddddddddddd");
71         std::wstring s;
72         s1 >> s;
73 
74         std::wistringstream s2 = std::move(s1);
75         s2 >> s;
76         assert(s == L"Bbbbb");
77 
78         std::wistringstream s3;
79         s3 = std::move(s2);
80         s3 >> s;
81         assert(s == L"Cccccccccc");
82 
83         s1 = std::move(s3);
84         s1 >> s;
85         assert(s == L"Dddddddddddddddddd");
86     }
87 
88   return 0;
89 }
90