diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-18 22:02:19 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-18 22:02:19 (GMT) |
commit | a5984f59f71739531fb78c3933a726e73dd54328 (patch) | |
tree | 839fdd36b93e7976c97b9a351e3937266d1dd7b3 /test/dtypes.c | |
parent | cf56cd041d119914d7a9bee79c22e59a8ce85059 (diff) | |
download | hdf5-a5984f59f71739531fb78c3933a726e73dd54328.zip hdf5-a5984f59f71739531fb78c3933a726e73dd54328.tar.gz hdf5-a5984f59f71739531fb78c3933a726e73dd54328.tar.bz2 |
[svn-r14212] Description:
Make H5Tarray_create() and H5Tget_array_dims() versioned, and drop the
"perm" parameter from the '2' versions.
Shift internal library usage to '2' versions.
Add simple regression tests for '1' versions.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Diffstat (limited to 'test/dtypes.c')
-rw-r--r-- | test/dtypes.c | 106 |
1 files changed, 71 insertions, 35 deletions
diff --git a/test/dtypes.c b/test/dtypes.c index e527757..bf98761 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -327,10 +327,10 @@ test_detect(void) hid_t atom_arr_id; /* Atomic Array datatype */ hid_t atom_vlf_id; /* Atomic VL datatype of float */ hid_t atom_vlc_id; /* Atomic VL datatype of char */ - hid_t atom_vls_id; /* Atomic VL string datatype */ + hid_t atom_vls_id; /* Atomic VL string datatype */ hid_t cplx_cmpd_id; /* Complex Compound datatype */ - unsigned rank = 2; /* Rank for array datatype */ - hsize_t dims[2]={3,3}; /* Dimensions for array datatype */ + unsigned rank = 2; /* Rank for array datatype */ + hsize_t dims[2] = {3,3}; /* Dimensions for array datatype */ TESTING("H5Tdetect_class()"); @@ -367,20 +367,8 @@ test_detect(void) /*-------------------------------------------------------------------------------- * Test class of some complex types. *------------------------------------------------------------------------------*/ - /* Try to create array datatype with a dimension permutation (should fail) */ - H5E_BEGIN_TRY { - int perm[2]={0,1}; /* Dimensions permutations for array datatype */ - - atom_arr_id = H5Tarray_create(H5T_STD_REF_OBJ, rank, dims, perm); - } H5E_END_TRY; - if(atom_arr_id>=0) { - H5_FAILED(); - printf("Dimension permutation accepted?\n"); - goto error; - } /* end if */ - /* Create an array datatype with an atomic base type */ - if((atom_arr_id = H5Tarray_create(H5T_STD_REF_OBJ, rank, dims, NULL)) < 0) TEST_ERROR + if((atom_arr_id = H5Tarray_create2(H5T_STD_REF_OBJ, rank, dims)) < 0) TEST_ERROR /* Make certain that the correct classes can be detected */ if(H5Tdetect_class(atom_arr_id,H5T_ARRAY)!=TRUE) TEST_ERROR @@ -699,8 +687,8 @@ test_compound_2(void) HDmemcpy(buf, orig, nelmts*sizeof(struct st)); /* Build hdf5 datatypes */ - array_dt = H5Tarray_create(H5T_NATIVE_INT,1, &four, NULL); - if ((st=H5Tcreate(H5T_COMPOUND, sizeof(struct st))) < 0 || + array_dt = H5Tarray_create2(H5T_NATIVE_INT,1, &four); + if((st = H5Tcreate(H5T_COMPOUND, sizeof(struct st))) < 0 || H5Tinsert(st, "a", HOFFSET(struct st, a), H5T_NATIVE_INT) < 0 || H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_INT) < 0 || H5Tinsert(st, "c", HOFFSET(struct st, c), array_dt) < 0 || @@ -709,8 +697,8 @@ test_compound_2(void) goto error; H5Tclose(array_dt); - array_dt = H5Tarray_create(H5T_NATIVE_INT, 1, &four, NULL); - if ((dt=H5Tcreate(H5T_COMPOUND, sizeof(struct dt))) < 0 || + array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, &four); + if((dt = H5Tcreate(H5T_COMPOUND, sizeof(struct dt))) < 0 || H5Tinsert(dt, "a", HOFFSET(struct dt, a), H5T_NATIVE_INT) < 0 || H5Tinsert(dt, "b", HOFFSET(struct dt, b), H5T_NATIVE_INT) < 0 || H5Tinsert(dt, "c", HOFFSET(struct dt, c), array_dt) < 0 || @@ -816,8 +804,8 @@ test_compound_3(void) HDmemcpy(buf, orig, nelmts*sizeof(struct st)); /* Build hdf5 datatypes */ - array_dt = H5Tarray_create(H5T_NATIVE_INT, 1, &four, NULL); - if ((st=H5Tcreate(H5T_COMPOUND, sizeof(struct st))) < 0 || + array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, &four); + if((st = H5Tcreate(H5T_COMPOUND, sizeof(struct st))) < 0 || H5Tinsert(st, "a", HOFFSET(struct st, a), H5T_NATIVE_INT) < 0 || H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_INT) < 0 || H5Tinsert(st, "c", HOFFSET(struct st, c), array_dt) < 0 || @@ -826,8 +814,8 @@ test_compound_3(void) goto error; H5Tclose(array_dt); - array_dt = H5Tarray_create(H5T_NATIVE_INT, 1, &four, NULL); - if ((dt=H5Tcreate(H5T_COMPOUND, sizeof(struct dt))) < 0 || + array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, &four); + if((dt = H5Tcreate(H5T_COMPOUND, sizeof(struct dt))) < 0 || H5Tinsert(dt, "a", HOFFSET(struct dt, a), H5T_NATIVE_INT) < 0 || H5Tinsert(dt, "c", HOFFSET(struct dt, c), array_dt) < 0 || H5Tinsert(dt, "e", HOFFSET(struct dt, e), H5T_NATIVE_INT) < 0) @@ -934,8 +922,8 @@ test_compound_4(void) HDmemcpy(buf, orig, nelmts*sizeof(struct st)); /* Build hdf5 datatypes */ - array_dt = H5Tarray_create(H5T_NATIVE_INT, 1, &four, NULL); - if ((st=H5Tcreate(H5T_COMPOUND, sizeof(struct st))) < 0 || + array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, &four); + if((st = H5Tcreate(H5T_COMPOUND, sizeof(struct st))) < 0 || H5Tinsert(st, "a", HOFFSET(struct st, a), H5T_NATIVE_INT) < 0 || H5Tinsert(st, "b", HOFFSET(struct st, b), H5T_NATIVE_INT) < 0 || H5Tinsert(st, "c", HOFFSET(struct st, c), array_dt) < 0 || @@ -944,8 +932,8 @@ test_compound_4(void) goto error; H5Tclose(array_dt); - array_dt = H5Tarray_create(H5T_NATIVE_INT, 1, &four, NULL); - if ((dt=H5Tcreate(H5T_COMPOUND, sizeof(struct dt))) < 0 || + array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, &four); + if((dt = H5Tcreate(H5T_COMPOUND, sizeof(struct dt))) < 0 || H5Tinsert(dt, "a", HOFFSET(struct dt, a), H5T_NATIVE_INT) < 0 || H5Tinsert(dt, "b", HOFFSET(struct dt, b), H5T_NATIVE_SHORT) < 0 || H5Tinsert(dt, "c", HOFFSET(struct dt, c), array_dt) < 0 || @@ -1052,12 +1040,12 @@ test_compound_5(void) /* Build datatypes */ short_array = H5Tcreate(H5T_COMPOUND, 4*sizeof(short)); - array_dt = H5Tarray_create(H5T_NATIVE_SHORT, 1, dims, NULL); + array_dt = H5Tarray_create2(H5T_NATIVE_SHORT, 1, dims); H5Tinsert(short_array, "_", 0, array_dt); H5Tclose(array_dt); int_array = H5Tcreate(H5T_COMPOUND, 4*sizeof(int)); - array_dt = H5Tarray_create(H5T_NATIVE_INT, 1, dims, NULL); + array_dt = H5Tarray_create2(H5T_NATIVE_INT, 1, dims); H5Tinsert(int_array, "_", 0, array_dt); H5Tclose(array_dt); @@ -1803,7 +1791,7 @@ test_compound_10(void) } /* end if */ /* Create the array datatype for c_string data */ - if((arr_tid = H5Tarray_create(cmpd_tid, 1, arr_dim, NULL)) < 0) { + if((arr_tid = H5Tarray_create2(cmpd_tid, 1, arr_dim)) < 0) { H5_FAILED(); AT(); printf("Can't create array type\n"); goto error; @@ -4683,7 +4671,7 @@ error: /*------------------------------------------------------------------------- - * Function: test_compat + * Function: test_deprec * * Purpose: Tests deprecated API routines for datatypes. * @@ -4697,15 +4685,63 @@ error: */ #ifndef H5_NO_DEPRECATED_SYMBOLS static int -test_compat(hid_t fapl) +test_deprec(hid_t fapl) { hid_t file = -1; /* File ID */ hid_t type = -1; /* Datatype ID */ + unsigned rank = 2; /* Rank for array datatype */ + hsize_t dims[2] = {3, 3}; /* Dimensions for array datatype */ + int perm[2] = {0, 1}; /* Dimensions permutations for array datatype */ + hsize_t rdims[2]= {0, 0}; /* Dimensions for querying array datatype */ + int rperm[2] = {-2, -2}; /* Dimensions permutations for array datatype */ + hbool_t dim_mismatch; /* Whether any dimensions didn't match */ char filename[1024]; + unsigned u; /* Local index variable */ herr_t status; /* Generic routine value */ TESTING("deprected API routines for datatypes"); + /* Create an array datatype with an atomic base type */ + /* (dimension permutations allowed, but not stored) */ + if((type = H5Tarray_create1(H5T_NATIVE_INT, rank, dims, perm)) < 0) + FAIL_STACK_ERROR + + /* Make certain that the correct classes can be detected */ + if(H5Tdetect_class(type, H5T_ARRAY) != TRUE) + FAIL_STACK_ERROR + if(H5Tdetect_class(type, H5T_INTEGER) != TRUE) + FAIL_STACK_ERROR + + /* Get the array dimensions */ + /* (Query the dimension permutations, which is allowed, but ignored) */ + if(H5Tget_array_dims1(type, rdims, rperm) < 0) + FAIL_STACK_ERROR + + /* Check the array dimensions */ + dim_mismatch = FALSE; + for(u = 0; u < rank; u++) + if(rdims[u] != dims[u]) { + TestErrPrintf("Array dimension information doesn't match!, rdims1[%u]=%d, tdims1[%u]=%d\n", u, (int)rdims[u], u, (int)dims[u]); + dim_mismatch = TRUE; + } /* end if */ + if(dim_mismatch) + FAIL_PUTS_ERROR(" Dimensions didn't match!") + + /* Check the array dimension permutations */ + dim_mismatch = FALSE; + for(u = 0; u < rank; u++) + if(rperm[u] != -2) { + TestErrPrintf("Array dimension permutation information was modified!, rdims1[%u]=%d, tdims1[%u]=%d\n", u, rperm[u], u, perm[u]); + dim_mismatch = TRUE; + } /* end if */ + if(dim_mismatch) + FAIL_PUTS_ERROR(" Dimension permutations modified!") + + /* Close the datatype */ + if(H5Tclose(type) < 0) + FAIL_STACK_ERROR + + h5_fixname(FILENAME[1], fapl, filename, sizeof filename); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR @@ -4760,7 +4796,7 @@ error: H5Fclose(file); } H5E_END_TRY; return 1; -} /* end test_compat() */ +} /* end test_deprec() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -4807,7 +4843,7 @@ main(void) nerrors += test_latest(); nerrors += test_int_float_except(); #ifndef H5_NO_DEPRECATED_SYMBOLS - nerrors += test_compat(fapl); + nerrors += test_deprec(fapl); #endif /* H5_NO_DEPRECATED_SYMBOLS */ h5_cleanup(FILENAME, fapl); /*must happen before first reset*/ reset_hdf5(); |