From 92d8414f73c02601f8b5e0ae2332165b7974723e Mon Sep 17 00:00:00 2001 From: Jordan Henderson Date: Mon, 11 Mar 2024 11:28:50 -0500 Subject: [PATCH] Fix up dsets test for some platforms with different long double format --- test/dsets.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/test/dsets.c b/test/dsets.c index f5b0f2a326f..fe04971847c 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) @@ -5967,7 +5985,6 @@ test_floattypes(hid_t file) if (H5Dclose(dataset) < 0) goto error; } -#endif #endif return SUCCEED;