Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libc/locale Add ISO10646 versions of these tests, ...
details: https://anonhg.NetBSD.org/src/rev/8d040eaf6f76
branches: trunk
changeset: 355088:8d040eaf6f76
user: perseant <perseant%NetBSD.org@localhost>
date: Wed Jul 12 17:32:51 2017 +0000
description:
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.
diffstat:
tests/lib/libc/locale/t_btowc.c | 23 ++++++++++++---
tests/lib/libc/locale/t_io.c | 54 +++++++++++++++++++++++++++++--------
tests/lib/libc/locale/t_mbrtowc.c | 24 ++++++++++++++--
tests/lib/libc/locale/t_mbstowcs.c | 20 ++++++++++++-
tests/lib/libc/locale/t_sprintf.c | 7 +---
tests/lib/libc/locale/t_wcstod.c | 44 +++++++++++++++++++++++-------
tests/lib/libc/locale/t_wctomb.c | 6 ++-
tests/lib/libc/locale/t_wctype.c | 25 ++++++++++++++++-
8 files changed, 161 insertions(+), 42 deletions(-)
diffs (truncated from 489 to 300 lines):
diff -r 0c56a119ce70 -r 8d040eaf6f76 tests/lib/libc/locale/t_btowc.c
--- a/tests/lib/libc/locale/t_btowc.c Wed Jul 12 17:10:09 2017 +0000
+++ b/tests/lib/libc/locale/t_btowc.c Wed Jul 12 17:32:51 2017 +0000
@@ -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 @@
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 @@
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);
diff -r 0c56a119ce70 -r 8d040eaf6f76 tests/lib/libc/locale/t_io.c
--- a/tests/lib/libc/locale/t_io.c Wed Jul 12 17:10:09 2017 +0000
+++ b/tests/lib/libc/locale/t_io.c Wed Jul 12 17:32:51 2017 +0000
@@ -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_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_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_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_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_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);
}
diff -r 0c56a119ce70 -r 8d040eaf6f76 tests/lib/libc/locale/t_mbrtowc.c
--- a/tests/lib/libc/locale/t_mbrtowc.c Wed Jul 12 17:10:09 2017 +0000
+++ b/tests/lib/libc/locale/t_mbrtowc.c Wed Jul 12 17:32:51 2017 +0000
@@ -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 @@
}, {
"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 @@
// 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 @@
"%zd (expected: %zd)", nchar, t->length);
}
+ printf("Now using mbsrtowcs\n");
+
{
wchar_t wbuf[SIZE];
size_t rv;
diff -r 0c56a119ce70 -r 8d040eaf6f76 tests/lib/libc/locale/t_mbstowcs.c
--- a/tests/lib/libc/locale/t_mbstowcs.c Wed Jul 12 17:10:09 2017 +0000
+++ b/tests/lib/libc/locale/t_mbstowcs.c Wed Jul 12 17:32:51 2017 +0000
@@ -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 @@
"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 @@
"\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 @@
"\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
diff -r 0c56a119ce70 -r 8d040eaf6f76 tests/lib/libc/locale/t_sprintf.c
Home |
Main Index |
Thread Index |
Old Index