1 /* Test wide output conversion for warn.
2 Copyright (C) 2018-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
24 #include <support/check.h>
25 #include <support/xmemstream.h>
28 /* Used to trigger the large-string path in __fxprintf. */
30 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
31 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
32 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
35 L"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
36 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
37 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
41 one_test (const char *message
, int error_code
, const wchar_t *expected
)
43 wchar_t *buffer
= NULL
;
45 FILE *fp
= open_wmemstream (&buffer
, &length
);
46 TEST_VERIFY_EXIT (fp
!= NULL
);
47 FILE *old_stderr
= stderr
;
53 warn ("%s with padding " PADDING
, message
);
59 warnx ("%s", message
);
62 warnx ("%s with padding " PADDING
, message
);
66 TEST_VERIFY_EXIT (!ferror (fp
));
67 TEST_COMPARE (fclose (fp
), 0);
68 if (wcscmp (buffer
, expected
) != 0)
69 FAIL_EXIT1 ("unexpected output: %ls", buffer
);
76 one_test ("no errno", -1,
77 L
"tst-warn-wide: no errno\n");
78 one_test ("no errno", -2,
79 L
"tst-warn-wide: no errno with padding " PADDING
"\n");
80 one_test ("with errno", EAGAIN
,
81 L
"tst-warn-wide: with errno: Resource temporarily unavailable\n");
82 one_test ("with errno", E2BIG
,
83 L
"tst-warn-wide: with errno with padding " PADDING
84 ": Argument list too long\n");
88 #include <support/test-driver.c>