summaryrefslogtreecommitdiffstats
path: root/test/dtransform.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2005-08-13 20:53:35 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2005-08-13 20:53:35 (GMT)
commit6b45f5172ccb4311e0be9ae15da3758abb6b0e67 (patch)
tree5a7a112fe7a8a98c6fecb45b513789d15962eb3d /test/dtransform.c
parent6562465a2c2a58cfbc2f47bf60bb538f7a783933 (diff)
downloadhdf5-6b45f5172ccb4311e0be9ae15da3758abb6b0e67.zip
hdf5-6b45f5172ccb4311e0be9ae15da3758abb6b0e67.tar.gz
hdf5-6b45f5172ccb4311e0be9ae15da3758abb6b0e67.tar.bz2
[svn-r11245] Purpose:
Code cleanup Description: Trim trailing whitespace, which is making 'diff'ing the two branches difficult. Solution: Ran this script in each directory: foreach f (*.[ch] *.cpp) sed 's/[[:blank:]]*$//' $f > sed.out && mv sed.out $f end Platforms tested: FreeBSD 4.11 (sleipnir) Too minor to require h5committest
Diffstat (limited to 'test/dtransform.c')
-rw-r--r--test/dtransform.c108
1 files changed, 54 insertions, 54 deletions
diff --git a/test/dtransform.c b/test/dtransform.c
index 2c09c76..085014b 100644
--- a/test/dtransform.c
+++ b/test/dtransform.c
@@ -18,22 +18,22 @@ hid_t dset_id_int_chunk;
hid_t dset_id_float_chunk;
-const float windchillFfloat[ROWS][COLS] =
+const float windchillFfloat[ROWS][COLS] =
{ {36.0, 31.0, 25.0, 19.0, 13.0, 7.0, 1.0, -5.0, -11.0, -16.0, -22.0, -28.0, -34.0, -40.0, -46.0, -52.0, -57.0, -63.0 },
- {34.0, 27.0, 21.0, 15.0, 9.0, 3.0, -4.0, -10.0, -16.0, -22.0, -28.0, -35.0, -41.0, -47.0, -53.0, -59.0, -66.0, -72.0 } ,
- {32.0, 25.0, 19.0, 13.0, 6.0, 0.0, -7.0, -13.0, -19.0, -26.0, -32.0, -39.0, -45.0, -51.0, -58.0, -64.0, -71.0, -77.0 },
- {30.0, 24.0, 17.0, 11.0, 4.0, -2.0, -9.0, -15.0, -22.0, -29.0, -35.0, -42.0, -48.0, -55.0, -61.0, -68.0, -74.0, -81.0 },
- {29.0, 23.0, 16.0, 9.0, 3.0, -4.0, -11.0, -17.0, -24.0, -31.0, -37.0, -44.0, -51.0, -58.0, -64.0, -71.0, -78.0, -84.0 },
- {28.0, 22.0, 15.0, 8.0, 1.0, -5.0, -12.0, -19.0, -26.0, -33.0, -39.0, -46.0, -53.0, -60.0, -67.0, -73.0, -80.0, -87.0 },
- {28.0, 21.0, 14.0, 7.0, 0.0, -7.0, -14.0, -21.0, -27.0, -34.0, -41.0, -48.0, -55.0, -62.0, -69.0, -76.0, -82.0, -89.0 },
- {27.0, 20.0, 13.0, 6.0, -1.0, -8.0, -15.0, -22.0, -29.0, -36.0, -43.0, -50.0, -57.0, -64.0, -71.0, -78.0, -84.0, -91.0 },
+ {34.0, 27.0, 21.0, 15.0, 9.0, 3.0, -4.0, -10.0, -16.0, -22.0, -28.0, -35.0, -41.0, -47.0, -53.0, -59.0, -66.0, -72.0 } ,
+ {32.0, 25.0, 19.0, 13.0, 6.0, 0.0, -7.0, -13.0, -19.0, -26.0, -32.0, -39.0, -45.0, -51.0, -58.0, -64.0, -71.0, -77.0 },
+ {30.0, 24.0, 17.0, 11.0, 4.0, -2.0, -9.0, -15.0, -22.0, -29.0, -35.0, -42.0, -48.0, -55.0, -61.0, -68.0, -74.0, -81.0 },
+ {29.0, 23.0, 16.0, 9.0, 3.0, -4.0, -11.0, -17.0, -24.0, -31.0, -37.0, -44.0, -51.0, -58.0, -64.0, -71.0, -78.0, -84.0 },
+ {28.0, 22.0, 15.0, 8.0, 1.0, -5.0, -12.0, -19.0, -26.0, -33.0, -39.0, -46.0, -53.0, -60.0, -67.0, -73.0, -80.0, -87.0 },
+ {28.0, 21.0, 14.0, 7.0, 0.0, -7.0, -14.0, -21.0, -27.0, -34.0, -41.0, -48.0, -55.0, -62.0, -69.0, -76.0, -82.0, -89.0 },
+ {27.0, 20.0, 13.0, 6.0, -1.0, -8.0, -15.0, -22.0, -29.0, -36.0, -43.0, -50.0, -57.0, -64.0, -71.0, -78.0, -84.0, -91.0 },
{26.0, 19.0, 12.0, 5.0, -2.0, -9.0, -16.0, -23.0, -30.0, -37.0, -44.0, -51.0, -58.0, -65.0, -72.0, -79.0, -86.0, -93.0 },
{26.0, 19.0, 12.0, 4.0, -3.0, -10.0, -17.0, -24.0, -31.0, -38.0, -45.0, -52.0, -60.0, -67.0, -74.0, -81.0, -88.0, -95.0},
- {25.0, 18.0, 11.0, 4.0, -3.0, -11.0, -18.0, -25.0, -32.0, -39.0, -46.0, -54.0, -61.0, -68.0, -75.0, -82.0, -89.0, -97.0},
- {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}
+ {25.0, 18.0, 11.0, 4.0, -3.0, -11.0, -18.0, -25.0, -32.0, -39.0, -46.0, -54.0, -61.0, -68.0, -75.0, -82.0, -89.0, -97.0},
+ {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}
};
-const int transformData[ROWS][COLS] =
+const int transformData[ROWS][COLS] =
{ {36, 31, 25, 19, 13, 7, 1, 5, 11, 16, 22, 28, 34, 40, 46, 52, 57, 63 },
{34, 27, 21, 15, 9, 3, 4, 10, 16, 22, 28, 35, 41, 47, 53, 59, 66, 72 } ,
{32, 25, 19, 13, 6, 0, 7, 13, 19, 26, 32, 39, 45, 51, 58, 64, 71, 77 },
@@ -63,7 +63,7 @@ const int transformData[ROWS][COLS] =
} \
} \
PASSED(); \
-}
+}
#define COMPARE(TYPE,VAR1,VAR2,TOL) \
{ \
@@ -80,7 +80,7 @@ const int transformData[ROWS][COLS] =
} \
} \
PASSED(); \
-}
+}
#define TEST_TYPE_CONTIG(XFORM, TYPE, HDF_TYPE, TEST_STR, COMPARE_DATA, SIGNED) \
{ \
@@ -216,7 +216,7 @@ int main(void)
hid_t dxpl_id_c_to_f, dxpl_id_c_to_f_copy, dxpl_id_simple, dxpl_id_polynomial, dxpl_id_polynomial_copy, dxpl_id_utrans_inv, file_id;
const char* c_to_f = "(9/5.0)*x + 32";
- const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */
+ 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";
@@ -231,9 +231,9 @@ int main(void)
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(init_test(&file_id) < 0) TEST_ERROR;
if(test_set() < 0) TEST_ERROR;
@@ -265,7 +265,7 @@ int main(void)
#if H5_SIZEOF_LONG_DOUBLE!=0
TEST_TYPE_CONTIG(dxpl_id_c_to_f, long double, H5T_NATIVE_LDOUBLE, "ldouble", windchillFfloat, 1);
#endif
-
+
TEST_TYPE_CHUNK(dxpl_id_utrans_inv, char, H5T_NATIVE_CHAR, "char", transformData, 0);
TEST_TYPE_CHUNK(dxpl_id_utrans_inv, unsigned char, H5T_NATIVE_UCHAR, "uchar", transformData, 0);
TEST_TYPE_CHUNK(dxpl_id_c_to_f, signed char, H5T_NATIVE_SCHAR, "schar", windchillFfloat, 1);
@@ -293,7 +293,7 @@ int main(void)
#if H5_SIZEOF_LONG_DOUBLE!=0
TEST_TYPE_CHUNK(dxpl_id_c_to_f, long double, H5T_NATIVE_LDOUBLE, "ldouble", windchillFfloat, 1);
#endif
-
+
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;
@@ -314,7 +314,7 @@ int main(void)
return 0;
-
+
error:
return -1;
}
@@ -327,39 +327,39 @@ int init_test(hid_t* file_id)
hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, cparms, filespace;
hsize_t dim[2] = {ROWS, COLS};
- hsize_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(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);
if(H5Pset_chunk(cparms, 2, dim)<0) TEST_ERROR;
-
+
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(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(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(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 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(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(H5Dwrite(dset_id_float_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(H5Dwrite(dset_id_float_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat)<0) TEST_ERROR;
+
-
PASSED();
@@ -371,7 +371,7 @@ int init_test(hid_t* file_id)
error:
return -1;
}
-
+
int test_poly(const hid_t dxpl_id_polynomial)
{
float polyflres[ROWS][COLS];
@@ -393,7 +393,7 @@ int test_poly(const hid_t dxpl_id_polynomial)
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)
-
+
for(row = 0; row<ROWS; row++)
{
for(col = 0; col<COLS; col++)
@@ -430,7 +430,7 @@ 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(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)
@@ -444,7 +444,7 @@ int test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_co
error:
return -1;
}
-
+
int test_trivial(const hid_t dxpl_id_simple)
{
float windchillFfloatread[ROWS][COLS];
@@ -492,10 +492,10 @@ int test_getset(const hid_t dxpl_id_c_to_f)
{
int row, col;
float windchillFfloatread[ROWS][COLS];
- const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */
+ 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);
-
+
TESTING("H5Pget_data_transform")
H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(c_to_f)+1);
if(HDstrcmp(c_to_f, ptrgetTest) != 0)
@@ -508,7 +508,7 @@ int test_getset(const hid_t dxpl_id_c_to_f)
PASSED();
if(H5Pset_data_transform(dxpl_id_c_to_f, simple)<0) TEST_ERROR;
-
+
TESTING("data transform, read after reseting of transform property")
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++)
@@ -524,12 +524,12 @@ int test_getset(const hid_t dxpl_id_c_to_f)
}
}
PASSED();
-
+
HDmemset(ptrgetTest, 0, strlen(c_to_f)+1);
free(ptrgetTest);
ptrgetTest = malloc(strlen(simple)+1);
-
+
HDmemset(ptrgetTest, 0, strlen(simple)+1);
TESTING("H5Pget_data_transform, after resetting transform property")
H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, strlen(simple)+1);
@@ -541,8 +541,8 @@ int test_getset(const hid_t dxpl_id_c_to_f)
}
else
PASSED();
-
- free(ptrgetTest);
+
+ free(ptrgetTest);
return 0;
@@ -556,12 +556,12 @@ int test_set(void)
H5E_auto_stack_t func;
const char* str = "(9/5.0)*x + 32";
char* ptrgetTest = malloc(strlen(str)+1);
-
+
if((dxpl_id = H5Pcreate(H5P_DATASET_XFER))<0) TEST_ERROR;
-
+
/* Test get before set */
H5Eget_auto_stack(H5E_DEFAULT,&func,NULL);
-
+
H5Eset_auto_stack(H5E_DEFAULT, NULL, NULL);
TESTING("H5Pget_data_transform (get before set)")
if(H5Pget_data_transform(dxpl_id, ptrgetTest, strlen(str)+1) < 0)
@@ -580,28 +580,28 @@ int test_set(void)
TESTING("H5Pset_data_transform (set with invalid transform 1)")
INVALID_SET_TEST("\0");
-
+
TESTING("H5Pset_data_transform (set with invalid transform 2)")
INVALID_SET_TEST(" ");
-
+
TESTING("H5Pset_data_transform (set with invalid transform 3)")
INVALID_SET_TEST("x+");
-
+
TESTING("H5Pset_data_transform (set with invalid transform 4)")
INVALID_SET_TEST("(x+5");
-
+
TESTING("H5Pset_data_transform (set with invalid transform 5)")
INVALID_SET_TEST("+");
-
+
TESTING("H5Pset_data_transform (set with invalid transform 6)")
INVALID_SET_TEST("(9/5)*x + x**2");
TESTING("H5Pset_data_transform (set with invalid transform 7)")
INVALID_SET_TEST("(9/5)x");
-
+
TESTING("H5Pset_data_transform (set with invalid transform 8)")
INVALID_SET_TEST("(9/5)*x + x^2");
-
+
H5Eset_auto_stack(H5E_DEFAULT, func, NULL);
return 0;