summaryrefslogtreecommitdiffstats
path: root/test/dtypes.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1999-06-07 15:05:02 (GMT)
committerRobb Matzke <matzke@llnl.gov>1999-06-07 15:05:02 (GMT)
commitb98fcbf5926e81f2e4ead8daa46e650566719e1c (patch)
tree1653e8084aff321512fb2d2bc842573fef62f220 /test/dtypes.c
parent2a10e682a13244d5c61982445f2d6ec5bc990a36 (diff)
downloadhdf5-b98fcbf5926e81f2e4ead8daa46e650566719e1c.zip
hdf5-b98fcbf5926e81f2e4ead8daa46e650566719e1c.tar.gz
hdf5-b98fcbf5926e81f2e4ead8daa46e650566719e1c.tar.bz2
[svn-r1306] Changes since 19990602
---------------------- ./doc/html/Datatypes.html ./test/dtypes.c Added documentation and tests for opaque types. ./tools/h5ls.c Added a `-x' or `--hexdump' argument which is not fully implemented (because I want to synchronize h5tools.c first) but which will eventually print raw data in hexadecimal format without any translation from disk. This would be useful for debugging references and VL types. ./tools/h5tools.c Added support for references (not quite finished yet, but compiles -- I wanted to sync up this file before Patrick and I got too far apart...) ./src/H5R.c Checked for error return value from H5R_get_object_type() ./src/H5A.c ./src/H5D.c Changed error return values from NULL to FAIL ./test/Makefile.in ./test/trefer.c Creates trefer1.h5 and trefer2.h5 so that the second test doesn't clobber the first file since the files might be useful for debugging.
Diffstat (limited to 'test/dtypes.c')
-rw-r--r--test/dtypes.c61
1 files changed, 60 insertions, 1 deletions
diff --git a/test/dtypes.c b/test/dtypes.c
index eaff31d..484ca24 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -76,6 +76,9 @@ static int skip_overflow_tests_g = 0;
/* Don't use hardware conversions if set */
static int without_hardware_g = 0;
+/* Count opaque conversions */
+static int num_opaque_conversions_g = 0;
+
/*
* Although we check whether a floating point overflow generates a SIGFPE and
* turn off overflow tests in that case, it might still be possible for an
@@ -1221,6 +1224,31 @@ test_conv_bitfield(void)
/*-------------------------------------------------------------------------
+ * Function: convert_opaque
+ *
+ * Purpose: A fake opaque conversion functions
+ *
+ * Return: Success: 0
+ *
+ * Failure: -1
+ *
+ * Programmer: Robb Matzke
+ * Friday, June 4, 1999
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+convert_opaque(hid_t UNUSED st, hid_t UNUSED dt, H5T_cdata_t *cdata,
+ size_t UNUSED nelmts, void UNUSED *_buf, void UNUSED *bkg)
+{
+ if (H5T_CONV_CONV==cdata->command) num_opaque_conversions_g++;
+ return 0;
+}
+
+
+/*-------------------------------------------------------------------------
* Function: test_opaque
*
* Purpose: Test opaque datatypes
@@ -1239,13 +1267,44 @@ test_conv_bitfield(void)
static int
test_opaque(void)
{
+#define OPAQUE_NELMTS 1000
hid_t st=-1, dt=-1;
+ herr_t status;
+ char buf[1]; /*not really used*/
+ int saved = num_opaque_conversions_g;
TESTING("opaque datatypes");
-
+
+ /* Build source and destination types */
if ((st=H5Tcreate(H5T_OPAQUE, 4))<0) goto error;
+ if (H5Tset_tag(st, "opaque source type")<0) goto error;
+ if ((dt=H5Tcreate(H5T_OPAQUE, 4))<0) goto error;
+ if (H5Tset_tag(dt, "opaque destination type")<0) goto error;
+
+ /* Make sure that we can't convert between the types yet */
+ H5E_BEGIN_TRY {
+ status = H5Tconvert(st, dt, OPAQUE_NELMTS, buf, NULL);
+ } H5E_END_TRY;
+ if (status>=0) {
+ FAILED();
+ printf(" opaque conversion should have failed but succeeded\n");
+ goto error;
+ }
+ /* Register a conversion function */
+ if (H5Tregister(H5T_PERS_HARD, "o_test", st, dt, convert_opaque)<0)
+ goto error;
+
+ /* Try the conversion again, this time it should work */
+ if (H5Tconvert(st, dt, OPAQUE_NELMTS, buf, NULL)<0) goto error;
+ if (saved+1 != num_opaque_conversions_g) {
+ FAILED();
+ printf(" unexpected number of opaque conversions\n");
+ goto error;
+ }
+
H5Tclose(st);
+ H5Tclose(dt);
PASSED();
return 0;