Changes that show the right way to iterate over enums.

This commit is contained in:
Dana Robinson 2019-03-21 10:09:55 -07:00
parent 97cdcc47e4
commit 85e2214d55

View File

@ -7627,7 +7627,10 @@ test_versionbounds(void)
H5F_t *filep = NULL; /* Pointer to internal structure of a file */ H5F_t *filep = NULL; /* Pointer to internal structure of a file */
H5T_t *dtypep = NULL; /* Pointer to internal structure of a datatype */ H5T_t *dtypep = NULL; /* Pointer to internal structure of a datatype */
hsize_t arr_dim[] = {ARRAY_LEN}; /* Length of the array */ hsize_t arr_dim[] = {ARRAY_LEN}; /* Length of the array */
int i, j; /* Indices for iterating over versions */
H5F_libver_t low, high; /* File format bounds */ H5F_libver_t low, high; /* File format bounds */
H5F_libver_t versions[] = {H5F_LIBVER_EARLIEST, H5F_LIBVER_V18, H5F_LIBVER_V110};
int versions_count = 3; /* Number of version bounds in the array */
unsigned highest_version; /* Highest version in nested datatypes */ unsigned highest_version; /* Highest version in nested datatypes */
color_t enum_val; /* Enum type index */ color_t enum_val; /* Enum type index */
herr_t ret = 0; /* Generic return value */ herr_t ret = 0; /* Generic return value */
@ -7691,19 +7694,19 @@ test_versionbounds(void)
ret = H5Tenum_insert(enum_type, "RED", &enum_val); ret = H5Tenum_insert(enum_type, "RED", &enum_val);
if (ret < 0) TEST_ERROR if (ret < 0) TEST_ERROR
H5_INC_ENUM(color_t, enum_val); enum_val = E1_GREEN;
ret = H5Tenum_insert(enum_type, "GREEN", &enum_val); ret = H5Tenum_insert(enum_type, "GREEN", &enum_val);
if (ret < 0) TEST_ERROR if (ret < 0) TEST_ERROR
H5_INC_ENUM(color_t, enum_val); enum_val = E1_BLUE;
ret = H5Tenum_insert(enum_type, "BLUE", &enum_val); ret = H5Tenum_insert(enum_type, "BLUE", &enum_val);
if (ret < 0) TEST_ERROR if (ret < 0) TEST_ERROR
H5_INC_ENUM(color_t, enum_val); enum_val = E1_ORANGE;
ret = H5Tenum_insert(enum_type, "ORANGE", &enum_val); ret = H5Tenum_insert(enum_type, "ORANGE", &enum_val);
if (ret < 0) TEST_ERROR if (ret < 0) TEST_ERROR
H5_INC_ENUM(color_t, enum_val); enum_val = E1_YELLOW;
ret = H5Tenum_insert(enum_type, "YELLOW", &enum_val); ret = H5Tenum_insert(enum_type, "YELLOW", &enum_val);
if (ret < 0) TEST_ERROR if (ret < 0) TEST_ERROR
@ -7727,8 +7730,9 @@ test_versionbounds(void)
skipping invalid combinations */ skipping invalid combinations */
/* Create the file, create and write to a dataset with compound datatype */ /* Create the file, create and write to a dataset with compound datatype */
/* Verify the dataset's datatype and its members */ /* Verify the dataset's datatype and its members */
for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; H5_INC_ENUM(H5F_libver_t, low)) { for(i = 0, low = versions[i]; i < versions_count; i++) {
for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; H5_INC_ENUM(H5F_libver_t, high)) {
for(j = 0, high = versions[j]; j < versions_count; j++) {
/* Set version bounds */ /* Set version bounds */
H5E_BEGIN_TRY { H5E_BEGIN_TRY {