summaryrefslogtreecommitdiffstats
path: root/test/titerate.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-08-26 18:37:33 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-08-26 18:37:33 (GMT)
commit15e1a2c0c0d53d264a5b4ea4f28d7beba6ccf1bd (patch)
treebd9d8d1d93916068eef38c224587a657e6828662 /test/titerate.c
parentff8132d5103a0a0399bd6cbc1faf6168c92db806 (diff)
downloadhdf5-15e1a2c0c0d53d264a5b4ea4f28d7beba6ccf1bd.zip
hdf5-15e1a2c0c0d53d264a5b4ea4f28d7beba6ccf1bd.tar.gz
hdf5-15e1a2c0c0d53d264a5b4ea4f28d7beba6ccf1bd.tar.bz2
[svn-r7413] Purpose:
Bug fix Description: H5Gget_objname_by_idx should allow NULL for the 'name' parameter, to allow for querying for the name's length. Solution: Allow NULL for the 'name' parameter, the internal functions were already ready to handle that case. Clean up RM information about H5Gget_objname_by_idx and H5Gget_objtype_by_idx also. Platforms tested: FreeBSD 4.8 (sleipnir) h5committest
Diffstat (limited to 'test/titerate.c')
-rw-r--r--test/titerate.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/test/titerate.c b/test/titerate.c
index 0c9ca5d..645bea3 100644
--- a/test/titerate.c
+++ b/test/titerate.c
@@ -118,7 +118,7 @@ static void test_iter_group(void)
int idx; /* Index in the group */
char name[NAMELEN]; /* temporary name buffer */
char *dnames[NDATASETS];/* Names of the datasets created */
- char dataset_name[16]; /* dataset name */
+ char dataset_name[NAMELEN]; /* dataset name */
iter_info info; /* Custom iteration information */
hsize_t num_membs; /* Number of group members */
herr_t ret; /* Generic return value */
@@ -197,17 +197,17 @@ static void test_iter_group(void)
VERIFY(num_membs,NDATASETS+2,"H5Gget_num_objs");
for(i=0; i< (int)num_membs; i++) {
- ret = H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, 32);
- CHECK(ret, FAIL, "H5Gget_objsname_by_idx");
+ ret = H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, NAMELEN);
+ CHECK(ret, FAIL, "H5Gget_objname_by_idx");
ret = (herr_t)H5Gget_objtype_by_idx(root_group, (hsize_t)i);
- CHECK(ret, FAIL, "H5Gget_objsname_by_idx");
+ CHECK(ret, FAIL, "H5Gget_objtype_by_idx");
}
H5E_BEGIN_TRY {
- ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)(NDATASETS+3), dataset_name, 16);
+ ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)(NDATASETS+3), dataset_name, NAMELEN);
} H5E_END_TRY;
- VERIFY(ret, FAIL, "H5Gget_objsname_by_idx");
+ VERIFY(ret, FAIL, "H5Gget_objname_by_idx");
ret = H5Gclose(root_group);
CHECK(ret, FAIL, "H5Gclose");
@@ -225,17 +225,17 @@ static void test_iter_group(void)
for(i=0; i< (int)num_membs; i++) {
H5G_obj_t obj_type; /* Type of object in file */
- ret = H5Gget_objname_by_idx(file, (hsize_t)i, dataset_name, 32);
- CHECK(ret, FAIL, "H5Gget_objsname_by_idx");
+ ret = H5Gget_objname_by_idx(file, (hsize_t)i, dataset_name, NAMELEN);
+ CHECK(ret, FAIL, "H5Gget_objname_by_idx");
obj_type = H5Gget_objtype_by_idx(file, (hsize_t)i);
- CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objsname_by_idx");
+ CHECK(obj_type, H5G_UNKNOWN, "H5Gget_objtype_by_idx");
}
H5E_BEGIN_TRY {
- ret = (herr_t)H5Gget_objname_by_idx(file, (hsize_t)(NDATASETS+3), dataset_name, 16);
+ ret = (herr_t)H5Gget_objname_by_idx(file, (hsize_t)(NDATASETS+3), dataset_name, NAMELEN);
} H5E_END_TRY;
- VERIFY(ret, FAIL, "H5Gget_objsname_by_idx");
+ VERIFY(ret, FAIL, "H5Gget_objname_by_idx");
}
/* Test invalid indices for starting iteration */
@@ -728,7 +728,8 @@ static void test_grp_memb_funcs(void)
char name[NAMELEN]; /* temporary name buffer */
char *dnames[NDATASETS+2];/* Names of the datasets created */
char *obj_names[NDATASETS+2];/* Names of the objects in group */
- char dataset_name[16]; /* dataset name */
+ char dataset_name[NAMELEN]; /* dataset name */
+ ssize_t name_len; /* Length of object's name */
hsize_t num_membs; /* Number of group members */
herr_t ret; /* Generic return value */
@@ -805,28 +806,35 @@ static void test_grp_memb_funcs(void)
VERIFY(num_membs,NDATASETS+2,"H5Gget_num_objs");
for(i=0; i< (int)num_membs; i++) {
- ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, 32);
- CHECK(ret, FAIL, "H5Gget_objsname_by_idx");
+ /* Test with NULL for name, to query length */
+ name_len = H5Gget_objname_by_idx(root_group, (hsize_t)i, NULL, NAMELEN);
+ CHECK(name_len, FAIL, "H5Gget_objname_by_idx");
+
+ ret = H5Gget_objname_by_idx(root_group, (hsize_t)i, dataset_name, NAMELEN);
+ CHECK(ret, FAIL, "H5Gget_objname_by_idx");
+
+ /* Double-check that the length is the same */
+ VERIFY(ret, name_len, "H5Gget_objname_by_idx");
/* Keep a copy of the dataset names around for later */
obj_names[i]=HDstrdup(dataset_name);
- CHECK(dnames[i], NULL, "strdup");
+ CHECK(obj_names[i], NULL, "strdup");
ret = (herr_t)H5Gget_objtype_by_idx(root_group, (hsize_t)i);
- CHECK(ret, FAIL, "H5Gget_objsname_by_idx");
+ CHECK(ret, FAIL, "H5Gget_objtype_by_idx");
if(!HDstrcmp(dataset_name, "grp"))
- VERIFY(ret, H5G_GROUP, "H5Gget_objsname_by_idx");
+ VERIFY(ret, H5G_GROUP, "H5Gget_objname_by_idx");
if(!HDstrcmp(dataset_name, "dtype"))
- VERIFY(ret, H5G_TYPE, "H5Gget_objsname_by_idx");
+ VERIFY(ret, H5G_TYPE, "H5Gget_objname_by_idx");
if(!HDstrncmp(dataset_name, "Dataset", 7))
- VERIFY(ret, H5G_DATASET, "H5Gget_objsname_by_idx");
+ VERIFY(ret, H5G_DATASET, "H5Gget_objname_by_idx");
}
H5E_BEGIN_TRY {
- ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)(NDATASETS+3), dataset_name, 16);
+ ret = (herr_t)H5Gget_objname_by_idx(root_group, (hsize_t)(NDATASETS+3), dataset_name, NAMELEN);
} H5E_END_TRY;
- VERIFY(ret, FAIL, "H5Gget_objsname_by_idx");
+ VERIFY(ret, FAIL, "H5Gget_objname_by_idx");
/* Sort the dataset names */
qsort(obj_names,NDATASETS+2,sizeof(char *),iter_strcmp);