diff options
author | Neil Fortner <nfortne2@hdfgroup.org> | 2009-01-27 16:05:53 (GMT) |
---|---|---|
committer | Neil Fortner <nfortne2@hdfgroup.org> | 2009-01-27 16:05:53 (GMT) |
commit | 4cd5a378c473faefd822beabbeccbb6e4f2f873e (patch) | |
tree | 83da835564a4e1440e57d38f90ecddb569478579 /test/dtypes.c | |
parent | 4f48c9c5552c9c11347480de48d98eeae32b6546 (diff) | |
download | hdf5-4cd5a378c473faefd822beabbeccbb6e4f2f873e.zip hdf5-4cd5a378c473faefd822beabbeccbb6e4f2f873e.tar.gz hdf5-4cd5a378c473faefd822beabbeccbb6e4f2f873e.tar.bz2 |
[svn-r16361] Purpose: Fix potential error with H5Tset_order
Description: H5Tset_order will now properly reject H5T_ORDER_NONE for most
datatypes. Previously this could cause major problems as the file could not be
flushed.
Tested: jam, smirom (h5committest)
Diffstat (limited to 'test/dtypes.c')
-rw-r--r-- | test/dtypes.c | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/test/dtypes.c b/test/dtypes.c index f4e0305..895d890 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -5645,6 +5645,172 @@ error: /*------------------------------------------------------------------------- + * Function: test_set_order + * + * Purpose: Tests H5Tset_order/H5Tget_order. Verifies that + * H5T_ORDER_NONE cannot be set. + * + * Return: Success: 0 + * + * Failure: number of errors + * + * Programmer: Neil Fortner + * January 23, 2009 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_set_order(void) +{ + hid_t dtype; /* Datatype ID */ + H5T_order_t order; /* Byte order */ + hsize_t dims[2] = {3, 4}; /* Array dimenstions */ + herr_t ret; /* Generic return value */ + + TESTING("H5Tset/get_order"); + + /* Integer */ + if ((dtype = H5Tcopy(H5T_STD_I32BE)) < 0) TEST_ERROR + if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR; + H5E_BEGIN_TRY + ret = H5Tset_order(dtype, H5T_ORDER_NONE); + H5E_END_TRY + if (ret >= 0) TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_LE) < 0) TEST_ERROR + if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR; + if (H5Tclose(dtype) < 0) TEST_ERROR + + /* Float */ + if ((dtype = H5Tcopy(H5T_IEEE_F64LE)) < 0) TEST_ERROR + if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR; + H5E_BEGIN_TRY + ret = H5Tset_order(dtype, H5T_ORDER_NONE); + H5E_END_TRY + if (ret >= 0) TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) TEST_ERROR + if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR; + if (H5Tclose(dtype) < 0) TEST_ERROR + + /* Time */ + if ((dtype = H5Tcopy(H5T_UNIX_D64BE)) < 0) TEST_ERROR + if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR; + H5E_BEGIN_TRY + ret = H5Tset_order(dtype, H5T_ORDER_NONE); + H5E_END_TRY + if (ret >= 0) TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_LE) < 0) TEST_ERROR + if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR; + if (H5Tclose(dtype) < 0) TEST_ERROR + + /* Fixed length string */ + if ((dtype = H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR + if (H5Tset_size(dtype, 5) < 0) TEST_ERROR + if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR; + if (H5Tset_order(dtype, H5T_ORDER_NONE) < 0) TEST_ERROR; + if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR; + + /* Variable length string */ + if (H5Tset_size(dtype, H5T_VARIABLE) < 0) TEST_ERROR + H5E_BEGIN_TRY + ret = H5Tset_order(dtype, H5T_ORDER_NONE); + H5E_END_TRY + if (ret >= 0) TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) TEST_ERROR + if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR; + if (H5Tclose(dtype) < 0) TEST_ERROR + + /* Bitfield */ + if ((dtype = H5Tcopy(H5T_STD_B16LE)) < 0) TEST_ERROR + if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR; + H5E_BEGIN_TRY + ret = H5Tset_order(dtype, H5T_ORDER_NONE); + H5E_END_TRY + if (ret >= 0) TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) TEST_ERROR + if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR; + if (H5Tclose(dtype) < 0) TEST_ERROR + + /* Opaque - functions should fail */ + if ((dtype = H5Tcreate(H5T_OPAQUE, 96)) < 0) TEST_ERROR + H5E_BEGIN_TRY + ret = H5Tset_order(dtype, H5T_ORDER_LE); + order = H5Tget_order(dtype); + H5E_END_TRY + if (ret >= 0) TEST_ERROR + if (order >= 0) TEST_ERROR + if (H5Tclose(dtype) < 0) TEST_ERROR + + /* Compound - functions should fail */ + if ((dtype = H5Tcreate(H5T_COMPOUND, 48)) < 0) TEST_ERROR + H5E_BEGIN_TRY + ret = H5Tset_order(dtype, H5T_ORDER_LE); + order = H5Tget_order(dtype); + H5E_END_TRY + if (ret >= 0) TEST_ERROR + if (order >= 0) TEST_ERROR + if (H5Tclose(dtype) < 0) TEST_ERROR + + /* Object reference */ + if ((dtype = H5Tcopy(H5T_STD_REF_OBJ)) < 0) TEST_ERROR + if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR; + if (H5Tset_order(dtype, H5T_ORDER_NONE) < 0) TEST_ERROR; + if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR; + if (H5Tclose(dtype) < 0) TEST_ERROR + + /* Region reference */ + if ((dtype = H5Tcopy(H5T_STD_REF_DSETREG)) < 0) TEST_ERROR + if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR; + if (H5Tset_order(dtype, H5T_ORDER_NONE) < 0) TEST_ERROR; + if (H5T_ORDER_NONE != H5Tget_order(dtype)) TEST_ERROR; + if (H5Tclose(dtype) < 0) TEST_ERROR + + /* Enum */ + if ((dtype = H5Tenum_create(H5T_STD_I16BE)) < 0) TEST_ERROR + if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR; + H5E_BEGIN_TRY + ret = H5Tset_order(dtype, H5T_ORDER_NONE); + H5E_END_TRY + if (ret >= 0) TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_LE) < 0) TEST_ERROR + if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR; + if (H5Tclose(dtype) < 0) TEST_ERROR + + /* Vlen */ + if ((dtype = H5Tvlen_create(H5T_STD_U64LE)) < 0) TEST_ERROR + if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR; + H5E_BEGIN_TRY + ret = H5Tset_order(dtype, H5T_ORDER_NONE); + H5E_END_TRY + if (ret >= 0) TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_BE) < 0) TEST_ERROR + if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR; + if (H5Tclose(dtype) < 0) TEST_ERROR + + /* Array */ + if ((dtype = H5Tarray_create2(H5T_IEEE_F64BE, 2, dims)) < 0) TEST_ERROR + if (H5T_ORDER_BE != H5Tget_order(dtype)) TEST_ERROR; + H5E_BEGIN_TRY + ret = H5Tset_order(dtype, H5T_ORDER_NONE); + H5E_END_TRY + if (ret >= 0) TEST_ERROR + if (H5Tset_order(dtype, H5T_ORDER_LE) < 0) TEST_ERROR + if (H5T_ORDER_LE != H5Tget_order(dtype)) TEST_ERROR; + if (H5Tclose(dtype) < 0) TEST_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY + H5Tclose (dtype); + H5E_END_TRY; + return 1; +} /* end test_set_order() */ + + +/*------------------------------------------------------------------------- * Function: test_deprec * * Purpose: Tests deprecated API routines for datatypes. @@ -5847,6 +6013,7 @@ main(void) nerrors += test_conv_bitfield(); nerrors += test_bitfield_funcs(); nerrors += test_opaque(); + nerrors += test_set_order(); if(nerrors) { printf("***** %lu FAILURE%s! *****\n", |