|
Packit Service |
a2ae7a |
/* Test of conversion of multibyte character to wide character.
|
|
Packit Service |
a2ae7a |
Copyright (C) 2008-2019 Free Software Foundation, Inc.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
This program is free software: you can redistribute it and/or modify
|
|
Packit Service |
a2ae7a |
it under the terms of the GNU General Public License as published by
|
|
Packit Service |
a2ae7a |
the Free Software Foundation; either version 3 of the License, or
|
|
Packit Service |
a2ae7a |
(at your option) any later version.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
This program is distributed in the hope that it will be useful,
|
|
Packit Service |
a2ae7a |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
a2ae7a |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
a2ae7a |
GNU General Public License for more details.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
You should have received a copy of the GNU General Public License
|
|
Packit Service |
a2ae7a |
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
/* Written by Bruno Haible <bruno@clisp.org>, 2008. */
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
#include <config.h>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
#include <wchar.h>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
#include "signature.h"
|
|
Packit Service |
a2ae7a |
SIGNATURE_CHECK (mbrtowc, size_t, (wchar_t *, char const *, size_t,
|
|
Packit Service |
a2ae7a |
mbstate_t *));
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
#include <locale.h>
|
|
Packit Service |
a2ae7a |
#include <stdio.h>
|
|
Packit Service |
a2ae7a |
#include <string.h>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
#include "macros.h"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
int
|
|
Packit Service |
a2ae7a |
main (int argc, char *argv[])
|
|
Packit Service |
a2ae7a |
{
|
|
Packit Service |
a2ae7a |
mbstate_t state;
|
|
Packit Service |
a2ae7a |
wchar_t wc;
|
|
Packit Service |
a2ae7a |
size_t ret;
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
/* configure should already have checked that the locale is supported. */
|
|
Packit Service |
a2ae7a |
if (setlocale (LC_ALL, "") == NULL)
|
|
Packit Service |
a2ae7a |
return 1;
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
/* Test zero-length input. */
|
|
Packit Service |
a2ae7a |
{
|
|
Packit Service |
a2ae7a |
memset (&state, '\0', sizeof (mbstate_t));
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, "x", 0, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == (size_t)(-2));
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
/* Test NUL byte input. */
|
|
Packit Service |
a2ae7a |
{
|
|
Packit Service |
a2ae7a |
memset (&state, '\0', sizeof (mbstate_t));
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, "", 1, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 0);
|
|
Packit Service |
a2ae7a |
ASSERT (wc == 0);
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (NULL, "", 1, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 0);
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
/* Test single-byte input. */
|
|
Packit Service |
a2ae7a |
{
|
|
Packit Service |
a2ae7a |
int c;
|
|
Packit Service |
a2ae7a |
char buf[1];
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
memset (&state, '\0', sizeof (mbstate_t));
|
|
Packit Service |
a2ae7a |
for (c = 0; c < 0x100; c++)
|
|
Packit Service |
a2ae7a |
switch (c)
|
|
Packit Service |
a2ae7a |
{
|
|
Packit Service |
a2ae7a |
default:
|
|
Packit Service |
a2ae7a |
if (! (c && 1 < argc && argv[1][0] == '5'))
|
|
Packit Service |
a2ae7a |
break;
|
|
Packit Service |
a2ae7a |
FALLTHROUGH;
|
|
Packit Service |
a2ae7a |
case '\t': case '\v': case '\f':
|
|
Packit Service |
a2ae7a |
case ' ': case '!': case '"': case '#': case '%':
|
|
Packit Service |
a2ae7a |
case '&': case '\'': case '(': case ')': case '*':
|
|
Packit Service |
a2ae7a |
case '+': case ',': case '-': case '.': case '/':
|
|
Packit Service |
a2ae7a |
case '0': case '1': case '2': case '3': case '4':
|
|
Packit Service |
a2ae7a |
case '5': case '6': case '7': case '8': case '9':
|
|
Packit Service |
a2ae7a |
case ':': case ';': case '<': case '=': case '>':
|
|
Packit Service |
a2ae7a |
case '?':
|
|
Packit Service |
a2ae7a |
case 'A': case 'B': case 'C': case 'D': case 'E':
|
|
Packit Service |
a2ae7a |
case 'F': case 'G': case 'H': case 'I': case 'J':
|
|
Packit Service |
a2ae7a |
case 'K': case 'L': case 'M': case 'N': case 'O':
|
|
Packit Service |
a2ae7a |
case 'P': case 'Q': case 'R': case 'S': case 'T':
|
|
Packit Service |
a2ae7a |
case 'U': case 'V': case 'W': case 'X': case 'Y':
|
|
Packit Service |
a2ae7a |
case 'Z':
|
|
Packit Service |
a2ae7a |
case '[': case '\\': case ']': case '^': case '_':
|
|
Packit Service |
a2ae7a |
case 'a': case 'b': case 'c': case 'd': case 'e':
|
|
Packit Service |
a2ae7a |
case 'f': case 'g': case 'h': case 'i': case 'j':
|
|
Packit Service |
a2ae7a |
case 'k': case 'l': case 'm': case 'n': case 'o':
|
|
Packit Service |
a2ae7a |
case 'p': case 'q': case 'r': case 's': case 't':
|
|
Packit Service |
a2ae7a |
case 'u': case 'v': case 'w': case 'x': case 'y':
|
|
Packit Service |
a2ae7a |
case 'z': case '{': case '|': case '}': case '~':
|
|
Packit Service |
a2ae7a |
/* c is in the ISO C "basic character set", or argv[1] starts
|
|
Packit Service |
a2ae7a |
with '5' so we are testing all nonnull bytes. */
|
|
Packit Service |
a2ae7a |
buf[0] = c;
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, buf, 1, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
if (c < 0x80)
|
|
Packit Service |
a2ae7a |
/* c is an ASCII character. */
|
|
Packit Service |
a2ae7a |
ASSERT (wc == c);
|
|
Packit Service |
a2ae7a |
else
|
|
Packit Service |
a2ae7a |
/* argv[1] starts with '5', that is, we are testing the C or POSIX
|
|
Packit Service |
a2ae7a |
locale.
|
|
Packit Service |
a2ae7a |
On most platforms, the bytes 0x80..0xFF map to U+0080..U+00FF.
|
|
Packit Service |
a2ae7a |
But on musl libc, the bytes 0x80..0xFF map to U+DF80..U+DFFF. */
|
|
Packit Service |
a2ae7a |
ASSERT (wc == (btowc (c) == WEOF ? c : btowc (c)));
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (NULL, buf, 1, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
break;
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
/* Test special calling convention, passing a NULL pointer. */
|
|
Packit Service |
a2ae7a |
{
|
|
Packit Service |
a2ae7a |
memset (&state, '\0', sizeof (mbstate_t));
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, NULL, 5, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 0);
|
|
Packit Service |
a2ae7a |
ASSERT (wc == (wchar_t) 0xBADFACE);
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
if (argc > 1)
|
|
Packit Service |
a2ae7a |
switch (argv[1][0])
|
|
Packit Service |
a2ae7a |
{
|
|
Packit Service |
a2ae7a |
case '1':
|
|
Packit Service |
a2ae7a |
/* Locale encoding is ISO-8859-1 or ISO-8859-15. */
|
|
Packit Service |
a2ae7a |
{
|
|
Packit Service |
a2ae7a |
char input[] = "B\374\337er"; /* "Büßer" */
|
|
Packit Service |
a2ae7a |
memset (&state, '\0', sizeof (mbstate_t));
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input, 1, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (wc == 'B');
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[0] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 1, 1, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (wctob (wc) == (unsigned char) '\374');
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[1] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
/* Test support of NULL first argument. */
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (NULL, input + 2, 3, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 2, 3, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (wctob (wc) == (unsigned char) '\337');
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[2] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 3, 2, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (wc == 'e');
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[3] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 4, 1, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (wc == 'r');
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
return 0;
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
case '2':
|
|
Packit Service |
a2ae7a |
/* Locale encoding is UTF-8. */
|
|
Packit Service |
a2ae7a |
{
|
|
Packit Service |
a2ae7a |
char input[] = "B\303\274\303\237er"; /* "Büßer" */
|
|
Packit Service |
a2ae7a |
memset (&state, '\0', sizeof (mbstate_t));
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input, 1, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (wc == 'B');
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[0] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 1, 1, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == (size_t)(-2));
|
|
Packit Service |
a2ae7a |
ASSERT (wc == (wchar_t) 0xBADFACE);
|
|
Packit Service |
a2ae7a |
ASSERT (!mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[1] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 2, 5, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (wctob (wc) == EOF);
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[2] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
/* Test support of NULL first argument. */
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (NULL, input + 3, 4, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 2);
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 3, 4, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 2);
|
|
Packit Service |
a2ae7a |
ASSERT (wctob (wc) == EOF);
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[3] = '\0';
|
|
Packit Service |
a2ae7a |
input[4] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 5, 2, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (wc == 'e');
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[5] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 6, 1, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (wc == 'r');
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
return 0;
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
case '3':
|
|
Packit Service |
a2ae7a |
/* Locale encoding is EUC-JP. */
|
|
Packit Service |
a2ae7a |
{
|
|
Packit Service |
a2ae7a |
char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */
|
|
Packit Service |
a2ae7a |
memset (&state, '\0', sizeof (mbstate_t));
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input, 1, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (wc == '<');
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[0] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 1, 2, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 2);
|
|
Packit Service |
a2ae7a |
ASSERT (wctob (wc) == EOF);
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[1] = '\0';
|
|
Packit Service |
a2ae7a |
input[2] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 3, 1, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == (size_t)(-2));
|
|
Packit Service |
a2ae7a |
ASSERT (wc == (wchar_t) 0xBADFACE);
|
|
Packit Service |
a2ae7a |
ASSERT (!mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[3] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 4, 4, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (wctob (wc) == EOF);
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[4] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
/* Test support of NULL first argument. */
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (NULL, input + 5, 3, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 2);
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 5, 3, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 2);
|
|
Packit Service |
a2ae7a |
ASSERT (wctob (wc) == EOF);
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[5] = '\0';
|
|
Packit Service |
a2ae7a |
input[6] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 7, 1, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (wc == '>');
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
return 0;
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
case '4':
|
|
Packit Service |
a2ae7a |
/* Locale encoding is GB18030. */
|
|
Packit Service |
a2ae7a |
{
|
|
Packit Service |
a2ae7a |
char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
|
|
Packit Service |
a2ae7a |
memset (&state, '\0', sizeof (mbstate_t));
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input, 1, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (wc == 'B');
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[0] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 1, 1, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == (size_t)(-2));
|
|
Packit Service |
a2ae7a |
ASSERT (wc == (wchar_t) 0xBADFACE);
|
|
Packit Service |
a2ae7a |
ASSERT (!mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[1] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 2, 7, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (wctob (wc) == EOF);
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[2] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
/* Test support of NULL first argument. */
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (NULL, input + 3, 6, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 4);
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 3, 6, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 4);
|
|
Packit Service |
a2ae7a |
ASSERT (wctob (wc) == EOF);
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[3] = '\0';
|
|
Packit Service |
a2ae7a |
input[4] = '\0';
|
|
Packit Service |
a2ae7a |
input[5] = '\0';
|
|
Packit Service |
a2ae7a |
input[6] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 7, 2, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (wc == 'e');
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
input[5] = '\0';
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
wc = (wchar_t) 0xBADFACE;
|
|
Packit Service |
a2ae7a |
ret = mbrtowc (&wc, input + 8, 1, &state);
|
|
Packit Service |
a2ae7a |
ASSERT (ret == 1);
|
|
Packit Service |
a2ae7a |
ASSERT (wc == 'r');
|
|
Packit Service |
a2ae7a |
ASSERT (mbsinit (&state));
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
return 0;
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
case '5':
|
|
Packit Service |
a2ae7a |
/* C locale; tested above. */
|
|
Packit Service |
a2ae7a |
return 0;
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
return 1;
|
|
Packit Service |
a2ae7a |
}
|