Replace FSF snail-mail address with URL.
[libiconv.git] / tests / test-to-wchar.c
blob952ac5b6a4debb16f84ddcee440f5801f5ca98ff
1 /* Copyright (C) 2009, 2011 Free Software Foundation, Inc.
2 This file is part of the GNU LIBICONV Library.
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.
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.
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.
16 If not, see <http://www.gnu.org/licenses/>. */
18 #include "config.h"
20 #include <stdlib.h>
21 #include <iconv.h>
22 #include <errno.h>
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>. */
28 int main ()
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];
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);
46 if (!(r == (size_t)(-1) && errno == EINVAL))
47 abort ();
50 return 0;