diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-01-28 02:11:39 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-01-28 02:11:39 (GMT) |
commit | 7191f26717255667e86c86559ffc316f73f4c1bd (patch) | |
tree | 3179c22066f9880e7f09849e8a620ad398f68fa9 /test | |
parent | 2cbd7f1b3cd50d21279ef81093632cb7bf6f97ea (diff) | |
download | hdf5-7191f26717255667e86c86559ffc316f73f4c1bd.zip hdf5-7191f26717255667e86c86559ffc316f73f4c1bd.tar.gz hdf5-7191f26717255667e86c86559ffc316f73f4c1bd.tar.bz2 |
[svn-r16369] Description:
Bring r16347:16367 from trunk into revise_chunks branch.
Tested on:
FreeBSD/32 6.3 (duty)
(h5committest not required on this branch)
Diffstat (limited to 'test')
-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 3aad1a7..991b2c9 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -5644,6 +5644,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. @@ -5846,6 +6012,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", |