summaryrefslogtreecommitdiffstats
path: root/test/tid.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2009-04-01 22:27:35 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2009-04-01 22:27:35 (GMT)
commit5d4294042e459b998d642c33d6233a6912f67c77 (patch)
tree549aab452376dce1c7432e12f731bd76b08be2d1 /test/tid.c
parent539406de996e938ef46a083a12b728627d0c1977 (diff)
downloadhdf5-5d4294042e459b998d642c33d6233a6912f67c77.zip
hdf5-5d4294042e459b998d642c33d6233a6912f67c77.tar.gz
hdf5-5d4294042e459b998d642c33d6233a6912f67c77.tar.bz2
[svn-r16653] Bug fix #1503 - H5Iget_type failed unexpected when an invalid ID was passed in. I put
some argument check in the internal function H5I_find_id and took out the assertion check. I also removed the argument check in H5Iis_valid because it's in H5I_find_id now. Tested on jam - simple change. Tested v1.8 already.
Diffstat (limited to 'test/tid.c')
-rw-r--r--test/tid.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/test/tid.c b/test/tid.c
index f3c00fc..9bb93e7 100644
--- a/test/tid.c
+++ b/test/tid.c
@@ -394,7 +394,7 @@ static int test_is_valid(void)
/* Check that an id of -1 is invalid */
tri_ret = H5Iis_valid(-1);
- VERIFY(tri_ret, FALSE, "H5Iis_valid");
+ VERIFY(tri_ret, FALSE, "H4Iis_valid");
if (tri_ret != FALSE)
goto out;
@@ -408,6 +408,46 @@ out:
return -1;
}
+/* Test the H5Iget_type function */
+static int test_get_type(void)
+{
+ hid_t dtype; /* datatype id */
+ H5I_type_t type_ret; /* return value */
+
+ /* Create a datatype id */
+ dtype = H5Tcopy(H5T_NATIVE_INT);
+ CHECK(dtype, FAIL, "H5Tcopy");
+ if (dtype < 0)
+ goto out;
+
+ /* Check that the ID is correct */
+ type_ret = H5Iget_type(dtype);
+ VERIFY(type_ret, H5I_DATATYPE, "H5Iget_type");
+ if (type_ret == H5I_BADID)
+ goto out;
+
+ /* Check that the ID is correct */
+ type_ret = H5Iget_type(H5T_STRING);
+ VERIFY(type_ret, H5I_BADID, "H5Iget_type");
+ if (type_ret != H5I_BADID)
+ goto out;
+
+ /* Check that the ID is correct */
+ type_ret = H5Iget_type(-1);
+ VERIFY(type_ret, H5I_BADID, "H5Iget_type");
+ if (type_ret != H5I_BADID)
+ goto out;
+
+ H5Tclose(dtype);
+
+ return 0;
+
+out:
+ if(dtype != H5I_INVALID_HID)
+ H5Tclose(dtype);
+
+ return -1;
+}
/* Test boundary cases with lots of types */
@@ -498,6 +538,7 @@ void test_ids(void)
if (basic_id_test() < 0) TestErrPrintf("Basic ID test failed\n");
if (id_predefined_test() < 0) TestErrPrintf("Predefined ID type test failed\n");
if (test_is_valid() < 0) TestErrPrintf("H5Iis_valid test failed\n");
+ if (test_get_type() < 0) TestErrPrintf("H5Iget_type test failed\n");
if (test_id_type_list() < 0) TestErrPrintf("ID type list test failed\n");
}