diff options
author | Robb Matzke <matzke@llnl.gov> | 1998-07-03 01:16:22 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1998-07-03 01:16:22 (GMT) |
commit | 203a7329154d957480aa83f8508276197e4738f4 (patch) | |
tree | f752776b0a688b520d7b8b90ed296242b5aad019 /test | |
parent | b81abe336d5ab6498fc6e382822a9f85be1af8e9 (diff) | |
download | hdf5-203a7329154d957480aa83f8508276197e4738f4.zip hdf5-203a7329154d957480aa83f8508276197e4738f4.tar.gz hdf5-203a7329154d957480aa83f8508276197e4738f4.tar.bz2 |
[svn-r446] Changes since 19980702
----------------------
./MANIFEST
Added new files from testpar directory.
./config/commence.in
Removed -D_POSIX_SOURCE because hdf5 uses a couple of
non-Posix things when certain debugging flags are switched on.
Diffstat (limited to 'test')
-rw-r--r-- | test/dtypes.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/test/dtypes.c b/test/dtypes.c index 455fd3b..083e73f 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -8,6 +8,7 @@ * Purpose: Tests the data type interface (H5T) */ #include <assert.h> +#include <float.h> #include <hdf5.h> #include <math.h> #include <signal.h> @@ -695,7 +696,7 @@ static int test_conv_flt_1 (const char *name, hid_t src, hid_t dst) { flt_t src_type, dst_type; /*data types */ - const size_t ntests=10; /*number of tests */ + const size_t ntests=5; /*number of tests */ const size_t nelmts=200000; /*num values per test */ const size_t max_fails=8; /*max number of failures*/ size_t fails_all_tests=0; /*number of failures */ @@ -799,7 +800,14 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst) } } else if (FLT_DOUBLE==src_type) { if (FLT_FLOAT==dst_type) { - hw_f = ((double*)saved)[j]; + /* Watch out for that FPE on overflow! */ + if (((double*)saved)[j] > FLT_MAX) { + hw_f = FLT_MAX; + } else if (((double*)saved)[j] < -FLT_MAX) { + hw_f = -FLT_MAX; + } else { + hw_f = ((double*)saved)[j]; + } hw = (unsigned char*)&hw_f; } else if (FLT_DOUBLE==dst_type) { hw_d = ((double*)saved)[j]; @@ -810,10 +818,24 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst) } } else { if (FLT_FLOAT==dst_type) { - hw_f = ((long double*)saved)[j]; + /* Watch out for that FPE on overflow! */ + if (((long double*)saved)[j] > FLT_MAX) { + hw_f = FLT_MAX; + } else if (((long double*)saved)[j] < -FLT_MAX) { + hw_f = -FLT_MAX; + } else { + hw_f = ((long double*)saved)[j]; + } hw = (unsigned char*)&hw_f; } else if (FLT_DOUBLE==dst_type) { - hw_d = ((long double*)saved)[j]; + /* Watch out for that FPE! */ + if (((long double*)saved)[j] > DBL_MAX) { + hw_d = DBL_MAX; + } else if (((long double*)saved)[j] < -DBL_MAX) { + hw_d = -DBL_MAX; + } else { + hw_d = ((long double*)saved)[j]; + } hw = (unsigned char*)&hw_d; } else { hw_ld = ((long double*)saved)[j]; @@ -993,7 +1015,7 @@ main(void) nerrors += test_named ()<0 ? 1 : 0; nerrors += test_conv_int ()<0 ? 1 : 0; -#ifndef LATER +#ifdef LATER /* * NOT READY FOR TESTING YET BECAUSE SOME SYSTEMS GENERATE A SIGFPE WHEN * AN OVERFLOW OCCURS CASTING A DOUBLE TO A FLOAT. |