diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2005-09-06 18:39:46 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2005-09-06 18:39:46 (GMT) |
commit | 7ef46b524b3c9dd56a7e0a106d5f4a4fd999acaa (patch) | |
tree | 38bf83c20818abddfcef0338f06611dbe89788e6 /test/dt_arith.c | |
parent | 9b1828ffd0799edabec86b79b15bd4b6b70bee28 (diff) | |
download | hdf5-7ef46b524b3c9dd56a7e0a106d5f4a4fd999acaa.zip hdf5-7ef46b524b3c9dd56a7e0a106d5f4a4fd999acaa.tar.gz hdf5-7ef46b524b3c9dd56a7e0a106d5f4a4fd999acaa.tar.bz2 |
[svn-r11355] Purpose: A new API function and its test.
Description: Put in a new API funciton, H5Tis_hard. It checks whether
the conversion function from a native type to another native type is a
compiler (hard) conversion. Also checked a test in test/dt_arith.c.
Platforms tested: h5committest and fuss.
Diffstat (limited to 'test/dt_arith.c')
-rw-r--r-- | test/dt_arith.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/dt_arith.c b/test/dt_arith.c index 0944524..abdba99 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -579,6 +579,66 @@ generates_sigfpe(void) /*------------------------------------------------------------------------- + * Function: test_hard_query + * + * Purpose: Tests H5Tis_hard() for querying whether a conversion is + * a hard one. + * + * Return: Success: 0 + * + * Failure: number of errors + * + * Programmer: Raymond Lu + * Friday, Sept 2, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_hard_query(void) +{ + htri_t ret; + + TESTING("query functions of hard conversion"); + + /* Verify the conversion from int to float is a hard conversion. */ + if((ret = H5Tis_hard(H5T_NATIVE_INT, H5T_NATIVE_FLOAT))!=TRUE) { + H5_FAILED(); + printf("Can't query conversion function\n"); + goto error; + } + + /* Unregister the hard conversion from int to float. Verify the conversion + * is a soft conversion. */ + H5Tunregister(H5T_PERS_HARD, NULL, H5T_NATIVE_INT, H5T_NATIVE_FLOAT, NULL); + if((ret = H5Tis_hard(H5T_NATIVE_INT, H5T_NATIVE_FLOAT))!=FALSE) { + H5_FAILED(); + printf("Can't query conversion function\n"); + goto error; + } + + /* Register the hard conversion from int to float. Verify the conversion + * is a hard conversion. */ + H5Tregister(H5T_PERS_HARD, "int_flt", H5T_NATIVE_INT, H5T_NATIVE_FLOAT, H5T_conv_int_float); + if((ret = H5Tis_hard(H5T_NATIVE_INT, H5T_NATIVE_FLOAT))!=TRUE) { + H5_FAILED(); + printf("Can't query conversion function\n"); + goto error; + } + + PASSED(); + reset_hdf5(); + + return 0; + + error: + reset_hdf5(); + return 1; +} + + +/*------------------------------------------------------------------------- * Function: test_derived_flt * * Purpose: Tests user-define and query functions of floating-point types. @@ -4769,6 +4829,9 @@ main(void) /* Do the tests */ + /* Test H5Tis_hard() for querying hard conversion. */ + nerrors += test_hard_query(); + /* Test user-define, query functions and software conversion * for user-defined floating-point types */ nerrors += test_derived_flt(); |