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() {
6767 int i3;
6868 spSt >> i3;
6969
70+ assert (spSt.good ());
7071 assert (str1 == CS (" zmt" ));
7172 assert (i1 == 94 );
7273 assert (str2 == CS (" hkt" ));
@@ -77,7 +78,9 @@ void test() {
7778 // Write to stream
7879 constexpr std::basic_string_view<CharT, TraitsT> sv1{SV (" year 2024" )};
7980 spSt << sv1;
81+
8082 assert (spSt.span ().size () == sv1.size ());
83+ assert (spSt.good ());
8184
8285 // Read from stream
8386 spSt.seekg (0 );
@@ -89,17 +92,28 @@ void test() {
8992 assert (str4 == CS (" year" ));
9093 assert (i4 == 2024 );
9194
95+ spSt >> i4;
96+ assert (spSt.fail ());
97+ spSt.clear ();
98+ assert (spSt.good ());
99+
92100 // Write to stream
93101 spSt << CS (" 94" );
94102 spSt << 84 ;
95- std::cout << spSt.span ().size () << std::endl;
103+
104+ assert (spSt.good ());
96105 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" ));
97108
98109 // Write to stream with overflow
99110 constexpr std::basic_string_view<CharT, TraitsT> sv2{
100111 SV (" This string should overflow! This string should overflow!" )};
101112 spSt << sv2;
102113 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 ());
103117 }
104118 // Mode: `in`
105119 {
You can’t perform that action at this time.
0 commit comments