Module Name: src
Committed By: perseant
Date: Wed Jul 12 17:32:51 UTC 2017
Modified Files:
src/tests/lib/libc/locale: t_btowc.c t_io.c t_mbrtowc.c t_mbstowcs.c
t_sprintf.c t_wcstod.c t_wctomb.c t_wctype.c
Log Message:
Add ISO10646 versions of these tests, conditional on __STDC_ISO_10646__ .
Also make the tests a bit more verbose, to aid debugging when they fail.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/locale/t_btowc.c \
src/tests/lib/libc/locale/t_mbrtowc.c \
src/tests/lib/libc/locale/t_mbstowcs.c \
src/tests/lib/libc/locale/t_wctype.c
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/locale/t_io.c \
src/tests/lib/libc/locale/t_wctomb.c
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/locale/t_sprintf.c
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/locale/t_wcstod.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/lib/libc/locale/t_btowc.c
diff -u src/tests/lib/libc/locale/t_btowc.c:1.1 src/tests/lib/libc/locale/t_btowc.c:1.2
--- src/tests/lib/libc/locale/t_btowc.c:1.1 Thu Jun 1 15:45:02 2017
+++ src/tests/lib/libc/locale/t_btowc.c Wed Jul 12 17:32:51 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_btowc.c,v 1.1 2017/06/01 15:45:02 perseant Exp $ */
+/* $NetBSD: t_btowc.c,v 1.2 2017/07/12 17:32:51 perseant Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -32,11 +32,12 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2017\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_btowc.c,v 1.1 2017/06/01 15:45:02 perseant Exp $");
+__RCSID("$NetBSD: t_btowc.c,v 1.2 2017/07/12 17:32:51 perseant Exp $");
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
+#include <errno.h>
#include <string.h>
#include <wchar.h>
@@ -85,18 +86,28 @@ static void
h_iso10646(struct test *t)
{
const char *cp;
- unsigned char c;
+ int c, wc;
char *str;
const wchar_t *wcp;
+ ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
+ printf("Trying locale: %s\n", t->locale);
+ ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
+ ATF_REQUIRE((str = setlocale(LC_ALL, NULL)) != NULL);
+ (void)printf("Using locale: %s\n", str);
+
/* These should have valid wchar representations */
for (cp = t->legal, wcp = t->wlegal; *cp != '\0'; ++cp, ++wcp) {
- c = (unsigned char)*cp;
+ c = (int)(unsigned char)*cp;
printf("Checking legal character 0x%x\n", c);
+ wc = btowc(c);
+
+ if (errno != 0)
+ printf(" btowc() failed with errno=%d\n", errno);
/* It should map to the known Unicode equivalent */
printf("btowc(0x%2.2x) = 0x%x, expecting 0x%x\n",
- c, btowc(c), *wcp);
+ c, wc, *wcp);
ATF_REQUIRE(btowc(c) == *wcp);
}
@@ -120,6 +131,8 @@ h_btowc(struct test *t)
ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
printf("Trying locale: %s\n", t->locale);
ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
+ ATF_REQUIRE((str = setlocale(LC_ALL, NULL)) != NULL);
+ (void)printf("Using locale: %s\n", str);
/* btowc(EOF) -> WEOF */
ATF_REQUIRE_EQ(btowc(EOF), WEOF);
Index: src/tests/lib/libc/locale/t_mbrtowc.c
diff -u src/tests/lib/libc/locale/t_mbrtowc.c:1.1 src/tests/lib/libc/locale/t_mbrtowc.c:1.2
--- src/tests/lib/libc/locale/t_mbrtowc.c:1.1 Fri Jul 15 07:35:21 2011
+++ src/tests/lib/libc/locale/t_mbrtowc.c Wed Jul 12 17:32:51 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mbrtowc.c,v 1.1 2011/07/15 07:35:21 jruoho Exp $ */
+/* $NetBSD: t_mbrtowc.c,v 1.2 2017/07/12 17:32:51 perseant Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2011\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_mbrtowc.c,v 1.1 2011/07/15 07:35:21 jruoho Exp $");
+__RCSID("$NetBSD: t_mbrtowc.c,v 1.2 2017/07/12 17:32:51 perseant Exp $");
#include <errno.h>
#include <locale.h>
@@ -98,19 +98,31 @@ static struct test {
}, {
"ja_JP.ISO2022-JP2",
"\033$BF|K\1348l\033(BA\033$B$\"\033(BB\033$B$$\033(B",
+#ifdef __STDC_ISO_10646__
+ { 0x65E5, 0x672C, 0x8A9E, 0x41, 0x3042, 0x42, 0x3044 },
+#else
{ 0x4200467c, 0x42004b5c, 0x4200386c, 0x41, 0x42002422, 0x42, 0x42002424 },
+#endif
{ 5, 2, 2, 4, 5, 4, 5 },
7
}, {
"ja_JP.SJIS",
"\223\372\226{\214\352A\202\240B\202\242",
- { 0x93fa, 0x967b, 0x8cea, 0x41, 0x82a0, 0x42, 0x82a2 },
+#ifdef __STDC_ISO_10646__
+ { 0x65E5, 0x672C, 0x8A9E, 0x41, 0x3042, 0x42, 0x3044 },
+#else
+ { 0x93FA, 0x967B, 0x8CEA, 0x41, 0x82A0, 0x42, 0x82A2 },
+#endif
{ 2, 2, 2, 1, 2, 1, 2 },
7
}, {
"ja_JP.eucJP",
"\306\374\313\334\270\354A\244\242B\244\244",
- { 0xc6fc, 0xcbdc, 0xb8ec, 0x41, 0xa4a2, 0x42, 0xa4a4 },
+#ifdef __STDC_ISO_10646__
+ { 0x65E5, 0x672C, 0x8A9E, 0x41, 0x3042, 0x42, 0x3044 },
+#else
+ { 0xC6FC, 0xCBDC, 0xB8EC, 0x41, 0xA4A2, 0x42, 0xA4A4 },
+#endif
{ 2, 2, 2, 1, 2, 1, 2 },
7
}, {
@@ -146,6 +158,8 @@ h_ctype2(const struct test *t, bool use_
// mbrtowc(0, 0, 0, &st); /* XXX for ISO2022-JP */
stp = use_mbstate ? &st : 0;
+ printf("First using repeated mbrtowc\n");
+
for (n = 9; n > 0; n--) {
const char *src = t->data;
wchar_t dst;
@@ -196,6 +210,8 @@ h_ctype2(const struct test *t, bool use_
"%zd (expected: %zd)", nchar, t->length);
}
+ printf("Now using mbsrtowcs\n");
+
{
wchar_t wbuf[SIZE];
size_t rv;
Index: src/tests/lib/libc/locale/t_mbstowcs.c
diff -u src/tests/lib/libc/locale/t_mbstowcs.c:1.1 src/tests/lib/libc/locale/t_mbstowcs.c:1.2
--- src/tests/lib/libc/locale/t_mbstowcs.c:1.1 Fri Jul 15 07:35:21 2011
+++ src/tests/lib/libc/locale/t_mbstowcs.c Wed Jul 12 17:32:51 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mbstowcs.c,v 1.1 2011/07/15 07:35:21 jruoho Exp $ */
+/* $NetBSD: t_mbstowcs.c,v 1.2 2017/07/12 17:32:51 perseant Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2011\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_mbstowcs.c,v 1.1 2011/07/15 07:35:21 jruoho Exp $");
+__RCSID("$NetBSD: t_mbstowcs.c,v 1.2 2017/07/12 17:32:51 perseant Exp $");
#include <errno.h>
#include <locale.h>
@@ -97,9 +97,15 @@ static struct test {
"ja_JP.ISO2022-JP",
"\033$B#J#I#S$G$9!#\033(Baaaa\033$B$\"$$$&$($*\033(B",
{
+#ifdef __STDC_ISO_10646__
+ 0xFF2A, 0xFF29, 0xFF33, 0x3067, 0x3059,
+ 0x3002, 0x61, 0x61, 0x61, 0x61, 0x3042, 0x3044,
+ 0x3046, 0x3048, 0x304A, 0x0A
+#else
0x4200234A, 0x42002349, 0x42002353, 0x42002447, 0x42002439,
0x42002123, 0x61, 0x61, 0x61, 0x61, 0x42002422, 0x42002424,
0x42002426, 0x42002428, 0x4200242A, 0x0A
+#endif
},
{ 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, -1 },
26
@@ -108,8 +114,13 @@ static struct test {
"\202r\202i\202h\202r\202\305\202\267\201Baaaa\202\240\202\242"
"\202\244\202\246\202\250",
{
+#ifdef __STDC_ISO_10646__
+ 0xFF33, 0xFF2A, 0xFF29, 0xFF33, 0x3067, 0x3059, 0x3002, 0x61,
+ 0x61, 0x61, 0x61, 0x3042, 0x3044, 0x3046, 0x3048, 0x304A, 0x0A
+#else
0x8272, 0x8269, 0x8268, 0x8272, 0x82C5, 0x82B7, 0x8142, 0x61,
0x61, 0x61, 0x61, 0x82A0, 0x82A2, 0x82A4, 0x82A6, 0x82A8, 0x0A
+#endif
},
{ 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, -1 },
28
@@ -118,8 +129,13 @@ static struct test {
"\243\305\243\325\243\303\244\307\244\271\241\243aaaa\244\242\244"
"\244\244\246\244\250\244\252",
{
+#ifdef __STDC_ISO_10646__
+ 0xFF25, 0xFF35, 0xFF23, 0x3067, 0x3059, 0x3002, 0x61, 0x61, 0x61,
+ 0x61, 0x3042, 0x3044, 0x3046, 0x3048, 0x304A, 0x0A
+#else
0xA3C5, 0xA3D5, 0xA3C3, 0xA4C7, 0xA4B9, 0xA1A3, 0x61, 0x61, 0x61,
0x61, 0xA4A2, 0xA4A4, 0xA4A6, 0xA4A8, 0xA4AA, 0x0A
+#endif
},
{ 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, -1 },
26
Index: src/tests/lib/libc/locale/t_wctype.c
diff -u src/tests/lib/libc/locale/t_wctype.c:1.1 src/tests/lib/libc/locale/t_wctype.c:1.2
--- src/tests/lib/libc/locale/t_wctype.c:1.1 Tue May 30 23:44:02 2017
+++ src/tests/lib/libc/locale/t_wctype.c Wed Jul 12 17:32:51 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_wctype.c,v 1.1 2017/05/30 23:44:02 perseant Exp $ */
+/* $NetBSD: t_wctype.c,v 1.2 2017/07/12 17:32:51 perseant Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2017\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_wctype.c,v 1.1 2017/05/30 23:44:02 perseant Exp $");
+__RCSID("$NetBSD: t_wctype.c,v 1.2 2017/07/12 17:32:51 perseant Exp $");
#include <locale.h>
#include <stdio.h>
@@ -91,6 +91,26 @@ static struct test {
{ /* xdigit */ "123abcABC", "xyz" },
},
}, {
+ "en_US.UTF-8",
+ {
+ { /* alnum */ "abc123", "&^%$" },
+ { /* alpha */ "ABCabc", "123*&^" },
+ { /* blank */ " \t", "abc123%$^&\r\n" },
+ { /* cntrl */ "\a", "abc123^&*" },
+ { /* digit */ "123", "abc*()" },
+ { /* graph */ "abc123ABC[];?~", " " },
+ { /* ideogram */ "", "" },
+ { /* lower */ "abc", "ABC123&*(" },
+ { /* phonogram */ "", "" },
+ { /* print */ "abcABC123%^&* ", "\r\n\t" },
+ { /* punct */ ".,;:!?", "abc123 \n" },
+ { /* rune */ "", "" },
+ { /* space */ " \t\r\n", "abc123ABC&*(" },
+ { /* special */ "", "" },
+ { /* upper */ "ABC", "abc123&*(" },
+ { /* xdigit */ "123abcABC", "xyz" },
+ },
+ }, {
"ru_RU.KOI8-R",
{
{ /* alnum */ "abc123i\xa3\xb3\xd6", "&^%$" },
@@ -129,6 +149,7 @@ h_ctype(const struct test *t)
ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
printf("Trying locale %s...\n", t->locale);
ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
+ printf("Using locale %s\n", setlocale(LC_CTYPE, NULL));
for (i = 0; i < 16; i++) {
/* Skip any type that has no chars */
Index: src/tests/lib/libc/locale/t_io.c
diff -u src/tests/lib/libc/locale/t_io.c:1.4 src/tests/lib/libc/locale/t_io.c:1.5
--- src/tests/lib/libc/locale/t_io.c:1.4 Tue Jan 21 00:32:16 2014
+++ src/tests/lib/libc/locale/t_io.c Wed Jul 12 17:32:51 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_io.c,v 1.4 2014/01/21 00:32:16 yamt Exp $ */
+/* $NetBSD: t_io.c,v 1.5 2017/07/12 17:32:51 perseant Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2011\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_io.c,v 1.4 2014/01/21 00:32:16 yamt Exp $");
+__RCSID("$NetBSD: t_io.c,v 1.5 2017/07/12 17:32:51 perseant Exp $");
#include <sys/param.h>
#include <errno.h>
@@ -53,8 +53,14 @@ ATF_TC_HEAD(bad_big5_wprintf, tc)
ATF_TC_BODY(bad_big5_wprintf, tc)
{
- /* XXX implementation detail knowledge (wchar_t encoding) */
- wchar_t ibuf[] = { 0xcf10, 0 };
+ wchar_t ibuf[] = {
+#ifdef __STDC_ISO_10646__
+ 0x0978, 0 /* An arbitrarily chosen Devangari symbol */
+#else
+ /* XXX implementation detail knowledge (wchar_t encoding) */
+ 0xcf10, 0
+#endif
+ };
setlocale(LC_CTYPE, "zh_TW.Big5");
ATF_REQUIRE_ERRNO(EILSEQ, wprintf(L"%ls\n", ibuf) < 0);
ATF_REQUIRE(ferror(stdout));
@@ -68,8 +74,14 @@ ATF_TC_HEAD(bad_big5_swprintf, tc)
ATF_TC_BODY(bad_big5_swprintf, tc)
{
- /* XXX implementation detail knowledge (wchar_t encoding) */
- wchar_t ibuf[] = { 0xcf10, 0 };
+ wchar_t ibuf[] = {
+#ifdef __STDC_ISO_10646__
+ 0x0978, 0 /* An arbitrarily chosen Devangari symbol */
+#else
+ /* XXX implementation detail knowledge (wchar_t encoding) */
+ 0xcf10, 0
+#endif
+ };
wchar_t obuf[20];
setlocale(LC_CTYPE, "zh_TW.Big5");
ATF_REQUIRE_ERRNO(EILSEQ,
@@ -84,8 +96,14 @@ ATF_TC_HEAD(good_big5_wprintf, tc)
ATF_TC_BODY(good_big5_wprintf, tc)
{
- /* XXX implementation detail knowledge (wchar_t encoding) */
- wchar_t ibuf[] = { 0xcf40, 0 };
+ wchar_t ibuf[] = {
+#ifdef __STDC_ISO_10646__
+ 0x67DC, 0
+#else
+ /* XXX implementation detail knowledge (wchar_t encoding) */
+ 0xcf40, 0
+#endif
+ };
setlocale(LC_CTYPE, "zh_TW.Big5");
ATF_REQUIRE_EQ(wprintf(L"%ls\n", ibuf), 2);
}
@@ -98,8 +116,14 @@ ATF_TC_HEAD(good_big5_swprintf, tc)
ATF_TC_BODY(good_big5_swprintf, tc)
{
- /* XXX implementation detail knowledge (wchar_t encoding) */
- wchar_t ibuf[] = { 0xcf40, 0 };
+ wchar_t ibuf[] = {
+#ifdef __STDC_ISO_10646__
+ 0x67DC, 0
+#else
+ /* XXX implementation detail knowledge (wchar_t encoding) */
+ 0xcf40, 0
+#endif
+ };
wchar_t obuf[20];
setlocale(LC_CTYPE, "zh_TW.Big5");
ATF_REQUIRE_EQ(swprintf(obuf, sizeof(obuf), L"%ls\n", ibuf), 2);
@@ -139,8 +163,14 @@ ATF_TC_BODY(good_big5_getwc, tc)
ATF_REQUIRE(fp != NULL);
setlocale(LC_CTYPE, "zh_TW.Big5");
- /* XXX implementation detail knowledge (wchar_t encoding) */
- ATF_REQUIRE_EQ(getwc(fp), 0xcf40);
+ ATF_REQUIRE_EQ(getwc(fp),
+#ifdef __STDC_ISO_10646__
+ 0x67DC
+#else
+ /* XXX implementation detail knowledge (wchar_t encoding) */
+ 0xcf40
+#endif
+ );
fclose(fp);
}
Index: src/tests/lib/libc/locale/t_wctomb.c
diff -u src/tests/lib/libc/locale/t_wctomb.c:1.4 src/tests/lib/libc/locale/t_wctomb.c:1.5
--- src/tests/lib/libc/locale/t_wctomb.c:1.4 Thu May 25 18:28:54 2017
+++ src/tests/lib/libc/locale/t_wctomb.c Wed Jul 12 17:32:51 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_wctomb.c,v 1.4 2017/05/25 18:28:54 perseant Exp $ */
+/* $NetBSD: t_wctomb.c,v 1.5 2017/07/12 17:32:51 perseant Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2011\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_wctomb.c,v 1.4 2017/05/25 18:28:54 perseant Exp $");
+__RCSID("$NetBSD: t_wctomb.c,v 1.5 2017/07/12 17:32:51 perseant Exp $");
#include <stdio.h>
#include <stdlib.h>
@@ -149,6 +149,8 @@ h_wctomb(const struct test *t, char tc)
(void)printf("At position %zd:\n", i);
(void)printf(" expected: %zd\n", t->mblen[i]);
(void)printf(" got : %zd\n", ret);
+ (void)strvis(buf, cs, VIS_WHITE | VIS_OCTAL);
+ (void)printf(" sequence: \"%s\"\n", buf);
atf_tc_fail("Test failed");
/* NOTREACHED */
}
Index: src/tests/lib/libc/locale/t_sprintf.c
diff -u src/tests/lib/libc/locale/t_sprintf.c:1.2 src/tests/lib/libc/locale/t_sprintf.c:1.3
--- src/tests/lib/libc/locale/t_sprintf.c:1.2 Wed Jun 7 22:59:42 2017
+++ src/tests/lib/libc/locale/t_sprintf.c Wed Jul 12 17:32:51 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sprintf.c,v 1.2 2017/06/07 22:59:42 perseant Exp $ */
+/* $NetBSD: t_sprintf.c,v 1.3 2017/07/12 17:32:51 perseant Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2017\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_sprintf.c,v 1.2 2017/06/07 22:59:42 perseant Exp $");
+__RCSID("$NetBSD: t_sprintf.c,v 1.3 2017/07/12 17:32:51 perseant Exp $");
#include <locale.h>
#include <stdio.h>
@@ -113,9 +113,6 @@ h_sprintf(const struct test *t)
ATF_REQUIRE(setlocale(LC_NUMERIC, t->locale) != NULL);
printf("Using locale: %s\n", setlocale(LC_ALL, NULL));
- if (!strcmp("POSIX", t->locale))
- atf_tc_expect_fail("%s", "PR standards/52282, printf doesn't respect empty thousands separator");
-
sprintf(buf, "%'f", t->double_value);
ATF_REQUIRE_STREQ(buf, t->double_result);
Index: src/tests/lib/libc/locale/t_wcstod.c
diff -u src/tests/lib/libc/locale/t_wcstod.c:1.3 src/tests/lib/libc/locale/t_wcstod.c:1.4
--- src/tests/lib/libc/locale/t_wcstod.c:1.3 Sat Oct 1 17:56:11 2011
+++ src/tests/lib/libc/locale/t_wcstod.c Wed Jul 12 17:32:51 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_wcstod.c,v 1.3 2011/10/01 17:56:11 christos Exp $ */
+/* $NetBSD: t_wcstod.c,v 1.4 2017/07/12 17:32:51 perseant Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2011\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_wcstod.c,v 1.3 2011/10/01 17:56:11 christos Exp $");
+__RCSID("$NetBSD: t_wcstod.c,v 1.4 2017/07/12 17:32:51 perseant Exp $");
#include <errno.h>
#include <math.h>
@@ -384,6 +384,35 @@ static struct test {
};
#endif /* !defined(__vax__) */
+
+ATF_TC(wcstombs);
+ATF_TC_HEAD(wcstombs, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks wcstombs(3) on the inputs to the wcstod test");
+}
+ATF_TC_BODY(wcstombs, tc)
+{
+ struct test *t;
+ size_t n;
+ char *buf;
+
+ /*
+ * Previously this was part of the wcstod test.
+ */
+ for (t = &tests[0]; t->wcs != NULL; ++t) {
+ printf("wcslen(\"%S\") = %zu\n", t->wcs, wcslen(t->wcs));
+ n = wcstombs(NULL, t->wcs, 0);
+ printf("wcstombs(NULL, \"%S\", 0) = %d\n", t->wcs, (int)n);
+ ATF_REQUIRE((buf = (void *)calloc(1, n + 1)) != NULL);
+ (void)wcstombs(buf, t->wcs, n + 1);
+ printf("wcstombs(buf, \"%S\", %d) = \"%s\"\n", t->wcs,
+ (int)(n + 1), buf);
+ ATF_REQUIRE_EQ(strlen(buf), wcslen(t->wcs));
+
+ free(buf);
+ }
+}
+
ATF_TC(wcstod);
ATF_TC_HEAD(wcstod, tc)
{
@@ -398,17 +427,11 @@ ATF_TC_BODY(wcstod, tc)
#if !defined(__vax__)
for (t = &tests[0]; t->wcs != NULL; ++t) {
- double d;
size_t n;
+ double d;
wchar_t *tail;
- char *buf;
- /* we do not supported %ls nor %S yet. */
- n = wcstombs(NULL, t->wcs, 0);
- ATF_REQUIRE((buf = (void *)malloc(n + 1)) != NULL);
- (void)wcstombs(buf, t->wcs, n + 1);
- (void)printf("Checking wcstod(\"%s\", &tail):\n", buf);
- free(buf);
+ (void)printf("Checking wcstod(\"%S\", &tail):\n", t->wcs);
errno = 0;
d = wcstod(t->wcs, &tail);
@@ -451,6 +474,7 @@ ATF_TC_BODY(wcstod, tc)
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, wcstod);
+ ATF_TP_ADD_TC(tp, wcstombs);
return atf_no_error();
}