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