Annotation of embedaddon/libiconv/tests/test-to-wchar.c, revision 1.1
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.
! 16: If not, write to the Free Software Foundation, Inc., 51 Franklin Street,
! 17: Fifth Floor, Boston, MA 02110-1301, USA. */
! 18:
! 19: #include "config.h"
! 20:
! 21: #include <stdlib.h>
! 22: #include <iconv.h>
! 23: #include <errno.h>
! 24:
! 25: /* This test checks that the conversion to wchar_t stops correctly when
! 26: the input is incomplete. Based on a bug report from
! 27: Tristan Gingold <gingold@adacore.com>. */
! 28:
! 29: int main ()
! 30: {
! 31: iconv_t cd = iconv_open ("wchar_t", "UTF-8");
! 32: if (cd == (iconv_t)(-1)) {
! 33: /* Skip the test on platforms without wchar_t
! 34: (Solaris 2.6, HP-UX 11.00). */
! 35: } else {
! 36: char inbuf[2] = { 0xc2, 0xa0 };
! 37: wchar_t outbuf[10];
! 38:
! 39: char *inptr = inbuf;
! 40: size_t inbytesleft = 1;
! 41: char *outptr = (char *) outbuf;
! 42: size_t outbytesleft = sizeof (outbuf);
! 43: size_t r = iconv (cd,
! 44: (ICONV_CONST char **) &inptr, &inbytesleft,
! 45: &outptr, &outbytesleft);
! 46:
! 47: if (!(r == (size_t)(-1) && errno == EINVAL))
! 48: abort ();
! 49: }
! 50:
! 51: return 0;
! 52: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>