From b89828d5b9284f4bd6d20ef66408c91283d7fbb3 Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Wed, 23 Mar 2005 12:55:27 -0500 Subject: [svn-r10386] Purpose: new tests for is scale, detach scales and iterate scales Description: Solution: Platforms tested: linux solaris Misc. update: --- hl/src/H5DS.c | 3 - hl/test/test_ds.c | 586 ++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 462 insertions(+), 127 deletions(-) diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index 552de73..8dfdc10 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -1013,7 +1013,6 @@ int H5DSget_num_scales(hid_t did, /* error zone, gracefully close */ out: H5E_BEGIN_TRY { - H5Dclose(did); H5Sclose(sid); H5Aclose(aid); H5Tclose(tid); @@ -1964,8 +1963,6 @@ out: H5Sclose(sid); H5Aclose(aid); H5Tclose(tid); - H5Dclose(did); - H5Dclose(dsid); } H5E_END_TRY; return FAIL; } diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c index c6d9b34..5e6b2fc 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -24,12 +24,16 @@ static herr_t verifiy_scale(hid_t dset, unsigned dim, hid_t scale, void *visitor_data); static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale, void *visitor_data); static herr_t match_dim_scale(hid_t did, unsigned dim, hid_t dsid, void *visitor_data); +static herr_t op_bogus(hid_t did, unsigned dim, hid_t dsid, void *visitor_data); + /* prototypes */ static int test_simple(void); static int test_errors(void); static int test_rank(void); +static int test_iterators(void); + @@ -73,6 +77,7 @@ int main(void) nerrors += test_simple()<0 ?1:0; nerrors += test_errors()<0 ?1:0; nerrors += test_rank()<0 ?1:0; + nerrors += test_iterators()<0 ?1:0; if (nerrors) goto error; printf("All dimension scales tests passed.\n"); @@ -96,6 +101,8 @@ error: * H5DSset_scale * H5DSget_scale_name * H5DSis_scale + * H5DSiterate_scales + * H5DSget_num_scales * *------------------------------------------------------------------------- */ @@ -1613,6 +1620,247 @@ out: } +/*------------------------------------------------------------------------- + * Function: op_bogus + * + * Purpose: example operator function used by H5DSiterate_scales, that does nothing + * + * Return: + * The return values from an operator are: + * Zero causes the iterator to continue, returning zero when all group members have been processed. + * Positive causes the iterator to immediately return that positive value, indicating + * short-circuit success. The iterator can be restarted at the next group member. + * Negative causes the iterator to immediately return that value, indicating failure. + * The iterator can be restarted at the next group member. + * + *------------------------------------------------------------------------- + */ + +static herr_t op_bogus(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data) +{ + /* define a default zero value for return. This will cause the iterator to continue */ + int ret = 0; + + /* unused */ + dset=dset; + dim=dim; + visitor_data=visitor_data; + + return ret; +} + + + + +/*------------------------------------------------------------------------- + * test several rank and types + *------------------------------------------------------------------------- + */ + +static int test_rank(void) +{ + hid_t fid; /* file ID */ + hid_t did; /* dataset ID */ + hid_t dsid; /* scale ID */ + int rank = 3; /* rank of data dataset */ + hsize_t dims[3] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE}; /* size of data dataset */ + char name[30]; /* dataset name buffer */ + char names[30]; /* dataset scale name buffer */ + char namel[30]; /* dataset label name buffer */ + int i; + + printf("Testing ranks\n"); + +/*------------------------------------------------------------------------- + * create a file, a dataset, scales + *------------------------------------------------------------------------- + */ + + /* create a file using default properties */ + if ((fid=H5Fcreate("test_ds3.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) + goto out; + + /* make a dataset */ + if (H5LTmake_dataset_int(fid,"dset_a",rank,dims,NULL)<0) + goto out; + + /* make scale datasets */ + for (i=0; i