1 /* Testing ucs4le_internal_loop() in gconv_simple.c.
2 Copyright (C) 2016 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
38 #if __BYTE_ORDER == __BIG_ENDIAN
39 /* On big-endian machines, ucs4le_internal_loop() swaps the bytes before
40 error checking. Thus the input values has to be swapped. */
41 # define VALUE(val) bswap_32 (val)
43 # define VALUE(val) val
45 uint32_t inbuf
[3] = { VALUE (0x41), VALUE (0x80000000), VALUE (0x42) };
46 uint32_t outbuf
[3] = { 0, 0, 0 };
48 cd
= iconv_open ("WCHAR_T", "UCS-4LE");
49 if (cd
== (iconv_t
) -1)
51 printf ("cannot convert from UCS4LE to wchar_t: %m\n");
55 inptr
= (char *) inbuf
;
56 inlen
= sizeof (inbuf
);
57 outptr
= (char *) outbuf
;
58 outlen
= sizeof (outbuf
);
60 n
= iconv (cd
, &inptr
, &inlen
, &outptr
, &outlen
);
65 printf ("incorrect iconv() return value: %zd, expected -1\n", n
);
71 printf ("incorrect error value: %s, expected %s\n",
72 strerror (e
), strerror (EILSEQ
));
76 if (inptr
!= (char *) &inbuf
[1])
78 printf ("inptr=0x%p does not point to invalid character! Expected=0x%p\n"
83 if (inlen
!= sizeof (inbuf
) - sizeof (uint32_t))
85 printf ("inlen=%zd != %zd\n"
86 , inlen
, sizeof (inbuf
) - sizeof (uint32_t));
90 if (outptr
!= (char *) &outbuf
[1])
92 printf ("outptr=0x%p does not point to invalid character in inbuf! "
94 , outptr
, &outbuf
[1]);
98 if (outlen
!= sizeof (inbuf
) - sizeof (uint32_t))
100 printf ("outlen=%zd != %zd\n"
101 , outlen
, sizeof (outbuf
) - sizeof (uint32_t));
105 if (outbuf
[0] != 0x41 || outbuf
[1] != 0 || outbuf
[2] != 0)
107 puts ("Characters conversion is incorrect!");
116 #define TEST_FUNCTION do_test ()
117 #include "../test-skeleton.c"