| 1 | // { dg-additional-options "-lstdc++exp" { target { *-*-mingw* } } } |
| 2 | // { dg-do run { target c++23 } } |
| 3 | // { dg-require-fileio "" } |
| 4 | |
| 5 | #include <ostream> |
| 6 | #include <spanstream> |
| 7 | #include <string_view> |
| 8 | #include <iostream> |
| 9 | #include <iomanip> |
| 10 | #include <testsuite_hooks.h> |
| 11 | |
| 12 | void |
| 13 | test_println_blank_ostream() |
| 14 | { |
| 15 | char buf[4]; |
| 16 | std::spanstream os(buf); |
| 17 | std::println(os); |
| 18 | std::string_view txt(os.span()); |
| 19 | VERIFY( txt == "\n" ); |
| 20 | } |
| 21 | |
| 22 | void |
| 23 | test_errors() |
| 24 | { |
| 25 | // Failure to generate output is reported by setting badbit. |
| 26 | std::stringstream in(std::ios::in); |
| 27 | std::println(in); // No exception here. |
| 28 | VERIFY(in.bad()); |
| 29 | #ifdef __cpp_exceptions |
| 30 | in.clear(); |
| 31 | in.exceptions(std::ios::badbit); |
| 32 | try |
| 33 | { |
| 34 | std::println(in); // Should throw now. |
| 35 | VERIFY(false); |
| 36 | } |
| 37 | catch (const std::ios::failure&) |
| 38 | { |
| 39 | } |
| 40 | #endif |
| 41 | } |
| 42 | |
| 43 | int main() |
| 44 | { |
| 45 | test_println_blank_ostream(); |
| 46 | test_errors(); |
| 47 | } |