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 Separate the C/POSIX locale test from ...
details: https://anonhg.NetBSD.org/src/rev/9e4a7de676a0
branches: trunk
changeset: 355708:9e4a7de676a0
user: perseant <perseant%NetBSD.org@localhost>
date: Thu Aug 10 19:08:43 2017 +0000
description:
Separate the C/POSIX locale test from the rest; make it more thorough
and more correct. This fixes a problem reported by martin@ when the
test is compiled with -funsigned-char.
diffstat:
tests/lib/libc/locale/t_btowc.c | 41 ++++++++++++++++++++++++++++++++---------
1 files changed, 32 insertions(+), 9 deletions(-)
diffs (72 lines):
diff -r 11e20bfc4ffd -r 9e4a7de676a0 tests/lib/libc/locale/t_btowc.c
--- a/tests/lib/libc/locale/t_btowc.c Thu Aug 10 19:03:25 2017 +0000
+++ b/tests/lib/libc/locale/t_btowc.c Thu Aug 10 19:08:43 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_btowc.c,v 1.2 2017/07/12 17:32:51 perseant Exp $ */
+/* $NetBSD: t_btowc.c,v 1.3 2017/08/10 19:08:43 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_btowc.c,v 1.2 2017/07/12 17:32:51 perseant Exp $");
+__RCSID("$NetBSD: t_btowc.c,v 1.3 2017/08/10 19:08:43 perseant Exp $");
#include <locale.h>
#include <stdio.h>
@@ -52,13 +52,6 @@
const wchar_t willegal[8]; /* ISO-10646 that do not map into charset */
} tests[] = {
{
- "C",
- "\377",
- "ABC123@\t",
- { 'A', 'B', 'C', '1', '2', '3', '@', '\t' },
- { 0x0430, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
- },
- {
"en_US.UTF-8",
"\200",
"ABC123@\t",
@@ -193,9 +186,39 @@
#endif /* ! __STDC_ISO_10646__ */
}
+ATF_TC(btowc_posix);
+ATF_TC_HEAD(btowc_posix, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks btowc(3) and wctob(3) for POSIX locale");
+}
+ATF_TC_BODY(btowc_posix, tc)
+{
+ const char *cp;
+ unsigned char c;
+ char *str;
+ const wchar_t *wcp;
+ int i;
+
+ ATF_REQUIRE_STREQ(setlocale(LC_ALL, "POSIX"), "POSIX");
+
+ /* btowc(EOF) -> WEOF */
+ ATF_REQUIRE_EQ(btowc(EOF), WEOF);
+
+ /* wctob(WEOF) -> EOF */
+ ATF_REQUIRE_EQ(wctob(WEOF), EOF);
+
+ /* All characters from 0 to 255, inclusive, map
+ onto their unsigned char equivalent */
+ for (i = 0; i <= 255; i++) {
+ ATF_REQUIRE_EQ(btowc(i), (wchar_t)(unsigned char)(i));
+ ATF_REQUIRE_EQ((unsigned char)wctob(i), (wchar_t)i);
+ }
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, btowc);
+ ATF_TP_ADD_TC(tp, btowc_posix);
ATF_TP_ADD_TC(tp, stdc_iso_10646);
return atf_no_error();
Home |
Main Index |
Thread Index |
Old Index