Annotation of embedaddon/libiconv/tests/test-to-wchar.c, revision 1.1.1.2
1.1 misho 1: /* Copyright (C) 2009, 2011 Free Software Foundation, Inc.
2: This file is part of the GNU LIBICONV Library.
3:
4: The GNU LIBICONV Library is free software; you can redistribute it
5: and/or modify it under the terms of the GNU Library General Public
6: License as published by the Free Software Foundation; either version 2
7: of the License, or (at your option) any later version.
8:
9: The GNU LIBICONV Library is distributed in the hope that it will be
10: useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: Library General Public License for more details.
13:
14: You should have received a copy of the GNU Library General Public
15: License along with the GNU LIBICONV Library; see the file COPYING.LIB.
1.1.1.2 ! misho 16: If not, see <https://www.gnu.org/licenses/>. */
1.1 misho 17:
18: #include "config.h"
19:
20: #include <stdlib.h>
21: #include <iconv.h>
22: #include <errno.h>
23:
24: /* This test checks that the conversion to wchar_t stops correctly when
25: the input is incomplete. Based on a bug report from
26: Tristan Gingold <gingold@adacore.com>. */
27:
28: int main ()
29: {
30: iconv_t cd = iconv_open ("wchar_t", "UTF-8");
31: if (cd == (iconv_t)(-1)) {
32: /* Skip the test on platforms without wchar_t
33: (Solaris 2.6, HP-UX 11.00). */
34: } else {
35: char inbuf[2] = { 0xc2, 0xa0 };
36: wchar_t outbuf[10];
37:
38: char *inptr = inbuf;
39: size_t inbytesleft = 1;
40: char *outptr = (char *) outbuf;
41: size_t outbytesleft = sizeof (outbuf);
42: size_t r = iconv (cd,
43: (ICONV_CONST char **) &inptr, &inbytesleft,
44: &outptr, &outbytesleft);
45:
46: if (!(r == (size_t)(-1) && errno == EINVAL))
47: abort ();
48: }
49:
50: return 0;
51: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>