diff options
author | Bruno Haible <bruno@clisp.org> | 2023-03-25 19:31:14 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2023-03-25 19:31:14 +0100 |
commit | fdae921011d0233db99799edbf4a858596265392 (patch) | |
tree | 0b28a07b1ccd2108ff6670ae0350b4890f1831e9 /tests/test-float.c | |
parent | 40dc98731c3fb4b114a6aee75918f2b64dca3550 (diff) | |
download | gnulib-fdae921011d0233db99799edbf4a858596265392.tar.gz |
Make some header file tests a bit stronger.
* tests/test-float.c: Include fpucw.h and macros.h only after checking
the macros.
* tests/test-glob-h.c: Include macros.h only after checking the types
and macros.
* tests/test-inttypes.c: Don't include <stddef.h>.
* tests/test-math.c: Include <limits.h> and macros.h only after checking
the types and macros.
* tests/test-stddef.c: Include <limits.h> only after checking the types
and macros.
* tests/test-sys_select.c: Include signature.h only after checking the
types.
* tests/test-sys_socket.c: Include <errno.h> only after checking the
types and macros.
* tests/test-wctype-h.c: Include macros.h only after checking the types.
Diffstat (limited to 'tests/test-float.c')
-rw-r--r-- | tests/test-float.c | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/tests/test-float.c b/tests/test-float.c index 315c3d6610..07c3ad1cf4 100644 --- a/tests/test-float.c +++ b/tests/test-float.c @@ -20,12 +20,48 @@ #include <float.h> -#include "fpucw.h" -#include "macros.h" - /* Check that FLT_RADIX is a constant expression. */ int a[] = { FLT_RADIX }; +/* ----------------------- Check macros for 'float' ----------------------- */ + +/* Check that the FLT_* macros expand to constant expressions. */ +int fb[] = + { + FLT_MANT_DIG, FLT_MIN_EXP, FLT_MAX_EXP, + FLT_DIG, FLT_MIN_10_EXP, FLT_MAX_10_EXP + }; +float fc[] = { FLT_EPSILON, FLT_MIN, FLT_MAX }; + +/* ----------------------- Check macros for 'double' ----------------------- */ + +/* Check that the DBL_* macros expand to constant expressions. */ +int db[] = + { + DBL_MANT_DIG, DBL_MIN_EXP, DBL_MAX_EXP, + DBL_DIG, DBL_MIN_10_EXP, DBL_MAX_10_EXP + }; +double dc[] = { DBL_EPSILON, DBL_MIN, DBL_MAX }; + +/* -------------------- Check macros for 'long double' -------------------- */ + +/* Check that the LDBL_* macros expand to constant expressions. */ +int lb[] = + { + LDBL_MANT_DIG, LDBL_MIN_EXP, LDBL_MAX_EXP, + LDBL_DIG, LDBL_MIN_10_EXP, LDBL_MAX_10_EXP + }; +long double lc1 = LDBL_EPSILON; +long double lc2 = LDBL_MIN; +#if 0 /* LDBL_MAX is not a constant expression on some platforms. */ +long double lc3 = LDBL_MAX; +#endif + +/* ------------------------------------------------------------------------- */ + +#include "fpucw.h" +#include "macros.h" + #if FLT_RADIX == 2 /* Return 2^n. */ @@ -117,14 +153,6 @@ pow2l (int n) /* ----------------------- Check macros for 'float' ----------------------- */ -/* Check that the FLT_* macros expand to constant expressions. */ -int fb[] = - { - FLT_MANT_DIG, FLT_MIN_EXP, FLT_MAX_EXP, - FLT_DIG, FLT_MIN_10_EXP, FLT_MAX_10_EXP - }; -float fc[] = { FLT_EPSILON, FLT_MIN, FLT_MAX }; - static void test_float (void) { @@ -196,14 +224,6 @@ test_float (void) /* ----------------------- Check macros for 'double' ----------------------- */ -/* Check that the DBL_* macros expand to constant expressions. */ -int db[] = - { - DBL_MANT_DIG, DBL_MIN_EXP, DBL_MAX_EXP, - DBL_DIG, DBL_MIN_10_EXP, DBL_MAX_10_EXP - }; -double dc[] = { DBL_EPSILON, DBL_MIN, DBL_MAX }; - static void test_double (void) { @@ -275,18 +295,6 @@ test_double (void) /* -------------------- Check macros for 'long double' -------------------- */ -/* Check that the LDBL_* macros expand to constant expressions. */ -int lb[] = - { - LDBL_MANT_DIG, LDBL_MIN_EXP, LDBL_MAX_EXP, - LDBL_DIG, LDBL_MIN_10_EXP, LDBL_MAX_10_EXP - }; -long double lc1 = LDBL_EPSILON; -long double lc2 = LDBL_MIN; -#if 0 /* LDBL_MAX is not a constant expression on some platforms. */ -long double lc3 = LDBL_MAX; -#endif - static void test_long_double (void) { |