summaryrefslogtreecommitdiffstats
path: root/test/dtypes.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/dtypes.c')
-rw-r--r--test/dtypes.c82
1 files changed, 71 insertions, 11 deletions
diff --git a/test/dtypes.c b/test/dtypes.c
index 0a3b6e4..655472c 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -4900,6 +4900,10 @@ opaque_funcs(void)
* Modifications: Raymond Lu
* July 13, 2009
* Added the test for VL string types.
+ *
+ * Raymond Lu
+ * 17 February 2011
+ * I added the test of reference count for decoded datatypes.
*-------------------------------------------------------------------------
*/
static int
@@ -5328,37 +5332,93 @@ test_encode(void)
} /* end if */
/*-----------------------------------------------------------------------
- * Close and release
+ * Test the reference count of the decoded datatypes
*-----------------------------------------------------------------------
*/
- /* Close datatype and file */
- if(H5Tclose(tid1) < 0) {
+
+ /* Make sure the reference counts for the decoded datatypes are one. */
+ if(H5Iget_ref(decoded_tid1) != 1) {
H5_FAILED();
- printf("Can't close datatype\n");
+ printf("Decoded datatype has incorrect reference count\n");
goto error;
} /* end if */
- if(H5Tclose(tid2) < 0) {
+
+ if(H5Iget_ref(decoded_tid2) != 1) {
H5_FAILED();
- printf("Can't close datatype\n");
+ printf("Decoded datatype has incorrect reference count\n");
goto error;
} /* end if */
- if(H5Tclose(tid3) < 0) {
+
+ if(H5Iget_ref(decoded_tid3) != 1) {
H5_FAILED();
- printf("Can't close datatype\n");
+ printf("Decoded datatype has incorrect reference count\n");
goto error;
} /* end if */
- if(H5Tclose(decoded_tid1) < 0) {
+ /* Make sure the reference counts for the decoded datatypes can be
+ * decremented and the datatypes are closed. */
+ if(H5Idec_ref(decoded_tid1) != 0) {
+ H5_FAILED();
+ printf("Decoded datatype can't close\n");
+ goto error;
+ } /* end if */
+
+ if(H5Idec_ref(decoded_tid2) != 0) {
+ H5_FAILED();
+ printf("Decoded datatype can't close\n");
+ goto error;
+ } /* end if */
+
+ if(H5Idec_ref(decoded_tid3) != 0) {
+ H5_FAILED();
+ printf("Decoded datatype can't close\n");
+ goto error;
+ } /* end if */
+
+ /* Make sure the decoded datatypes are already closed. */
+ H5E_BEGIN_TRY {
+ ret = H5Tclose(decoded_tid1);
+ } H5E_END_TRY;
+ if(ret!=FAIL) {
+ H5_FAILED();
+ printf("Decoded datatype should have been closed\n");
+ goto error;
+ }
+
+ H5E_BEGIN_TRY {
+ ret = H5Tclose(decoded_tid2);
+ } H5E_END_TRY;
+ if(ret!=FAIL) {
+ H5_FAILED();
+ printf("Decoded datatype should have been closed\n");
+ goto error;
+ }
+
+ H5E_BEGIN_TRY {
+ ret = H5Tclose(decoded_tid3);
+ } H5E_END_TRY;
+ if(ret!=FAIL) {
+ H5_FAILED();
+ printf("Decoded datatype should have been closed\n");
+ goto error;
+ }
+
+ /*-----------------------------------------------------------------------
+ * Close and release
+ *-----------------------------------------------------------------------
+ */
+ /* Close datatype and file */
+ if(H5Tclose(tid1) < 0) {
H5_FAILED();
printf("Can't close datatype\n");
goto error;
} /* end if */
- if(H5Tclose(decoded_tid2) < 0) {
+ if(H5Tclose(tid2) < 0) {
H5_FAILED();
printf("Can't close datatype\n");
goto error;
} /* end if */
- if(H5Tclose(decoded_tid3) < 0) {
+ if(H5Tclose(tid3) < 0) {
H5_FAILED();
printf("Can't close datatype\n");
goto error;