@@ -69,7 +69,7 @@ locale_test_suite := tst_iswalnum tst_iswalpha tst_iswcntrl \
tst_wcspbrk tst_wcsrtombs tst_wcsspn tst_wcsstr \
tst_wcstod tst_wcstok tst_wcstombs tst_wcswidth \
tst_wcsxfrm tst_wctob tst_wctomb tst_wctrans \
- tst_wctype tst_wcwidth
+ tst_wctype tst_wcwidth tst_wcsfrom
tests = $(locale_test_suite) tst-digits tst-setlocale bug-iconv-trans \
tst-leaks tst-mbswcs1 tst-mbswcs2 tst-mbswcs3 tst-mbswcs4 tst-mbswcs5 \
new file mode 100644
@@ -0,0 +1,82 @@
+/*
+ * TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY
+ *
+ * FILE: dat_wcsfrom.c
+ *
+ * int wcsfromf (wchar_t *__restrict dest, size_t size,
+ * const char * format, float f)
+ * int wcsfromd (wchar_t *__restrict dest, size_t size,
+ * const char * format, double f)
+ * int wcsfroml (wchar_t *__restrict dest, size_t size,
+ * const char * format, long double f)
+ */
+
+
+TST_WCSFROM tst_wcsfrom_loc [] = {
+ {
+ { Twcsfrom, TST_LOC_de },
+ {
+ {
+ /*01*/
+ /*I*/
+ {0.0},
+ /*E*/
+ {0, 0, 0, { 0x0030,0x002C,0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,0x0000 },
+ { 0x0030,0x0000 },
+ { 0x0030,0x0000 }},
+ },
+ {
+ /*02*/
+ /*I*/
+ {123.45645},
+ /*E*/
+ {0, 0, 0, { 0x0031,0x0032,0x0033,0x002C,0x0034,0x0035,0x0036,0x0034,0x0035,0x0031,0x0000 },
+ { 0x0031,0x0032,0x0033,0x002C,0x0034,0x0035,0x0036,0x0000 },
+ { 0x0031,0x0032,0x0033,0x002C,0x0034,0x0035,0x0036,0x0000 }},
+ },
+ { .is_last = 1 }
+ }
+ },
+ {
+ { Twcsfrom, TST_LOC_enUS },
+ {
+ {
+ /*01*/
+ /*I*/
+ {0.0},
+ /*E*/
+ {0, 0, 0, { 0x0030,0x002E,0x0030,0x0030,0x0030,0x0030,0x0030,0x0030,0x0000 },
+ { 0x0030,0x0000 },
+ { 0x0030,0x0000 }},
+ },
+ {
+ /*02*/
+ /*I*/
+ {123.45645},
+ /*E*/
+ {0, 0, 0, { 0x0031,0x0032,0x0033,0x002E,0x0034,0x0035,0x0036,0x0034,0x0035,0x0031,0x0000 },
+ { 0x0031,0x0032,0x0033,0x002E,0x0034,0x0035,0x0036,0x0000 },
+ { 0x0031,0x0032,0x0033,0x002E,0x0034,0x0035,0x0036,0x0000 }},
+ },
+ { .is_last = 1 }
+ }
+ },
+ {
+ { Twcsfrom, TST_LOC_eucJP },
+ {
+ {
+ /*01*/
+ /*I*/
+ {123.45645},
+ /*E*/
+ {0, 0, 0, { 0x0031,0x0032,0x0033,0x002E,0x0034,0x0035,0x0036,0x0034,0x0035,0x0031,0x0000 },
+ { 0x0031,0x0032,0x0033,0x002E,0x0034,0x0035,0x0036,0x0000 },
+ { 0x0031,0x0032,0x0033,0x002E,0x0034,0x0035,0x0036,0x0000 }},
+ },
+ { .is_last = 1 }
+ }
+ },
+ {
+ { Twcsfrom, TST_LOC_end }
+ }
+};
@@ -52,6 +52,7 @@
#define Twctrans 48
#define Twctype 49
#define Twcwidth 50
+#define Twcsfrom 51
/* Name of each test. */
#define S_ISWALNUM "iswalnum"
@@ -156,5 +157,6 @@ extern int tst_wctomb (FILE *, int);
extern int tst_wctrans (FILE *, int);
extern int tst_wctype (FILE *, int);
extern int tst_wcwidth (FILE *, int);
+extern int tst_wcsfrom (FILE *, int);
#endif /* TGN_FUNCDEF_H */
@@ -575,6 +575,31 @@ TEX_WCSTOD_REC;
TMD_RECHEAD (WCSTOD);
+/*----------------------------------------------------------------------*/
+/* WCSFROM: int wcsfromf (wchar_t * dest, size_t size, */
+/* const char * format, float f) */
+/* WCSFROM: int wcsfromd (wchar_t * dest, size_t size, */
+/* const char * format, double d) */
+/* WCSFROM: int wcsfroml (wchar_t * dest, size_t size, */
+/* const char * format, long double l) */
+/*----------------------------------------------------------------------*/
+
+typedef struct
+{
+ float val;
+}
+TIN_WCSFROM_REC;
+
+typedef struct
+{
+ TMD_ERRET (int);
+ wchar_t f[WCSSIZE];
+ wchar_t d[WCSSIZE];
+ wchar_t l[WCSSIZE];
+}
+TEX_WCSFROM_REC;
+
+TMD_RECHEAD (WCSFROM);
/*----------------------------------------------------------------------*/
/* WCSTOK: wchar_t *wcstok (wchar_t *ws, const wchar_t *dlm, */
new file mode 100644
@@ -0,0 +1,75 @@
+/*
+ * int wcsfromf (wchar_t * dest, size_t size,
+ * const char * format, float f)
+ * int wcsfromd (wchar_t * dest, size_t size,
+ * const char * format, double d)
+ * int wcsfroml (wchar_t * dest, size_t size,
+ * const char * format, long double l)
+*/
+
+#define TST_FUNCTION wcsfrom
+
+#include "tsp_common.c"
+#include "dat_wcsfrom.c"
+
+/* Splat n variants of the same test for the various strfrom functions. */
+#define GEN_TEST_STRFROM_FOREACH(mfunc, ...) \
+ mfunc ( f, float, "%f", ##__VA_ARGS__) \
+ mfunc ( d, double, "%g", ##__VA_ARGS__) \
+ mfunc ( l, long double, "%g", ##__VA_ARGS__)
+/* The arguments to the generated macros are:
+ * FSUF - Function suffix
+ * FTYPE - float type
+ * FMT - format specifier
+ */
+
+#define STRFROM_TEST_FOREACH(mfunc, ...) \
+({ \
+ int result = 0; \
+ result |= mfunc ## f (__VA_ARGS__); \
+ result |= mfunc ## d (__VA_ARGS__); \
+ result |= mfunc ## l (__VA_ARGS__); \
+ result; \
+})
+
+#define TEST_STRFROM(FSUF, FTYPE, FMT) \
+static int \
+test_strfrom ## FSUF (FILE *fp) \
+{ \
+ wchar_t buf[WCSSIZE]; \
+ TST_DECL_VARS (int); \
+ TST_DO_TEST (wcsfrom) \
+ { \
+ TST_HEAD_LOCALE (wcsfrom, "wcsfrom"# FSUF); \
+ TST_DO_REC (wcsfrom) \
+ { \
+ TST_GET_ERRET (wcsfrom); \
+ TST_CLEAR_ERRNO; \
+ ret_exp = 0; \
+ TST_SAVE_ERRNO; \
+ ret = wcsfrom ## FSUF (buf, WCSSIZE, FMT, \
+ TST_INPUT (wcsfrom).val); \
+ TST_IF_RETURN ("wcsfrom"# FSUF) \
+ { \
+ }; \
+ ret = wcscmp (buf, TST_EXPECT (wcsfrom).FSUF); \
+ if (ret != 0) \
+ { \
+ err_count++; \
+ Result (C_FAILURE, "wcsfrom"# FSUF, CASE_3, \
+ "return value is wrong"); \
+ } \
+ else \
+ Result (C_SUCCESS, "wcsfrom"# FSUF, CASE_3, MS_PASSED); \
+ } \
+ } \
+ return err_count; \
+}
+
+GEN_TEST_STRFROM_FOREACH (TEST_STRFROM)
+
+int
+tst_wcsfrom (FILE *fp, int debug_flg)
+{
+ return STRFROM_TEST_FOREACH (test_strfrom, fp);
+}
@@ -79,7 +79,7 @@ tests := tst-strtol tst-strtod testmb testrand testsort testdiv \
tst-tininess tst-strtod-underflow tst-tls-atexit \
tst-setcontext3 tst-tls-atexit-nodelete \
tst-strtol-locale tst-strtod-nan-locale tst-strfmon_l \
- tst-quick_exit tst-thread-quick_exit
+ tst-quick_exit tst-thread-quick_exit tst-strfrom
tests-static := tst-secure-getenv
ifeq ($(have-cxx-thread_local),yes)
CFLAGS-tst-quick_exit.o = -std=c++11
@@ -161,6 +161,7 @@ $(objpfx)tst-strtod5.out: $(gen-locales)
$(objpfx)tst-strtol-locale.out: $(gen-locales)
$(objpfx)tst-strtod-nan-locale.out: $(gen-locales)
$(objpfx)tst-strfmon_l.out: $(gen-locales)
+$(objpfx)tst-strfrom.out: $(gen-locales)
endif
# Testdir has to be named stdlib and needs to be writable
@@ -22,8 +22,12 @@
#include <string.h>
#include "tst-strtod.h"
+#define _CONCAT(a, b) a ## b
+#define CONCAT(a, b) _CONCAT (a, b)
+#define FNPFX str
+#define STRFROM(x) CONCAT (CONCAT (FNPFX, from), x)
-#define TEST_STRTOD(FSUF, FTYPE, FTOSTR, FTOSTRM, LSUF, CSUF) \
+#define TEST_STRTOD(FSUF, FTYPE, FTOSTR, LSUF, CSUF) \
static int \
test_strto ## FSUF (void) \
{ \
@@ -45,8 +49,8 @@ test_strto ## FSUF (void) \
{ \
char fstr[FSTRLENMAX]; \
char fcntstr[FSTRLENMAX]; \
- FTOSTR (fstr, sizeof (fstr), "%" FTOSTRM "g", f); \
- FTOSTR (fcntstr, sizeof (fstr), "%" FTOSTRM "g", (FTYPE) cnt); \
+ STRFROM(FTOSTR) (fstr, sizeof (fstr), "%g", f); \
+ STRFROM(FTOSTR) (fcntstr, sizeof (fstr), "%g", (FTYPE) cnt); \
printf ("strto" #FSUF "(\"%s\") " \
"failed for cnt == %d (%s instead of %s)\n", \
buf, cnt, fstr, fcntstr); \
@@ -12,7 +12,7 @@ static const char *tests[] =
};
#define ntests (sizeof (tests) / sizeof (tests[0]))
-#define TEST_STRTOD(FSUF, FTYPE, FTOSTR, FTOSTRM, LSUF, CSUF) \
+#define TEST_STRTOD(FSUF, FTYPE, FTOSTR, LSUF, CSUF) \
static int \
test_strto ## FSUF (void) \
{ \
new file mode 100644
@@ -0,0 +1,173 @@
+/* Tests for strfromf, strfromd, strfroml functions.
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <float.h>
+#include <math.h>
+#include <locale/localeinfo.h>
+
+#include "tst-strtod.h"
+
+#ifndef WIDE
+# define STR_CMP strcmp
+# define STR_TO_LD strtold
+# define CHAR_T char
+# define PRINT printf
+# define L_(Str) Str
+# define S "%s"
+# define FNPFX str
+#endif
+
+#define STRX(x) #x
+#define STR(x) STRX (x)
+#define FNPFXS STR (FNPFX)
+
+#define _CONCAT(a, b) a ## b
+#define CONCAT(a, b) _CONCAT (a, b)
+#define STRFROM(x) CONCAT (CONCAT (FNPFX, from), x)
+
+struct ltest
+{
+ const CHAR_T *expect;
+ double val;
+ const char *fmt;
+ int size;
+ int rc;
+};
+static const struct ltest ltests[] = {
+ {L_("12345.3"), 12345.345, "%g", 50, 7},
+ {L_("1.000001"), 0x80000Ap-23, "%f", 50, 8},
+ {L_("inf"), HUGE_VAL, "%f", 50, 3},
+ {L_("-inf"), -HUGE_VAL, "%g", 50, 4},
+ {L_("12.345"), 12.345, "%g", 50, 6},
+ {L_("1.2345e+20"), 12.345e19, "%g", 50, 10},
+ {L_("-1e+08"), -.1e+9, "%g", 50, 6},
+ {L_("0.125000"), .125, "%f", 50, 8},
+ {L_("100000"), 1e5, "%g", 50, 6},
+ {L_("9.999"), 9.999, "%.3f", 50, 5},
+ {L_("0.000000"), 0.0, "%f", 50, 8},
+ {L_("0"), 0.0, "%g", 50, 1},
+ {L_("8.000000"), 0x10p-1, "%f", 50, 8},
+ {L_("8"), 0x10p-1, "%g", 50, 1},
+ {L_("INF"), DBL_MAX * DBL_MAX, "%F", 50, 3},
+ {L_("-INF"), -DBL_MAX * DBL_MAX, "%G", 50, 4},
+ {L_("9.900000"), 9.9, "%f", 50, 8},
+ {L_("9.900"), 9.9, "%.3f", 50, 5},
+ {L_("1"), 10.000e-1, "%.f", 50, 1},
+ {L_("2"), 200.000e-2, "%g", 50, 1},
+ {L_("9.912346"), 9.91234567812345678, "%f", 50, 8},
+ {L_("7.987654e+01"), 79.87654321, "%e", 50, 12},
+ {L_("7.987654E+01"), 79.87654321, "%E", 50, 12},
+ {L_("7.988e+01"), 79.87654321, "%.3e", 50, 9},
+ {L_("7.987654e+01"), 79.87654321, "%.6e", 50, 12},
+ {L_("79.8765"), 79.87654321, "%g", 50, 7},
+ {L_("79.8765"), 79.87654321, "%G", 50, 7},
+ {L_("5.070602e+30"), 0x1p102, "%e", 50, 12},
+ {L_("1.038459e+34"), 0x1000p101, "%e", 50, 12},
+ {L_("2.097152e+06"), 0x2p020, "%e", 50, 12},
+ {L_("1.000000e+38"), 1e+38, "%e", 50, 12},
+ {L_("1.000000e+38"), 1e38, "%e", 50, 12},
+ {L_("1.000000e-37"), 1e-37, "%e", 50, 12},
+ {L_("1.000000e-37"), 0.00000001e-29, "%e", 50, 12},
+ {L_("1.000000e-37"), 1.000000e-37, "%e", 50, 12},
+ {L_("3.761582e-37"), 0x1p-121, "%e", 50, 12},
+ {L_("3.761582e-37"), 0x0.0001p-105, "%e", 50, 12},
+ {L_("5.900000e-16"), 5.9e-16, "%e", 50, 12},
+ {L_("1.000001"), 0x80000Ap-23, "%f", 50, 8},
+ {L_("inf"), HUGE_VAL, "%f", 50, 3},
+ {L_("-INF"), -HUGE_VAL, "%G", 50, 4},
+ {L_("1.2345e+20"), 12.345e19, "%g", 50, 10},
+ {L_("0.125000"), .125, "%f", 50, 8},
+ {L_("100000"), 1e5, "%g", 50, 6},
+ {L_("0x1.8p-11"), 0x0.0030p+0, "%a", 50, 9},
+ {L_("0x1p-10"), 0x0.0040p+0, "%a", 50, 7},
+ {L_("0x1.08p+56"), 0x1.08p56, "%a", 50, 10},
+ {L_("0x1p+61"), 0x1p61, "%a", 50, 7},
+ {L_("0x1.0001p+61"), 0x1.0001p61, "%a", 50, 12},
+ {L_("0x1.4p+3"), 10.0, "%a", 50, 8},
+ {L_("0X1.4P+3"), 10.0, "%A", 50, 8},
+ {L_("nan"), NAN, "%e", 50, 3},
+ {L_("-NAN"), -NAN, "%G", 50, 4},
+ {L_("1.79769e+38"), 1.79769e+38, "%g", 50, 11},
+ {L_("nan"), __builtin_nan (""), "%f", 50, 3},
+ {L_("NAN"), __builtin_nans (""), "%G", 50, 3},
+#ifndef WIDE
+ {L_("9.1"), 9.123456, "%.5f", 4, 7},
+#else
+ {L_("9.1"), 9.123456, "%.5f", 4, -1},
+#endif
+ {NULL, 0, "%f", 50, 0},
+};
+
+#define NTESTS (sizeof (tests) / sizeof (tests[0]))
+
+#define TEST_STRFROM(STRTOF, FTYPE, FTOSTR, LSUF, CSUF) \
+static int \
+test_ ## STRTOF (void) \
+{ \
+ CHAR_T buf[50]; \
+ const struct ltest *lt; \
+ int status = 0; \
+ int rc = 0, rc1 = 0; \
+ for (lt = ltests; lt->expect != NULL; ++lt) \
+ { \
+ rc = STRFROM(FTOSTR)(buf, lt->size, lt->fmt, lt->val); \
+ if (strcmp(lt->fmt, "%a") == 0 || strcmp(lt->fmt, "%A") == 0) \
+ rc1 = (STR_TO_LD(lt->expect, NULL) == STR_TO_LD(buf, NULL)) \
+ ? 0 : 1; \
+ else \
+ rc1 = (STR_CMP(buf, lt->expect) != 0) || (rc != lt->rc); \
+ if (rc1) \
+ { \
+ PRINT(L_(""FNPFXS "from" #FTOSTR ": got " S "(%d), expected " \
+ S "(%d)\n"), buf, rc, lt->expect, lt->rc); \
+ status++; \
+ } \
+ } \
+ return status; \
+}
+
+GEN_TEST_STRTOD_FOREACH (TEST_STRFROM)
+
+static int
+test_locale (const char *locale)
+{
+ PRINT (L_("Testing in locale: %s\n"), locale);
+ if (setlocale (LC_CTYPE, locale) == NULL)
+ {
+ PRINT (L_("Cannot set locale %s\n"), locale);
+ }
+ return STRTOD_TEST_FOREACH (test_);
+}
+static int
+do_test (void)
+{
+ int result = 0;
+ result += test_locale ("C");
+ result += test_locale ("de_DE.UTF-8");
+ result += test_locale ("en_US.ISO-8859-1");
+ result += test_locale ("en_US.UTF-8");
+ result += test_locale ("tr_TR.ISO-8859-9");
+ result += test_locale ("tr_TR.UTF-8");
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
@@ -47,6 +47,7 @@
#define CONCAT(a, b) _CONCAT (a, b)
#define STRTO(x) CONCAT (CONCAT (FNPFX, to), x)
+#define STRFROM(x) CONCAT (CONCAT (FNPFX, from), x)
#if LDBL_MANT_DIG == 106 && LDBL_MAX_EXP == 1024
/* This is a stupid hack for IBM long double. This test ignores
@@ -58,11 +59,11 @@
/* Generator to create an FTYPE member variabled named FSUF
used to populate struct member variables. */
-#define FTYPE_MEMBER(FSUF, FTYPE, FTOSTR, FTOSTRM, LSUF, CSUF) \
+#define FTYPE_MEMBER(FSUF, FTYPE, FTOSTR, LSUF, CSUF) \
FTYPE FSUF;
/* Likewise, but each member is of type bool. */
-#define BOOL_MEMBER(FSUF, FTYPE, FTOSTR, FTOSTRM, LSUF, CSUF) \
+#define BOOL_MEMBER(FSUF, FTYPE, FTOSTR, LSUF, CSUF) \
bool FSUF;
#define STRUCT_FOREACH_FLOAT_FTYPE GEN_TEST_STRTOD_FOREACH (FTYPE_MEMBER)
@@ -96,13 +97,13 @@
/* long double is special, and handled above. */
/* Selector for expected result field of a given type. */
-#define _ENTRY(FSUF, FTYPE, FTOSTR, FTOSTRM, LSUF, CSUF, ...) \
+#define _ENTRY(FSUF, FTYPE, FTOSTR, LSUF, CSUF, ...) \
CONCAT (CHOOSE_ ## FSUF (__VA_ARGS__), LSUF),
#define ENTRY(...) \
GEN_TEST_STRTOD_FOREACH (_ENTRY, __VA_ARGS__)
/* Selector for boolean exact tag of expected results. */
-#define _XNTRY(FSUF, FTYPE, FTOSTR, FTOSTRM, LSUF, CSUF, ...) \
+#define _XNTRY(FSUF, FTYPE, FTOSTR, LSUF, CSUF, ...) \
CHOOSE_ ## FSUF (__VA_ARGS__),
#define XNTRY(...) \
GEN_TEST_STRTOD_FOREACH (_XNTRY, __VA_ARGS__)
@@ -157,7 +158,7 @@ struct test {
#define STR(x) STRX (x)
#define FNPFXS STR (FNPFX)
-#define GEN_ONE_TEST(FSUF, FTYPE, FTOSTR, FTOSTRM, LSUF, CSUF) \
+#define GEN_ONE_TEST(FSUF, FTYPE, FTOSTR, LSUF, CSUF) \
{ \
FTYPE f = STRTO (FSUF) (s, NULL); \
if (f != expected->FSUF \
@@ -166,9 +167,8 @@ struct test {
{ \
CHAR efstr[FSTRLENMAX]; \
CHAR fstr[FSTRLENMAX]; \
- FTOSTR (efstr, FSTRLENMAX, L_("%") L_(FTOSTRM) L_("a"), \
- expected->FSUF); \
- FTOSTR (fstr, FSTRLENMAX, L_("%") L_(FTOSTRM) L_("a"), f);\
+ STRFROM(FTOSTR)(efstr, FSTRLENMAX, "%a", expected->FSUF); \
+ STRFROM(FTOSTR)(fstr, FSTRLENMAX, "%a", f); \
printf (FNPFXS "to" #FSUF " (" STRM ") returned " STRM \
" not " STRM " (%s)\n", \
s, fstr, efstr, mode_name); \
@@ -23,14 +23,13 @@
/* Splat n variants of the same test for the various strtod functions. */
#define GEN_TEST_STRTOD_FOREACH(mfunc, ...) \
- mfunc ( f, float, snprintf, "", f, f, ##__VA_ARGS__) \
- mfunc ( d, double, snprintf, "", , , ##__VA_ARGS__) \
- mfunc ( ld, long double, snprintf, "L", L, l, ##__VA_ARGS__)
+ mfunc ( f, float, f, f, f, ##__VA_ARGS__) \
+ mfunc ( d, double, d, , , ##__VA_ARGS__) \
+ mfunc ( ld, long double, l, L, l, ##__VA_ARGS__)
/* The arguments to the generated macros are:
FSUF - Function suffix
FTYPE - float type
- FTOSTR - float to string func
- FTOSTRM - Optional modifier for FTOSTR format
+ FTOSTR - float to string func suffix
LSUF - Literal suffix
CSUF - C standardish suffix for many of the math functions
*/
@@ -5,7 +5,7 @@
#include "tst-strtod.h"
-#define TEST_STRTOD(FSUF, FTYPE, FTOSTR, FTOSTRM, LSUF, CSUF) \
+#define TEST_STRTOD(FSUF, FTYPE, FTOSTR, LSUF, CSUF) \
static int \
test_strto ## FSUF (const char str[]) \
{ \
@@ -51,7 +51,7 @@ strop-tests := wcscmp wcsncmp wmemcmp wcslen wcschr wcsrchr wcscpy wcsnlen \
tests := tst-wcstof wcsmbs-tst1 tst-wcsnlen tst-btowc tst-mbrtowc \
tst-wcrtomb tst-wcpncpy tst-mbsrtowcs tst-wchar-h tst-mbrtowc2 \
tst-c16c32-1 wcsatcliff tst-wcstol-locale tst-wcstod-nan-locale \
- tst-wcstod-round \
+ tst-wcstod-round tst-wcsfrom \
$(addprefix test-,$(strop-tests))
include ../Rules
@@ -69,6 +69,7 @@ $(objpfx)tst-wcrtomb.out: $(gen-locales)
$(objpfx)wcsmbs-tst1.out: $(gen-locales)
$(objpfx)tst-wcstol-locale.out: $(gen-locales)
$(objpfx)tst-wcstod-nan-locale.out: $(gen-locales)
+$(objpfx)tst-wcsfrom.out: $(gen-locales)
endif
$(objpfx)tst-wcstod-round: $(libm)
new file mode 100644
@@ -0,0 +1,30 @@
+/* Test wcsfromf, wcsfromd and wcsfroml functions.
+ Copyright (C) 2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <wchar.h>
+
+#define WIDE 1
+#define L_(str) L ## str
+#define FNPFX wcs
+#define STR_TO_LD wcstold
+#define STR_CMP wcscmp
+#define CHAR_T wchar_t
+#define PRINT wprintf
+#define S "%ls"
+
+#include "../stdlib/tst-strfrom.c"
From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com> This patch adds tests for strfrom and wcsfrom functions. 2016-08-23 Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com> * localedata/Makefile (locale_test_suite): Add tst_wcsfrom. * localedata/tests-mbwc/dat_wcsfrom.c: New file. * localedata/tests-mbwc/tgn_funcdef.h (Twcsfrom): New macro. (tst_wcsfrom): Declare. * localedata/tests-mbwc/tst_types.h: New struct TEX_WCSFROM_REC and TIN_WCSFROM_REC. * localedata/tests-mbwc/tst_wcsfrom.c: New file. * stdlib/Makefile (tests): Add tst-strfrom. * stdlib/tst-strfrom.c: New file. * stdlib/bug-strtod.c: Refactor based on GEN_TEST_STRTOD_FOREACH. * stdlib/bug-strtod2.c: Likewise. * stdlib/tst-strtod-round-skeleton.c: Likewise. * stdlib/tst-strtod6.c: Likewise. * stdlib/tst-strtod.h (GEN_TEST_STRTOD_FOREACH): New field for strfrom function suffix. * wcsmbs/Makefile (tests): Add tst-wcsfrom. * wcsmbs/tst-wcsfrom.c: New file. --- localedata/Makefile | 2 +- localedata/tests-mbwc/dat_wcsfrom.c | 82 +++++++++++++++++ localedata/tests-mbwc/tgn_funcdef.h | 2 + localedata/tests-mbwc/tst_types.h | 25 ++++++ localedata/tests-mbwc/tst_wcsfrom.c | 75 ++++++++++++++++ stdlib/Makefile | 3 +- stdlib/bug-strtod.c | 10 ++- stdlib/bug-strtod2.c | 2 +- stdlib/tst-strfrom.c | 173 ++++++++++++++++++++++++++++++++++++ stdlib/tst-strtod-round-skeleton.c | 16 ++-- stdlib/tst-strtod.h | 9 +- stdlib/tst-strtod6.c | 2 +- wcsmbs/Makefile | 3 +- wcsmbs/tst-wcsfrom.c | 30 +++++++ 14 files changed, 413 insertions(+), 21 deletions(-) create mode 100644 localedata/tests-mbwc/dat_wcsfrom.c create mode 100644 localedata/tests-mbwc/tst_wcsfrom.c create mode 100644 stdlib/tst-strfrom.c create mode 100644 wcsmbs/tst-wcsfrom.c