summaryrefslogtreecommitdiffstats
path: root/test/dtypes.c
diff options
context:
space:
mode:
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;