X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=tests%2Ftest-mbrtowc.c;h=404128b97978ae47eeae76dda28b1a0eb96afe5d;hb=refs%2Fheads%2Fupstream;hp=4d2d5cb1d4fbcf7d3388775ec647d83527939481;hpb=931b01b091932a1f796c23379ea32abb68bd5895;p=platform%2Fupstream%2Fm4.git
diff --git a/tests/test-mbrtowc.c b/tests/test-mbrtowc.c
index 4d2d5cb..404128b 100644
--- a/tests/test-mbrtowc.c
+++ b/tests/test-mbrtowc.c
@@ -1,5 +1,5 @@
/* Test of conversion of multibyte character to wide character.
- Copyright (C) 2008-2013 Free Software Foundation, Inc.
+ Copyright (C) 2008-2021 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see . */
+ along with this program. If not, see . */
/* Written by Bruno Haible , 2008. */
@@ -46,10 +46,7 @@ main (int argc, char *argv[])
memset (&state, '\0', sizeof (mbstate_t));
wc = (wchar_t) 0xBADFACE;
ret = mbrtowc (&wc, "x", 0, &state);
- /* gnulib's implementation returns (size_t)(-2).
- The AIX 5.1 implementation returns (size_t)(-1).
- glibc's implementation returns 0. */
- ASSERT (ret == (size_t)(-2) || ret == (size_t)(-1) || ret == 0);
+ ASSERT (ret == (size_t)(-2));
ASSERT (mbsinit (&state));
}
@@ -75,6 +72,10 @@ main (int argc, char *argv[])
for (c = 0; c < 0x100; c++)
switch (c)
{
+ default:
+ if (! (c && 1 < argc && argv[1][0] == '5'))
+ break;
+ FALLTHROUGH;
case '\t': case '\v': case '\f':
case ' ': case '!': case '"': case '#': case '%':
case '&': case '\'': case '(': case ')': case '*':
@@ -96,12 +97,21 @@ main (int argc, char *argv[])
case 'p': case 'q': case 'r': case 's': case 't':
case 'u': case 'v': case 'w': case 'x': case 'y':
case 'z': case '{': case '|': case '}': case '~':
- /* c is in the ISO C "basic character set". */
+ /* c is in the ISO C "basic character set", or argv[1] starts
+ with '5' so we are testing all nonnull bytes. */
buf[0] = c;
wc = (wchar_t) 0xBADFACE;
ret = mbrtowc (&wc, buf, 1, &state);
ASSERT (ret == 1);
- ASSERT (wc == c);
+ if (c < 0x80)
+ /* c is an ASCII character. */
+ ASSERT (wc == c);
+ else
+ /* argv[1] starts with '5', that is, we are testing the C or POSIX
+ locale.
+ On most platforms, the bytes 0x80..0xFF map to U+0080..U+00FF.
+ But on musl libc, the bytes 0x80..0xFF map to U+DF80..U+DFFF. */
+ ASSERT (wc == (btowc (c) == 0xDF00 + c ? btowc (c) : c));
ASSERT (mbsinit (&state));
ret = mbrtowc (NULL, buf, 1, &state);
ASSERT (ret == 1);
@@ -328,7 +338,7 @@ main (int argc, char *argv[])
ASSERT (ret == 1);
ASSERT (wc == 'e');
ASSERT (mbsinit (&state));
- input[5] = '\0';
+ input[7] = '\0';
wc = (wchar_t) 0xBADFACE;
ret = mbrtowc (&wc, input + 8, 1, &state);
@@ -337,6 +347,10 @@ main (int argc, char *argv[])
ASSERT (mbsinit (&state));
}
return 0;
+
+ case '5':
+ /* C locale; tested above. */
+ return 0;
}
return 1;