| 1 |
// { dg-additional-options "-lstdc++exp" { target { *-*-mingw* } } } |
| 2 |
// { dg-do run { target c++23 } } |
| 3 |
// { dg-require-fileio "" } |
| 4 |
|
| 5 |
#include <print> |
| 6 |
#include <cstdio> |
| 7 |
#include <testsuite_hooks.h> |
| 8 |
#include <testsuite_fs.h> |
| 9 |
|
| 10 |
void |
| 11 |
test_println_blank() |
| 12 |
{ |
| 13 |
std::print("1"); |
| 14 |
std::println(); |
| 15 |
std::println("2"); |
| 16 |
// { dg-output "1\r?\n2" } |
| 17 |
} |
| 18 |
|
| 19 |
void |
| 20 |
test_println_blank_file() |
| 21 |
{ |
| 22 |
__gnu_test::scoped_file f; |
| 23 |
FILE* strm = std::fopen(f.path.string().c_str(), "w"); |
| 24 |
VERIFY( strm ); |
| 25 |
std::println(strm); |
| 26 |
std::fclose(strm); |
| 27 |
|
| 28 |
std::ifstream in(f.path); |
| 29 |
std::string txt(std::istreambuf_iterator<char>(in), {}); |
| 30 |
VERIFY( txt == "\n" ); |
| 31 |
} |
| 32 |
|
| 33 |
void |
| 34 |
test_errors() |
| 35 |
{ |
| 36 |
#ifdef __cpp_exceptions |
| 37 |
try |
| 38 |
{ |
| 39 |
std::println(stdin); |
| 40 |
VERIFY(false); |
| 41 |
} |
| 42 |
catch (const std::system_error&) |
| 43 |
{ |
| 44 |
} |
| 45 |
#endif |
| 46 |
} |
| 47 |
|
| 48 |
int main() |
| 49 |
{ |
| 50 |
test_println_blank(); |
| 51 |
test_println_blank_file(); |
| 52 |
test_errors(); |
| 53 |
} |