From e8d91eb9bc35814a61dd7271f35b13ca4220e1f0 Mon Sep 17 00:00:00 2001 From: Matthew Larson Date: Mon, 22 Jan 2024 15:53:05 -0600 Subject: [PATCH] Cleanup --- test/API/H5_api_dataset_test.c | 70 ++++++++++++++++------------------ test/API/H5_api_dataset_test.h | 9 +---- 2 files changed, 33 insertions(+), 46 deletions(-) diff --git a/test/API/H5_api_dataset_test.c b/test/API/H5_api_dataset_test.c index 17788ac1b36..b2910f25b9e 100644 --- a/test/API/H5_api_dataset_test.c +++ b/test/API/H5_api_dataset_test.c @@ -1275,10 +1275,10 @@ test_create_dataset_predefined_types(void) hid_t fspace_id = H5I_INVALID_HID; hid_t dset_id = H5I_INVALID_HID; hid_t predefined_type_test_table[] = {H5T_STD_U8LE, H5T_STD_U8BE, H5T_STD_I8LE, H5T_STD_I8BE, - H5T_STD_U16LE, H5T_STD_U16BE, H5T_STD_I16LE, H5T_STD_I16BE, - H5T_STD_U32LE, H5T_STD_U32BE, H5T_STD_I32LE, H5T_STD_I32BE, - H5T_STD_U64LE, H5T_STD_U64BE, H5T_STD_I64LE, H5T_STD_I64BE, - H5T_IEEE_F32LE, H5T_IEEE_F32BE, H5T_IEEE_F64LE, H5T_IEEE_F64BE}; + H5T_STD_U16LE, H5T_STD_U16BE, H5T_STD_I16LE, H5T_STD_I16BE, + H5T_STD_U32LE, H5T_STD_U32BE, H5T_STD_I32LE, H5T_STD_I32BE, + H5T_STD_U64LE, H5T_STD_U64BE, H5T_STD_I64LE, H5T_STD_I64BE, + H5T_IEEE_F32LE, H5T_IEEE_F32BE, H5T_IEEE_F64LE, H5T_IEEE_F64BE}; TESTING("dataset creation with predefined datatypes"); @@ -2554,7 +2554,7 @@ test_create_dataset_creation_properties(void) for (i = 0; i < num_elems; i++) { val = (double *)(read_buf) + i; - if (!(VL_DBL_REL_EQUAL(*(double *)val, DATASET_FILL_VALUE_TEST_DOUBLE_FILL_VALUE, + if (!(H5_DBL_REL_EQUAL(*(double *)val, DATASET_FILL_VALUE_TEST_DOUBLE_FILL_VALUE, 0.0000001))) { H5_FAILED(); printf(" incorrect value read from dataset"); @@ -3129,17 +3129,18 @@ test_create_dataset_creation_properties(void) { if (read_buf) { free(read_buf); - - H5Sclose(compact_fspace_id); - H5Sclose(fspace_id); - H5Tclose(compact_dtype); - H5Tclose(dset_dtype); - H5Dclose(dset_id); - H5Pclose(dcpl_id); - H5Gclose(group_id); - H5Gclose(container_group); - H5Fclose(file_id); } + + H5Sclose(compact_fspace_id); + H5Sclose(fspace_id); + H5Tclose(compact_dtype); + H5Tclose(dset_dtype); + H5Dclose(dset_id); + H5Pclose(dcpl_id); + H5Gclose(group_id); + H5Gclose(container_group); + H5Fclose(file_id); + H5E_END_TRY return 1; @@ -4907,8 +4908,8 @@ test_read_multi_dataset_small_all(void) for (i = 0; i < DATASET_MULTI_COUNT; i++) { char dset_name[DSET_NAME_BUF_SIZE]; - if (DSET_NAME_BUF_SIZE <= (unsigned int)snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", - DATASET_SMALL_READ_TEST_ALL_DSET_NAME, i, '\0')) + if (DSET_NAME_BUF_SIZE <= snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", + DATASET_SMALL_READ_TEST_ALL_DSET_NAME, i, '\0')) TEST_ERROR; if ((dset_id_arr[i] = H5Dcreate2(group_id, dset_name, DATASET_SMALL_READ_TEST_ALL_DSET_DTYPE, @@ -5052,9 +5053,8 @@ test_read_multi_dataset_small_hyperslab(void) for (i = 0; i < DATASET_MULTI_COUNT; i++) { char dset_name[DSET_NAME_BUF_SIZE]; - if (DSET_NAME_BUF_SIZE <= (unsigned int)snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", - DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_NAME, i, - '\0')) + if (DSET_NAME_BUF_SIZE <= snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", + DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_NAME, i, '\0')) TEST_ERROR; if ((dset_id_arr[i] = H5Dcreate2(group_id, dset_name, DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_DTYPE, @@ -5206,9 +5206,8 @@ test_read_multi_dataset_small_point_selection(void) for (i = 0; i < DATASET_MULTI_COUNT; i++) { char dset_name[DSET_NAME_BUF_SIZE]; - if (DSET_NAME_BUF_SIZE <= (unsigned int)snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", - DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_NAME, i, - '\0')) + if (DSET_NAME_BUF_SIZE <= snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", + DATASET_SMALL_READ_TEST_HYPERSLAB_DSET_NAME, i, '\0')) TEST_ERROR; if ((dset_id_arr[i] = @@ -6977,9 +6976,8 @@ test_write_multi_dataset_small_all(void) for (i = 0; i < DATASET_MULTI_COUNT; i++) { char dset_name[DSET_NAME_BUF_SIZE]; - if (DSET_NAME_BUF_SIZE <= (unsigned int)snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", - DATASET_SMALL_WRITE_MULTI_TEST_ALL_DSET_NAME, i, - '\0')) + if (DSET_NAME_BUF_SIZE <= snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", + DATASET_SMALL_WRITE_MULTI_TEST_ALL_DSET_NAME, i, '\0')) TEST_ERROR; if ((dset_id_arr[i] = H5Dcreate2(group_id, dset_name, DATASET_SMALL_WRITE_TEST_ALL_DSET_DTYPE, @@ -7000,9 +6998,8 @@ test_write_multi_dataset_small_all(void) for (i = 0; i < DATASET_MULTI_COUNT; i++) { char dset_name[DSET_NAME_BUF_SIZE]; - if (DSET_NAME_BUF_SIZE <= (unsigned int)snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", - DATASET_SMALL_WRITE_MULTI_TEST_ALL_DSET_NAME, i, - '\0')) + if (DSET_NAME_BUF_SIZE <= snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", + DATASET_SMALL_WRITE_MULTI_TEST_ALL_DSET_NAME, i, '\0')) TEST_ERROR; if ((dset_id_arr[i] = H5Dopen2(group_id, dset_name, H5P_DEFAULT)) < 0) { @@ -7152,9 +7149,8 @@ test_write_multi_dataset_small_hyperslab(void) for (i = 0; i < DATASET_MULTI_COUNT; i++) { char dset_name[DSET_NAME_BUF_SIZE]; - if (DSET_NAME_BUF_SIZE <= (unsigned int)snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", - DATASET_SMALL_WRITE_MULTI_TEST_HYPERSLAB_DSET_NAME, - i, '\0')) + if (DSET_NAME_BUF_SIZE <= snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", + DATASET_SMALL_WRITE_MULTI_TEST_HYPERSLAB_DSET_NAME, i, '\0')) TEST_ERROR; if ((dset_id_arr[i] = H5Dcreate2(group_id, dset_name, DATASET_SMALL_WRITE_TEST_HYPERSLAB_DSET_DTYPE, @@ -7312,9 +7308,8 @@ test_write_multi_dataset_small_point_selection(void) for (i = 0; i < DATASET_MULTI_COUNT; i++) { char dset_name[DSET_NAME_BUF_SIZE]; - if (DSET_NAME_BUF_SIZE <= - (unsigned int)snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", - DATASET_SMALL_WRITE_MULTI_TEST_POINT_SELECTION_DSET_NAME, i, '\0')) + if (DSET_NAME_BUF_SIZE <= snprintf(dset_name, DSET_NAME_BUF_SIZE, "%s%zu%c", + DATASET_SMALL_WRITE_MULTI_TEST_POINT_SELECTION_DSET_NAME, i, '\0')) TEST_ERROR; if ((dset_id_arr[i] = @@ -7485,9 +7480,8 @@ test_write_multi_dataset_data_verification(void) data_size *= DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPESIZE; for (i = 0; i < DATASET_MULTI_COUNT; i++) { - if (DSET_NAME_BUF_SIZE <= (unsigned int)snprintf(dset_names[i], DSET_NAME_BUF_SIZE, "%s%zu%c", - DATASET_DATA_VERIFY_WRITE_MULTI_TEST_DSET_NAME, i, - '\0')) + if (DSET_NAME_BUF_SIZE <= snprintf(dset_names[i], DSET_NAME_BUF_SIZE, "%s%zu%c", + DATASET_DATA_VERIFY_WRITE_MULTI_TEST_DSET_NAME, i, '\0')) TEST_ERROR; if ((dset_id_arr[i] = H5Dcreate2(group_id, dset_names[i], DATASET_DATA_VERIFY_WRITE_TEST_DSET_DTYPE, diff --git a/test/API/H5_api_dataset_test.h b/test/API/H5_api_dataset_test.h index 1bdf7aa455d..086dc1c6dc4 100644 --- a/test/API/H5_api_dataset_test.h +++ b/test/API/H5_api_dataset_test.h @@ -23,13 +23,6 @@ int H5_api_dataset_test(void); * * ************************************************/ -/* Check if the relative difference is smaller than a - * predefined value M. See if two values are relatively equal. - * It's the developer's responsibility not to pass in the value 0, which - * may cause the equation to fail. - */ -#define VL_DBL_REL_EQUAL(X, Y, M) (fabs(((Y) - (X)) / (X)) < (M)) - #define DATASET_CREATE_UNDER_ROOT_DSET_NAME "/dset_under_root" #define DATASET_CREATE_UNDER_ROOT_SPACE_RANK 2 @@ -67,7 +60,7 @@ int H5_api_dataset_test(void); #define ZERO_DIM_DSET_TEST_DSET_NAME "zero_dim_dset" #define DATASET_MANY_CREATE_GROUP_NAME "group_for_many_datasets" -#define DSET_NAME_BUF_SIZE 64u +#define DSET_NAME_BUF_SIZE 64 #define DATASET_NUMB 100u #define DATASET_SHAPE_TEST_DSET_BASE_NAME "dataset_shape_test"