Skip to content

Commit 7b7d825

Browse files
committed
Tests: updated ospanstream, spanbuf, spanstream
1 parent d348c6f commit 7b7d825

File tree

8 files changed

+215
-35
lines changed

8 files changed

+215
-35
lines changed

libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/assign.move.pass.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,42 +36,87 @@ void test() {
3636
// Mode: default (`in` | `out`)
3737
{
3838
SpStream rhsSpSt{sp};
39+
assert(rhsSpSt.span().data() == arr);
40+
assert(rhsSpSt.span().empty());
41+
assert(rhsSpSt.span().size() == 0);
42+
3943
SpStream spSt = std::move(rhsSpSt);
4044
assert(spSt.span().data() == arr);
4145
assert(spSt.span().empty());
4246
assert(spSt.span().size() == 0);
47+
48+
// After move
49+
assert(rhsSpSt.span().data() == arr);
50+
assert(rhsSpSt.span().empty());
51+
assert(rhsSpSt.span().size() == 0);
4352
}
4453
// Mode: `in`
4554
{
4655
SpStream rhsSpSt{sp, std::ios_base::in};
56+
assert(rhsSpSt.span().data() == arr);
57+
assert(rhsSpSt.span().empty());
58+
assert(rhsSpSt.span().size() == 0);
59+
4760
SpStream spSt = std::move(rhsSpSt);
4861
assert(spSt.span().data() == arr);
4962
assert(spSt.span().empty());
5063
assert(spSt.span().size() == 0);
64+
65+
// After move
66+
assert(rhsSpSt.span().data() == arr);
67+
assert(rhsSpSt.span().empty());
68+
assert(rhsSpSt.span().size() == 0);
5169
}
5270
// Mode `out`
5371
{
5472
SpStream rhsSpSt{sp, std::ios_base::out};
73+
assert(rhsSpSt.span().data() == arr);
74+
assert(rhsSpSt.span().empty());
75+
assert(rhsSpSt.span().size() == 0);
76+
5577
SpStream spSt = std::move(rhsSpSt);
5678
assert(spSt.span().data() == arr);
5779
assert(spSt.span().empty());
5880
assert(spSt.span().size() == 0);
81+
82+
// After move
83+
assert(rhsSpSt.span().data() == arr);
84+
assert(rhsSpSt.span().empty());
85+
assert(rhsSpSt.span().size() == 0);
5986
}
6087
// Mode: multiple
6188
{
6289
SpStream rhsSpSt{sp, std::ios_base::in | std::ios_base::out | std::ios_base::binary};
90+
assert(rhsSpSt.span().data() == arr);
91+
assert(rhsSpSt.span().empty());
92+
assert(rhsSpSt.span().size() == 0);
93+
6394
SpStream spSt = std::move(rhsSpSt);
6495
assert(spSt.span().data() == arr);
6596
assert(spSt.span().empty());
6697
assert(spSt.span().size() == 0);
98+
99+
// After move
100+
assert(rhsSpSt.span().data() == arr);
101+
assert(rhsSpSt.span().empty());
102+
assert(rhsSpSt.span().size() == 0);
67103
}
68104
// Mode `ate`
69105
{
70106
SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate};
107+
assert(rhsSpSt.span().data() == arr);
108+
assert(!rhsSpSt.span().empty());
109+
assert(rhsSpSt.span().size() == 4);
110+
71111
SpStream spSt = std::move(rhsSpSt);
72112
assert(spSt.span().data() == arr);
73113
assert(!spSt.span().empty());
74114
assert(spSt.span().size() == 4);
115+
116+
// After move
117+
assert(rhsSpSt.span().data() == arr);
118+
assert(!rhsSpSt.span().empty());
119+
assert(rhsSpSt.span().size() == 4);
75120
}
76121
}
77122

libcxx/test/std/input.output/span.streams/ospanstream/ospanstream.cons/ctor.move.pass.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,53 @@ void test() {
3636
// Mode: default (`in` | `out`)
3737
{
3838
SpStream rhsSpSt{sp};
39+
assert(rhsSpSt.span().data() == arr);
40+
assert(rhsSpSt.span().empty());
41+
assert(rhsSpSt.span().size() == 0);
42+
3943
SpStream spSt{std::move(rhsSpSt)};
4044
assert(spSt.span().data() == arr);
4145
assert(spSt.span().empty());
4246
assert(spSt.span().size() == 0);
47+
48+
// After move
49+
assert(rhsSpSt.span().data() == arr);
50+
assert(rhsSpSt.span().empty());
51+
assert(rhsSpSt.span().size() == 0);
4352
}
4453
// Mode: `in`
4554
{
4655
SpStream rhsSpSt{sp, std::ios_base::in};
56+
assert(rhsSpSt.span().data() == arr);
57+
assert(rhsSpSt.span().empty());
58+
assert(rhsSpSt.span().size() == 0);
59+
4760
SpStream spSt{std::move(rhsSpSt)};
4861
assert(spSt.span().data() == arr);
4962
assert(spSt.span().empty());
5063
assert(spSt.span().size() == 0);
64+
65+
// After move
66+
assert(rhsSpSt.span().data() == arr);
67+
assert(rhsSpSt.span().empty());
68+
assert(rhsSpSt.span().size() == 0);
5169
}
5270
// Mode `out`
5371
{
5472
SpStream rhsSpSt{sp, std::ios_base::out};
73+
assert(rhsSpSt.span().data() == arr);
74+
assert(rhsSpSt.span().empty());
75+
assert(rhsSpSt.span().size() == 0);
76+
5577
SpStream spSt{std::move(rhsSpSt)};
5678
assert(spSt.span().data() == arr);
5779
assert(spSt.span().empty());
5880
assert(spSt.span().size() == 0);
81+
82+
// After move
83+
assert(rhsSpSt.span().data() == arr);
84+
assert(rhsSpSt.span().empty());
85+
assert(rhsSpSt.span().size() == 0);
5986
}
6087
// Mode: multiple
6188
{
@@ -64,14 +91,28 @@ void test() {
6491
assert(spSt.span().data() == arr);
6592
assert(spSt.span().empty());
6693
assert(spSt.span().size() == 0);
94+
95+
// After move
96+
assert(rhsSpSt.span().data() == arr);
97+
assert(rhsSpSt.span().empty());
98+
assert(rhsSpSt.span().size() == 0);
6799
}
68100
// Mode `ate`
69101
{
70102
SpStream rhsSpSt{sp, std::ios_base::out | std::ios_base::ate};
103+
assert(rhsSpSt.span().data() == arr);
104+
assert(!rhsSpSt.span().empty());
105+
assert(rhsSpSt.span().size() == 4);
106+
71107
SpStream spSt{std::move(rhsSpSt)};
72108
assert(spSt.span().data() == arr);
73109
assert(!spSt.span().empty());
74110
assert(spSt.span().size() == 4);
111+
112+
// After move
113+
assert(rhsSpSt.span().data() == arr);
114+
assert(!rhsSpSt.span().empty());
115+
assert(rhsSpSt.span().size() == 4);
75116
}
76117
}
77118

libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/mode.pass.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,32 +49,31 @@ void test() {
4949

5050
// Mode: `in`
5151
{
52-
SpBuf spBuf(std::ios_base::in);
52+
SpBuf spBuf{std::ios_base::in};
5353
assert(spBuf.span().data() == nullptr);
5454
assert(spBuf.span().empty());
5555
assert(spBuf.span().size() == 0);
5656
}
5757
// Mode: `out`
5858
{
59-
SpBuf spBuf(std::ios_base::out);
59+
SpBuf spBuf{std::ios_base::out};
6060
assert(spBuf.span().data() == nullptr);
6161
// Mode `out` counts read characters
6262
assert(spBuf.span().empty());
6363
assert(spBuf.span().size() == 0);
6464
}
6565
// Mode: multiple
6666
{
67-
SpBuf spBuf(std::ios_base::in | std::ios_base::out | std::ios_base::binary);
67+
SpBuf spBuf{std::ios_base::in | std::ios_base::out | std::ios_base::binary};
6868
assert(spBuf.span().data() == nullptr);
6969
// Mode `out` counts read character
7070
assert(spBuf.span().empty());
7171
assert(spBuf.span().size() == 0);
7272
}
7373
// Mode: `ate`
7474
{
75-
SpBuf spBuf(std::ios_base::out | std::ios_base::ate);
75+
SpBuf spBuf{std::ios_base::out | std::ios_base::ate};
7676
assert(spBuf.span().data() == nullptr);
77-
7877
assert(spBuf.span().empty());
7978
assert(spBuf.span().size() == 0);
8079
}

libcxx/test/std/input.output/span.streams/spanbuf/spanbuf.cons/move.pass.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void test() {
164164
assert(rhsSpBuf.span().empty());
165165
assert(rhsSpBuf.span().size() == 0);
166166

167-
SpBuf spBuf(std::move(rhsSpBuf));
167+
SpBuf spBuf{std::move(rhsSpBuf)};
168168
assert(spBuf.span().data() == nullptr);
169169
// Mode `out` counts read characters
170170
assert(spBuf.span().empty());
@@ -183,7 +183,7 @@ void test() {
183183
assert(rhsSpBuf.span().empty());
184184
assert(rhsSpBuf.span().size() == 0);
185185

186-
SpBuf spBuf(std::move(rhsSpBuf));
186+
SpBuf spBuf{std::move(rhsSpBuf)};
187187
assert(spBuf.span().data() == nullptr);
188188
assert(spBuf.span().empty());
189189
assert(spBuf.span().size() == 0);
@@ -201,7 +201,7 @@ void test() {
201201
assert(rhsSpBuf.span().empty());
202202
assert(rhsSpBuf.span().size() == 0);
203203

204-
SpBuf spBuf(std::move(rhsSpBuf));
204+
SpBuf spBuf{std::move(rhsSpBuf)};
205205
assert(spBuf.span().data() == nullptr);
206206
// Mode `out` counts read characters
207207
assert(spBuf.span().empty());
@@ -221,7 +221,7 @@ void test() {
221221
assert(rhsSpBuf.span().empty());
222222
assert(rhsSpBuf.span().size() == 0);
223223

224-
SpBuf spBuf(std::move(rhsSpBuf));
224+
SpBuf spBuf{std::move(rhsSpBuf)};
225225
assert(spBuf.span().data() == nullptr);
226226
// Mode `out` counts read characters
227227
assert(spBuf.span().empty());
@@ -235,7 +235,7 @@ void test() {
235235
// Mode: `ate`
236236
{
237237
SpBuf rhsSpBuf{std::ios_base::ate};
238-
SpBuf spBuf(std::move(rhsSpBuf));
238+
SpBuf spBuf{std::move(rhsSpBuf)};
239239
assert(spBuf.span().data() == nullptr);
240240
assert(spBuf.span().empty());
241241
assert(spBuf.span().size() == 0);
@@ -260,7 +260,7 @@ void test() {
260260
assert(rhsSpBuf.span().empty());
261261
assert(rhsSpBuf.span().size() == 0);
262262

263-
SpBuf spBuf(std::move(rhsSpBuf));
263+
SpBuf spBuf{std::move(rhsSpBuf)};
264264
assert(spBuf.span().data() == arr);
265265
// Mode `out` counts read characters
266266
assert(spBuf.span().empty());
@@ -278,10 +278,15 @@ void test() {
278278
assert(!rhsSpBuf.span().empty());
279279
assert(rhsSpBuf.span().size() == 4);
280280

281-
SpBuf spBuf(std::move(rhsSpBuf));
281+
SpBuf spBuf{std::move(rhsSpBuf)};
282282
assert(spBuf.span().data() == arr);
283283
assert(!spBuf.span().empty());
284284
assert(spBuf.span().size() == 4);
285+
286+
// After move
287+
assert(rhsSpBuf.span().data() == arr);
288+
assert(!rhsSpBuf.span().empty());
289+
assert(rhsSpBuf.span().size() == 4);
285290
}
286291
// Mode `out`
287292
{
@@ -291,7 +296,7 @@ void test() {
291296
assert(rhsSpBuf.span().empty());
292297
assert(rhsSpBuf.span().size() == 0);
293298

294-
SpBuf spBuf(std::move(rhsSpBuf));
299+
SpBuf spBuf{std::move(rhsSpBuf)};
295300
assert(spBuf.span().data() == arr);
296301
// Mode `out` counts read characters
297302
assert(spBuf.span().empty());
@@ -310,7 +315,7 @@ void test() {
310315
assert(rhsSpBuf.span().empty());
311316
assert(rhsSpBuf.span().size() == 0);
312317

313-
SpBuf spBuf(std::move(rhsSpBuf));
318+
SpBuf spBuf{std::move(rhsSpBuf)};
314319
assert(spBuf.span().data() == arr);
315320
// Mode `out` counts read characters
316321
assert(spBuf.span().empty());
@@ -328,7 +333,7 @@ void test() {
328333
assert(!rhsSpBuf.span().empty());
329334
assert(rhsSpBuf.span().size() == 4);
330335

331-
SpBuf spBuf(std::move(rhsSpBuf));
336+
SpBuf spBuf{std::move(rhsSpBuf)};
332337
assert(spBuf.span().data() == arr);
333338
assert(!spBuf.span().empty());
334339
assert(spBuf.span().size() == 4);

0 commit comments

Comments
 (0)