diff options
author | jhendersonHDF <jhenderson@hdfgroup.org> | 2024-03-11 19:39:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-11 19:39:13 (GMT) |
commit | 4279c351f50350ae17c0f76392768fee1d4e2976 (patch) | |
tree | 1dcf4e0fd117a1b73796eefdb8c65dcfc2e03dd6 | |
parent | 8340c4cb1f2d86982fe926f8edfd3f1efb668a55 (diff) | |
download | hdf5-4279c351f50350ae17c0f76392768fee1d4e2976.zip hdf5-4279c351f50350ae17c0f76392768fee1d4e2976.tar.gz hdf5-4279c351f50350ae17c0f76392768fee1d4e2976.tar.bz2 |
Fix up dsets test for some platforms with different long double format (#4114)
-rw-r--r-- | test/dsets.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/test/dsets.c b/test/dsets.c index f5b0f2a..fe04971 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -5877,33 +5877,51 @@ test_floattypes(hid_t file) if (H5Dclose(dataset) < 0) goto error; } -#if 0 + #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE /* long double */ { long double orig_data[2][5] = { - {(long double)1.6081706885101836e+600L, (long double)-255.3209917099448032099170994480, - (long double)1.2677579992621376e-610L, (long double)64568.289448797700289448797700, - (long double)-1.0619721778839084e-750L}, - {(long double)2.1499497833454840991499497833454840e+560L, + {(long double)1.6081706885101836e+300L, (long double)-255.3209917099448032099170994480, + (long double)1.2677579992621376e-310L, (long double)64568.289448797700289448797700, + (long double)-1.0619721778839084e-310L}, + {(long double)2.1499497833454840991499497833454840e+257L, (long double)6.6562295504670740996562295504670740e-3, (long double)-1.5747263393432150995747263393432150, (long double)1.0711093225222612990711093225222612, (long double)-9.8971679387636870998971679387636870e-1}}; long double new_data[2][5]; + size_t old_precision; TESTING(" long double (setup)"); /* Define user-defined quad-precision floating-point type for dataset */ datatype = H5Tcopy(H5T_NATIVE_LDOUBLE); - precision = 128; - if (H5Tset_precision(datatype, precision) < 0) - goto error; - if (H5Tset_fields(datatype, (size_t)127, (size_t)112, (size_t)15, (size_t)0, (size_t)112) < 0) - goto error; - offset = 0; - if (H5Tset_offset(datatype, offset) < 0) + offset = 5; + precision = 123; + if (0 == (old_precision = H5Tget_precision(datatype))) goto error; + if (old_precision < precision) { + /* Increasing precision, call H5Tset_precision first */ + if (H5Tset_precision(datatype, precision) < 0) + goto error; + /* H5Tset_precision may have changed our offset */ + if (H5Tset_offset(datatype, offset) < 0) + goto error; + if (H5Tset_fields(datatype, (size_t)127, (size_t)112, (size_t)15, (size_t)offset, (size_t)107) < + 0) + goto error; + } + else { + /* Decreasing precision, call H5Tset_fields first */ + if (H5Tset_offset(datatype, offset) < 0) + goto error; + if (H5Tset_fields(datatype, (size_t)127, (size_t)112, (size_t)15, (size_t)offset, (size_t)107) < + 0) + goto error; + if (H5Tset_precision(datatype, precision) < 0) + goto error; + } if (H5Tset_size(datatype, (size_t)16) < 0) goto error; if (H5Tset_ebias(datatype, (size_t)255) < 0) @@ -5968,7 +5986,6 @@ test_floattypes(hid_t file) goto error; } #endif -#endif return SUCCEED; |