|
Packit |
6c4009 |
#include <array_length.h>
|
|
Packit |
6c4009 |
#include <locale.h>
|
|
Packit |
6c4009 |
#include <stdio.h>
|
|
Packit |
6c4009 |
#include <stdlib.h>
|
|
Packit |
6c4009 |
#include <wchar.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* This is the relevant piece from the charmap:
|
|
Packit |
6c4009 |
<UFF61> /x8e/xa1 HALFWIDTH IDEOGRAPHIC FULL STOP
|
|
Packit |
6c4009 |
<UFF62> /x8e/xa2 HALFWIDTH LEFT CORNER BRACKET
|
|
Packit |
6c4009 |
<UFF63> /x8e/xa3 HALFWIDTH RIGHT CORNER BRACKET
|
|
Packit |
6c4009 |
<UFF64> /x8e/xa4 HALFWIDTH IDEOGRAPHIC COMMA
|
|
Packit |
6c4009 |
*/
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
const char input[] = "\x8e\xa1g\x8e\xa2h\x8e\xa3i\x8e\xa4j";
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
static int
|
|
Packit |
6c4009 |
do_test (void)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
wchar_t buf[1000];
|
|
Packit |
6c4009 |
int result = 0;
|
|
Packit |
6c4009 |
ssize_t n;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (setlocale (LC_ALL, "ja_JP.EUC-JP") == NULL)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
puts ("cannot set locale");
|
|
Packit |
6c4009 |
exit (1);
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define CHECK(fmt, nexp, exp) \
|
|
Packit |
6c4009 |
n = swprintf (buf, array_length (buf), fmt, input); \
|
|
Packit |
6c4009 |
if (n != nexp) \
|
|
Packit |
6c4009 |
{ \
|
|
Packit |
6c4009 |
printf ("swprintf (.., .., L\"%ls\", \"%ls\") return %d, not %d\n", \
|
|
Packit |
6c4009 |
fmt, (wchar_t*) input, (int) n, (int) nexp); \
|
|
Packit |
6c4009 |
result = 1; \
|
|
Packit |
6c4009 |
} \
|
|
Packit |
6c4009 |
else if (wcscmp (buf, exp) != 0) \
|
|
Packit |
6c4009 |
{ \
|
|
Packit |
6c4009 |
printf ("\
|
|
Packit |
6c4009 |
swprintf (.., .., L\"%ls\", \"%ls\") produced \"%ls\", not \"%ls\"\n", \
|
|
Packit |
6c4009 |
fmt, (wchar_t *) input, buf, exp ); \
|
|
Packit |
6c4009 |
result = 1; \
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
CHECK (L"[%-6.0s]", 8, L"[ ]");
|
|
Packit |
6c4009 |
CHECK (L"[%-6.1s]", 8, L"[\xff61 ]");
|
|
Packit |
6c4009 |
CHECK (L"[%-6.2s]", 8, L"[\xff61g ]");
|
|
Packit |
6c4009 |
CHECK (L"[%-6.3s]", 8, L"[\xff61g\xff62 ]");
|
|
Packit |
6c4009 |
CHECK (L"[%-6.4s]", 8, L"[\xff61g\xff62h ]");
|
|
Packit |
6c4009 |
CHECK (L"[%-6.5s]", 8, L"[\xff61g\xff62h\xff63 ]");
|
|
Packit |
6c4009 |
CHECK (L"[%-6.6s]", 8, L"[\xff61g\xff62h\xff63i]");
|
|
Packit |
6c4009 |
CHECK (L"[%-6.7s]", 9, L"[\xff61g\xff62h\xff63i\xff64]");
|
|
Packit |
6c4009 |
CHECK (L"[%-6.8s]", 10, L"[\xff61g\xff62h\xff63i\xff64j]");
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return result;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define TEST_FUNCTION do_test ()
|
|
Packit |
6c4009 |
#include "../test-skeleton.c"
|