1 /* Testing ucs4le_internal_loop() in gconv_simple.c.
2 Copyright (C) 2016-2021 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 <https://www.gnu.org/licenses/>. */
39 #if __BYTE_ORDER == __BIG_ENDIAN
40 /* On big-endian machines, ucs4le_internal_loop() swaps the bytes before
41 error checking. Thus the input values has to be swapped. */
42 # define VALUE(val) bswap_32 (val)
44 # define VALUE(val) val
46 uint32_t inbuf
[3] = { VALUE (0x41), VALUE (0x80000000), VALUE (0x42) };
47 uint32_t outbuf
[3] = { 0, 0, 0 };
49 cd
= iconv_open ("WCHAR_T", "UCS-4LE");
50 if (cd
== (iconv_t
) -1)
52 printf ("cannot convert from UCS4LE to wchar_t: %m\n");
56 inptr
= (char *) inbuf
;
57 inlen
= sizeof (inbuf
);
58 outptr
= (char *) outbuf
;
59 outlen
= sizeof (outbuf
);
61 n
= iconv (cd
, &inptr
, &inlen
, &outptr
, &outlen
);
66 printf ("incorrect iconv() return value: %zd, expected -1\n", n
);
72 printf ("incorrect error value: %s, expected %s\n",
73 strerror (e
), strerror (EILSEQ
));
77 if (inptr
!= (char *) &inbuf
[1])
79 printf ("inptr=0x%p does not point to invalid character! Expected=0x%p\n"
84 if (inlen
!= sizeof (inbuf
) - sizeof (uint32_t))
86 printf ("inlen=%zd != %zd\n"
87 , inlen
, sizeof (inbuf
) - sizeof (uint32_t));
91 if (outptr
!= (char *) &outbuf
[1])
93 printf ("outptr=0x%p does not point to invalid character in inbuf! "
95 , outptr
, &outbuf
[1]);
99 if (outlen
!= sizeof (inbuf
) - sizeof (uint32_t))
101 printf ("outlen=%zd != %zd\n"
102 , outlen
, sizeof (outbuf
) - sizeof (uint32_t));
106 if (outbuf
[0] != 0x41 || outbuf
[1] != 0 || outbuf
[2] != 0)
108 puts ("Characters conversion is incorrect!");
117 #define TEST_FUNCTION do_test ()
118 #include "../test-skeleton.c"