1 /* Bug 28524: Conversion from ISO-2022-JP-3 with iconv
2 may emit spurious NUL character on state reset.
3 Copyright The GNU Toolchain Authors.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
22 #include <support/check.h>
29 size_t inleft
= sizeof (in
) - 1;
32 size_t outleft
= sizeof (out
);
35 cd
= iconv_open ("UTF8", "ISO-2022-JP-3");
36 TEST_VERIFY_EXIT (cd
!= (iconv_t
) -1);
38 /* First call to iconv should alter internal state.
39 Now, JISX0201_Kana_set is selected and
40 state value != ASCII_set. */
41 TEST_VERIFY (iconv (cd
, &inbuf
, &inleft
, &outbuf
, &outleft
) != (size_t) -1);
43 /* No bytes should have been added to
44 the output buffer at this point. */
45 TEST_VERIFY (outbuf
== out
);
46 TEST_VERIFY (outleft
== sizeof (out
));
48 /* Second call shall emit spurious NUL character in unpatched glibc. */
49 TEST_VERIFY (iconv (cd
, NULL
, NULL
, &outbuf
, &outleft
) != (size_t) -1);
51 /* No characters are expected to be produced. */
52 TEST_VERIFY (outbuf
== out
);
53 TEST_VERIFY (outleft
== sizeof (out
));
55 TEST_VERIFY_EXIT (iconv_close (cd
) != -1);
60 #include <support/test-driver.c>