File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
libcxx/test/std/input.output/span.streams/spanstream Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ void test() {
67
67
int i3;
68
68
spSt >> i3;
69
69
70
+ assert (spSt.good ());
70
71
assert (str1 == CS (" zmt" ));
71
72
assert (i1 == 94 );
72
73
assert (str2 == CS (" hkt" ));
@@ -77,7 +78,9 @@ void test() {
77
78
// Write to stream
78
79
constexpr std::basic_string_view<CharT, TraitsT> sv1{SV (" year 2024" )};
79
80
spSt << sv1;
81
+
80
82
assert (spSt.span ().size () == sv1.size ());
83
+ assert (spSt.good ());
81
84
82
85
// Read from stream
83
86
spSt.seekg (0 );
@@ -89,17 +92,28 @@ void test() {
89
92
assert (str4 == CS (" year" ));
90
93
assert (i4 == 2024 );
91
94
95
+ spSt >> i4;
96
+ assert (spSt.fail ());
97
+ spSt.clear ();
98
+ assert (spSt.good ());
99
+
92
100
// Write to stream
93
101
spSt << CS (" 94" );
94
102
spSt << 84 ;
95
- std::cout << spSt.span ().size () << std::endl;
103
+
104
+ assert (spSt.good ());
96
105
assert (spSt.span ().size () == sv1.size () + 4 );
106
+ std::basic_string<CharT, TraitsT> expectedStr1{spSt.span ().data (), std::size_t {spSt.span ().size ()}};
107
+ assert (expectedStr1 == CS (" year 20249484" ));
97
108
98
109
// Write to stream with overflow
99
110
constexpr std::basic_string_view<CharT, TraitsT> sv2{
100
111
SV (" This string should overflow! This string should overflow!" )};
101
112
spSt << sv2;
102
113
assert (spSt.span ().size () == arrSize);
114
+ std::basic_string<CharT, TraitsT> expectedStr2{spSt.span ().data (), std::size_t {spSt.span ().size ()}};
115
+ assert (expectedStr2 == CS (" year 20249484This string shoul" ));
116
+ assert (spSt.fail ());
103
117
}
104
118
// Mode: `in`
105
119
{
You can’t perform that action at this time.
0 commit comments