Remove unused sysdeps/unix/sysv/sigaction.c.
[glibc.git] / wcsmbs / tst-mbsnrtowcs.c
blob29ff7c26a8a1567f7b79cdf9f80e6d21f6bdb947
1 /* Copyright (C) 2012 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>,
4 2012.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 /* Test bugzilla 13691 */
22 #include <stdio.h>
23 #include <string.h>
24 #include <wchar.h>
25 #include <locale.h>
27 static int
28 do_test (void)
30 const char * in = "A";
31 const char *inbuf = in;
32 size_t inlen = strchr (in, '\0') - inbuf;
34 wchar_t out[5];
35 mbstate_t ps;
37 const char *locale = "vi_VN.TCVN5712-1";
38 if (!setlocale (LC_ALL, locale))
40 printf ("Locale not available.\n");
41 return 1;
44 memset (&ps, '\0', sizeof (ps));
45 memset (out, '\0', sizeof (out));
47 /* If the bug isn't fixed, it isn't going to return from mbsnrtowcs due to
48 an assert(). */
49 size_t n = mbsnrtowcs (out, &inbuf, inlen, sizeof(out) - 1, &ps);
51 int result = 0;
53 if (n != 1)
55 printf ("n = %zu, expected 1\n", n);
56 result = 1;
59 int i;
60 printf ("in = ");
61 for (i = 0; i < inlen; i++)
63 printf ("0x%X ", in[i]);
65 printf ("\n");
67 char * outb = (char *) out;
68 printf ("out =");
69 for (i = 0; i < sizeof (out); i++)
71 if (i % 4 == 0)
73 printf (" 0x");
75 printf ("%X", outb[i]);
77 printf ("\n");
79 return result;
82 #define TEST_FUNCTION do_test ()
83 #include "../test-skeleton.c"