1 /* Test for invalid input to wcrtomb.
2 Copyright (C) 2001-2024 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/>. */
27 do_test (const char *loc
)
35 nloc
= setlocale (LC_ALL
, loc
);
38 printf ("could not set locale \"%s\"\n", loc
);
41 printf ("new locale: %s\n", nloc
);
43 memset (&state
, '\0', sizeof (state
));
45 n
= wcrtomb (buf
, (wchar_t) -15l, &state
);
47 printf ("n = %zd, errno = %d (%s)\n", n
, errno
, strerror (errno
));
49 res
= n
!= (size_t) -1 || errno
!= EILSEQ
;
64 res
|= do_test ("de_DE.ISO-8859-1");
65 res
|= do_test ("de_DE.UTF-8");
66 res
|= do_test ("en_US.ANSI_X3.4-1968");
67 res
|= do_test ("ja_JP.EUC-JP");
68 res
|= do_test ("hr_HR.ISO-8859-2");
69 //res |= do_test ("ru_RU.KOI8-R");