Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed Jan 22, 2024
1 parent 181c431 commit e8d91eb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 46 deletions.
70 changes: 32 additions & 38 deletions test/API/H5_api_dataset_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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] =
Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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] =
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 1 addition & 8 deletions test/API/H5_api_dataset_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit e8d91eb

Please sign in to comment.