summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorschwarze <>2017-08-16 01:40:30 +0000
committerschwarze <>2017-08-16 01:40:30 +0000
commit60d2a4f81a2187a90209c4c1cbf0a85eb5c1a5c3 (patch)
treeb61b4dab72aee9d1a05dc8d9fdb1c57a7de345a1 /src
parenta2bafb65aadaf63075b88786093b416231dcaaf4 (diff)
downloadopenbsd-60d2a4f81a2187a90209c4c1cbf0a85eb5c1a5c3.tar.gz
openbsd-60d2a4f81a2187a90209c4c1cbf0a85eb5c1a5c3.tar.bz2
openbsd-60d2a4f81a2187a90209c4c1cbf0a85eb5c1a5c3.zip
test nl_langinfo_l(3), iswalpha_l(3), towupper_l(3)
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libc/locale/uselocale/Makefile4
-rw-r--r--src/regress/lib/libc/locale/uselocale/uselocale.c43
2 files changed, 44 insertions, 3 deletions
diff --git a/src/regress/lib/libc/locale/uselocale/Makefile b/src/regress/lib/libc/locale/uselocale/Makefile
index 3c3f487df8..a10471bcf6 100644
--- a/src/regress/lib/libc/locale/uselocale/Makefile
+++ b/src/regress/lib/libc/locale/uselocale/Makefile
@@ -1,7 +1,7 @@
1# $OpenBSD: Makefile,v 1.2 2017/08/15 23:46:51 schwarze Exp $ 1# $OpenBSD: Makefile,v 1.3 2017/08/16 01:40:30 schwarze Exp $
2 2
3PROG = uselocale 3PROG = uselocale
4CFLAGS += -Wno-macro-redefined 4CFLAGS += -Wno-macro-redefined -Wno-int-to-pointer-cast
5LDFLAGS += -pthread 5LDFLAGS += -pthread
6 6
7run-regress-${PROG}: ${PROG} 7run-regress-${PROG}: ${PROG}
diff --git a/src/regress/lib/libc/locale/uselocale/uselocale.c b/src/regress/lib/libc/locale/uselocale/uselocale.c
index c33c1e21fa..01f7bcaca9 100644
--- a/src/regress/lib/libc/locale/uselocale/uselocale.c
+++ b/src/regress/lib/libc/locale/uselocale/uselocale.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: uselocale.c,v 1.2 2017/08/15 23:46:51 schwarze Exp $ */ 1/* $OpenBSD: uselocale.c,v 1.3 2017/08/16 01:40:30 schwarze Exp $ */
2/* 2/*
3 * Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> 3 * Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
4 * 4 *
@@ -17,10 +17,12 @@
17 17
18#include <err.h> 18#include <err.h>
19#include <errno.h> 19#include <errno.h>
20#include <langinfo.h>
20#include <locale.h> 21#include <locale.h>
21#include <pthread.h> 22#include <pthread.h>
22#include <stdlib.h> 23#include <stdlib.h>
23#include <string.h> 24#include <string.h>
25#include <wctype.h>
24 26
25/* Keep in sync with /usr/src/lib/libc/locale/rune.h. */ 27/* Keep in sync with /usr/src/lib/libc/locale/rune.h. */
26#define _LOCALE_NONE (locale_t)0 28#define _LOCALE_NONE (locale_t)0
@@ -89,6 +91,24 @@ TESTFUNC(uselocale, locale_t, "%p", "%p", TOPT_ERR)
89#define FUNCARGS category, locname 91#define FUNCARGS category, locname
90TESTFUNC(setlocale, const char *, "%d, %s", "%s", TOPT_STR) 92TESTFUNC(setlocale, const char *, "%d, %s", "%s", TOPT_STR)
91 93
94#define FUNCPARA nl_item item
95#define FUNCARGS item
96TESTFUNC(nl_langinfo, const char *, "%ld", "%s", TOPT_STR)
97
98#define FUNCPARA nl_item item, locale_t locale
99#define FUNCARGS item, locale
100TESTFUNC(nl_langinfo_l, const char *, "%ld, %p", "%s", TOPT_STR)
101
102#define FUNCPARA wint_t wc
103#define FUNCARGS wc
104TESTFUNC(iswalpha, int, "U+%.4X", "%d", 0)
105TESTFUNC(towupper, wint_t, "U+%.4X", "U+%.4X", 0)
106
107#define FUNCPARA wint_t wc, locale_t locale
108#define FUNCARGS wc, locale
109TESTFUNC(iswalpha_l, int, "U+%.4X, %p", "%d", 0)
110TESTFUNC(towupper_l, wint_t, "U+%.4X, %p", "U+%.4X", 0)
111
92static void 112static void
93_test_MB_CUR_MAX(int line, int ee, size_t ar) 113_test_MB_CUR_MAX(int line, int ee, size_t ar)
94{ 114{
@@ -196,6 +216,27 @@ child_func(void *arg)
196 TEST_R(uselocale, LC_GLOBAL_LOCALE, _LOCALE_UTF8); 216 TEST_R(uselocale, LC_GLOBAL_LOCALE, _LOCALE_UTF8);
197 TEST_R(MB_CUR_MAX, 4); 217 TEST_R(MB_CUR_MAX, 4);
198 TEST_R(uselocale, _LOCALE_UTF8, _LOCALE_NONE); 218 TEST_R(uselocale, _LOCALE_UTF8, _LOCALE_NONE);
219 TEST_R(nl_langinfo, "UTF-8", CODESET);
220 TEST_R(nl_langinfo_l, "UTF-8", CODESET, _LOCALE_UTF8);
221 TEST_R(nl_langinfo_l, "US-ASCII", CODESET, _LOCALE_C);
222 TEST_R(iswalpha, 1, 0x00E9); /* e accent aigu */
223 TEST_R(iswalpha_l, 1, 0x00E9, _LOCALE_UTF8);
224 TEST_R(iswalpha_l, 0, 0x00E9, _LOCALE_C);
225 TEST_R(iswalpha, 1, 0x0153); /* ligature oe */
226 TEST_R(iswalpha_l, 1, 0x0153, _LOCALE_UTF8);
227 TEST_R(iswalpha_l, 0, 0x0153, _LOCALE_C);
228 TEST_R(iswalpha, 0, 0x2205); /* for all */
229 TEST_R(iswalpha_l, 0, 0x2205, _LOCALE_UTF8);
230 TEST_R(iswalpha_l, 0, 0x2205, _LOCALE_C);
231 TEST_R(towupper, 0x00C9, 0x00E9);
232 TEST_R(towupper_l, 0x00C9, 0x00E9, _LOCALE_UTF8);
233 TEST_R(towupper_l, 0x00E9, 0x00E9, _LOCALE_C);
234 TEST_R(towupper, 0x0152, 0x0153);
235 TEST_R(towupper_l, 0x0152, 0x0153, _LOCALE_UTF8);
236 TEST_R(towupper_l, 0x0153, 0x0153, _LOCALE_C);
237 TEST_R(towupper, 0x2205, 0x2205);
238 TEST_R(towupper_l, 0x2205, 0x2205, _LOCALE_UTF8);
239 TEST_R(towupper_l, 0x2205, 0x2205, _LOCALE_C);
199 240
200 /* Test non-ctype newlocale(3). */ 241 /* Test non-ctype newlocale(3). */
201 TEST_R(newlocale, _LOCALE_C, LC_MESSAGES_MASK, "en_US.UTF-8"); 242 TEST_R(newlocale, _LOCALE_C, LC_MESSAGES_MASK, "en_US.UTF-8");