diff options
author | Allen Byrne <50328838+byrnHDF@users.noreply.github.com> | 2022-03-11 23:02:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-11 23:02:38 (GMT) |
commit | b3e02f8e9a8aa5431a81ef0424caffdf0548c12d (patch) | |
tree | a2cc15bcca7402ed6c4ac5db6c47820567c77b7e | |
parent | 9dc35264c768a9c9869946ab987a1a66f9540c35 (diff) | |
download | hdf5-b3e02f8e9a8aa5431a81ef0424caffdf0548c12d.zip hdf5-b3e02f8e9a8aa5431a81ef0424caffdf0548c12d.tar.gz hdf5-b3e02f8e9a8aa5431a81ef0424caffdf0548c12d.tar.bz2 |
Implemented suggestion in #1381 for dtransform test (#1490)
-rw-r--r-- | c++/test/titerate.cpp | 19 | ||||
-rw-r--r-- | test/dtransform.c | 21 |
2 files changed, 22 insertions, 18 deletions
diff --git a/c++/test/titerate.cpp b/c++/test/titerate.cpp index 17620ca..7fb64c4 100644 --- a/c++/test/titerate.cpp +++ b/c++/test/titerate.cpp @@ -67,7 +67,8 @@ typedef struct { iter_enum command; /* The type of return value */ } iter_info; -int iter_strcmp(const void *s1, const void *s2); +static int iter_strcmp(const void *s1, const void *s2); +static void printelems(const Group &group, const H5std_string &dsname, const H5std_string &atname); /*------------------------------------------------------------------------- * Function: iter_strcmp @@ -75,7 +76,7 @@ int iter_strcmp(const void *s1, const void *s2); * Purpose String comparison routine for qsort *------------------------------------------------------------------------- */ -int +static int iter_strcmp(const void *s1, const void *s2) { return (HDstrcmp(*(const char *const *)s1, *(const char *const *)s2)); @@ -168,8 +169,7 @@ test_iter_group(FileAccPropList &fapl) /* Keep a copy of the dataset names */ lnames[i] = HDstrdup(name); check_values(lnames[i], "HDstrdup returns NULL", __LINE__, __FILE__); - - } /* end for */ + } /* Create a group and named datatype under root group for testing */ Group grp(file.createGroup(GROUP1, 0)); @@ -206,7 +206,7 @@ test_iter_group(FileAccPropList &fapl) // oinfo = root_group.childObjType((hsize_t)i, H5_INDEX_NAME, H5_ITER_INC, "."); // ret = H5Oget_info_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, // H5P_DEFAULT); - } /* end for */ + } // Attempted to iterate with invalid index, should fail try { @@ -352,7 +352,7 @@ test_iter_group(FileAccPropList &fapl) * Purpose Open an attribute and verify that it has a the correct name *------------------------------------------------------------------------- */ -const H5std_string FILE_NAME("titerate.h5"); +const H5std_string FILE_NAME("test_member_access.h5"); const H5std_string GRP_NAME("/Group_A"); const H5std_string FDATASET_NAME("file dset"); const H5std_string GDATASET_NAME("group dset"); @@ -360,7 +360,7 @@ const H5std_string ATTR_NAME("Units"); const H5std_string FATTR_NAME("F attr"); const H5std_string GATTR_NAME("G attr"); const int DIM1 = 2; -void +static void printelems(const Group &group, const H5std_string &dsname, const H5std_string &atname) { try { @@ -397,6 +397,9 @@ test_HDFFV_9920() int attr_data[2] = {100, 200}; hsize_t dims[1] = {DIM1}; + /* Output message about test being performed */ + SUBTEST("Member access"); + try { // Create a new file and a group in it H5File file(FILE_NAME, H5F_ACC_TRUNC); @@ -426,6 +429,7 @@ test_HDFFV_9920() printelems(file, FDATASET_NAME, FATTR_NAME); printelems(gr1, GDATASET_NAME, GATTR_NAME); + PASSED(); } // end of try block // Catch all failures for handling in the same way @@ -474,4 +478,5 @@ extern "C" void cleanup_iterate() { HDremove(FILE_ITERATE.c_str()); + HDremove(FILE_NAME.c_str()); } // cleanup_iterate diff --git a/test/dtransform.c b/test/dtransform.c index 743103f..33cf3b7 100644 --- a/test/dtransform.c +++ b/test/dtransform.c @@ -122,9 +122,8 @@ const int transformData[ROWS][COLS] = {{36, 31, 25, 19, 13, 7, 1, 5, 11, 16, 22, { \ TYPE array[ROWS][COLS]; \ const char *f_to_c = "(5/9.0)*(x-32)"; \ - /* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to \ - * fit into uchar */ \ - const char *utrans = "((x+100)/4)*3"; \ + /* utrans is a transform for char types: numbers are restricted from -128 to 127, fits into char */ \ + const char *utrans = "(x/4+25)*3"; \ \ hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, dset, dset_nn, dt_nn; \ H5T_order_t order; \ @@ -199,6 +198,8 @@ const int transformData[ROWS][COLS] = {{36, 31, 25, 19, 13, 7, 1, 5, 11, 16, 22, COMPARE(TYPE, array, COMPARE_DATA, 2) \ } \ \ + if (H5Dclose(dset_nn) < 0) \ + TEST_ERROR; \ if (H5Dclose(dset) < 0) \ TEST_ERROR; \ if (H5Sclose(dataspace) < 0) \ @@ -209,9 +210,8 @@ const int transformData[ROWS][COLS] = {{36, 31, 25, 19, 13, 7, 1, 5, 11, 16, 22, { \ TYPE array[ROWS][COLS]; \ const char *f_to_c = "(5/9.0)*(x-32)"; \ - /* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to \ - * fit into uchar */ \ - const char *utrans = "((x+100)/4)*3"; \ + /* utrans is a transform for char types: numbers are restricted from -128 to 127, fits into char */ \ + const char *utrans = "(x/4+25)*3"; \ \ hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, cparms, memspace, dset_chunk, filespace; \ hsize_t dim[2] = {ROWS, COLS}; \ @@ -312,7 +312,7 @@ main(void) const char *simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */ const char *polynomial = "(2+x)* ((x-8)/2)"; /* inverses the utrans transform in init_test to get back original array */ - const char *utrans_inv = "(x/3)*4 - 100"; + const char *utrans_inv = "(x/3 - 25)*4"; if ((file_id = H5Fcreate("dtransform.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; @@ -438,9 +438,8 @@ static int init_test(hid_t file_id) { const char *f_to_c = "(5/9.0)*(x-32)"; - /* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to fit - * into uchar */ - const char *utrans = "((x+100)/4)*3"; + /* utrans is a transform for char types: numbers are restricted from -128 to 127, fits into char */ + const char *utrans = "(x/4+25)*3"; hid_t dataspace = -1; hid_t dxpl_id_f_to_c = -1; @@ -467,7 +466,7 @@ init_test(hid_t file_id) if ((dataspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR - TESTING("Intializing test...") + TESTING("Initializing test...") if ((dset_id_int = H5Dcreate2(file_id, "/default_int", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) |