Switch to autoconf 2.72.
[libiconv.git] / tests / test-to-wchar.c
blob95b5053eb1f44ef0ee68c75ebbee57a4810dd8cf
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 Lesser General Public
6 License as published by the Free Software Foundation; either version 2.1
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 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU LIBICONV Library; see the file COPYING.LIB.
16 If not, see <https://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;