From c147d9fffb241cfdd3b4524665ce2b3009568747 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 20 Feb 2011 18:18:31 +0100 Subject: [PATCH] wcrtomb: Add more tests for native Windows platforms. * tests/test-wcrtomb-w32-1.sh: New file. * tests/test-wcrtomb-w32-2.sh: New file. * tests/test-wcrtomb-w32-3.sh: New file. * tests/test-wcrtomb-w32-4.sh: New file. * tests/test-wcrtomb-w32-5.sh: New file. * tests/test-wcrtomb-w32.c: New file. * modules/wcrtomb-tests (Files): Add them. (Makefile.am): Arrange to run these tests. * tests/test-wcrtomb-w32-6.sh: New file, currently unused. * tests/test-wcrtomb-w32-7.sh: New file, currently unused. --- ChangeLog | 14 ++ modules/wcrtomb-tests | 13 +- tests/test-mbrtowc-w32.c | 138 +++++++++++++++ tests/test-wcrtomb-w32-1.sh | 4 + tests/test-wcrtomb-w32-2.sh | 4 + tests/test-wcrtomb-w32-3.sh | 4 + tests/test-wcrtomb-w32-4.sh | 4 + tests/test-wcrtomb-w32-5.sh | 4 + tests/test-wcrtomb-w32-6.sh | 7 + tests/test-wcrtomb-w32-7.sh | 7 + tests/test-wcrtomb-w32.c | 332 ++++++++++++++++++++++++++++++++++++ 11 files changed, 529 insertions(+), 2 deletions(-) create mode 100755 tests/test-wcrtomb-w32-1.sh create mode 100755 tests/test-wcrtomb-w32-2.sh create mode 100755 tests/test-wcrtomb-w32-3.sh create mode 100755 tests/test-wcrtomb-w32-4.sh create mode 100755 tests/test-wcrtomb-w32-5.sh create mode 100755 tests/test-wcrtomb-w32-6.sh create mode 100755 tests/test-wcrtomb-w32-7.sh create mode 100644 tests/test-wcrtomb-w32.c diff --git a/ChangeLog b/ChangeLog index 715ebcc086..f1d7070faf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-02-22 Bruno Haible + + wcrtomb: Add more tests for native Windows platforms. + * tests/test-wcrtomb-w32-1.sh: New file. + * tests/test-wcrtomb-w32-2.sh: New file. + * tests/test-wcrtomb-w32-3.sh: New file. + * tests/test-wcrtomb-w32-4.sh: New file. + * tests/test-wcrtomb-w32-5.sh: New file. + * tests/test-wcrtomb-w32.c: New file. + * modules/wcrtomb-tests (Files): Add them. + (Makefile.am): Arrange to run these tests. + * tests/test-wcrtomb-w32-6.sh: New file, currently unused. + * tests/test-wcrtomb-w32-7.sh: New file, currently unused. + 2011-02-20 Bruno Haible wcrtomb: Enhance test. diff --git a/modules/wcrtomb-tests b/modules/wcrtomb-tests index 4c85b17135..32f9d3a7f0 100644 --- a/modules/wcrtomb-tests +++ b/modules/wcrtomb-tests @@ -1,6 +1,12 @@ Files: tests/test-wcrtomb.sh tests/test-wcrtomb.c +tests/test-wcrtomb-w32-1.sh +tests/test-wcrtomb-w32-2.sh +tests/test-wcrtomb-w32-3.sh +tests/test-wcrtomb-w32-4.sh +tests/test-wcrtomb-w32-5.sh +tests/test-wcrtomb-w32.c tests/signature.h tests/macros.h m4/locale-fr.m4 @@ -19,11 +25,14 @@ gt_LOCALE_JA gt_LOCALE_ZH_CN Makefile.am: -TESTS += test-wcrtomb.sh +TESTS += \ + test-wcrtomb.sh \ + test-wcrtomb-w32-1.sh test-wcrtomb-w32-2.sh test-wcrtomb-w32-3.sh \ + test-wcrtomb-w32-4.sh test-wcrtomb-w32-5.sh TESTS_ENVIRONMENT += \ LOCALE_FR='@LOCALE_FR@' \ LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \ LOCALE_JA='@LOCALE_JA@' \ LOCALE_ZH_CN='@LOCALE_ZH_CN@' -check_PROGRAMS += test-wcrtomb +check_PROGRAMS += test-wcrtomb test-wcrtomb-w32 diff --git a/tests/test-mbrtowc-w32.c b/tests/test-mbrtowc-w32.c index e9dd043127..ee8caf9c62 100644 --- a/tests/test-mbrtowc-w32.c +++ b/tests/test-mbrtowc-w32.c @@ -18,6 +18,7 @@ #include +#include #include #include #include @@ -319,6 +320,19 @@ test_one_locale (const char *name, int codepage) ASSERT (ret == 1); ASSERT (wc == '>'); ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); } return 0; @@ -378,6 +392,19 @@ test_one_locale (const char *name, int codepage) ASSERT (ret == 1); ASSERT (wc == '>'); ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); } return 0; @@ -437,6 +464,19 @@ test_one_locale (const char *name, int codepage) ASSERT (ret == 1); ASSERT (wc == '>'); ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); } return 0; @@ -496,6 +536,43 @@ test_one_locale (const char *name, int codepage) ASSERT (ret == 1); ASSERT (wc == 'r'); ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\201\045", 2, &state); /* 0x81 0x25 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\201\060\377", 3, &state); /* 0x81 0x30 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\201\060\377\064", 4, &state); /* 0x81 0x30 0xFF 0x34 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\201\060\211\072", 4, &state); /* 0x81 0x30 0x89 0x3A */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); } return 0; @@ -553,6 +630,67 @@ test_one_locale (const char *name, int codepage) ASSERT (ret == 1); ASSERT (wc == 'r'); ASSERT (mbsinit (&state)); + + /* Test some invalid input. */ + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\303\300", 2, &state); /* 0xC3 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\343\300", 2, &state); /* 0xE3 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\343\300\200", 3, &state); /* 0xE3 0xC0 0x80 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\343\200\300", 3, &state); /* 0xE3 0x80 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\300", 2, &state); /* 0xF3 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\300\200\200", 4, &state); /* 0xF3 0xC0 0x80 0x80 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\200\300", 3, &state); /* 0xF3 0x80 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\200\300\200", 4, &state); /* 0xF3 0x80 0xC0 0x80 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); + + memset (&state, '\0', sizeof (mbstate_t)); + wc = (wchar_t) 0xBADFACE; + ret = mbrtowc (&wc, "\363\200\200\300", 4, &state); /* 0xF3 0x80 0x80 0xC0 */ + ASSERT (ret == (size_t)-1); + ASSERT (errno == EILSEQ); } return 0; diff --git a/tests/test-wcrtomb-w32-1.sh b/tests/test-wcrtomb-w32-1.sh new file mode 100755 index 0000000000..50c82f59fa --- /dev/null +++ b/tests/test-wcrtomb-w32-1.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP1252 locale. +./test-wcrtomb-w32${EXEEXT} French_France 1252 diff --git a/tests/test-wcrtomb-w32-2.sh b/tests/test-wcrtomb-w32-2.sh new file mode 100755 index 0000000000..783c70cb97 --- /dev/null +++ b/tests/test-wcrtomb-w32-2.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP1256 locale. +./test-wcrtomb-w32${EXEEXT} "Arabic_Saudi Arabia" 1256 diff --git a/tests/test-wcrtomb-w32-3.sh b/tests/test-wcrtomb-w32-3.sh new file mode 100755 index 0000000000..619ea644a2 --- /dev/null +++ b/tests/test-wcrtomb-w32-3.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP932 locale. +./test-wcrtomb-w32${EXEEXT} Japanese_Japan 932 diff --git a/tests/test-wcrtomb-w32-4.sh b/tests/test-wcrtomb-w32-4.sh new file mode 100755 index 0000000000..67b6803016 --- /dev/null +++ b/tests/test-wcrtomb-w32-4.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP950 locale. +./test-wcrtomb-w32${EXEEXT} Chinese_Taiwan 950 diff --git a/tests/test-wcrtomb-w32-5.sh b/tests/test-wcrtomb-w32-5.sh new file mode 100755 index 0000000000..9841fa9417 --- /dev/null +++ b/tests/test-wcrtomb-w32-5.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Test a CP936 locale. +./test-wcrtomb-w32${EXEEXT} Chinese_China 936 diff --git a/tests/test-wcrtomb-w32-6.sh b/tests/test-wcrtomb-w32-6.sh new file mode 100755 index 0000000000..1709c983e2 --- /dev/null +++ b/tests/test-wcrtomb-w32-6.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# This test is not enabled by default, because MSVCRT does not support and +# will likely never support locales with MB_CUR_MAX > 2. + +# Test a GB18030 locale. +./test-wcrtomb-w32${EXEEXT} Chinese_China 54936 diff --git a/tests/test-wcrtomb-w32-7.sh b/tests/test-wcrtomb-w32-7.sh new file mode 100755 index 0000000000..bea12ab3e2 --- /dev/null +++ b/tests/test-wcrtomb-w32-7.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# This test is not enabled by default, because MSVCRT does not support and +# will likely never support locales with MB_CUR_MAX > 2. + +# Test some UTF-8 locales. +./test-wcrtomb-w32${EXEEXT} French_France Japanese_Japan Chinese_Taiwan Chinese_China 65001 diff --git a/tests/test-wcrtomb-w32.c b/tests/test-wcrtomb-w32.c new file mode 100644 index 0000000000..0b094981b3 --- /dev/null +++ b/tests/test-wcrtomb-w32.c @@ -0,0 +1,332 @@ +/* Test of conversion of wide character to multibyte character. + Copyright (C) 2008-2011 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 + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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 . */ + +#include + +#include + +#include +#include +#include +#include + +#include "macros.h" + +#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ + +static int +test_one_locale (const char *name, int codepage) +{ + char buf[64]; + size_t ret; + +# if 1 + /* Portable code to set the locale. */ + { + char name_with_codepage[1024]; + + sprintf (name_with_codepage, "%s.%d", name, codepage); + + /* Set the locale. */ + if (setlocale (LC_ALL, name_with_codepage) == NULL) + return 77; + } +# else + /* Hacky way to set a locale.codepage combination that setlocale() refuses + to set. */ + { + /* Codepage of the current locale, set with setlocale(). + Not necessarily the same as GetACP(). */ + extern __declspec(dllimport) unsigned int __lc_codepage; + + /* Set the locale. */ + if (setlocale (LC_ALL, name) == NULL) + return 77; + + /* Clobber the codepage and MB_CUR_MAX, both set by setlocale(). */ + __lc_codepage = codepage; + switch (codepage) + { + case 1252: + case 1256: + MB_CUR_MAX = 1; + break; + case 932: + case 950: + case 936: + MB_CUR_MAX = 2; + break; + case 54936: + case 65001: + MB_CUR_MAX = 4; + break; + } + + /* Test whether the codepage is really available. */ + { + mbstate_t state; + wchar_t wc; + + memset (&state, '\0', sizeof (mbstate_t)); + if (mbrtowc (&wc, " ", 1, &state) == (size_t)(-1)) + return 77; + } + } +# endif + + /* Test NUL character. */ + { + buf[0] = 'x'; + ret = wcrtomb (buf, 0, NULL); + ASSERT (ret == 1); + ASSERT (buf[0] == '\0'); + } + + /* Test single bytes. */ + { + int c; + + for (c = 0; c < 0x100; c++) + switch (c) + { + case '\t': case '\v': case '\f': + case ' ': case '!': case '"': case '#': case '%': + case '&': case '\'': case '(': case ')': case '*': + case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case ':': case ';': case '<': case '=': case '>': + case '?': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + 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 '^': case '_': + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + 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". */ + ret = wcrtomb (buf, btowc (c), NULL); + ASSERT (ret == 1); + ASSERT (buf[0] == (char) c); + break; + } + } + + /* Test special calling convention, passing a NULL pointer. */ + { + ret = wcrtomb (NULL, '\0', NULL); + ASSERT (ret == 1); + ret = wcrtomb (NULL, btowc ('x'), NULL); + ASSERT (ret == 1); + } + + switch (codepage) + { + case 1252: + /* Locale encoding is CP1252, an extension of ISO-8859-1. */ + { + /* Convert "B\374\337er": "Büßer" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00FC, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\374", 1) == 0); + ASSERT (buf[1] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00DF, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\337", 1) == 0); + ASSERT (buf[1] == 'x'); + } + return 0; + + case 1256: + /* Locale encoding is CP1256, not the same as ISO-8859-6. */ + { + /* Convert "x\302\341\346y": "xآلوy" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x0622, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\302", 1) == 0); + ASSERT (buf[1] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x0644, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\341", 1) == 0); + ASSERT (buf[1] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x0648, NULL); + ASSERT (ret == 1); + ASSERT (memcmp (buf, "\346", 1) == 0); + ASSERT (buf[1] == 'x'); + } + return 0; + + case 932: + /* Locale encoding is CP932, similar to Shift_JIS. */ + { + /* Convert "<\223\372\226\173\214\352>": "<日本語>" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x65E5, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\223\372", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x672C, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\226\173", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x8A9E, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\214\352", 2) == 0); + ASSERT (buf[2] == 'x'); + } + return 0; + + case 950: + /* Locale encoding is CP950, similar to Big5. */ + { + /* Convert "<\244\351\245\273\273\171>": "<日本語>" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x65E5, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\244\351", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x672C, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\245\273", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x8A9E, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\273\171", 2) == 0); + ASSERT (buf[2] == 'x'); + } + return 0; + + case 936: + /* Locale encoding is CP936 = GBK, an extension of GB2312. */ + { + /* Convert "<\310\325\261\276\325\132>": "<日本語>" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x65E5, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\310\325", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x672C, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\261\276", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x8A9E, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\325\132", 2) == 0); + ASSERT (buf[2] == 'x'); + } + return 0; + + case 54936: + /* Locale encoding is CP54936 = GB18030. */ + { + /* Convert "B\250\271\201\060\211\070er": "Büßer" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00FC, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\250\271", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00DF, NULL); + ASSERT (ret == 4); + ASSERT (memcmp (buf, "\201\060\211\070", 4) == 0); + ASSERT (buf[4] == 'x'); + } + return 0; + + case 65001: + /* Locale encoding is CP65001 = UTF-8. */ + { + /* Convert "B\303\274\303\237er": "Büßer" */ + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00FC, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\303\274", 2) == 0); + ASSERT (buf[2] == 'x'); + + memset (buf, 'x', 8); + ret = wcrtomb (buf, 0x00DF, NULL); + ASSERT (ret == 2); + ASSERT (memcmp (buf, "\303\237", 2) == 0); + ASSERT (buf[2] == 'x'); + } + return 0; + + default: + return 1; + } +} + +int +main (int argc, char *argv[]) +{ + int codepage = atoi (argv[argc - 1]); + int result; + int i; + + result = 77; + for (i = 1; i < argc - 1; i++) + { + int ret = test_one_locale (argv[i], codepage); + + if (ret != 77) + result = ret; + } + + if (result == 77) + { + fprintf (stderr, "Skipping test: found no locale with codepage %d\n", + codepage); + } + return result; +} + +#else + +int +main (int argc, char *argv[]) +{ + fputs ("Skipping test: not a native Windows system\n", stderr); + return 77; +} + +#endif -- 2.30.2