Skip to content

Commit b940dcb

Browse files
committed
Mass test cleanup
1 parent 96b560a commit b940dcb

37 files changed

+180
-996
lines changed

libcxx/test/std/input.output/span.streams/ispanstream/inherited.stream.ops.pass.cpp

Lines changed: 65 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
1414
// class basic_spanstream
1515
// : public basic_iostream<charT, traits> {
1616

17-
// Test stream operations inherited from `basic_istream` and `basic_ostream`
17+
// Test stream operations inherited from `basic_istream`
1818

1919
#include <cassert>
2020
#include <span>
2121
#include <spanstream>
22-
#include <string>
2322
#include <string_view>
2423

2524
#include "constexpr_char_traits.h"
@@ -29,206 +28,101 @@
2928
#include "../helper_macros.h"
3029
#include "../helper_types.h"
3130

31+
#include <print> // REMOVE ME
32+
#include <iostream> // REMOVE ME
33+
34+
template <typename CharT, typename TraitsT>
35+
void test_ispanstream(std::basic_ispanstream<CharT, TraitsT>& spSt, std::size_t size) {
36+
assert(spSt);
37+
assert(!spSt.bad());
38+
assert(!spSt.fail());
39+
assert(spSt.good());
40+
assert(spSt.span().size() == size);
41+
42+
// Read from stream
43+
std::basic_string<CharT, TraitsT> str1;
44+
spSt >> str1;
45+
int i1;
46+
spSt >> i1;
47+
std::basic_string<CharT, TraitsT> str2;
48+
spSt >> str2;
49+
int i2;
50+
spSt >> i2;
51+
std::basic_string<CharT, TraitsT> str3;
52+
spSt >> str3;
53+
int i3;
54+
spSt >> i3;
55+
56+
assert(str1 == CS("zmt"));
57+
assert(i1 == 94);
58+
assert(str2 == CS("hkt"));
59+
assert(i2 == 82);
60+
assert(str3 == CS("pir"));
61+
assert(i3 == 43);
62+
63+
assert(spSt);
64+
assert(!spSt.bad());
65+
assert(!spSt.fail());
66+
assert(spSt.good());
67+
68+
spSt.clear();
69+
70+
assert(spSt);
71+
assert(!spSt.bad());
72+
assert(!spSt.fail());
73+
assert(spSt.good());
74+
}
75+
3276
template <typename CharT, typename TraitsT = std::char_traits<CharT>>
3377
void test() {
3478
using SpStream = std::basic_ispanstream<CharT, TraitsT>;
3579

3680
constexpr std::basic_string_view<CharT, TraitsT> sv{SV("zmt 94 hkt 82 pir 43vr")};
37-
constexpr auto arrSize{30UZ};
38-
assert(sv.size() < arrSize);
81+
assert(sv.size() < 30UZ);
3982

4083
// Create a std::span test value
41-
CharT arr[arrSize]{};
84+
CharT arr[30UZ]{};
4285
initialize_array_from_string_view(arr, sv);
4386

4487
std::span<CharT> sp{arr};
4588

4689
// Create a "Read Only Sequence" test value
47-
CharT rosArr[arrSize]{};
90+
CharT rosArr[30UZ]{};
4891
initialize_array_from_string_view(rosArr, sv);
4992

50-
ReadOnlySpan<CharT, arrSize> ros{rosArr};
51-
assert(ros.size() == arrSize);
93+
ReadOnlySpan<CharT, 30UZ> ros{rosArr};
94+
assert(ros.size() == 30UZ);
5295

53-
// `std::span` + Mode: default (`in`)
96+
// std::span` + Mode: default (`in`)
5497
{
5598
SpStream spSt(sp);
56-
57-
assert(spSt);
58-
assert(!spSt.bad());
59-
assert(!spSt.fail());
60-
assert(spSt.good());
61-
assert(spSt.span().size() == arrSize);
62-
63-
// Read from stream
64-
std::basic_string<CharT, TraitsT> str1;
65-
spSt >> str1;
66-
int i1;
67-
spSt >> i1;
68-
std::basic_string<CharT, TraitsT> str2;
69-
spSt >> str2;
70-
int i2;
71-
spSt >> i2;
72-
std::basic_string<CharT, TraitsT> str3;
73-
spSt >> str3;
74-
int i3;
75-
spSt >> i3;
76-
77-
assert(str1 == CS("zmt"));
78-
assert(i1 == 94);
79-
assert(str2 == CS("hkt"));
80-
assert(i2 == 82);
81-
assert(str3 == CS("pir"));
82-
assert(i3 == 43);
83-
84-
assert(spSt);
85-
assert(!spSt.bad());
86-
assert(!spSt.fail());
87-
assert(spSt.good());
88-
89-
spSt.clear();
90-
91-
assert(spSt);
92-
assert(!spSt.bad());
93-
assert(!spSt.fail());
94-
assert(spSt.good());
99+
test_ispanstream(spSt, 30UZ);
95100
}
96-
// `ReadOnlySpan` + Mode: default (`in`)
101+
// std::span` + Mode: explicit `in`
97102
{
98-
SpStream spSt(sp);
99-
100-
assert(spSt);
101-
assert(!spSt.bad());
102-
assert(!spSt.fail());
103-
assert(spSt.good());
104-
assert(spSt.span().size() == arrSize);
105-
106-
// Read from stream
107-
std::basic_string<CharT, TraitsT> str1;
108-
spSt >> str1;
109-
int i1;
110-
spSt >> i1;
111-
std::basic_string<CharT, TraitsT> str2;
112-
spSt >> str2;
113-
int i2;
114-
spSt >> i2;
115-
std::basic_string<CharT, TraitsT> str3;
116-
spSt >> str3;
117-
int i3;
118-
spSt >> i3;
119-
120-
assert(str1 == CS("zmt"));
121-
assert(i1 == 94);
122-
assert(str2 == CS("hkt"));
123-
assert(i2 == 82);
124-
assert(str3 == CS("pir"));
125-
assert(i3 == 43);
126-
127-
assert(spSt);
128-
assert(!spSt.bad());
129-
assert(!spSt.fail());
130-
assert(spSt.good());
131-
132-
spSt.clear();
133-
134-
assert(spSt);
135-
assert(!spSt.bad());
136-
assert(!spSt.fail());
137-
assert(spSt.good());
103+
SpStream spSt(sp, std::ios_base::in);
104+
test_ispanstream(spSt, 30UZ);
138105
}
139106

140-
// `std::span` + Mode: `ate`
107+
// `ReadOnlySpan` + Mode: default (`in`)
141108
{
142-
SpStream spSt(sp, std::ios_base::ate);
143-
144-
assert(spSt);
145-
assert(!spSt.bad());
146-
assert(!spSt.fail());
147-
assert(spSt.good());
148-
assert(spSt.span().size() == arrSize);
149-
150-
// Read from stream
151-
std::basic_string<CharT, TraitsT> str1;
152-
spSt >> str1;
153-
int i1;
154-
spSt >> i1;
155-
std::basic_string<CharT, TraitsT> str2;
156-
spSt >> str2;
157-
int i2;
158-
spSt >> i2;
159-
std::basic_string<CharT, TraitsT> str3;
160-
spSt >> str3;
161-
int i3;
162-
spSt >> i3;
163-
164-
assert(str1 == CS("zmt"));
165-
assert(i1 == 94);
166-
assert(str2 == CS("hkt"));
167-
assert(i2 == 82);
168-
assert(str3 == CS("pir"));
169-
assert(i3 == 43);
170-
171-
assert(spSt);
172-
assert(!spSt.bad());
173-
assert(!spSt.fail());
174-
assert(spSt.good());
175-
176-
spSt.clear();
177-
178-
assert(spSt);
179-
assert(!spSt.bad());
180-
assert(!spSt.fail());
181-
assert(spSt.good());
109+
SpStream spSt(ros);
110+
test_ispanstream(spSt, 30UZ);
182111
}
183-
// `ReadOnlySpan` + Mode: `ate`
112+
184113
{
185114
SpStream spSt(sp, std::ios_base::ate);
186-
187-
assert(spSt);
188-
assert(!spSt.bad());
189-
assert(!spSt.fail());
190-
assert(spSt.good());
191-
assert(spSt.span().size() == arrSize);
192-
193-
// Read from stream
194-
std::basic_string<CharT, TraitsT> str1;
195-
spSt >> str1;
196-
int i1;
197-
spSt >> i1;
198-
std::basic_string<CharT, TraitsT> str2;
199-
spSt >> str2;
200-
int i2;
201-
spSt >> i2;
202-
std::basic_string<CharT, TraitsT> str3;
203-
spSt >> str3;
204-
int i3;
205-
spSt >> i3;
206-
207-
assert(str1 == CS("zmt"));
208-
assert(i1 == 94);
209-
assert(str2 == CS("hkt"));
210-
assert(i2 == 82);
211-
assert(str3 == CS("pir"));
212-
assert(i3 == 43);
213-
214-
assert(spSt);
215-
assert(!spSt.bad());
216-
assert(!spSt.fail());
217-
assert(spSt.good());
218-
219-
spSt.clear();
220-
221-
assert(spSt);
222-
assert(!spSt.bad());
223-
assert(!spSt.fail());
224-
assert(spSt.good());
115+
std::println(stderr, "spSt.span().size() = {}", spSt.span().size());
116+
// std::println(stderr, "spSt.tellg() = {}", spSt.tellg());
117+
std::cerr << "spSt.tellg() = " << spSt.tellg() << std::endl;
118+
assert(false);
225119
}
226120
}
227121

228122
int main(int, char**) {
229123
test<char>();
230124
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
231-
test<wchar_t>();
125+
// test<wchar_t>();
232126
#endif
233127

234128
return 0;

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

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -42,68 +42,28 @@ void test() {
4242
{
4343
SpStream rhsSpSt{sp};
4444
assert(rhsSpSt.span().data() == arr);
45-
assert(!rhsSpSt.span().empty());
4645
assert(rhsSpSt.span().size() == 4);
4746

4847
SpStream spSt = std::move(rhsSpSt);
4948
assert(spSt.span().data() == arr);
50-
assert(!spSt.span().empty());
5149
assert(spSt.span().size() == 4);
5250

5351
// Test after move
5452
assert(rhsSpSt.span().data() == arr);
55-
assert(!rhsSpSt.span().empty());
5653
assert(rhsSpSt.span().size() == 4);
5754
}
58-
// Mode: `in`
55+
// Mode: explicit `in`
5956
{
6057
SpStream rhsSpSt{sp, std::ios_base::in};
6158
assert(rhsSpSt.span().data() == arr);
62-
assert(!rhsSpSt.span().empty());
6359
assert(rhsSpSt.span().size() == 4);
6460

6561
SpStream spSt = std::move(rhsSpSt);
6662
assert(spSt.span().data() == arr);
67-
assert(!spSt.span().empty());
6863
assert(spSt.span().size() == 4);
6964

7065
// Test after move
7166
assert(rhsSpSt.span().data() == arr);
72-
assert(!rhsSpSt.span().empty());
73-
assert(rhsSpSt.span().size() == 4);
74-
}
75-
// Mode: `ate`
76-
{
77-
SpStream rhsSpSt{sp, std::ios_base::ate};
78-
assert(rhsSpSt.span().data() == arr);
79-
assert(!rhsSpSt.span().empty());
80-
assert(rhsSpSt.span().size() == 4);
81-
82-
SpStream spSt = std::move(rhsSpSt);
83-
assert(spSt.span().data() == arr);
84-
assert(!spSt.span().empty());
85-
assert(spSt.span().size() == 4);
86-
87-
// Test after move
88-
assert(rhsSpSt.span().data() == arr);
89-
assert(!rhsSpSt.span().empty());
90-
assert(rhsSpSt.span().size() == 4);
91-
}
92-
// Mode: multiple
93-
{
94-
SpStream rhsSpSt{sp, std::ios_base::ate | std::ios_base::binary};
95-
assert(rhsSpSt.span().data() == arr);
96-
assert(!rhsSpSt.span().empty());
97-
assert(rhsSpSt.span().size() == 4);
98-
99-
SpStream spSt = std::move(rhsSpSt);
100-
assert(spSt.span().data() == arr);
101-
assert(!spSt.span().empty());
102-
assert(spSt.span().size() == 4);
103-
104-
// Test after move
105-
assert(rhsSpSt.span().data() == arr);
106-
assert(!rhsSpSt.span().empty());
10767
assert(rhsSpSt.span().size() == 4);
10868
}
10969
}

0 commit comments

Comments
 (0)