diff options
Diffstat (limited to 'test/dtransform.c')
-rw-r--r-- | test/dtransform.c | 147 |
1 files changed, 66 insertions, 81 deletions
diff --git a/test/dtransform.c b/test/dtransform.c index ebe90bb..6dc5eb2 100644 --- a/test/dtransform.c +++ b/test/dtransform.c @@ -98,22 +98,22 @@ const int transformData[ROWS][COLS] = if(SIGNED) \ { \ if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER))<0) TEST_ERROR; \ - if((err= H5Pset_data_transform(dxpl_id_f_to_c, f_to_c))<0) TEST_ERROR; \ - if((err = H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat))<0) TEST_ERROR; \ - if((err = H5Pclose(dxpl_id_f_to_c))<0) TEST_ERROR; \ + if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c)<0) TEST_ERROR; \ + if(H5Dwrite(dset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat)<0) TEST_ERROR; \ + if(H5Pclose(dxpl_id_f_to_c)<0) TEST_ERROR; \ } \ else \ { \ if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER))<0) TEST_ERROR; \ - if((err= H5Pset_data_transform(dxpl_id_utrans, utrans))<0) TEST_ERROR; \ - if((err = H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_utrans, transformData))<0) TEST_ERROR; \ - if((err = H5Pclose(dxpl_id_utrans))<0) TEST_ERROR; \ + if(H5Pset_data_transform(dxpl_id_utrans, utrans)<0) TEST_ERROR; \ + if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_utrans, transformData)<0) TEST_ERROR; \ + if(H5Pclose(dxpl_id_utrans)<0) TEST_ERROR; \ } \ \ \ TESTING("contiguous, no data type conversion ("TEST_STR"->"TEST_STR")") \ \ - if((err = H5Dread(dset, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array))<0) TEST_ERROR; \ + if(H5Dread(dset, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array)<0) TEST_ERROR; \ if(SIGNED) \ COMPARE(TYPE, array, COMPARE_DATA, 2) \ else \ @@ -123,15 +123,15 @@ const int transformData[ROWS][COLS] = { \ TESTING("contiguous, with type conversion (float->"TEST_STR")") \ \ - if((err = H5Dread(dset_id_float, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array))<0) TEST_ERROR; \ + if(H5Dread(dset_id_float, HDF_TYPE, H5S_ALL, H5S_ALL, XFORM, array)<0) TEST_ERROR; \ if(SIGNED) \ COMPARE(TYPE, array, COMPARE_DATA, 2) \ else \ UCOMPARE(TYPE, array, COMPARE_DATA, 4) \ } \ \ - if((err = H5Dclose(dset))<0) TEST_ERROR; \ - if((err = H5Sclose(dataspace))<0) TEST_ERROR; \ + if(H5Dclose(dset)<0) TEST_ERROR; \ + if(H5Sclose(dataspace)<0) TEST_ERROR; \ } #define TEST_TYPE_CHUNK(XFORM, TYPE, HDF_TYPE, TEST_STR, COMPARE_DATA, SIGNED) \ @@ -143,38 +143,38 @@ const int transformData[ROWS][COLS] = \ hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, cparms, memspace, dset_chunk, filespace; \ hsize_t dim[2] = {ROWS, COLS}; \ - hssize_t offset[2] = {0, 0}; \ + hsize_t offset[2] = {0, 0}; \ \ \ if((dataspace = H5Screate_simple(2, dim, NULL))<0) TEST_ERROR; \ \ cparms = H5Pcreate(H5P_DATASET_CREATE); \ - if( (err = H5Pset_chunk(cparms, 2, dim)) < 0) TEST_ERROR; \ + if(H5Pset_chunk(cparms, 2, dim) < 0) TEST_ERROR; \ \ if((dset_chunk = H5Dcreate(file_id, "/transformtest_chunk_"TEST_STR, HDF_TYPE, dataspace, cparms))<0) TEST_ERROR; \ filespace = H5Dget_space (dset_chunk); \ memspace = H5Screate_simple(2, dim, NULL); \ - if((err = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL)) < 0) TEST_ERROR; \ + if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 0) TEST_ERROR; \ \ if(SIGNED) \ { \ if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER))<0) TEST_ERROR; \ - if((err= H5Pset_data_transform(dxpl_id_f_to_c, f_to_c))<0) TEST_ERROR; \ - if((err = H5Dwrite(dset_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat))<0) TEST_ERROR; \ - if((err = H5Pclose(dxpl_id_f_to_c))<0) TEST_ERROR; \ + if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c)<0) TEST_ERROR; \ + if(H5Dwrite(dset_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat)<0) TEST_ERROR; \ + if(H5Pclose(dxpl_id_f_to_c)<0) TEST_ERROR; \ } \ else \ { \ if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER))<0) TEST_ERROR; \ - if((err= H5Pset_data_transform(dxpl_id_utrans, utrans))<0) TEST_ERROR; \ - if((err = H5Dwrite(dset_chunk, H5T_NATIVE_INT, dataspace, filespace, dxpl_id_utrans, transformData))<0) TEST_ERROR; \ - if((err = H5Pclose(dxpl_id_utrans))<0) TEST_ERROR; \ + if(H5Pset_data_transform(dxpl_id_utrans, utrans)<0) TEST_ERROR; \ + if(H5Dwrite(dset_chunk, H5T_NATIVE_INT, dataspace, filespace, dxpl_id_utrans, transformData)<0) TEST_ERROR; \ + if(H5Pclose(dxpl_id_utrans)<0) TEST_ERROR; \ } \ \ \ TESTING("chunked, no data type conversion ("TEST_STR"->"TEST_STR")") \ \ - if((err = H5Dread(dset_chunk, HDF_TYPE, memspace, filespace, XFORM, array))<0) TEST_ERROR; \ + if(H5Dread(dset_chunk, HDF_TYPE, memspace, filespace, XFORM, array)<0) TEST_ERROR; \ if(SIGNED) \ COMPARE(TYPE, array, COMPARE_DATA, 2) \ else \ @@ -184,7 +184,7 @@ const int transformData[ROWS][COLS] = { \ TESTING("chunked, with type conversion (float->"TEST_STR")") \ \ - if((err = H5Dread(dset_id_float_chunk, HDF_TYPE, memspace, filespace, XFORM, array))<0) TEST_ERROR; \ + if(H5Dread(dset_id_float_chunk, HDF_TYPE, memspace, filespace, XFORM, array)<0) TEST_ERROR; \ if(SIGNED) \ COMPARE(TYPE, array, COMPARE_DATA, 2) \ else \ @@ -193,13 +193,13 @@ const int transformData[ROWS][COLS] = \ \ \ - if((err = H5Dclose(dset_chunk))<0) TEST_ERROR; \ - if((err = H5Sclose(dataspace))<0) TEST_ERROR; \ + if(H5Dclose(dset_chunk)<0) TEST_ERROR; \ + if(H5Sclose(dataspace)<0) TEST_ERROR; \ } #define INVALID_SET_TEST(TRANSFORM) \ { \ - if((err = H5Pset_data_transform(dxpl_id, TRANSFORM))<0) \ + if(H5Pset_data_transform(dxpl_id, TRANSFORM)<0) \ { \ PASSED(); \ } \ @@ -221,23 +221,21 @@ int main(void) /* inverses the utrans transform in init_test to get back original array */ const char* utrans_inv = "(x/3)*4 - 100"; - herr_t err; - if((dxpl_id_c_to_f = H5Pcreate(H5P_DATASET_XFER))<0) TEST_ERROR; if((dxpl_id_simple = H5Pcreate(H5P_DATASET_XFER))<0) TEST_ERROR; if((dxpl_id_utrans_inv = H5Pcreate(H5P_DATASET_XFER))<0) TEST_ERROR; if((dxpl_id_polynomial = H5Pcreate(H5P_DATASET_XFER))<0) TEST_ERROR; - if((err = H5Pset_data_transform(dxpl_id_c_to_f, c_to_f))<0) TEST_ERROR; - if((err = H5Pset_data_transform(dxpl_id_polynomial, polynomial))<0) TEST_ERROR; - if((err = H5Pset_data_transform(dxpl_id_simple, simple))<0) TEST_ERROR; - if((err = H5Pset_data_transform(dxpl_id_utrans_inv, utrans_inv))<0) TEST_ERROR; + if(H5Pset_data_transform(dxpl_id_c_to_f, c_to_f)<0) TEST_ERROR; + if(H5Pset_data_transform(dxpl_id_polynomial, polynomial)<0) TEST_ERROR; + if(H5Pset_data_transform(dxpl_id_simple, simple)<0) TEST_ERROR; + if(H5Pset_data_transform(dxpl_id_utrans_inv, utrans_inv)<0) TEST_ERROR; if((dxpl_id_polynomial_copy = H5Pcopy(dxpl_id_polynomial)) < 0) TEST_ERROR; if((dxpl_id_c_to_f_copy = H5Pcopy(dxpl_id_c_to_f)) < 0) TEST_ERROR; /* Run all the tests */ - if((err = init_test(&file_id)) < 0) TEST_ERROR; - if((err = test_set()) < 0) TEST_ERROR; + if(init_test(&file_id) < 0) TEST_ERROR; + if(test_set() < 0) TEST_ERROR; TEST_TYPE_CONTIG(dxpl_id_utrans_inv, char, H5T_NATIVE_CHAR, "char", transformData, 0); TEST_TYPE_CONTIG(dxpl_id_utrans_inv, unsigned char, H5T_NATIVE_UCHAR, "uchar", transformData, 0); @@ -273,23 +271,23 @@ int main(void) TEST_TYPE_CHUNK(dxpl_id_c_to_f, double, H5T_NATIVE_DOUBLE, "double", windchillFfloat, 1); TEST_TYPE_CHUNK(dxpl_id_c_to_f, long double, H5T_NATIVE_LDOUBLE, "ldouble", windchillFfloat, 1); - if((err = test_copy(dxpl_id_c_to_f_copy, dxpl_id_polynomial_copy)) < 0) TEST_ERROR; - if((err = test_trivial(dxpl_id_simple)) < 0) TEST_ERROR; - if((err = test_poly(dxpl_id_polynomial)) < 0) TEST_ERROR; - if((err = test_getset(dxpl_id_c_to_f)) < 0) TEST_ERROR; + if(test_copy(dxpl_id_c_to_f_copy, dxpl_id_polynomial_copy) < 0) TEST_ERROR; + if(test_trivial(dxpl_id_simple) < 0) TEST_ERROR; + if(test_poly(dxpl_id_polynomial) < 0) TEST_ERROR; + if(test_getset(dxpl_id_c_to_f) < 0) TEST_ERROR; /* Close the objects we opened/created */ - if((err = H5Dclose(dset_id_int))<0) TEST_ERROR; - if((err = H5Dclose(dset_id_int_chunk))<0) TEST_ERROR; - if((err = H5Dclose(dset_id_float))<0) TEST_ERROR; - if((err = H5Dclose(dset_id_float_chunk))<0) TEST_ERROR; - if((err = H5Fclose(file_id))<0) TEST_ERROR; - if((err = H5Pclose(dxpl_id_c_to_f))<0) TEST_ERROR; - if((err = H5Pclose(dxpl_id_c_to_f_copy))<0) TEST_ERROR; - if((err = H5Pclose(dxpl_id_polynomial))<0) TEST_ERROR; - if((err = H5Pclose(dxpl_id_polynomial_copy))<0) TEST_ERROR; - if((err = H5Pclose(dxpl_id_simple))<0) TEST_ERROR; - if((err = H5Pclose(dxpl_id_utrans_inv))<0) TEST_ERROR; + if(H5Dclose(dset_id_int)<0) TEST_ERROR; + if(H5Dclose(dset_id_int_chunk)<0) TEST_ERROR; + if(H5Dclose(dset_id_float)<0) TEST_ERROR; + if(H5Dclose(dset_id_float_chunk)<0) TEST_ERROR; + if(H5Fclose(file_id)<0) TEST_ERROR; + if(H5Pclose(dxpl_id_c_to_f)<0) TEST_ERROR; + if(H5Pclose(dxpl_id_c_to_f_copy)<0) TEST_ERROR; + if(H5Pclose(dxpl_id_polynomial)<0) TEST_ERROR; + if(H5Pclose(dxpl_id_polynomial_copy)<0) TEST_ERROR; + if(H5Pclose(dxpl_id_simple)<0) TEST_ERROR; + if(H5Pclose(dxpl_id_utrans_inv)<0) TEST_ERROR; return 0; @@ -304,50 +302,47 @@ int init_test(hid_t* file_id) /* 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"; - herr_t err; - hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, cparms, filespace, memspace; + hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, cparms, filespace; hsize_t dim[2] = {ROWS, COLS}; - hssize_t offset[2] = {0, 0}; + hsize_t offset[2] = {0, 0}; if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER))<0) TEST_ERROR; if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER))<0) TEST_ERROR; - if((err= H5Pset_data_transform(dxpl_id_f_to_c, f_to_c))<0) TEST_ERROR; - if((err= H5Pset_data_transform(dxpl_id_utrans, utrans))<0) TEST_ERROR; + if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c)<0) TEST_ERROR; + if(H5Pset_data_transform(dxpl_id_utrans, utrans)<0) TEST_ERROR; if((*file_id = H5Fcreate("dtransform.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0) TEST_ERROR; cparms = H5Pcreate(H5P_DATASET_CREATE); - err = H5Pset_chunk(cparms, 2, dim); + if(H5Pset_chunk(cparms, 2, dim)<0) TEST_ERROR; - memspace = H5Screate_simple(2, dim, NULL); - if((dataspace = H5Screate_simple(2, dim, NULL))<0) TEST_ERROR; TESTING("Intializing test...") if((dset_id_int = H5Dcreate(*file_id, "/default_int", H5T_NATIVE_INT, dataspace, H5P_DEFAULT))<0) TEST_ERROR; - if((err = H5Dwrite(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat))<0) TEST_ERROR; + if(H5Dwrite(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat)<0) TEST_ERROR; if((dset_id_float = H5Dcreate(*file_id, "/default_float", H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT))<0) TEST_ERROR; - if((err = H5Dwrite(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat))<0) TEST_ERROR; + if(H5Dwrite(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat)<0) TEST_ERROR; if((dset_id_int_chunk = H5Dcreate(*file_id, "/default_chunk_int", H5T_NATIVE_INT, dataspace, cparms))<0) TEST_ERROR; filespace = H5Dget_space (dset_id_int_chunk); - if((err = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL)) < 0) TEST_ERROR; - if((err = H5Dwrite(dset_id_int_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat))<0) TEST_ERROR; + if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 0) TEST_ERROR; + if(H5Dwrite(dset_id_int_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat)<0) TEST_ERROR; if((dset_id_float_chunk = H5Dcreate(*file_id, "/default_chunk_float", H5T_NATIVE_FLOAT, dataspace, cparms))<0) TEST_ERROR; - if((err = H5Dwrite(dset_id_float_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat))<0) TEST_ERROR; + if(H5Dwrite(dset_id_float_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat)<0) TEST_ERROR; PASSED(); - if((err = H5Pclose(dxpl_id_f_to_c))<0) TEST_ERROR; - if((err = H5Pclose(dxpl_id_utrans))<0) TEST_ERROR; - if((err = H5Sclose(dataspace))<0) TEST_ERROR; + if(H5Pclose(dxpl_id_f_to_c)<0) TEST_ERROR; + if(H5Pclose(dxpl_id_utrans)<0) TEST_ERROR; + if(H5Sclose(dataspace)<0) TEST_ERROR; return 0; error: @@ -360,8 +355,6 @@ int test_poly(const hid_t dxpl_id_polynomial) int polyintread[ROWS][COLS]; float polyflread[ROWS][COLS]; int windchillC; - - herr_t err; int row, col; for(row = 0; row<ROWS; row++) @@ -374,7 +367,7 @@ int test_poly(const hid_t dxpl_id_polynomial) } TESTING("data transform, polynomial transform (int->float)") - if((err = H5Dread(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_polynomial, polyflread))<0) TEST_ERROR; + if(H5Dread(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_polynomial, polyflread)<0) TEST_ERROR; COMPARE(float, polyflread, polyflres, 2.0) @@ -388,7 +381,7 @@ int test_poly(const hid_t dxpl_id_polynomial) } TESTING("data transform, polynomial transform (float->int)") - if((err = H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_polynomial, polyintread))<0) TEST_ERROR; + if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_polynomial, polyintread)<0) TEST_ERROR; COMPARE(int, polyintread, polyflres, 4) return 0; @@ -403,9 +396,6 @@ int test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_co float polyflres[ROWS][COLS]; int polyintread[ROWS][COLS]; int windchillFintread[ROWS][COLS]; - - herr_t err; - int row, col; for(row = 0; row<ROWS; row++) @@ -419,11 +409,11 @@ int test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_co TESTING("data transform, linear transform w/ copied property") - if((err = H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f_copy, windchillFintread))<0) TEST_ERROR; + if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f_copy, windchillFintread)<0) TEST_ERROR; COMPARE(int, windchillFintread, windchillFfloat, 2) TESTING("data transform, polynomial transform w/ copied property") - if((err = H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_polynomial_copy, polyintread))<0) TEST_ERROR; + if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_polynomial_copy, polyintread)<0) TEST_ERROR; COMPARE(int, polyintread, polyflres, 2) return 0; @@ -436,12 +426,10 @@ int test_trivial(const hid_t dxpl_id_simple) { float windchillFfloatread[ROWS][COLS]; int windchillFintread[ROWS][COLS]; - - herr_t err; int row, col; TESTING("data transform, trivial transform, without type conversion") - if((err = H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_simple, windchillFfloatread))<0) TEST_ERROR; + if(H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_simple, windchillFfloatread)<0) TEST_ERROR; for(row = 0; row<ROWS; row++) { for(col = 0; col<COLS; col++) @@ -457,7 +445,7 @@ int test_trivial(const hid_t dxpl_id_simple) PASSED(); TESTING("data transform, trivial transform, with type conversion") - if((err = H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_simple, windchillFintread))<0) TEST_ERROR; + if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_simple, windchillFintread)<0) TEST_ERROR; for(row = 0; row<ROWS; row++) { for(col = 0; col<COLS; col++) @@ -479,10 +467,8 @@ error: int test_getset(const hid_t dxpl_id_c_to_f) { - herr_t err; int row, col; float windchillFfloatread[ROWS][COLS]; - const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */ const char* c_to_f = "(9/5.0)*x + 32"; char* ptrgetTest = HDmalloc(HDstrlen(simple)+1); @@ -498,10 +484,10 @@ int test_getset(const hid_t dxpl_id_c_to_f) else PASSED(); - if((err = H5Pset_data_transform(dxpl_id_c_to_f, simple))<0) TEST_ERROR; + if(H5Pset_data_transform(dxpl_id_c_to_f, simple)<0) TEST_ERROR; TESTING("data transform, read after reseting of transform property") - if((err = H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f, windchillFfloatread))<0) TEST_ERROR; + if(H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f, windchillFfloatread)<0) TEST_ERROR; for(row = 0; row<ROWS; row++) { for(col = 0; col<COLS; col++) @@ -544,7 +530,6 @@ error: int test_set(void) { hid_t dxpl_id; - herr_t err; H5E_auto_stack_t func; const char* str = "(9/5.0)*x + 32"; char* ptrgetTest = malloc(strlen(str)+1); |