From 5075bb85d7147de586c4e2c0fd6fa200e6af9cb9 Mon Sep 17 00:00:00 2001 From: Leon Arber Date: Thu, 16 Sep 2004 13:12:19 -0500 Subject: [svn-r9268] Purpose: Added tests for polynomial transforms. Platforms tested: sol + eirene Misc. update: --- test/dtransform.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 5 deletions(-) diff --git a/test/dtransform.c b/test/dtransform.c index c12530a..84387df 100644 --- a/test/dtransform.c +++ b/test/dtransform.c @@ -4,14 +4,15 @@ #define COLS 18 int compare_int(int* a, int* b, int tol); -int compare_float(float* a, float* b, float tol); +int compare_float(float* a, float* b, double tol); int main(void) { - hid_t file_id, dxpl_id_f_to_c, dxpl_id_c_to_f, dxpl_id_simple, dset_id_int, dset_id_float, datatype, dataspace; + hid_t file_id, dxpl_id_f_to_c, dxpl_id_c_to_f, dxpl_id_c_to_f_copy, dxpl_id_simple, dxpl_id_polynomial, dxpl_id_polynomial_copy, dset_id_int, dset_id_float, datatype, dataspace; hsize_t dim[2] = {ROWS, COLS}; const char* f_to_c = "(5/9.0)*(x-32)"; const char* c_to_f = "(9/5.0)*x + 32"; + const char* polynomial = "(2+x)* ((x-8)/2)"; const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */ int windchillFint[ROWS][COLS] = { {36, 31, 25, 19, 13, 7, 1, -5, -11, -16, -22, -28, -34, -40, -46, -52, -57, -63 }, @@ -43,6 +44,10 @@ int main(void) {25.0, 17.0, 10.0, 3.0, -4.0, -11.0, -19.0, -26.0, -33.0, -40.0, -48.0, -55.0, -62.0, -69.0, -76.0, -84.0, -91.0, -98.0} }; float windchillFfloatread[ROWS][COLS]; + float polyflres[ROWS][COLS]; + int polyintres[ROWS][COLS]; + float polyflread[ROWS][COLS]; + int polyintread[ROWS][COLS]; int windchillCint[ROWS][COLS]; herr_t err; int row, col; @@ -54,15 +59,30 @@ int main(void) for(col = 0; colint)") + if((err = H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_polynomial, polyintread))<0) TEST_ERROR; + if( (compare_int(*polyintres, *polyintread, 2)) == 0) + { + fprintf(stderr, "ERROR: Conversion failed to match computed data\n"); + TEST_ERROR; + } + else + PASSED(); + + 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( (compare_int(*polyintres, *polyintread, 2)) == 0) + { + fprintf(stderr, "ERROR: Conversion failed to match computed data\n"); + TEST_ERROR; + } + else + PASSED(); + + + 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( (compare_float(*polyflres, *polyflread, 2.0)) == 0) + { + fprintf(stderr, "ERROR: Conversion failed to match computed data\n"); + TEST_ERROR; + } + else + PASSED(); + + + 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; for(row = 0; row