annotate tests/test-mbsrtowcs.c @ 14350:4cf3b58aaf12

Don't interfere with a program's definition of __attribute__. * lib/argp.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (argp_error, __argp_error, argp_failure, __argp_failure): Use it. * lib/argp-fmtstream.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (__argp_fmtstream_printf, argp_fmtstream_printf): Use it. * lib/argp-help.c (hol_entry_long_iterate): Use __attribute__ only for GCC 3 or newer. * lib/error.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (error, error_at_line): Use it. * lib/hash.h (__attribute__): Remove definition. (ATTRIBUTE_WUR): Update definition. Define always. * lib/openat.h (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. * lib/sigpipe-die.h (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. * lib/vasnprintf.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (asnprintf, vasnprintf): Use it. * lib/xalloc.h (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. (ATTRIBUTE_MALLOC, ATTRIBUTE_ALLOC_SIZE): Define always. * lib/xmemdup0.h (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. * lib/xprintf.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (xprintf, xvprintf, xfprintf, xvfprintf): Use it. * lib/xstrtol.h (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. * lib/xvasprintf.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (xasprintf, xvasprintf): Use it. * tests/test-argmatch.c (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. * tests/test-exclude.c (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. Reported by Paul Eggert.
author Bruno Haible <bruno@clisp.org>
date Sun, 13 Feb 2011 23:21:20 +0100
parents 97fc9a21a8fb
children 8250f2777afc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of conversion of string to wide string.
14079
97fc9a21a8fb maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents: 12559
diff changeset
2 Copyright (C) 2008-2011 Free Software Foundation, Inc.
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 /* Written by Bruno Haible <bruno@clisp.org>, 2008. */
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include <config.h>
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include <wchar.h>
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
12489
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
23 #include "signature.h"
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
24 SIGNATURE_CHECK (mbsrtowcs, size_t, (wchar_t *, char const **, size_t,
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
25 mbstate_t *));
33ab12a7cea2 tests: add signature checks
Eric Blake <ebb9@byu.net>
parents: 12421
diff changeset
26
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 #include <locale.h>
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 #include <stdio.h>
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 #include <string.h>
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30
12496
a48d3d749ca5 Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents: 12489
diff changeset
31 #include "macros.h"
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 int
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 main (int argc, char *argv[])
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 {
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 mbstate_t state;
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 wchar_t wc;
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 size_t ret;
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 /* configure should already have checked that the locale is supported. */
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 if (setlocale (LC_ALL, "") == NULL)
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 return 1;
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 /* Test NUL byte input. */
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 {
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 const char *src;
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 memset (&state, '\0', sizeof (mbstate_t));
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 src = "";
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 ret = mbsrtowcs (NULL, &src, 0, &state);
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 ASSERT (ret == 0);
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 ASSERT (mbsinit (&state));
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 src = "";
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 ret = mbsrtowcs (NULL, &src, 1, &state);
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 ASSERT (ret == 0);
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 ASSERT (mbsinit (&state));
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59
10919
45375d4f306e Avoid compiler warnings on Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 10915
diff changeset
60 wc = (wchar_t) 0xBADFACE;
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 src = "";
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 ret = mbsrtowcs (&wc, &src, 0, &state);
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 ASSERT (ret == 0);
10915
f4d48672847f Avoid test failure on platforms where sizeof (wchar_t) < sizeof (int).
Bruno Haible <bruno@clisp.org>
parents: 10914
diff changeset
64 ASSERT (wc == (wchar_t) 0xBADFACE);
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 ASSERT (mbsinit (&state));
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66
10919
45375d4f306e Avoid compiler warnings on Cygwin.
Bruno Haible <bruno@clisp.org>
parents: 10915
diff changeset
67 wc = (wchar_t) 0xBADFACE;
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 src = "";
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 ret = mbsrtowcs (&wc, &src, 1, &state);
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 ASSERT (ret == 0);
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 ASSERT (wc == 0);
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 ASSERT (mbsinit (&state));
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 }
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 if (argc > 1)
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 {
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 int unlimited;
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 for (unlimited = 0; unlimited < 2; unlimited++)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
80 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
81 #define BUFSIZE 10
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
82 wchar_t buf[BUFSIZE];
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
83 const char *src;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
84 mbstate_t temp_state;
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
86 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
87 size_t i;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
88 for (i = 0; i < BUFSIZE; i++)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
89 buf[i] = (wchar_t) 0xBADFACE;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
90 }
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
92 switch (argv[1][0])
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
93 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
94 case '1':
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
95 /* Locale encoding is ISO-8859-1 or ISO-8859-15. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
96 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
97 char input[] = "B\374\337er"; /* "Büßer" */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
98 memset (&state, '\0', sizeof (mbstate_t));
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
100 wc = (wchar_t) 0xBADFACE;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
101 ret = mbrtowc (&wc, input, 1, &state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
102 ASSERT (ret == 1);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
103 ASSERT (wc == 'B');
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
104 ASSERT (mbsinit (&state));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
105 input[0] = '\0';
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
107 wc = (wchar_t) 0xBADFACE;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
108 ret = mbrtowc (&wc, input + 1, 1, &state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
109 ASSERT (ret == 1);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
110 ASSERT (wctob (wc) == (unsigned char) '\374');
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
111 ASSERT (mbsinit (&state));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
112 input[1] = '\0';
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
114 src = input + 2;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
115 temp_state = state;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
116 ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 1, &temp_state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
117 ASSERT (ret == 3);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
118 ASSERT (src == input + 2);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
119 ASSERT (mbsinit (&state));
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
121 src = input + 2;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
122 ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 1, &state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
123 ASSERT (ret == (unlimited ? 3 : 1));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
124 ASSERT (src == (unlimited ? NULL : input + 3));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
125 ASSERT (wctob (buf[0]) == (unsigned char) '\337');
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
126 if (unlimited)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
127 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
128 ASSERT (buf[1] == 'e');
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
129 ASSERT (buf[2] == 'r');
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
130 ASSERT (buf[3] == 0);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
131 ASSERT (buf[4] == (wchar_t) 0xBADFACE);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
132 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
133 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
134 ASSERT (buf[1] == (wchar_t) 0xBADFACE);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
135 ASSERT (mbsinit (&state));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
136 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
137 break;
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
138
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
139 case '2':
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
140 /* Locale encoding is UTF-8. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
141 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
142 char input[] = "B\303\274\303\237er"; /* "Büßer" */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
143 memset (&state, '\0', sizeof (mbstate_t));
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
144
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
145 wc = (wchar_t) 0xBADFACE;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
146 ret = mbrtowc (&wc, input, 1, &state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
147 ASSERT (ret == 1);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
148 ASSERT (wc == 'B');
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
149 ASSERT (mbsinit (&state));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
150 input[0] = '\0';
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
151
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
152 wc = (wchar_t) 0xBADFACE;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
153 ret = mbrtowc (&wc, input + 1, 1, &state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
154 ASSERT (ret == (size_t)(-2));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
155 ASSERT (wc == (wchar_t) 0xBADFACE);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
156 ASSERT (!mbsinit (&state));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
157 input[1] = '\0';
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
158
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
159 src = input + 2;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
160 temp_state = state;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
161 ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
162 ASSERT (ret == 4);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
163 ASSERT (src == input + 2);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
164 ASSERT (!mbsinit (&state));
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
165
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
166 src = input + 2;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
167 ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
168 ASSERT (ret == (unlimited ? 4 : 2));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
169 ASSERT (src == (unlimited ? NULL : input + 5));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
170 ASSERT (wctob (buf[0]) == EOF);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
171 ASSERT (wctob (buf[1]) == EOF);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
172 if (unlimited)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
173 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
174 ASSERT (buf[2] == 'e');
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
175 ASSERT (buf[3] == 'r');
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
176 ASSERT (buf[4] == 0);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
177 ASSERT (buf[5] == (wchar_t) 0xBADFACE);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
178 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
179 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
180 ASSERT (buf[2] == (wchar_t) 0xBADFACE);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
181 ASSERT (mbsinit (&state));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
182 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
183 break;
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
184
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
185 case '3':
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
186 /* Locale encoding is EUC-JP. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
187 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
188 char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
189 memset (&state, '\0', sizeof (mbstate_t));
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
190
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
191 wc = (wchar_t) 0xBADFACE;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
192 ret = mbrtowc (&wc, input, 1, &state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
193 ASSERT (ret == 1);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
194 ASSERT (wc == '<');
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
195 ASSERT (mbsinit (&state));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
196 input[0] = '\0';
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
197
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
198 wc = (wchar_t) 0xBADFACE;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
199 ret = mbrtowc (&wc, input + 1, 2, &state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
200 ASSERT (ret == 2);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
201 ASSERT (wctob (wc) == EOF);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
202 ASSERT (mbsinit (&state));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
203 input[1] = '\0';
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
204 input[2] = '\0';
10923
ecb63809e77e Avoid test failure on AIX.
Bruno Haible <bruno@clisp.org>
parents: 10919
diff changeset
205
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
206 wc = (wchar_t) 0xBADFACE;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
207 ret = mbrtowc (&wc, input + 3, 1, &state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
208 ASSERT (ret == (size_t)(-2));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
209 ASSERT (wc == (wchar_t) 0xBADFACE);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
210 ASSERT (!mbsinit (&state));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
211 input[3] = '\0';
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
212
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
213 src = input + 4;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
214 temp_state = state;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
215 ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
216 ASSERT (ret == 3);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
217 ASSERT (src == input + 4);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
218 ASSERT (!mbsinit (&state));
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
219
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
220 src = input + 4;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
221 ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
222 ASSERT (ret == (unlimited ? 3 : 2));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
223 ASSERT (src == (unlimited ? NULL : input + 7));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
224 ASSERT (wctob (buf[0]) == EOF);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
225 ASSERT (wctob (buf[1]) == EOF);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
226 if (unlimited)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
227 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
228 ASSERT (buf[2] == '>');
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
229 ASSERT (buf[3] == 0);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
230 ASSERT (buf[4] == (wchar_t) 0xBADFACE);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
231 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
232 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
233 ASSERT (buf[2] == (wchar_t) 0xBADFACE);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
234 ASSERT (mbsinit (&state));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
235 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
236 break;
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
237
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
238 case '4':
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
239 /* Locale encoding is GB18030. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
240 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
241 char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
242 memset (&state, '\0', sizeof (mbstate_t));
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
243
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
244 wc = (wchar_t) 0xBADFACE;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
245 ret = mbrtowc (&wc, input, 1, &state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
246 ASSERT (ret == 1);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
247 ASSERT (wc == 'B');
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
248 ASSERT (mbsinit (&state));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
249 input[0] = '\0';
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
250
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
251 wc = (wchar_t) 0xBADFACE;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
252 ret = mbrtowc (&wc, input + 1, 1, &state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
253 ASSERT (ret == (size_t)(-2));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
254 ASSERT (wc == (wchar_t) 0xBADFACE);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
255 ASSERT (!mbsinit (&state));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
256 input[1] = '\0';
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
257
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
258 src = input + 2;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
259 temp_state = state;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
260 ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
261 ASSERT (ret == 4);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
262 ASSERT (src == input + 2);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
263 ASSERT (!mbsinit (&state));
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
264
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
265 src = input + 2;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
266 ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
267 ASSERT (ret == (unlimited ? 4 : 2));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
268 ASSERT (src == (unlimited ? NULL : input + 7));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
269 ASSERT (wctob (buf[0]) == EOF);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
270 ASSERT (wctob (buf[1]) == EOF);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
271 if (unlimited)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
272 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
273 ASSERT (buf[2] == 'e');
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
274 ASSERT (buf[3] == 'r');
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
275 ASSERT (buf[4] == 0);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
276 ASSERT (buf[5] == (wchar_t) 0xBADFACE);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
277 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
278 else
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
279 ASSERT (buf[2] == (wchar_t) 0xBADFACE);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
280 ASSERT (mbsinit (&state));
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
281 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
282 break;
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
283
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
284 default:
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
285 return 1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
286 }
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10930
diff changeset
287 }
10914
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
288
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
289 return 0;
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
290 }
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
291
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
292 return 1;
4200847287e8 Tests for module 'mbsrtowcs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
293 }