From 20f6e6203a637980e401d876914d41447f7487db Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Fri, 25 Mar 2005 13:31:37 -0500 Subject: [svn-r10446] Purpose: new test Description: added a test for a scalar scale Solution: Platforms tested: linux solaris AIX IRIX Misc. update: --- hl/src/H5DS.c | 10 +++++-- hl/test/test_ds.c | 87 ++++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 67 insertions(+), 30 deletions(-) diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index fbff253..b32387f 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -185,6 +185,10 @@ herr_t H5DSattach_scale(hid_t did, if ((rank=H5Sget_simple_extent_ndims(sid))<0) goto out; + /* scalar rank */ + if (rank==0) + rank=1; + /* close dataset space */ if (H5Sclose(sid)<0) return FAIL; @@ -1331,7 +1335,7 @@ out: * the string terminator is stored in the last position of the buffer to * properly terminate the string. * - * Return: size of name if found, Failure: FAIL + * Return: size of name if found, zero if not found, Failure: FAIL * * Programmer: pvn@ncsa.uiuc.edu * @@ -1381,7 +1385,7 @@ ssize_t H5DSget_scale_name(hid_t did, return FAIL; if (has_name == 0) - return FAIL; + return 0; /*------------------------------------------------------------------------- * open the attribute @@ -1400,7 +1404,7 @@ ssize_t H5DSget_scale_name(hid_t did, goto out; /* get the size */ - if ((nbytes = H5Tget_size(tid))<0) + if ((nbytes = H5Tget_size(tid))==0) goto out; /* allocate a temporary buffer */ diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c index b819186..fa1c3de 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -63,7 +63,10 @@ static int test_iterators(void); #define DIM0_LABEL "Latitude" #define DIM1_LABEL "Longitude" - +#define FILE1 "test_ds1.h5" +#define FILE2 "test_ds2.h5" +#define FILE3 "test_ds3.h5" +#define FILE4 "test_ds4.h5" /*------------------------------------------------------------------------- * the main program @@ -152,7 +155,7 @@ static int test_simple(void) */ /* create a file using default properties */ - if ((fid=H5Fcreate("test_ds1.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) + if ((fid=H5Fcreate(FILE1,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) goto out; /*------------------------------------------------------------------------- @@ -850,7 +853,7 @@ static int test_simple(void) if ((gid=H5Gcreate(fid,"grp",0))<0) goto out; - /* create the data space for the dataset */ + /* create the data space for the dataset */ if ((sid=H5Screate_simple(rank,dims,NULL))<0) goto out; @@ -1721,7 +1724,7 @@ static int test_errors(void) */ /* create a file using default properties */ - if ((fid=H5Fcreate("test_ds2.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) + if ((fid=H5Fcreate(FILE2,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) goto out; /* create a group */ if ((gid=H5Gcreate(fid,"grp",0))<0) @@ -2099,7 +2102,7 @@ static int test_iterators(void) */ /* create a file using default properties */ - if ((fid=H5Fcreate("test_ds4.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) + if ((fid=H5Fcreate(FILE3,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) goto out; /* create a group */ if ((gid=H5Gcreate(fid,"grp",0))<0) @@ -2270,11 +2273,16 @@ static int test_rank(void) hid_t did; /* dataset ID */ hid_t dsid; /* scale ID */ hid_t sid; /* space ID */ - int rank = 3; /* rank of data dataset */ - hsize_t dims[3] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE}; /* size of data dataset */ + hid_t sidds; /* space ID */ + hsize_t dims1[1] = {DIM1_SIZE}; /* size of data dataset */ + hsize_t dims2[2] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */ + hsize_t dims3[3] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE}; /* size of data dataset */ + hsize_t dimss[2] = {1,1}; /* 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 bufi[1]={2}; + float buff[1]={1}; int i; printf("Testing ranks\n"); @@ -2285,20 +2293,24 @@ static int test_rank(void) */ /* create a file using default properties */ - if ((fid=H5Fcreate("test_ds3.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) + if ((fid=H5Fcreate(FILE4,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) goto out; - /* make a dataset */ - if (H5LTmake_dataset_int(fid,"dset_a",rank,dims,NULL)<0) + /* make a dataset a 3D data dataset */ + if (H5LTmake_dataset_int(fid,"dset_a",3,dims3,NULL)<0) goto out; - /* make scale datasets */ - for (i=0; i