Refactor bug-strtod.c to better test new types.
[platform/upstream/glibc.git] / stdlib / tst-strtod.h
1 /* Common utilities for testing strtod and its derivatives.
2    This file is part of the GNU C Library.
3    Copyright (C) 2016 Free Software Foundation, Inc.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
18
19 #ifndef _TST_STRTOD_H
20 #define _TST_STRTOD_H
21
22 #define FSTRLENMAX 128
23
24 /* Splat n variants of the same test for the various strtod functions.  */
25 #define GEN_TEST_STRTOD_FOREACH(mfunc)            \
26     mfunc (  f,       float, snprintf,  "", f, f) \
27     mfunc (  d,      double, snprintf,  "",  ,  ) \
28     mfunc ( ld, long double, snprintf, "L", L, l)
29 /* The arguments to the generated macros are:
30    FSUF - Function suffix
31    FTYPE - float type
32    FTOSTR - float to string func
33    FTOSTRM - Optional modifier for FTOSTR format
34    LSUF - Literal suffix
35    CSUF - C standardish suffix for many of the math functions
36 */
37
38
39
40 #define STRTOD_TEST_FOREACH(mfunc, ...)   \
41 ({                                        \
42    int result = 0;                        \
43    result |= mfunc ## f  (__VA_ARGS__);   \
44    result |= mfunc ## d  (__VA_ARGS__);   \
45    result |= mfunc ## ld (__VA_ARGS__);   \
46    result;                                \
47 })
48
49
50 #endif