diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2005-08-13 20:53:35 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2005-08-13 20:53:35 (GMT) |
commit | 6b45f5172ccb4311e0be9ae15da3758abb6b0e67 (patch) | |
tree | 5a7a112fe7a8a98c6fecb45b513789d15962eb3d /hl/test | |
parent | 6562465a2c2a58cfbc2f47bf60bb538f7a783933 (diff) | |
download | hdf5-6b45f5172ccb4311e0be9ae15da3758abb6b0e67.zip hdf5-6b45f5172ccb4311e0be9ae15da3758abb6b0e67.tar.gz hdf5-6b45f5172ccb4311e0be9ae15da3758abb6b0e67.tar.bz2 |
[svn-r11245] Purpose:
Code cleanup
Description:
Trim trailing whitespace, which is making 'diff'ing the two branches
difficult.
Solution:
Ran this script in each directory:
foreach f (*.[ch] *.cpp)
sed 's/[[:blank:]]*$//' $f > sed.out && mv sed.out $f
end
Platforms tested:
FreeBSD 4.11 (sleipnir)
Too minor to require h5committest
Diffstat (limited to 'hl/test')
-rw-r--r-- | hl/test/pal_rgb.h | 2 | ||||
-rw-r--r-- | hl/test/test_ds.c | 546 | ||||
-rw-r--r-- | hl/test/test_image.c | 210 | ||||
-rw-r--r-- | hl/test/test_lite.c | 88 | ||||
-rw-r--r-- | hl/test/test_packet.c | 24 | ||||
-rw-r--r-- | hl/test/test_table.c | 516 |
6 files changed, 693 insertions, 693 deletions
diff --git a/hl/test/pal_rgb.h b/hl/test/pal_rgb.h index 4b66220..08b5b61 100644 --- a/hl/test/pal_rgb.h +++ b/hl/test/pal_rgb.h @@ -258,7 +258,7 @@ const unsigned char pal_rgb[256*3] = {255,255,255, 131,0,0, 127,0,0 }; - + diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c index 8269805..41016d4 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -85,7 +85,7 @@ int main(void) if (nerrors) goto error; printf("All dimension scales tests passed.\n"); return 0; - + error: printf("***** %d DIMENSION SCALES TEST%s FAILED! *****\n",nerrors, 1 == nerrors ? "" : "S"); return 1; @@ -146,23 +146,23 @@ static int test_simple(void) char *name_out=NULL; /* scale name buffer */ char snames[3]; /* scale name buffer */ int i, j; - - + + printf("Testing API functions\n"); - + /*------------------------------------------------------------------------- * create a file for the test *------------------------------------------------------------------------- - */ + */ /* create a file using default properties */ if ((fid=H5Fcreate(FILE1,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) goto out; - + /*------------------------------------------------------------------------- * create datasets: 1 "data" dataset and 4 dimension scales *------------------------------------------------------------------------- - */ + */ /* make a dataset */ if (H5LTmake_dataset_int(fid,"dset_a",rank,dims,buf)<0) @@ -188,11 +188,11 @@ static int test_simple(void) if (H5LTmake_dataset_int(fid,DS_22_NAME,rankds,s2_dim,s22_wbuf)<0) goto out; - + /*------------------------------------------------------------------------- * test 1: attach scale *------------------------------------------------------------------------- - */ + */ TESTING2("attach scales"); @@ -203,7 +203,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * attach the DS_1_NAME dimension scale to "dset_a" *------------------------------------------------------------------------- - */ + */ /* get the DS dataset id */ if ((dsid = H5Dopen(fid,DS_1_NAME))<0) @@ -220,7 +220,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * attach the DS_11_NAME dimension scale to "dset_a" *------------------------------------------------------------------------- - */ + */ /* get the DS dataset id */ if ((dsid = H5Dopen(fid,DS_11_NAME))<0) @@ -237,7 +237,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * attach the DS_2_NAME dimension scale to "dset_a" *------------------------------------------------------------------------- - */ + */ /* get the DS dataset id */ if ((dsid = H5Dopen(fid,DS_2_NAME))<0) @@ -250,11 +250,11 @@ static int test_simple(void) /* close DS id */ if (H5Dclose(dsid)<0) goto out; - + /*------------------------------------------------------------------------- * attach the DS_21_NAME dimension scale to "dset_a" *------------------------------------------------------------------------- - */ + */ /* get the DS dataset id */ if ((dsid = H5Dopen(fid,DS_21_NAME))<0) @@ -271,7 +271,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * attach the DS_22_NAME dimension scale to "dset_a" *------------------------------------------------------------------------- - */ + */ /* get the DS dataset id */ if ((dsid = H5Dopen(fid,DS_22_NAME))<0) @@ -286,11 +286,11 @@ static int test_simple(void) goto out; - + /*------------------------------------------------------------------------- * verify attachment *------------------------------------------------------------------------- - */ + */ if ((dsid = H5Dopen(fid,DS_1_NAME))<0) goto out; @@ -320,11 +320,11 @@ static int test_simple(void) if (H5Dclose(dsid)) goto out; - + /* close dataset ID of "dset_a" */ if (H5Dclose(did)<0) goto out; - + PASSED(); @@ -332,15 +332,15 @@ static int test_simple(void) /*------------------------------------------------------------------------- * test 2: get number of scales *------------------------------------------------------------------------- - */ + */ TESTING2("get number of scales"); /*------------------------------------------------------------------------- * verify that "dset_a" has dimension scales *------------------------------------------------------------------------- - */ - + */ + /* get the dataset id for "dset_a" */ if ((did = H5Dopen(fid,"dset_a"))<0) goto out; @@ -361,11 +361,11 @@ static int test_simple(void) if (H5Dclose(did)<0) goto out; - + /*------------------------------------------------------------------------- * create datasets: 1 "data" dataset and 1 dimension scale *------------------------------------------------------------------------- - */ + */ /* make a dataset */ if (H5LTmake_dataset_int(fid,"dset_b",rank,dims,buf)<0) @@ -378,7 +378,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * attach the scale to "dset_b" *------------------------------------------------------------------------- - */ + */ if ((did = H5Dopen(fid,"dset_b"))<0) goto out; @@ -394,7 +394,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * verify if "dset_b" has dimension scales *------------------------------------------------------------------------- - */ + */ /* get the dataset id for "dset_b" */ if ((did = H5Dopen(fid,"dset_b"))<0) @@ -422,7 +422,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * test 3: detach scales *------------------------------------------------------------------------- - */ + */ TESTING2("detach scales "); @@ -430,7 +430,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * create datasets: one "data" dataset and 4 dimension scales *------------------------------------------------------------------------- - */ + */ /* make a dataset */ if (H5LTmake_dataset_int(fid,"dset_c",rank,dims,buf)<0) @@ -456,7 +456,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * attach the scales to "dset_c" *------------------------------------------------------------------------- - */ + */ if ((did = H5Dopen(fid,"dset_c"))<0) goto out; @@ -495,7 +495,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * verify if "dset_c" has dimension scales *------------------------------------------------------------------------- - */ + */ if ((did = H5Dopen(fid,"dset_c"))<0) goto out; @@ -511,11 +511,11 @@ static int test_simple(void) goto out; if (H5Dclose(did)<0) goto out; - + /*------------------------------------------------------------------------- * detach the "ds_c_21" dimension scale to "dset_c" *------------------------------------------------------------------------- - */ + */ /* get the dataset id for "dset_c" */ if ((did = H5Dopen(fid,"dset_c"))<0) @@ -526,7 +526,7 @@ static int test_simple(void) goto out; /* detach the "ds_c_21" dimension scale to "dset_c" in DIM 1 */ - if (H5DSdetach_scale(did,dsid,1)<0) + if (H5DSdetach_scale(did,dsid,1)<0) goto out; /* close DS id */ @@ -540,7 +540,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * "dset_c" must have now 2 dimension scales at DIM 1 *------------------------------------------------------------------------- - */ + */ if ((did = H5Dopen(fid,"dset_c"))<0) goto out; @@ -555,7 +555,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * detach the "ds_c_22" dimension scale to "dset_c" *------------------------------------------------------------------------- - */ + */ /* get the dataset id for "dset_c" */ if ((did = H5Dopen(fid,"dset_c"))<0) @@ -566,7 +566,7 @@ static int test_simple(void) goto out; /* detach the "ds_c_22" dimension scale to "dset_c" in DIM 1 */ - if (H5DSdetach_scale(did,dsid,1)<0) + if (H5DSdetach_scale(did,dsid,1)<0) goto out; /* close DS id */ @@ -580,7 +580,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * "dset_c" must have now 1 dimension scale at DIM 1 *------------------------------------------------------------------------- - */ + */ if ((did = H5Dopen(fid,"dset_c"))<0) goto out; @@ -595,7 +595,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * detach the "ds_c_2" dimension scale to "dset_c" *------------------------------------------------------------------------- - */ + */ /* get the dataset id for "dset_c" */ if ((did = H5Dopen(fid,"dset_c"))<0) @@ -606,7 +606,7 @@ static int test_simple(void) goto out; /* detach the "ds_c_2" dimension scale to "dset_c" in DIM 1 */ - if (H5DSdetach_scale(did,dsid,1)<0) + if (H5DSdetach_scale(did,dsid,1)<0) goto out; /* close DS id */ @@ -620,7 +620,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * "dset_c" must have now 0 dimension scales at DIM 1 *------------------------------------------------------------------------- - */ + */ if ((did = H5Dopen(fid,"dset_c"))<0) goto out; @@ -634,9 +634,9 @@ static int test_simple(void) /*------------------------------------------------------------------------- - * create 3 datasets: 1 "data" dataset and 2 dimension scales + * create 3 datasets: 1 "data" dataset and 2 dimension scales *------------------------------------------------------------------------- - */ + */ if (H5LTmake_dataset_int(fid,"dset_d",rank,dims,NULL)<0) goto out; if (H5LTmake_dataset_int(fid,"ds_d_1",rankds,s1_dim,NULL)<0) @@ -647,7 +647,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * attach them *------------------------------------------------------------------------- - */ + */ if ((did = H5Dopen(fid,"dset_d"))<0) goto out; @@ -670,7 +670,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * verify *------------------------------------------------------------------------- - */ + */ if ((did = H5Dopen(fid,"dset_d"))<0) goto out; @@ -696,7 +696,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * detach *------------------------------------------------------------------------- - */ + */ /* get the dataset id for "dset_d" */ if ((did = H5Dopen(fid,"dset_d"))<0) @@ -707,7 +707,7 @@ static int test_simple(void) goto out; /* detach the dimension scale to "dset_d" in DIM 0 */ - if (H5DSdetach_scale(did,dsid,DIM0)<0) + if (H5DSdetach_scale(did,dsid,DIM0)<0) goto out; /* verify attach, it must return 0 for no attach */ @@ -725,8 +725,8 @@ static int test_simple(void) /*------------------------------------------------------------------------- * attach again *------------------------------------------------------------------------- - */ - + */ + /* get the dataset id for "dset_d" */ if ((did = H5Dopen(fid,"dset_d"))<0) goto out; @@ -736,7 +736,7 @@ static int test_simple(void) goto out; /* attach "ds_d_1" again in DIM 0 */ - if (H5DSattach_scale(did,dsid,DIM0)<0) + if (H5DSattach_scale(did,dsid,DIM0)<0) goto out; /* verify attach, it must return 1 for attach */ @@ -760,8 +760,8 @@ static int test_simple(void) /*------------------------------------------------------------------------- * detach/detach *------------------------------------------------------------------------- - */ - + */ + /* get the dataset id for "dset_d" */ if ((did = H5Dopen(fid,"dset_d"))<0) goto out; @@ -771,11 +771,11 @@ static int test_simple(void) goto out; /* detach the "ds_d_2" dimension scale to "dset_d" in DIM 1 */ - if (H5DSdetach_scale(did,dsid,DIM1)<0) + if (H5DSdetach_scale(did,dsid,DIM1)<0) goto out; /* detach again, it should fail */ - if (H5DSdetach_scale(did,dsid,DIM1)==SUCCESS) + if (H5DSdetach_scale(did,dsid,DIM1)==SUCCESS) goto out; /* verify attach, it must return 0 for no attach */ @@ -799,8 +799,8 @@ static int test_simple(void) /*------------------------------------------------------------------------- * attach twice *------------------------------------------------------------------------- - */ - + */ + /* get the dataset id for "dset_d" */ if ((did = H5Dopen(fid,"dset_d"))<0) goto out; @@ -810,7 +810,7 @@ static int test_simple(void) goto out; /* attach "ds_d_2" in DIM 1 */ - if (H5DSattach_scale(did,dsid,DIM1)<0) + if (H5DSattach_scale(did,dsid,DIM1)<0) goto out; /* verify attach, it must return 1 for attach */ @@ -824,9 +824,9 @@ static int test_simple(void) goto out; /* attach "ds_d_2" again in DIM 1 */ - if (H5DSattach_scale(did,dsid,DIM1)<0) + if (H5DSattach_scale(did,dsid,DIM1)<0) goto out; - + /* verify attach, it must return 1 for attach */ if (H5DSis_attached(did,dsid,DIM1)!=1) goto out; @@ -846,19 +846,19 @@ static int test_simple(void) goto out; /*------------------------------------------------------------------------- - * create 10 datasets: 5 "data" dataset and 5 dimension scales + * create 10 datasets: 5 "data" dataset and 5 dimension scales *------------------------------------------------------------------------- - */ + */ /* create a group */ - if ((gid=H5Gcreate(fid,"grp",0))<0) + if ((gid=H5Gcreate(fid,"grp",0))<0) goto out; - + /* create the data space for the dataset */ if ((sid=H5Screate_simple(rank,dims,NULL))<0) goto out; - for (i=0; i<5; i++) + for (i=0; i<5; i++) { sprintf(dname,"dset_%d",i); if ((did = H5Dcreate(gid,dname,H5T_NATIVE_INT,sid,H5P_DEFAULT))<0) @@ -877,14 +877,14 @@ static int test_simple(void) /*------------------------------------------------------------------------- * attach for DIM 0 *------------------------------------------------------------------------- - */ + */ - for (i=0; i<5; i++) + for (i=0; i<5; i++) { sprintf(dname,"dset_%d",i); if ((did = H5Dopen(gid,dname))<0) goto out; - for (j=0; j<5; j++) + for (j=0; j<5; j++) { sprintf(sname,"ds_%d",j); if((dsid = H5Dopen(gid,sname))<0) @@ -901,14 +901,14 @@ static int test_simple(void) /*------------------------------------------------------------------------- * dettach for DIM0 *------------------------------------------------------------------------- - */ + */ - for (i=0; i<5; i++) + for (i=0; i<5; i++) { sprintf(dname,"dset_%d",i); if ((did = H5Dopen(gid,dname))<0) goto out; - for (j=0; j<5; j++) + for (j=0; j<5; j++) { sprintf(sname,"ds_%d",j); if((dsid = H5Dopen(gid,sname))<0) @@ -926,14 +926,14 @@ static int test_simple(void) /*------------------------------------------------------------------------- * attach again for DIM0 *------------------------------------------------------------------------- - */ + */ - for (i=0; i<5; i++) + for (i=0; i<5; i++) { sprintf(dname,"dset_%d",i); if ((did = H5Dopen(gid,dname))<0) goto out; - for (j=0; j<5; j++) + for (j=0; j<5; j++) { sprintf(sname,"ds_%d",j); if((dsid = H5Dopen(gid,sname))<0) @@ -960,10 +960,10 @@ static int test_simple(void) /*------------------------------------------------------------------------- * create a dataset and attach only to 1 dimension *------------------------------------------------------------------------- - */ + */ TESTING2("attach only to 1 dimension"); - + /* make a dataset */ if (H5LTmake_dataset_int(fid,"dset_e",rank,dims,NULL)<0) goto out; @@ -984,7 +984,7 @@ static int test_simple(void) /* try to detach all dimensions. for dimensions 0 and 2, it is an error */ - for (i=0; i<rank; i++) + for (i=0; i<rank; i++) { if ( i==1 ) { @@ -1002,15 +1002,15 @@ static int test_simple(void) goto out; if (H5Dclose(did)<0) goto out; - + PASSED(); /*------------------------------------------------------------------------- * test 4: set/get label *------------------------------------------------------------------------- - */ - + */ + TESTING2("set/get label"); if ((did = H5Dopen(fid,"dset_a"))<0) @@ -1019,7 +1019,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * set label *------------------------------------------------------------------------- - */ + */ if (H5DSset_label(did,DIM0,DIM0_LABEL)<0) goto out; @@ -1029,7 +1029,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * get the scale name using a static buffer *------------------------------------------------------------------------- - */ + */ if (H5DSget_label(did,DIM0,dim0_label,sizeof(dim0_label))<0) goto out; @@ -1044,7 +1044,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * get the scale name using a dynamic buffer *------------------------------------------------------------------------- - */ + */ if ((dim0_label_size=H5DSget_label(did,DIM0,NULL,0))<0) goto out; @@ -1061,19 +1061,19 @@ static int test_simple(void) goto out; if (H5DSget_label(did,DIM1,dim1_labeld,dim1_label_size)<0) goto out; - + if (strncmp(DIM0_LABEL,dim0_labeld,dim0_label_size-1)!=0) goto out; if (strncmp(DIM1_LABEL,dim1_labeld,dim1_label_size-1)!=0) goto out; if (dim0_labeld) - { + { free(dim0_labeld); dim0_labeld=NULL; } if (dim1_labeld) - { + { free(dim1_labeld); dim1_labeld=NULL; } @@ -1082,7 +1082,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * get the label using a static buffer smaller than the string lenght *------------------------------------------------------------------------- - */ + */ if (H5DSget_label(did,DIM0,dim0_labels,sizeof(dim0_labels))<0) goto out; @@ -1100,11 +1100,11 @@ static int test_simple(void) goto out; PASSED(); - + /*------------------------------------------------------------------------- * test 5: set scale/get scale name *------------------------------------------------------------------------- - */ + */ TESTING2("set scale/get scale name"); if ((dsid = H5Dopen(fid,DS_1_NAME))<0) @@ -1120,7 +1120,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * get the scale name using a dynamic buffer *------------------------------------------------------------------------- - */ + */ /* get the lenght of the scale name (pass NULL in name) */ if ((name_len=H5DSget_scale_name(dsid,NULL,0))<0) @@ -1134,12 +1134,12 @@ static int test_simple(void) /* get the scale name using this buffer */ if (H5DSget_scale_name(dsid,name_out,name_len)<0) goto out; - + if (strcmp(SCALE_1_NAME,name_out)!=0) goto out; if (name_out) - { + { free(name_out); name_out=NULL; } @@ -1147,24 +1147,24 @@ static int test_simple(void) /*------------------------------------------------------------------------- * get the scale name using a static buffer *------------------------------------------------------------------------- - */ + */ /* get the scale name using this buffer */ if (H5DSget_scale_name(dsid,sname,sizeof(sname))<0) goto out; - + if (strcmp(SCALE_1_NAME,sname)!=0) goto out; /*------------------------------------------------------------------------- * get the scale name using a static buffer smaller than the string lenght *------------------------------------------------------------------------- - */ + */ /* get the scale name using this buffer */ if (H5DSget_scale_name(dsid,snames,sizeof(snames))<0) goto out; - + if (strncmp(SCALE_1_NAME,snames,sizeof(snames)-1)!=0) goto out; @@ -1172,9 +1172,9 @@ static int test_simple(void) goto out; /*------------------------------------------------------------------------- - * add scale names + * add scale names *------------------------------------------------------------------------- - */ + */ if ((dsid = H5Dopen(fid,DS_11_NAME))<0) goto out; @@ -1210,7 +1210,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * test 6: test iterate scales with a function verifiy_scale *------------------------------------------------------------------------- - */ + */ TESTING2("iterate scales (verify scale)"); /* get the dataset id for "dset_a" */ @@ -1241,7 +1241,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * test 7: test iterate scales with a function read_scale *------------------------------------------------------------------------- - */ + */ TESTING2("iterate scales (read scale values)"); @@ -1272,7 +1272,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * test 8: test iterate scales with a function match_dim_scale *------------------------------------------------------------------------- - */ + */ TESTING2("iterate scales (verify the scale sizes match)"); /* get the dataset id for "dset_a" */ @@ -1282,7 +1282,7 @@ static int test_simple(void) /* get dataset space */ if ((sid = H5Dget_space(did))<0) goto out; - + /* get rank */ if ((rank=H5Sget_simple_extent_ndims(sid))<0) goto out; @@ -1294,13 +1294,13 @@ static int test_simple(void) { int match_size; /* does this scale size matches the dataset DIM size */ int idx=0; /* scale index to start iterating, on return, index where iterator stoped */ - + /* iterate trough all the dimensions */ for(dim=0; dim<(unsigned)rank; dim++) { if ((match_size=H5DSiterate_scales(did,dim,&idx,match_dim_scale,NULL))<0) goto out; - + /* "dset_a" was defined with all dimension scales size matching the size of its dimensions */ if (match_size==0) goto out; @@ -1311,7 +1311,7 @@ static int test_simple(void) } } - + /* close */ if (H5Dclose(did)<0) goto out; @@ -1323,13 +1323,13 @@ static int test_simple(void) /*------------------------------------------------------------------------- * test 9: test iterate scales with a function match_dim_scale *------------------------------------------------------------------------- - */ + */ TESTING2("iterate scales (verify the scale sizes do not match)"); /*------------------------------------------------------------------------- * create 3 datasets: 1 "data" dataset and dimension scales (some are empty) *------------------------------------------------------------------------- - */ + */ if (H5LTmake_dataset_int(fid,"dset_f",rank,dims,buf)<0) goto out; if (H5LTmake_dataset_int(fid,"ds_f_1",rankds,s1_dim,NULL)<0) @@ -1342,7 +1342,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * attach them *------------------------------------------------------------------------- - */ + */ if ((did = H5Dopen(fid,"dset_f"))<0) goto out; @@ -1371,7 +1371,7 @@ static int test_simple(void) /*------------------------------------------------------------------------- * verify match *------------------------------------------------------------------------- - */ + */ /* get the dataset id for "dset_f" */ if ((did = H5Dopen(fid,"dset_f"))<0) goto out; @@ -1379,7 +1379,7 @@ static int test_simple(void) /* get dataset space */ if ((sid = H5Dget_space(did))<0) goto out; - + /* get rank */ if ((rank=H5Sget_simple_extent_ndims(sid))<0) goto out; @@ -1391,7 +1391,7 @@ static int test_simple(void) { int match_size; /* does this scale size matches the dataset DIM size */ int idx; /* scale index to start iterating, on return, index where iterator stoped */ - + /* iterate trough all the dimensions */ for(dim=0; dim<(unsigned)rank; dim++) { @@ -1400,7 +1400,7 @@ static int test_simple(void) if ((match_size=H5DSiterate_scales(did,dim,&idx,match_dim_scale,NULL))<0) goto out; - + /* "dset_e" was defined with : dim 0: 2 scales, first is empty dim 1: 1 scale, empty */ @@ -1416,7 +1416,7 @@ static int test_simple(void) }/*switch*/ }/*for*/ } - + /* close */ if (H5Dclose(did)<0) goto out; @@ -1429,13 +1429,13 @@ static int test_simple(void) /*------------------------------------------------------------------------- * end *------------------------------------------------------------------------- - */ + */ /* close */ H5Fclose(fid); return 0; - + /* error zone, gracefully close */ out: H5E_BEGIN_TRY { @@ -1454,13 +1454,13 @@ out: * Purpose: example operator function used by H5DSiterate_scales, used * to verify that SCALE_ID refers to a valid DS dataset * - * 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. + * 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. * *------------------------------------------------------------------------- */ @@ -1468,15 +1468,15 @@ out: static herr_t verifiy_scale(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; - + int ret = 0; + /* unused */ dset=dset; dim=dim; visitor_data=visitor_data; - /* define a positive value for return value. This will cause the iterator to - immediately return that positive value, indicating short-circuit success + /* define a positive value for return value. This will cause the iterator to + immediately return that positive value, indicating short-circuit success */ /* the parameter DS dataset must be a valid DS dataset */ @@ -1484,9 +1484,9 @@ static herr_t verifiy_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visi { ret = 1; } - + return ret; -} +} /*------------------------------------------------------------------------- @@ -1495,13 +1495,13 @@ static herr_t verifiy_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visi * Purpose: example operator function used by H5DSiterate_scales, used * to read data from DS dataset. compare read and write buffers * - * 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 + * 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 * * *------------------------------------------------------------------------- @@ -1538,7 +1538,7 @@ static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor /* get type size */ if ((size=H5Tget_size(mtid))==0) goto out; - + if (nelmts) { buf=(char *) malloc((unsigned)(nelmts*size)); @@ -1546,7 +1546,7 @@ static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor goto out; if (H5Dread(scale_id,mtid,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) goto out; - + for(i=0; i<nelmts; i++) { if (buf[i] != data[i]) @@ -1555,19 +1555,19 @@ static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor goto out; } } - + } /* if */ - + if (H5Sclose(sid)<0) goto out; - if (H5Tclose(tid)<0) + if (H5Tclose(tid)<0) goto out; - if (H5Tclose(mtid)<0) + if (H5Tclose(mtid)<0) goto out; if (buf) free(buf); - - + + return ret; /* error zone, gracefully close */ @@ -1581,7 +1581,7 @@ static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor } H5E_END_TRY; return FAIL; -} +} /*------------------------------------------------------------------------- @@ -1590,13 +1590,13 @@ static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor * Purpose: example operator function used by H5DSiterate_scales, used * to verify the the DSID scale size matches the dataset DIM size * - * 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. + * 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. * *------------------------------------------------------------------------- */ @@ -1612,7 +1612,7 @@ static herr_t match_dim_scale(hid_t did, unsigned dim, hid_t dsid, void *visitor /*------------------------------------------------------------------------- * get DID (dataset) space info *------------------------------------------------------------------------- - */ + */ /* get dataset space */ if ((sid = H5Dget_space(did))<0) @@ -1625,16 +1625,16 @@ static herr_t match_dim_scale(hid_t did, unsigned dim, hid_t dsid, void *visitor /* close the dataspace id */ if (H5Sclose(sid)<0) goto out; - + /*------------------------------------------------------------------------- * get DSID (scale) space info *------------------------------------------------------------------------- - */ - + */ + /* get the space for the scale */ if ((sid = H5Dget_space(dsid))<0) goto out; - + /* get size of the DS array */ if ((nelmts = H5Sget_simple_extent_npoints(sid))<0) goto out; @@ -1642,7 +1642,7 @@ static herr_t match_dim_scale(hid_t did, unsigned dim, hid_t dsid, void *visitor /* close */ if (H5Sclose(sid)<0) goto out; - + /* the size of the DS array must match the dimension of the dataset */ if (nelmts == (hssize_t)dims[dim]) ret = 1; @@ -1654,13 +1654,13 @@ static herr_t match_dim_scale(hid_t did, unsigned dim, hid_t dsid, void *visitor ret = 0; return ret; - + out: H5E_BEGIN_TRY { H5Sclose(sid); } H5E_END_TRY; return FAIL; -} +} /*------------------------------------------------------------------------- @@ -1668,13 +1668,13 @@ out: * * 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. + * 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. * *------------------------------------------------------------------------- */ @@ -1682,15 +1682,15 @@ out: 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; - + int ret = 0; + /* unused */ dset=dset; dim=dim; visitor_data=visitor_data; - + return ret; -} +} @@ -1716,19 +1716,19 @@ static int test_errors(void) hid_t sid; /* space ID */ hid_t sidds; /* space ID */ hsize_t pal_dims[] = {9,3}; - + printf("Testing error conditions\n"); /*------------------------------------------------------------------------- * create a file, spaces, dataset and group ids *------------------------------------------------------------------------- - */ + */ /* create a file using default properties */ if ((fid=H5Fcreate(FILE2,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) goto out; /* create a group */ - if ((gid=H5Gcreate(fid,"grp",0))<0) + if ((gid=H5Gcreate(fid,"grp",0))<0) goto out; /* create the data space for the dataset */ if ((sid=H5Screate_simple(rank,dims,NULL))<0) @@ -1746,7 +1746,7 @@ static int test_errors(void) /*------------------------------------------------------------------------- * attempt to attach a dataset to itself, it should fail *------------------------------------------------------------------------- - */ + */ TESTING2("attach a dataset to itself"); @@ -1758,7 +1758,7 @@ static int test_errors(void) /*------------------------------------------------------------------------- * attempt to attach a group with a dataset, it should fail *------------------------------------------------------------------------- - */ + */ TESTING2("attach a group with a dataset"); if (H5DSattach_scale(gid,dsid,0)==SUCCESS) @@ -1769,7 +1769,7 @@ static int test_errors(void) /*------------------------------------------------------------------------- * attempt to attach a dataset with a group, it should fail *------------------------------------------------------------------------- - */ + */ TESTING2("attach a dataset with a group"); if (H5DSattach_scale(did,gid,0)==SUCCESS) @@ -1780,7 +1780,7 @@ static int test_errors(void) /*------------------------------------------------------------------------- * attempt to set scale for a group, it should fail *------------------------------------------------------------------------- - */ + */ TESTING2("set scale for a group"); if (H5DSset_scale(gid,"scale 1")==SUCCESS) @@ -1791,7 +1791,7 @@ static int test_errors(void) /*------------------------------------------------------------------------- * close IDs for this set *------------------------------------------------------------------------- - */ + */ /* close */ if (H5Dclose(dsid)<0) @@ -1809,14 +1809,14 @@ static int test_errors(void) /*------------------------------------------------------------------------- * try to attach a scale that has scales *------------------------------------------------------------------------- - */ + */ TESTING2("attach a scale that has scales"); /* create the data space for the scale */ if ((sidds=H5Screate_simple(rankds,s1_dim,NULL))<0) goto out; - + /* create a dataset "ds_b" for the scale */ if ((dsid=H5Dcreate(fid,"ds_b",H5T_NATIVE_INT,sidds,H5P_DEFAULT))<0) goto out; @@ -1876,9 +1876,9 @@ static int test_errors(void) PASSED(); /*------------------------------------------------------------------------- - * try to attach a dataset that is a scale + * try to attach a dataset that is a scale *------------------------------------------------------------------------- - */ + */ TESTING2("attach to a dataset that is a scale"); @@ -1905,7 +1905,7 @@ static int test_errors(void) /*------------------------------------------------------------------------- * try to attach a scale to an image, pallete or table *------------------------------------------------------------------------- - */ + */ TESTING2("attach to a dataset that is a reserved class dataset"); @@ -1940,7 +1940,7 @@ static int test_errors(void) /*------------------------------------------------------------------------- * is scale *------------------------------------------------------------------------- - */ + */ TESTING2("is scale"); @@ -1972,9 +1972,9 @@ static int test_errors(void) /*------------------------------------------------------------------------- - * detach + * detach *------------------------------------------------------------------------- - */ + */ TESTING2("detach scale from dataset it is not attached to"); @@ -2000,9 +2000,9 @@ static int test_errors(void) /*------------------------------------------------------------------------- - * detach + * detach *------------------------------------------------------------------------- - */ + */ TESTING2("detach scale from group"); @@ -2028,9 +2028,9 @@ static int test_errors(void) /*------------------------------------------------------------------------- - * detach + * detach *------------------------------------------------------------------------- - */ + */ TESTING2("detach scale when scale is group"); @@ -2060,7 +2060,7 @@ static int test_errors(void) goto out; return 0; - + /* error zone, gracefully close */ out: H5E_BEGIN_TRY { @@ -2094,19 +2094,19 @@ static int test_iterators(void) hid_t dsid; /* scale ID */ char dname[30]; /* dataset name */ int i; - + printf("Testing iterators\n"); /*------------------------------------------------------------------------- * create a file, spaces, dataset and group ids *------------------------------------------------------------------------- - */ + */ /* create a file using default properties */ if ((fid=H5Fcreate(FILE3,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) goto out; /* create a group */ - if ((gid=H5Gcreate(fid,"grp",0))<0) + if ((gid=H5Gcreate(fid,"grp",0))<0) goto out; /* close */ if (H5Gclose(gid)<0) @@ -2119,9 +2119,9 @@ static int test_iterators(void) goto out; /*------------------------------------------------------------------------- - * iterate when the dataset has no scales + * iterate when the dataset has no scales *------------------------------------------------------------------------- - */ + */ TESTING2("iterate when the dataset has no scales "); @@ -2143,7 +2143,7 @@ static int test_iterators(void) /*------------------------------------------------------------------------- * iterate on dimension that is outside the rank *------------------------------------------------------------------------- - */ + */ TESTING2("iterate on dimension that is outside the rank "); @@ -2164,7 +2164,7 @@ static int test_iterators(void) /*------------------------------------------------------------------------- * iterate for dimension with many scales *------------------------------------------------------------------------- - */ + */ TESTING2("iterate for dimension with many scales "); @@ -2172,7 +2172,7 @@ static int test_iterators(void) if ((did = H5Dopen(fid,"dset_a"))<0) goto out; - for (i=0; i<100; i++) + for (i=0; i<100; i++) { /* make a DS */ sprintf(dname,"ds_%d",i); @@ -2188,11 +2188,11 @@ static int test_iterators(void) if (H5Dclose(dsid)<0) goto out; } - + /* iterate trough the 1st dimension of "dset_a" */ if (H5DSiterate_scales(did,0,NULL,op_bogus,NULL)<0) goto out; - + /* close */ if (H5Dclose(did)<0) goto out; @@ -2202,7 +2202,7 @@ static int test_iterators(void) /*------------------------------------------------------------------------- * iterate on group *------------------------------------------------------------------------- - */ + */ TESTING2("iterate on group "); @@ -2224,7 +2224,7 @@ static int test_iterators(void) /*------------------------------------------------------------------------- * iterate in deleted scales *------------------------------------------------------------------------- - */ + */ TESTING2("iterate in deleted scales "); @@ -2234,11 +2234,11 @@ static int test_iterators(void) /* open the previously written "dset_a" */ if ((did = H5Dopen(fid,"dset_a"))<0) goto out; - + /* iterate */ if (H5DSiterate_scales(did,0,NULL,op_bogus,NULL)==SUCCESS) goto out; - + /* close */ if (H5Dclose(did)<0) goto out; @@ -2251,7 +2251,7 @@ static int test_iterators(void) goto out; return 0; - + /* error zone, gracefully close */ out: H5E_BEGIN_TRY { @@ -2264,7 +2264,7 @@ out: /*------------------------------------------------------------------------- - * test several ranks + * test several ranks *------------------------------------------------------------------------- */ @@ -2285,18 +2285,18 @@ static int test_rank(void) int bufi[1]={2}; float buff[1]={1}; int i; - + printf("Testing ranks\n"); /*------------------------------------------------------------------------- * create a file, a dataset, scales *------------------------------------------------------------------------- - */ + */ /* create a file using default properties */ if ((fid=H5Fcreate(FILE4,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) goto out; - + /* make a dataset a 3D data dataset */ if (H5LTmake_dataset_int(fid,"dset_a",3,dims3,NULL)<0) goto out; @@ -2312,18 +2312,18 @@ static int test_rank(void) /* make a 3D scale dataset */ if (H5LTmake_dataset_int(fid,"ds_a_2",3,dims3,NULL)<0) goto out; - + /*------------------------------------------------------------------------- - * attach + * attach *------------------------------------------------------------------------- - */ + */ TESTING2("attach"); - + if ((did = H5Dopen(fid,"dset_a"))<0) goto out; - - for (i=0; i<3; i++) + + for (i=0; i<3; i++) { sprintf(name,"ds_a_%d",i); if((dsid = H5Dopen(fid,name))<0) @@ -2335,24 +2335,24 @@ static int test_rank(void) if (H5Dclose(dsid)<0) goto out; } - + if (H5Dclose(did)<0) goto out; - + PASSED(); - + /*------------------------------------------------------------------------- - * detach + * detach *------------------------------------------------------------------------- - */ + */ TESTING2("detach"); - + if ((did = H5Dopen(fid,"dset_a"))<0) goto out; - - for (i=0; i<3; i++) + + for (i=0; i<3; i++) { sprintf(name,"ds_a_%d",i); if((dsid = H5Dopen(fid,name))<0) @@ -2366,20 +2366,20 @@ static int test_rank(void) } if (H5Dclose(did)<0) goto out; - + PASSED(); /*------------------------------------------------------------------------- * attach, set, get names, labels *------------------------------------------------------------------------- - */ + */ TESTING2("attach, set, get names, labels"); - + if ((did = H5Dopen(fid,"dset_a"))<0) goto out; - - for (i=0; i<3; i++) + + for (i=0; i<3; i++) { sprintf(name,"ds_a_%d",i); if((dsid = H5Dopen(fid,name))<0) @@ -2403,19 +2403,19 @@ static int test_rank(void) if (strcmp(name,namel)!=0) goto out; } - + if (H5Dclose(did)<0) goto out; - + PASSED(); /*------------------------------------------------------------------------- - * attach a scalar scale + * attach a scalar scale *------------------------------------------------------------------------- - */ + */ TESTING2("attach a scalar scale"); - + /* create the data space for the dataset */ if ((sid=H5Screate_simple(2,dimss,NULL))<0) goto out; @@ -2447,18 +2447,18 @@ static int test_rank(void) goto out; if (H5Dclose(dsid)<0) goto out; - + PASSED(); /*------------------------------------------------------------------------- - * close + * close *------------------------------------------------------------------------- - */ + */ if (H5Fclose(fid)<0) goto out; return 0; - + /* error zone, gracefully close */ out: H5E_BEGIN_TRY { @@ -2474,7 +2474,7 @@ out: /*------------------------------------------------------------------------- * attach scales with several datatypes *------------------------------------------------------------------------- - */ + */ static int test_types(void) { @@ -2491,21 +2491,21 @@ static int test_types(void) unsigned short s2_ushort[DIM2_SIZE] = {10,20,30,40}; /* data of DS 2 dataset */ char *s1_str = "ABC"; char *s2_str = "ABCD"; - + printf("Testing scales with several datatypes\n"); - + /*------------------------------------------------------------------------- * create a file for the test *------------------------------------------------------------------------- - */ + */ /* create a file using default properties */ if ((fid=H5Fcreate(FILE5,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) goto out; - + /*------------------------------------------------------------------------- * create datasets: 1 "data" dataset and 2 dimension scales *------------------------------------------------------------------------- - */ + */ /* make a dataset */ if (H5LTmake_dataset_int(fid,"dset_a",rank,dims,buf)<0) @@ -2518,11 +2518,11 @@ static int test_types(void) /* make a DS dataset for the second dimension */ if (H5LTmake_dataset(fid,DS_2_NAME,rankds,s2_dim,H5T_NATIVE_USHORT,s2_ushort)<0) goto out; - + /*------------------------------------------------------------------------- * floating point and short scales *------------------------------------------------------------------------- - */ + */ TESTING2("floating point and short scales"); @@ -2536,7 +2536,7 @@ static int test_types(void) /* attach the DS_1_NAME dimension scale to "dset_a" at dimension 0 */ if (H5DSattach_scale(did,dsid,DIM0)<0) goto out; - /* set name */ + /* set name */ if (H5DSset_scale(dsid,SCALE_1_NAME)<0) goto out; /* close DS id */ @@ -2548,7 +2548,7 @@ static int test_types(void) /* attach the DS_2_NAME dimension scale to "dset_a" at dimension 1 */ if (H5DSattach_scale(did,dsid,DIM1)<0) goto out; - /* set name */ + /* set name */ if (H5DSset_scale(dsid,SCALE_2_NAME)<0) goto out; /* close DS id */ @@ -2564,11 +2564,11 @@ static int test_types(void) goto out; PASSED(); - + /*------------------------------------------------------------------------- * create datasets: 1 "data" dataset and 2 dimension scales *------------------------------------------------------------------------- - */ + */ /* make a dataset */ if (H5LTmake_dataset_int(fid,"dset_b",rank,dims,buf)<0) @@ -2581,11 +2581,11 @@ static int test_types(void) /* make a DS dataset for the second dimension */ if (H5LTmake_dataset_string(fid,"ds_b_2",s2_str)<0) goto out; - + /*------------------------------------------------------------------------- * floating point and short scales *------------------------------------------------------------------------- - */ + */ TESTING2("string scales"); @@ -2598,7 +2598,7 @@ static int test_types(void) /* attach the DS_1_NAME dimension scale to "dset_b" at dimension 0 */ if (H5DSattach_scale(did,dsid,DIM0)<0) goto out; - /* set name */ + /* set name */ if (H5DSset_scale(dsid,SCALE_1_NAME)<0) goto out; /* close DS id */ @@ -2610,7 +2610,7 @@ static int test_types(void) /* attach the DS_2_NAME dimension scale to "dset_b" at dimension 1 */ if (H5DSattach_scale(did,dsid,DIM1)<0) goto out; - /* set name */ + /* set name */ if (H5DSset_scale(dsid,SCALE_2_NAME)<0) goto out; /* close DS id */ @@ -2628,14 +2628,14 @@ static int test_types(void) PASSED(); /*------------------------------------------------------------------------- - * close + * close *------------------------------------------------------------------------- - */ + */ if (H5Fclose(fid)<0) goto out; return 0; - + /* error zone, gracefully close */ out: H5E_BEGIN_TRY { @@ -2650,7 +2650,7 @@ out: /*------------------------------------------------------------------------- * read realistic data and generate an HDF5 file with dimension scales *------------------------------------------------------------------------- - */ + */ static int test_data(void) { @@ -2667,13 +2667,13 @@ static int test_data(void) hsize_t londims[1]; /* array to hold dimensions */ float fill=-99; /* fill value */ - + printf("Testing reading ASCII data and generate HDF5 data with scales\n"); - + /*------------------------------------------------------------------------- * create a file for the test *------------------------------------------------------------------------- - */ + */ /* create a file using default properties */ if ((fid=H5Fcreate(FILE6,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) goto out; @@ -2681,7 +2681,7 @@ static int test_data(void) /*------------------------------------------------------------------------- * read data *------------------------------------------------------------------------- - */ + */ /* read ASCII bathymetry data */ if (read_data("dsdata.txt",2,dims,&vals)<0) @@ -2698,14 +2698,14 @@ static int test_data(void) /*------------------------------------------------------------------------- * generating scales *------------------------------------------------------------------------- - */ + */ TESTING2("generating scales"); - + /*------------------------------------------------------------------------- * create datasets: 1 "data" dataset and 2 dimension scales *------------------------------------------------------------------------- - */ + */ /* make a DS dataset for the first dimension */ if (H5LTmake_dataset_float(fid,"lat",1,latdims,latbuf)<0) @@ -2734,9 +2734,9 @@ static int test_data(void) goto out; /*------------------------------------------------------------------------- - * attach + * attach *------------------------------------------------------------------------- - */ + */ /* get the dataset id for "data" */ if ((did = H5Dopen(fid,"data"))<0) @@ -2748,7 +2748,7 @@ static int test_data(void) /* attach the DS_1_NAME dimension scale to "data" at dimension 0 */ if (H5DSattach_scale(did,dsid,DIM0)<0) goto out; - /* set name */ + /* set name */ if (H5DSset_scale(dsid,SCALE_1_NAME)<0) goto out; /* close DS id */ @@ -2760,7 +2760,7 @@ static int test_data(void) /* attach the DS_2_NAME dimension scale to "data" at dimension 1 */ if (H5DSattach_scale(did,dsid,DIM1)<0) goto out; - /* set name */ + /* set name */ if (H5DSset_scale(dsid,SCALE_2_NAME)<0) goto out; /* close DS id */ @@ -2776,18 +2776,18 @@ static int test_data(void) goto out; PASSED(); - + /*------------------------------------------------------------------------- - * close + * close *------------------------------------------------------------------------- - */ + */ if (H5Fclose(fid)<0) goto out; return 0; - + /* error zone, gracefully close */ out: H5E_BEGIN_TRY { @@ -2808,7 +2808,7 @@ out: * * dimension i * n - * + * * followed by the data * *------------------------------------------------------------------------- @@ -2832,7 +2832,7 @@ static int read_data( const char* fname, int ndims, hsize_t *dims, float **buf ) strcpy(data_file, srcdir); strcat(data_file, "/"); } - /* read first data file */ + /* read first data file */ strcat(data_file,fname); f = fopen(data_file, "r"); diff --git a/hl/test/test_image.c b/hl/test/test_image.c index 539991d..3803afe 100644 --- a/hl/test/test_image.c +++ b/hl/test/test_image.c @@ -53,7 +53,7 @@ static int read_data(const char* file_name, hsize_t *width, hsize_t *height ); static int read_palette(const char* file_name, rgb_t *palette, int palette_size); /* globals */ -unsigned char *image_data = NULL; +unsigned char *image_data = NULL; /*------------------------------------------------------------------------- * the main program @@ -71,7 +71,7 @@ int main(void) if (nerrors) goto error; printf("All image tests passed.\n"); return 0; - + error: printf("***** %d IMAGE TEST%s FAILED! *****\n",nerrors, 1 == nerrors ? "" : "S"); return 1; @@ -113,13 +113,13 @@ static int test_simple(void) 252,252,84, /* yellow */ 252,168,0, /* orange */ 252,0,0}; /* red */ - + /* create an image of 9 values divided evenly by the array */ space = WIDTH*HEIGHT / PAL_ENTRIES; for (i=0, j=0, n=0; i < WIDTH*HEIGHT; i++, j++ ) { image_in1[i] = n; - if ( j > space ) + if ( j > space ) { n++; j=0; @@ -130,14 +130,14 @@ static int test_simple(void) for (i=0, j=0, n=0; i < WIDTH*HEIGHT*3; i++, j++) { image_in2[i] = n; - if (j==3) + if (j==3) { n++; j=0; } if (n>255) n=0; } - + /* create a file using default properties */ if ((fid=H5Fcreate(FILE1,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) goto out; @@ -163,7 +163,7 @@ static int test_simple(void) /* attach the palette to the image dataset */ if (H5IMlink_palette(fid,"image1","palette")<0) goto out; - + /* get info */ if (H5IMget_image_info(fid,"image1",&width,&height,&planes,interlace,&npals)<0) goto out; @@ -180,11 +180,11 @@ static int test_simple(void) /* read image */ if (H5IMread_image(fid,"image1",image_out1)<0) goto out; - + /* check */ - for (i = 0; i < height*width*planes; i++) + for (i = 0; i < height*width*planes; i++) { - if ( image_in1[i] != image_out1[i] ) + if ( image_in1[i] != image_out1[i] ) { goto out; } @@ -199,7 +199,7 @@ static int test_simple(void) */ TESTING2("true color image"); - + /* write image */ if (H5IMmake_image_24bit(fid,"image2",WIDTH,HEIGHT,"INTERLACE_PIXEL",image_in2)) goto out; @@ -220,9 +220,9 @@ static int test_simple(void) goto out; /* check */ - for (i = 0; i < height*width*planes; i++) + for (i = 0; i < height*width*planes; i++) { - if ( image_in2[i] != image_out2[i] ) + if ( image_in2[i] != image_out2[i] ) { goto out; } @@ -252,9 +252,9 @@ static int test_simple(void) goto out; /* check */ - for (i = 0; i < 2; i++) + for (i = 0; i < 2; i++) { - if ( pal_dims[i] != pal_dims_out[i] ) + if ( pal_dims[i] != pal_dims_out[i] ) { goto out; } @@ -269,9 +269,9 @@ static int test_simple(void) goto out; /* check */ - for (i = 0; i < PAL_ENTRIES*3; i++) + for (i = 0; i < PAL_ENTRIES*3; i++) { - if ( pal_data_in[i] != pal_data_out[i] ) + if ( pal_data_in[i] != pal_data_out[i] ) { goto out; } @@ -308,14 +308,14 @@ static int test_simple(void) PASSED(); /*------------------------------------------------------------------------- - * close + * close *------------------------------------------------------------------------- - */ + */ if (H5Fclose(fid)<0) goto out; return 0; - + /* error zone, gracefully close */ out: H5E_BEGIN_TRY { @@ -354,7 +354,7 @@ static int test_data(void) TESTING2("make indexed image"); - /* read first data file */ + /* read first data file */ if (read_data(DATA_FILE1,&width,&height)<0) goto out; @@ -371,11 +371,11 @@ static int test_data(void) * palette #1. rainbow palette. data is contained in "pal_rgb.h" *------------------------------------------------------------------------- */ - + /* initialize the palette data */ pal_dims[0] = 256; pal_dims[1] = 3; - + /* make a palette */ if (H5IMmake_palette(fid,PAL1_NAME,pal_dims,pal_rgb)<0) goto out; @@ -385,7 +385,7 @@ static int test_data(void) goto out; /*------------------------------------------------------------------------- - * palette #2. sepia palette. + * palette #2. sepia palette. * read a PAL file and attach the palette to the HDF5 file *------------------------------------------------------------------------- */ @@ -411,7 +411,7 @@ static int test_data(void) goto out; /*------------------------------------------------------------------------- - * palette #3. earth palette. + * palette #3. earth palette. * read a PAL file and attach the palette to the HDF5 file *------------------------------------------------------------------------- */ @@ -440,7 +440,7 @@ static int test_data(void) /*------------------------------------------------------------------------- - * palette #4. blue-red + * palette #4. blue-red * make a palette whith blue to red colors *------------------------------------------------------------------------- */ @@ -467,16 +467,16 @@ static int test_data(void) TESTING2("make true color image with pixel interlace"); - /* read second data file */ + /* read second data file */ if ((read_data(DATA_FILE2,&width,&height))<0) goto out; - + /* make image */ if ((H5IMmake_image_24bit(fid,IMAGE2_NAME,width,height,"INTERLACE_PIXEL",image_data))<0) goto out; PASSED(); - + /*------------------------------------------------------------------------- * True color image example with plane interlace *------------------------------------------------------------------------- @@ -484,26 +484,26 @@ static int test_data(void) TESTING2("make true color image with plane interlace"); - /* read third data file */ + /* read third data file */ if ((read_data(DATA_FILE3,&width,&height))<0) goto out; - + /* make image */ if ((H5IMmake_image_24bit(fid,IMAGE3_NAME,width,height,"INTERLACE_PLANE",image_data))<0) goto out; PASSED(); - + /*------------------------------------------------------------------------- - * close + * close *------------------------------------------------------------------------- - */ + */ if (H5Fclose(fid)<0) goto out; return 0; - + /* error zone, gracefully close */ out: H5E_BEGIN_TRY { @@ -515,23 +515,23 @@ out: /* - The following test provides an examples of how to generate HDF5 image data from - floating point data. In the example we use real life topographic data - (from the North American hemisphere). In the dataset sea values are represented - as negative numbers and land values are represented as positive numbers. - The example generates 3 HDF5 images, one that generates an image from all the values, - another that generates an image from the land values and another that generates an + The following test provides an examples of how to generate HDF5 image data from + floating point data. In the example we use real life topographic data + (from the North American hemisphere). In the dataset sea values are represented + as negative numbers and land values are represented as positive numbers. + The example generates 3 HDF5 images, one that generates an image from all the values, + another that generates an image from the land values and another that generates an image from the sea values. For the example we used data from MODB, the Mediterranean Oceanic Data Base http://modb.oce.ulg.ac.be/ - + */ static int test_generate(void) { hid_t fid; hsize_t pal_dims[2] = { 256, 3 }; - float *data; + float *data; int imax, jmax, kmax; float valex, xmin, xmax, value; FILE *f; @@ -555,7 +555,7 @@ static int test_generate(void) strcat(data_file, "/"); } strcat(data_file,DATA_FILE4); - + /*------------------------------------------------------------------------- * read data; the file data format is described below *------------------------------------------------------------------------- @@ -570,14 +570,14 @@ static int test_generate(void) } /* -!The first line of the ASCII file contains the dimension of the array : -! IMAX, JMAX, KMAX. The integers are stored with the FORTRAN format I5. -!The second line contains the exclusion value, the minimum and the maximum value of this -! file. These numbers are stored with the FORTRAN format E12.5. -! The remaining lines contains the data of the array, with 5 numbers per line -! (except the last line for each I-line). -! The array is stored in horizontal slices from sea surface to sea bottom and from -! north to south. So the indexes go from : +!The first line of the ASCII file contains the dimension of the array : +! IMAX, JMAX, KMAX. The integers are stored with the FORTRAN format I5. +!The second line contains the exclusion value, the minimum and the maximum value of this +! file. These numbers are stored with the FORTRAN format E12.5. +! The remaining lines contains the data of the array, with 5 numbers per line +! (except the last line for each I-line). +! The array is stored in horizontal slices from sea surface to sea bottom and from +! north to south. So the indexes go from : ! ! DO K = KMAX to 1 ! DO J = JMAX to 1 @@ -586,7 +586,7 @@ static int test_generate(void) ! OD ! OD ! OD -! +! ! ____________________________ ! / /| (imax,jmax,kmax) ! / sea surface / | @@ -603,21 +603,21 @@ static int test_generate(void) ! i ! */ - - - fscanf( f, "%d %d %d", &imax, &jmax, &kmax ); - fscanf( f, "%f %f %f", &valex, &xmin, &xmax ); - + + + fscanf( f, "%d %d %d", &imax, &jmax, &kmax ); + fscanf( f, "%f %f %f", &valex, &xmin, &xmax ); + data = (float*) malloc ( imax * jmax * kmax * sizeof( float )); image_data = (unsigned char*) malloc ( imax * jmax * kmax * sizeof( unsigned char )); - - for ( i = 0; i < imax * jmax * kmax; i++ ) + + for ( i = 0; i < imax * jmax * kmax; i++ ) { - fscanf( f, "%f ", &value ); + fscanf( f, "%f ", &value ); data[i] = value; } fclose( f ); - + /*------------------------------------------------------------------------- * transform the data from floating point to unsigend char * we are processing all the data here @@ -625,18 +625,18 @@ static int test_generate(void) */ TESTING2("make indexed image from all the data"); - - for ( i = 0; i < imax * jmax * kmax; i++ ) + + for ( i = 0; i < imax * jmax * kmax; i++ ) { image_data[i] = (unsigned char)(( 255 * (data[i] - xmin ) ) / (xmax - xmin )); } - + /* Make the image */ if ((H5IMmake_image_8bit(fid,"All data",(hsize_t)imax,(hsize_t)jmax,image_data))<0) goto out; PASSED(); - + /*------------------------------------------------------------------------- * transform the data from floating point to unsigend char * here we just process the land data @@ -644,21 +644,21 @@ static int test_generate(void) */ TESTING2("make indexed image from land data"); - - for ( i = 0; i < imax * jmax * kmax; i++ ) + + for ( i = 0; i < imax * jmax * kmax; i++ ) { if ( data[i] < 0 ) image_data[i] = 0; else image_data[i] = (unsigned char)(( 255 * (data[i] ) ) / xmax ); } - + /* make the image */ if ((H5IMmake_image_8bit(fid,"Land data",(hsize_t)imax,(hsize_t)jmax,image_data))<0) goto out; PASSED(); - + /*------------------------------------------------------------------------- * transform the data from floating point to unsigend char * here we just process the sea data @@ -666,32 +666,32 @@ static int test_generate(void) */ TESTING2("make indexed image from sea data"); - - for ( i = 0; i < imax * jmax * kmax; i++ ) + + for ( i = 0; i < imax * jmax * kmax; i++ ) { if ( data[i] > 0 ) image_data[i] = 0; else image_data[i] = (unsigned char)(( 255 * (data[i] - xmin ) ) / xmin ); } - + /* make the image */ if ((H5IMmake_image_8bit(fid,"Sea data",(hsize_t)imax,(hsize_t)jmax,image_data))<0) goto out; PASSED(); - + /*------------------------------------------------------------------------- * make a palette and attach it to the datasets *------------------------------------------------------------------------- */ TESTING2("attaching palettes"); - + /* make a palette */ if ((H5IMmake_palette(fid,PAL1_NAME,pal_dims,pal_rgb))<0) goto out; - + /* attach the palette to the image datasets */ if ((H5IMlink_palette(fid,"All data",PAL1_NAME))<0) goto out; @@ -701,17 +701,17 @@ static int test_generate(void) goto out; PASSED(); - + /*------------------------------------------------------------------------- - * close + * close *------------------------------------------------------------------------- - */ + */ if (H5Fclose(fid)<0) goto out; return 0; - + /* error zone, gracefully close */ out: H5E_BEGIN_TRY { @@ -733,7 +733,7 @@ out: * n * width * n - * + * * followed by the image data * *------------------------------------------------------------------------- @@ -778,10 +778,10 @@ static int read_data( const char* fname, /*IN*/ fscanf( f, "%s", str ); fscanf( f, "%d", &color_planes ); fscanf( f, "%s", str ); - fscanf( f, "%d", &h); + fscanf( f, "%d", &h); fscanf( f, "%s", str ); - fscanf( f, "%d", &w); - + fscanf( f, "%d", &w); + *width = (hsize_t)w; *height = (hsize_t)h; @@ -811,7 +811,7 @@ static int read_data( const char* fname, /*IN*/ * Read an ASCII palette file .PAL into an array * the files have a header of the type * - * Parameters: + * Parameters: * fname - name of file to read. * palette - array of rgb_t to store the read palette. * palette_size - number of elements in 'palette' array @@ -825,8 +825,8 @@ static int read_data( const char* fname, /*IN*/ #define STRING_CWPAL "CWPAL" #define VERSION_CWPAL "100" -static int read_palette(const char* fname, - rgb_t *palette, +static int read_palette(const char* fname, + rgb_t *palette, int palette_size) { FILE *file; @@ -850,42 +850,42 @@ static int read_palette(const char* fname, strcat(data_file, "/"); } strcat(data_file,fname); - + /* ensure the given palette is valid */ if (!palette) return -1; - + /* open the input file */ if (!(file = fopen(data_file, "r"))) { printf( "Could not open file %s. Try set $srcdir \n", data_file ); return -1; } - + /* read the file ident string */ if (fgets(buffer, sizeof(buffer), file) == NULL) { fclose(file); return -1; } - + /* ensure it matches the palette file ident string */ - if ( strncmp(buffer, STRING_JASC, sizeof(STRING_JASC) - 1) != 0 && + if ( strncmp(buffer, STRING_JASC, sizeof(STRING_JASC) - 1) != 0 && strncmp(buffer, STRING_CWPAL, sizeof(STRING_CWPAL) - 1) != 0 ) { fclose(file); return -1; } - + /* read the version string */ if (fgets(buffer, sizeof(buffer), file) == NULL) { fclose(file); return -1; } - - /* ensure it matches the palette file version string */ - if ( strncmp(buffer, VERSION_JASC, sizeof(VERSION_JASC) - 1) != 0 && + + /* ensure it matches the palette file version string */ + if ( strncmp(buffer, VERSION_JASC, sizeof(VERSION_JASC) - 1) != 0 && strncmp(buffer, VERSION_CWPAL, sizeof(VERSION_CWPAL) - 1) != 0 ) { fclose(file); @@ -898,31 +898,31 @@ static int read_palette(const char* fname, fclose(file); return -1; } - - - /* extract the number of colors. + + + /* extract the number of colors. check for missing version or number of colors in this case it reads the first entry */ - if ( strlen( buffer ) > 4 ) + if ( strlen( buffer ) > 4 ) { fclose(file); return -1; } - + if (sscanf(buffer, "%d", &nentries) != 1) { fclose(file); return -1; } - - /* ensure there are a sensible number of colors in the palette */ + + /* ensure there are a sensible number of colors in the palette */ if ((nentries < 0) || (nentries > 256) || (nentries > palette_size)) { fclose(file); return(-1); } - + /* read the palette entries */ for (i = 0; i < nentries; i++) { @@ -940,7 +940,7 @@ static int read_palette(const char* fname, /* close file */ fclose(file); - + return nentries; } diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c index bc5fb72..ae29444 100644 --- a/hl/test/test_lite.c +++ b/hl/test/test_lite.c @@ -62,7 +62,7 @@ static int test_dsets( void ) char data_char_out[DIM]; short data_short_in[DIM] = {1,2,3,4,5,6}; short data_short_out[DIM]; - int data_int_in[DIM] = {1,2,3,4,5,6}; + int data_int_in[DIM] = {1,2,3,4,5,6}; int data_int_out[DIM]; long data_long_in[DIM] = {1,2,3,4,5,6}; long data_long_out[DIM]; @@ -74,7 +74,7 @@ static int test_dsets( void ) char data_string_out[20]; int i; - + /* Create a new file using default properties. */ file_id = H5Fcreate( FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ); @@ -91,13 +91,13 @@ static int test_dsets( void ) /* Read dataset using the basic HDF5 API */ - if ( ( dataset_id = H5Dopen ( file_id, DSET0_NAME) ) < 0 ) + if ( ( dataset_id = H5Dopen ( file_id, DSET0_NAME) ) < 0 ) goto out; - if ( H5Dread ( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_int_out ) < 0 ) + if ( H5Dread ( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_int_out ) < 0 ) goto out; - if ( H5Dclose( dataset_id ) < 0 ) + if ( H5Dclose( dataset_id ) < 0 ) goto out; for (i = 0; i < DIM; i++) @@ -110,7 +110,7 @@ static int test_dsets( void ) PASSED(); /*------------------------------------------------------------------------- - * read using the LT function H5LTread_dataset + * read using the LT function H5LTread_dataset *------------------------------------------------------------------------- */ @@ -127,7 +127,7 @@ static int test_dsets( void ) } PASSED(); - + /*------------------------------------------------------------------------- * test the H5LTmake_dataset_ functions *------------------------------------------------------------------------- @@ -135,7 +135,7 @@ static int test_dsets( void ) /*------------------------------------------------------------------------- - * H5LTmake_dataset_char + * H5LTmake_dataset_char *------------------------------------------------------------------------- */ @@ -171,7 +171,7 @@ static int test_dsets( void ) /*------------------------------------------------------------------------- - * H5LTmake_dataset_short + * H5LTmake_dataset_short *------------------------------------------------------------------------- */ @@ -206,7 +206,7 @@ static int test_dsets( void ) PASSED(); /*------------------------------------------------------------------------- - * H5LTmake_dataset_int + * H5LTmake_dataset_int *------------------------------------------------------------------------- */ @@ -219,14 +219,14 @@ static int test_dsets( void ) /* Read dataset */ if ( H5LTread_dataset( file_id, DSET3_NAME, H5T_NATIVE_INT, data_int_out ) < 0 ) goto out; - + for (i = 0; i < DIM; i++) { if ( data_int_in[i] != data_int_out[i] ) { goto out; } } - + /* Read dataset */ if ( H5LTread_dataset_int( file_id, DSET3_NAME, data_int_out ) < 0 ) goto out; @@ -242,7 +242,7 @@ static int test_dsets( void ) /*------------------------------------------------------------------------- - * H5LTmake_dataset_long + * H5LTmake_dataset_long *------------------------------------------------------------------------- */ @@ -278,7 +278,7 @@ static int test_dsets( void ) /*------------------------------------------------------------------------- - * H5LTmake_dataset_float + * H5LTmake_dataset_float *------------------------------------------------------------------------- */ @@ -314,7 +314,7 @@ static int test_dsets( void ) /*------------------------------------------------------------------------- - * H5LTmake_dataset_double + * H5LTmake_dataset_double *------------------------------------------------------------------------- */ @@ -327,7 +327,7 @@ static int test_dsets( void ) /* Read dataset */ if ( H5LTread_dataset( file_id, DSET6_NAME, H5T_NATIVE_DOUBLE, data_double_out ) < 0 ) goto out; - + for (i = 0; i < DIM; i++) { if ( data_double_in[i] != data_double_out[i] ) { @@ -350,7 +350,7 @@ static int test_dsets( void ) /*------------------------------------------------------------------------- - * H5LTmake_dataset_string + * H5LTmake_dataset_string *------------------------------------------------------------------------- */ @@ -363,17 +363,17 @@ static int test_dsets( void ) /* Read dataset */ if ( H5LTread_dataset_string(file_id,DSET7_NAME,data_string_out) < 0 ) goto out; - - if ( strcmp(data_string_in,data_string_out) != 0 ) + + if ( strcmp(data_string_in,data_string_out) != 0 ) goto out; - - + + /*------------------------------------------------------------------------- * end tests *------------------------------------------------------------------------- */ - + /* Close the file. */ H5Fclose( file_id ); @@ -399,7 +399,7 @@ static int test_attr( void ) hid_t file_id; hid_t dataset_id; hid_t group_id; - hid_t space_id; + hid_t space_id; hsize_t dims[1] = { 5 }; /* Create a new file using default properties. */ @@ -414,7 +414,7 @@ static int test_attr( void ) if ((space_id = H5Screate_simple( 1, dims, NULL ))<0) goto out; /* Create the dataset */ - if ((dataset_id = H5Dcreate( file_id , "dset", H5T_NATIVE_INT, space_id, + if ((dataset_id = H5Dcreate( file_id , "dset", H5T_NATIVE_INT, space_id, H5P_DEFAULT ))<0) goto out; /* Close */ @@ -426,33 +426,33 @@ static int test_attr( void ) */ /* Create a group. */ - if ((group_id = H5Gcreate( file_id, "grp", 0 ))<0) + if ((group_id = H5Gcreate( file_id, "grp", 0 ))<0) goto out; - + /* Close */ H5Gclose( group_id ); - + /*------------------------------------------------------------------------- - * + * * Create attributes in the root group - * Note that we are calling the H5LTset_attribute functions with the name "." - * + * Note that we are calling the H5LTset_attribute functions with the name "." + * *------------------------------------------------------------------------- */ if (make_attributes( file_id, "." )<0) goto out; - + /*------------------------------------------------------------------------- - * + * * Create attributes in the dataset "dset" - * + * *------------------------------------------------------------------------- */ if (make_attributes( file_id, "dset" )<0) goto out; - + /*------------------------------------------------------------------------- - * + * * Create attributes in the group "grp" * *------------------------------------------------------------------------- @@ -519,7 +519,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) */ TESTING("H5LTset_attribute_string"); - + /* Set the attribute */ if ( H5LTset_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_in ) < 0 ) return -1; @@ -533,12 +533,12 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) TESTING("H5LTget_attribute_string"); - + /* Get the attribute */ if ( H5LTget_attribute_string( loc_id, obj_name, ATTR1_NAME, attr_str_out ) < 0 ) return -1; - if ( strcmp( attr_str_in, attr_str_out ) != 0 ) + if ( strcmp( attr_str_in, attr_str_out ) != 0 ) { return -1; } @@ -994,13 +994,13 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) /*------------------------------------------------------------------------- - * H5LTget_attribute_ndims test + * H5LTget_attribute_ndims test *------------------------------------------------------------------------- */ TESTING("H5LTget_attribute_ndims"); - + if ( H5LTget_attribute_ndims( loc_id, obj_name, ATTR2_NAME, &rank_out ) < 0 ) return -1; @@ -1011,7 +1011,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) PASSED(); /*------------------------------------------------------------------------- - * H5LTget_attribute_info test + * H5LTget_attribute_info test *------------------------------------------------------------------------- */ @@ -1060,12 +1060,12 @@ int main( void ) /* check for errors */ if (nerrors) goto error; - + return 0; - + error: return 1; - + } diff --git a/hl/test/test_packet.c b/hl/test/test_packet.c index 38e1bc4..cd9a9e9 100644 --- a/hl/test/test_packet.c +++ b/hl/test/test_packet.c @@ -38,20 +38,20 @@ * structure used for some tests, a particle *------------------------------------------------------------------------- */ -typedef struct particle_t +typedef struct particle_t { char name[16]; int lati; int longi; float pressure; - double temperature; + double temperature; } particle_t; /*------------------------------------------------------------------------- * a static array of particles for writing and checking reads *------------------------------------------------------------------------- */ -static particle_t testPart[NRECORDS] = { +static particle_t testPart[NRECORDS] = { {"zero", 0,0, 0.0f, 0.0}, {"one", 10,10, 1.0f, 10.0}, {"two", 20,20, 2.0f, 20.0}, @@ -122,14 +122,14 @@ static int create_hl_table(hid_t fid) HOFFSET( particle_t, temperature )}; /* Define field information */ - const char *field_names[NFIELDS] = + const char *field_names[NFIELDS] = { "Name","Latitude", "Longitude", "Pressure", "Temperature" }; hid_t field_type[NFIELDS]; hid_t string_type; hsize_t chunk_size = 10; int *fill_data = NULL; int compress = 0; - herr_t status; + herr_t status; /* Initialize the field field_type */ string_type = H5Tcopy( H5T_C_S1 ); @@ -142,13 +142,13 @@ static int create_hl_table(hid_t fid) /*------------------------------------------------------------------------ - * H5TBmake_table + * H5TBmake_table *------------------------------------------------------------------------- */ status=H5TBmake_table( "Table Title", fid, H5TB_TABLE_NAME, (hsize_t) NFIELDS, - (hsize_t)NRECORDS, sizeof(particle_t), - field_names, part_offset, field_type, + (hsize_t)NRECORDS, sizeof(particle_t), + field_names, part_offset, field_type, chunk_size, fill_data, compress, testPart ); if(status<0) @@ -750,7 +750,7 @@ int test_opaque(hid_t fid) * * ensures that the packet table API throws the correct errors used on * objects that are not packet tables. - * + * *------------------------------------------------------------------------- */ int test_error(hid_t fid) @@ -807,7 +807,7 @@ int test_error(hid_t fid) if(H5PTread_packets(id, 0, 1, readBuf) >= 0) goto out; if(H5PTcreate_index(id) >= 0) - goto out; + goto out; H5E_END_TRY id_open=0; @@ -833,7 +833,7 @@ int test_error(hid_t fid) if(H5PTread_packets(id, 0, 1, readBuf) >= 0) goto out; if(H5PTcreate_index(id) >= 0) - goto out; + goto out; H5E_END_TRY PASSED(); @@ -882,7 +882,7 @@ int main(void) /*------------------------------------------------------------------------- * Packet test: test each function of the packet table *------------------------------------------------------------------------- - */ + */ /* create a file using default properties */ fid=H5Fcreate(TEST_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); diff --git a/hl/test/test_table.c b/hl/test/test_table.c index 42987b2..6483932 100644 --- a/hl/test/test_table.c +++ b/hl/test/test_table.c @@ -29,7 +29,7 @@ * * Functions tested: * - * H5TBmake_table + * H5TBmake_table * H5TBread_table * H5TBwrite_records * H5TBread_records @@ -56,12 +56,12 @@ * structure used for all tests, a particle with properties *------------------------------------------------------------------------- */ -typedef struct particle_t +typedef struct particle_t { char name[16]; long longi; float pressure; - double temperature; + double temperature; int lati; } particle_t; @@ -72,24 +72,24 @@ typedef struct particle_t static hid_t h5file_open(const char *fname, unsigned flags); static int cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf ); -static int compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords, +static int compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords, particle_t *rbuf, particle_t *wbuf); /*------------------------------------------------------------------------- * a subset of particle_t, with latitude and longitude fields *------------------------------------------------------------------------- */ - typedef struct position_t + typedef struct position_t { long longi; int lati; } position_t; /*------------------------------------------------------------------------- - * a subset of particle_t, with name and pressure fields + * a subset of particle_t, with name and pressure fields *------------------------------------------------------------------------- */ - typedef struct namepressure_t + typedef struct namepressure_t { char name[16]; float pressure; @@ -117,7 +117,7 @@ static int compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords, { char name[16]; long longi; - double temperature; + double temperature; int lati; } particle3_t; @@ -159,7 +159,7 @@ int test_table(hid_t fid, int write) hsize_t start2; /* record to start writing in 2nd table */ /*------------------------------------------------------------------------- - * read, write, insert, append buffers + * read, write, insert, append buffers *------------------------------------------------------------------------- */ particle_t rbuf[NRECORDS+4]; @@ -169,7 +169,7 @@ int test_table(hid_t fid, int write) particle_t abuf[2]={{"eight",80,8.0f,80.0,80},{"nine",90,9.0f,90.0,90}}; particle_t ibuf[2]={{"zero", 0, 0.0f, 0.0, 0},{"zero", 0, 0.0f, 0.0, 0}}; particle_t wbufd[NRECORDS]; - particle_t wbuf[NRECORDS] = { + particle_t wbuf[NRECORDS] = { {"zero", 0, 0.0f, 0.0, 0,}, {"one", 10, 1.0f, 10.0, 10}, {"two", 20, 2.0f, 20.0, 20}, @@ -187,23 +187,23 @@ int test_table(hid_t fid, int write) position_t position_out[NRECORDS]; position_t position_in[NRECORDS] = { {0,0}, {10,10}, - {20,20}, - {30,30}, + {20,20}, + {30,30}, {40,40}, - {50,50}, - {60,60}, + {50,50}, + {60,60}, {70,70} }; /* buffers for the fields "Name,Pressure" */ namepressure_t namepre_out[NRECORDS]; - namepressure_t namepre_in[NRECORDS] = + namepressure_t namepre_in[NRECORDS] = { {"zero",0.0f}, - {"one", 1.0f}, - {"two", 2.0f}, - {"three", 3.0f}, + {"one", 1.0f}, + {"two", 2.0f}, + {"three", 3.0f}, {"four", 4.0f}, {"five", 5.0f}, - {"six", 6.0f}, - {"seven", 7.0f}, + {"six", 6.0f}, + {"seven", 7.0f}, }; @@ -219,7 +219,7 @@ int test_table(hid_t fid, int write) HOFFSET( position_t, lati ) }; size_t field_offset_namepre[2]= - { + { HOFFSET( namepressure_t, name ), HOFFSET( namepressure_t, pressure ) }; @@ -229,12 +229,12 @@ int test_table(hid_t fid, int write) sizeof(position_in[0].lati) }; size_t field_sizes_namepre[2]= - { + { sizeof(namepre_in[0].name), sizeof(namepre_in[0].pressure) }; size_t field_sizes_pre[1]= - { + { sizeof(namepre_in[0].pressure) }; @@ -295,7 +295,7 @@ int test_table(hid_t fid, int write) sizeof( rbuf3[0].longi), sizeof( rbuf3[0].temperature), sizeof( rbuf3[0].lati)}; - + /*------------------------------------------------------------------------- * initialize table parameters @@ -306,7 +306,7 @@ int test_table(hid_t fid, int write) */ size_t type_size_mem = sizeof( particle_t ); - size_t field_offset[NFIELDS]= + size_t field_offset[NFIELDS]= { HOFFSET( particle_t, name ), HOFFSET( particle_t, longi ), @@ -314,17 +314,17 @@ int test_table(hid_t fid, int write) HOFFSET( particle_t, temperature ), HOFFSET( particle_t, lati ) }; - size_t field_size[NFIELDS] = + size_t field_size[NFIELDS] = { sizeof( rbuf[0].name), sizeof( rbuf[0].longi), sizeof( rbuf[0].pressure), sizeof( rbuf[0].temperature), - sizeof( rbuf[0].lati) + sizeof( rbuf[0].lati) }; - const char *field_names[NFIELDS] = + const char *field_names[NFIELDS] = { "Name","Longitude","Pressure","Temperature","Latitude" }; - hid_t field_type[NFIELDS]; + hid_t field_type[NFIELDS]; hid_t string_type = H5Tcopy( H5T_C_S1 ); H5Tset_size( string_type, 16 ); field_type[0] = string_type; @@ -337,7 +337,7 @@ int test_table(hid_t fid, int write) * * Functions tested: * - * H5TBmake_table + * H5TBmake_table * H5TBread_table * *------------------------------------------------------------------------- @@ -348,29 +348,29 @@ int test_table(hid_t fid, int write) if (H5TBmake_table(TITLE,fid,"table1",NFIELDS,NRECORDS,type_size_mem, field_names,field_offset,field_type, - chunk_size,fill,compress,wbuf)<0) + chunk_size,fill,compress,wbuf)<0) goto out; PASSED(); } TESTING2("reading table"); - + /*------------------------------------------------------------------------- * read the table *------------------------------------------------------------------------- */ - - if (H5TBread_table(fid,"table1",type_size_mem,field_offset,field_size,rbuf)<0) + + if (H5TBread_table(fid,"table1",type_size_mem,field_offset,field_size,rbuf)<0) goto out; - + /* compare the extracted table with the original array */ - for( i = 0; i < NRECORDS; i++ ) + for( i = 0; i < NRECORDS; i++ ) { - if (cmp_par(i,i,rbuf,wbuf)<0) + if (cmp_par(i,i,rbuf,wbuf)<0) goto out; } - + PASSED(); @@ -382,35 +382,35 @@ int test_table(hid_t fid, int write) * *------------------------------------------------------------------------- */ - if (write) + if (write) { TESTING2("writing records"); /* create an empty table */ if (H5TBmake_table(TITLE,fid,"table2",NFIELDS,NRECORDS,type_size_mem, field_names,field_offset,field_type, - chunk_size,fill,compress,0)<0) + chunk_size,fill,compress,0)<0) goto out; /*------------------------------------------------------------------------- * write records, start at 0, write 8 - * pos = 0 1 2 3 4 5 6 7 - * data= 0 1 2 3 4 5 6 7 + * pos = 0 1 2 3 4 5 6 7 + * data= 0 1 2 3 4 5 6 7 *------------------------------------------------------------------------- */ wstart=0; wrecords=8; if (H5TBwrite_records(fid,"table2",wstart,wrecords,type_size_mem,field_offset, - field_size,wbuf)<0) + field_size,wbuf)<0) goto out; /* read it back */ - if (H5TBread_table(fid,"table2",type_size_mem,field_offset,field_size,rbuf)<0) + if (H5TBread_table(fid,"table2",type_size_mem,field_offset,field_size,rbuf)<0) goto out; - + /* compare */ - for( i = 0; i < NRECORDS; i++ ) + for( i = 0; i < NRECORDS; i++ ) { - if (cmp_par(i,i,rbuf,wbuf)<0) + if (cmp_par(i,i,rbuf,wbuf)<0) goto out; } @@ -427,14 +427,14 @@ int test_table(hid_t fid, int write) */ TESTING2("reading records"); - + /*------------------------------------------------------------------------- * read records, start at 0, read 8 - * pos = 0 1 2 3 4 5 6 7 + * pos = 0 1 2 3 4 5 6 7 * data= 0 1 2 3 4 5 6 7 *------------------------------------------------------------------------- */ - + /*------------------------------------------------------------------------- * for the read test we cannot use "table2" because it has been appended * we use the original "table1" instead @@ -444,16 +444,16 @@ int test_table(hid_t fid, int write) strcpy(tname,"table2"); else strcpy(tname,"table1"); - + rstart=0; rrecords=8; if (H5TBread_records(fid,tname,rstart,rrecords,type_size_mem,field_offset, - field_size,rbuf)<0) + field_size,rbuf)<0) goto out; /* compare */ - for( i=rstart; i<rrecords; i++) + for( i=rstart; i<rrecords; i++) { - if (cmp_par(i,i,rbuf,wbuf)<0) + if (cmp_par(i,i,rbuf,wbuf)<0) goto out; } PASSED(); @@ -473,32 +473,32 @@ int test_table(hid_t fid, int write) /*------------------------------------------------------------------------- * append 2 records - * pos = 0 1 2 3 4 5 6 7 8 9 + * pos = 0 1 2 3 4 5 6 7 8 9 * data= 0 1 2 3 4 5 6 7 8 9 *------------------------------------------------------------------------- */ arecords=2; - if (H5TBappend_records(fid,"table2",arecords,type_size_mem,field_offset,field_size,abuf)<0) + if (H5TBappend_records(fid,"table2",arecords,type_size_mem,field_offset,field_size,abuf)<0) return 1; - if (H5TBget_table_info(fid,"table2",&rfields,&rrecords)<0) + if (H5TBget_table_info(fid,"table2",&rfields,&rrecords)<0) return 1; rstart=0; rrecords=NRECORDS+arecords; if (H5TBread_records(fid,"table2",rstart,rrecords,type_size_mem,field_offset, - field_size,rbuf)<0) + field_size,rbuf)<0) return 1; /* compare */ wrecords=8; - for( i=rstart; i<wrecords; i++) + for( i=rstart; i<wrecords; i++) { - if (cmp_par(i,i,rbuf,wbuf)<0) + if (cmp_par(i,i,rbuf,wbuf)<0) goto out; } - for( i=wrecords, j=0; i<rrecords; i++,j++) + for( i=wrecords, j=0; i<rrecords; i++,j++) { - if (cmp_par(i,j,rbuf,abuf)<0) + if (cmp_par(i,j,rbuf,abuf)<0) goto out; } PASSED(); @@ -520,44 +520,44 @@ int test_table(hid_t fid, int write) /*------------------------------------------------------------------------- * insert 2 records * pos = 0 1 2 3 4 5 6 7 8 9 10 11 - * data= 0 0 0 1 2 3 4 5 6 7 8 9 + * data= 0 0 0 1 2 3 4 5 6 7 8 9 *------------------------------------------------------------------------- */ istart=1; irecords=2; - if (H5TBinsert_record(fid,"table2",istart,irecords,type_size_mem,field_offset,field_size,ibuf)<0) + if (H5TBinsert_record(fid,"table2",istart,irecords,type_size_mem,field_offset,field_size,ibuf)<0) return 1; - if (H5TBget_table_info(fid,"table2",&rfields,&rrecords)<0) + if (H5TBget_table_info(fid,"table2",&rfields,&rrecords)<0) return 1; if (H5TBread_records(fid,"table2",rstart,rrecords,type_size_mem,field_offset, - field_size,rbuf)<0) + field_size,rbuf)<0) return 1; /* compare */ - for( i=0; i<12; i++) + for( i=0; i<12; i++) { if (i<istart) { - if (cmp_par(i,i,rbuf,wbuf)<0) + if (cmp_par(i,i,rbuf,wbuf)<0) goto out; } else if (i>=istart && i<istart+irecords) { j=i-istart; - if (cmp_par(i,j,rbuf,ibuf)<0) + if (cmp_par(i,j,rbuf,ibuf)<0) goto out; } else if (i>=istart+irecords && i<10) { j=i-irecords; - if (cmp_par(i,j,rbuf,wbuf)<0) + if (cmp_par(i,j,rbuf,wbuf)<0) goto out; } - else + else { j=i-10; - if (cmp_par(i,j,rbuf,abuf)<0) + if (cmp_par(i,j,rbuf,abuf)<0) goto out; } } @@ -579,151 +579,151 @@ int test_table(hid_t fid, int write) /*------------------------------------------------------------------------- * Create a table - * pos = 0 1 2 3 4 5 6 7 - * data= 0 1 2 3 4 5 6 7 + * pos = 0 1 2 3 4 5 6 7 + * data= 0 1 2 3 4 5 6 7 *------------------------------------------------------------------------- */ - for( i=0; i<NRECORDS; i++) + for( i=0; i<NRECORDS; i++) wbufd[i] = wbuf[i]; if (H5TBmake_table(TITLE,fid,"table3",NFIELDS,NRECORDS,type_size_mem, field_names,field_offset,field_type, - chunk_size,fill,compress,wbufd)<0) + chunk_size,fill,compress,wbufd)<0) goto out; /*------------------------------------------------------------------------- * Delete records, start at 2, delete 3 - * pos = 0 1 2 3 4 - * data= 0 1 5 6 7 + * pos = 0 1 2 3 4 + * data= 0 1 5 6 7 *------------------------------------------------------------------------- */ dstart=2; drecords=3; - if (H5TBdelete_record(fid,"table3",dstart,drecords)<0) + if (H5TBdelete_record(fid,"table3",dstart,drecords)<0) goto out; - if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0) + if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0) goto out; - rstart=0; + rstart=0; if (H5TBread_records(fid,"table3",rstart,rrecords,type_size_mem,field_offset, - field_size,rbuf)<0) + field_size,rbuf)<0) goto out; /* Compare */ - nrecords=NRECORDS; + nrecords=NRECORDS; assert(rrecords == nrecords-drecords); - if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0) + if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0) goto out; - + /*------------------------------------------------------------------------- * reset compare buffer *------------------------------------------------------------------------- */ - nrecords=rrecords; - for( i=0; i<nrecords; i++) + nrecords=rrecords; + for( i=0; i<nrecords; i++) wbufd[i] = rbuf[i]; /*------------------------------------------------------------------------- * Delete records, start at 0, delete 2 - * pos = 0 1 2 - * data= 5 6 7 + * pos = 0 1 2 + * data= 5 6 7 *------------------------------------------------------------------------- */ dstart=0; drecords=2; - if (H5TBdelete_record(fid,"table3",dstart,drecords)<0) + if (H5TBdelete_record(fid,"table3",dstart,drecords)<0) goto out; - if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0) + if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0) goto out; - rstart=0; + rstart=0; if (H5TBread_records(fid,"table3",rstart,rrecords,type_size_mem,field_offset, - field_size,rbuf)<0) + field_size,rbuf)<0) goto out; /* Compare */ assert(rrecords == nrecords-drecords); - if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0) + if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0) goto out; /*------------------------------------------------------------------------- * reset compare buffer *------------------------------------------------------------------------- */ - nrecords=rrecords; - for( i=0; i<nrecords; i++) + nrecords=rrecords; + for( i=0; i<nrecords; i++) wbufd[i] = rbuf[i]; /*------------------------------------------------------------------------- * Delete records, start at 1, delete 1 - * pos = 0 1 - * data= 5 7 + * pos = 0 1 + * data= 5 7 *------------------------------------------------------------------------- */ dstart=1; drecords=1; - if (H5TBdelete_record(fid,"table3",dstart,drecords)<0) + if (H5TBdelete_record(fid,"table3",dstart,drecords)<0) goto out; - if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0) + if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0) goto out; - rstart=0; + rstart=0; if (H5TBread_records(fid,"table3",rstart,rrecords,type_size_mem,field_offset, - field_size,rbuf)<0) + field_size,rbuf)<0) goto out; /* Compare */ assert(rrecords == nrecords-drecords); - if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0) + if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0) goto out; /*------------------------------------------------------------------------- * reset compare buffer *------------------------------------------------------------------------- */ - nrecords=rrecords; - for( i=0; i<nrecords; i++) + nrecords=rrecords; + for( i=0; i<nrecords; i++) wbufd[i] = rbuf[i]; /*------------------------------------------------------------------------- * Delete records, start at 0, delete 1 - * pos = 0 - * data= 7 + * pos = 0 + * data= 7 *------------------------------------------------------------------------- */ dstart=0; drecords=1; - if (H5TBdelete_record(fid,"table3",dstart,drecords)<0) + if (H5TBdelete_record(fid,"table3",dstart,drecords)<0) goto out; - if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0) + if (H5TBget_table_info(fid,"table3",&rfields,&rrecords)<0) goto out; - rstart=0; + rstart=0; if (H5TBread_records(fid,"table3",rstart,rrecords,type_size_mem,field_offset, - field_size,rbuf)<0) + field_size,rbuf)<0) goto out; /* Compare */ assert(rrecords == nrecords-drecords); - if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0) + if (compare_deleted(rrecords,dstart,drecords,rbuf,wbufd)<0) goto out; /*------------------------------------------------------------------------- * reset compare buffer *------------------------------------------------------------------------- */ - nrecords=rrecords; - for( i=0; i<nrecords; i++) + nrecords=rrecords; + for( i=0; i<nrecords; i++) wbufd[i] = rbuf[i]; /* Read complete table */ - if (H5TBread_table(fid,"table3",type_size_mem,field_offset,field_size,rbuf)<0) + if (H5TBread_table(fid,"table3",type_size_mem,field_offset,field_size,rbuf)<0) goto out; /* Compare */ - for( i=0; i<rrecords; i++) + for( i=0; i<rrecords; i++) { - if (cmp_par(i,i,rbuf,wbufd)<0) + if (cmp_par(i,i,rbuf,wbufd)<0) goto out; } @@ -739,7 +739,7 @@ int test_table(hid_t fid, int write) * *------------------------------------------------------------------------- */ - + if (write) { TESTING2("adding records"); @@ -747,42 +747,42 @@ int test_table(hid_t fid, int write) /* create 2 tables */ if (H5TBmake_table(TITLE,fid,"table4",NFIELDS,NRECORDS,type_size_mem, field_names,field_offset,field_type, - chunk_size,fill,compress,wbuf)<0) + chunk_size,fill,compress,wbuf)<0) goto out; if (H5TBmake_table(TITLE,fid,"table5",NFIELDS,NRECORDS,type_size_mem, field_names,field_offset,field_type, - chunk_size,fill,compress,wbuf)<0) + chunk_size,fill,compress,wbuf)<0) goto out; /* add the records from "table4" to "table5" */ - start1 = 3; - nrecords = 2; - start2 = 6; + start1 = 3; + nrecords = 2; + start2 = 6; if ( H5TBadd_records_from(fid,"table4",start1,nrecords,"table5",start2)<0) goto out; /* read final table */ - if (H5TBread_table(fid,"table5",type_size_mem,field_offset,field_size,rbuf)<0) + if (H5TBread_table(fid,"table5",type_size_mem,field_offset,field_size,rbuf)<0) goto out; /* compare */ - for( i = 0; i < NRECORDS+2; i++ ) + for( i = 0; i < NRECORDS+2; i++ ) { if ( i < start2 ) { - if (cmp_par(i,i,rbuf,wbuf)<0) + if (cmp_par(i,i,rbuf,wbuf)<0) goto out; } else if ( i < start2+nrecords ) { j = i-start1; - if (cmp_par(i,j,rbuf,wbuf)<0) + if (cmp_par(i,j,rbuf,wbuf)<0) goto out; } - else + else { j = i-nrecords; - if (cmp_par(i,j,rbuf,wbuf)<0) + if (cmp_par(i,j,rbuf,wbuf)<0) goto out; } } @@ -799,7 +799,7 @@ int test_table(hid_t fid, int write) * *------------------------------------------------------------------------- */ - + if (write) { TESTING2("combining tables"); @@ -807,11 +807,11 @@ int test_table(hid_t fid, int write) /* create 2 tables */ if (H5TBmake_table(TITLE,fid,"table6",NFIELDS,NRECORDS,type_size_mem, field_names,field_offset,field_type, - chunk_size,fill,compress,wbuf)<0) + chunk_size,fill,compress,wbuf)<0) goto out; if (H5TBmake_table(TITLE,fid,"table7",NFIELDS,NRECORDS,type_size_mem, field_names,field_offset,field_type, - chunk_size,fill,compress,wbuf)<0) + chunk_size,fill,compress,wbuf)<0) goto out; /* combine the two tables into a third */ @@ -819,20 +819,20 @@ int test_table(hid_t fid, int write) goto out; /* read merged table */ - if (H5TBread_table(fid,"table8",type_size_mem,field_offset,field_size,rbufc)<0) + if (H5TBread_table(fid,"table8",type_size_mem,field_offset,field_size,rbufc)<0) goto out; /* compare */ - for( i = 0; i < NRECORDS*2; i++ ) + for( i = 0; i < NRECORDS*2; i++ ) { if ( i < NRECORDS ) { - if (cmp_par(i,i,rbufc,wbuf)<0) + if (cmp_par(i,i,rbufc,wbuf)<0) goto out; } else { - if (cmp_par(i,i-NRECORDS,rbufc,wbuf)<0) + if (cmp_par(i,i-NRECORDS,rbufc,wbuf)<0) goto out; } } @@ -845,15 +845,15 @@ int test_table(hid_t fid, int write) /* create 2 files using default properties. */ fid1 = H5Fcreate("combine_tables1.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT); fid2 = H5Fcreate("combine_tables2.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT); - + /* create 2 tables, one in each file */ if (H5TBmake_table(TITLE,fid1,"table1",NFIELDS,NRECORDS,type_size_mem, field_names,field_offset,field_type, - chunk_size,fill,compress,wbuf)<0) + chunk_size,fill,compress,wbuf)<0) goto out; if (H5TBmake_table(TITLE,fid2,"table2",NFIELDS,NRECORDS,type_size_mem, field_names,field_offset,field_type, - chunk_size,fill,compress,wbuf)<0) + chunk_size,fill,compress,wbuf)<0) goto out; /* combine the two tables into a third */ @@ -861,20 +861,20 @@ int test_table(hid_t fid, int write) goto out; /* read merged table */ - if (H5TBread_table(fid1,"table3",type_size_mem,field_offset,field_size,rbufc)<0) + if (H5TBread_table(fid1,"table3",type_size_mem,field_offset,field_size,rbufc)<0) goto out; /* compare */ - for( i = 0; i < NRECORDS*2; i++ ) + for( i = 0; i < NRECORDS*2; i++ ) { if ( i < NRECORDS ) { - if (cmp_par(i,i,rbufc,wbuf)<0) + if (cmp_par(i,i,rbufc,wbuf)<0) goto out; } else { - if (cmp_par(i,i-NRECORDS,rbufc,wbuf)<0) + if (cmp_par(i,i-NRECORDS,rbufc,wbuf)<0) goto out; } } @@ -902,37 +902,37 @@ int test_table(hid_t fid, int write) /* make an empty table with fill values */ if (H5TBmake_table(TITLE,fid,"table9",NFIELDS,NRECORDS,type_size_mem, field_names,field_offset,field_type, - chunk_size,fill1,compress,0)<0) + chunk_size,fill1,compress,0)<0) goto out; /* write the pressure field starting at record 2 */ - start = 2; - nrecords = 3; + start = 2; + nrecords = 3; if (H5TBwrite_fields_name(fid,"table9","Pressure",start,nrecords,sizeof(float), 0,field_sizes_pre,pressure_in)<0) goto out; /* write the new longitude and latitude information starting at record 2 */ - start = 2; + start = 2; nrecords = 3; if (H5TBwrite_fields_name(fid,"table9","Latitude,Longitude",start,nrecords,sizeof(position_t), field_offset_pos,field_sizes_pos,position_in)<0) goto out; /* read back the all table */ - start = 0; - nrecords = NRECORDS; - if (H5TBread_table(fid,"table9",type_size_mem,field_offset,field_size,rbuf)<0) + start = 0; + nrecords = NRECORDS; + if (H5TBread_table(fid,"table9",type_size_mem,field_offset,field_size,rbuf)<0) goto out; /* compare the read values with the initial values */ - for( i = 0; i < NRECORDS; i++ ) + for( i = 0; i < NRECORDS; i++ ) { if ( i >= 2 && i <= 4 ) { if ( rbuf[i].lati != position_in[i].lati || rbuf[i].longi != position_in[i].longi || - rbuf[i].pressure != pressure_in[i] ) + rbuf[i].pressure != pressure_in[i] ) { fprintf(stderr,"%ld %f %d\n", rbuf[i].longi,rbuf[i].pressure,rbuf[i].lati); @@ -955,7 +955,7 @@ int test_table(hid_t fid, int write) *------------------------------------------------------------------------- */ TESTING2("reading fields by name"); - + /*------------------------------------------------------------------------- * write and read the "Pressure" field *------------------------------------------------------------------------- @@ -964,32 +964,32 @@ int test_table(hid_t fid, int write) { if (H5TBmake_table(TITLE,fid,"table10",NFIELDS,NRECORDS,type_size_mem, field_names,field_offset,field_type, - chunk_size,fill1,compress,0)<0) + chunk_size,fill1,compress,0)<0) goto out; - + /* write the pressure field to all the records */ - start = 0; - nrecords = NRECORDS; - if ( H5TBwrite_fields_name(fid,"table10","Pressure",start,nrecords, + start = 0; + nrecords = NRECORDS; + if ( H5TBwrite_fields_name(fid,"table10","Pressure",start,nrecords, sizeof( float ),0,field_sizes_pre,pressure_in)<0) goto out; } - + /* read the "Pressure" field */ - start = 0; - nrecords = NRECORDS; - if ( H5TBread_fields_name(fid,"table10","Pressure",start,nrecords, + start = 0; + nrecords = NRECORDS; + if ( H5TBread_fields_name(fid,"table10","Pressure",start,nrecords, sizeof(float),0,field_sizes_pre,pressure_out)<0) goto out; - + /* Compare the extracted table with the initial values */ - for( i = 0; i < NRECORDS; i++ ) + for( i = 0; i < NRECORDS; i++ ) { if ( pressure_out[i] != pressure_in[i] ) { goto out; } } - + /*------------------------------------------------------------------------- * Write and read the "Latitude,Longitude" fields *------------------------------------------------------------------------- @@ -997,28 +997,28 @@ int test_table(hid_t fid, int write) if (write) { /* Write the new longitude and latitude information to all the records */ - start = 0; - nrecords = NRECORDS; - if ( H5TBwrite_fields_name(fid,"table10", "Latitude,Longitude", start, nrecords, + start = 0; + nrecords = NRECORDS; + if ( H5TBwrite_fields_name(fid,"table10", "Latitude,Longitude", start, nrecords, sizeof( position_t ), field_offset_pos, field_sizes_pos, position_in ) < 0 ) goto out; }/*write*/ - + /* Read the "Latitude,Longitude" fields */ - start = 0; - nrecords = NRECORDS; - if ( H5TBread_fields_name( fid, "table10", "Latitude,Longitude", + start = 0; + nrecords = NRECORDS; + if ( H5TBread_fields_name( fid, "table10", "Latitude,Longitude", start, nrecords, sizeof(position_t), field_offset_pos, field_sizes_pos, position_out ) < 0 ) goto out; - + /* Compare the extracted table with the initial values */ - for( i = 0; i < NRECORDS; i++ ) + for( i = 0; i < NRECORDS; i++ ) { if ( position_out[i].lati != position_in[i].lati || - position_out[i].longi != position_in[i].longi ) + position_out[i].longi != position_in[i].longi ) goto out; } - + /*------------------------------------------------------------------------- * Write and read the "Name,Pressure" fields @@ -1027,23 +1027,23 @@ int test_table(hid_t fid, int write) if (write) { /* Write the new name and pressure information to all the records */ - start = 0; - nrecords = NRECORDS; - if ( H5TBwrite_fields_name( fid, "table10", "Name,Pressure", start, nrecords, + start = 0; + nrecords = NRECORDS; + if ( H5TBwrite_fields_name( fid, "table10", "Name,Pressure", start, nrecords, sizeof( namepressure_t ), field_offset_namepre, field_sizes_namepre, namepre_in ) < 0 ) goto out; }/*write*/ /* Read the "Name,Pressure" fields */ - start = 0; - nrecords = NRECORDS; - if ( H5TBread_fields_name( fid, "table10", "Name,Pressure", + start = 0; + nrecords = NRECORDS; + if ( H5TBread_fields_name( fid, "table10", "Name,Pressure", start, nrecords, sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre, namepre_out ) < 0 ) goto out; /* Compare the extracted table with the initial values */ - for( i = 0; i < NRECORDS; i++ ) + for( i = 0; i < NRECORDS; i++ ) { if ( ( strcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) || namepre_out[i].pressure != namepre_in[i].pressure ) { @@ -1051,7 +1051,7 @@ int test_table(hid_t fid, int write) } } /* reset buffer */ - for( i = 0; i < NRECORDS; i++ ) + for( i = 0; i < NRECORDS; i++ ) { strcpy( namepre_out[i].name, "\0" ); namepre_out[i].pressure = -1; @@ -1061,15 +1061,15 @@ int test_table(hid_t fid, int write) * read only 3 records of the "Name,Pressure" fields, starting at record 2 *------------------------------------------------------------------------- */ - start = 2; - nrecords = 3; - if ( H5TBread_fields_name( fid, "table10", "Name,Pressure", - start, nrecords, sizeof(namepressure_t), field_offset_namepre, + start = 2; + nrecords = 3; + if ( H5TBread_fields_name( fid, "table10", "Name,Pressure", + start, nrecords, sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre, namepre_out ) < 0 ) goto out; /* Compare the extracted table with the initial values */ - for( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { if ( ( strcmp( namepre_out[i].name, namepre_in[start+i].name ) != 0 ) || namepre_out[i].pressure != namepre_in[start+i].pressure ) { @@ -1093,42 +1093,42 @@ int test_table(hid_t fid, int write) /* make an empty table */ if (H5TBmake_table(TITLE,fid,"table11",NFIELDS,NRECORDS,type_size_mem, field_names,field_offset,field_type, - chunk_size,fill,compress,NULL)<0) + chunk_size,fill,compress,NULL)<0) goto out; /* write the pressure field starting at record 2 */ nfields = 1; - start = 2; - nrecords = 3; - if ( H5TBwrite_fields_index(fid, "table11", nfields, field_index_pre, start, nrecords, + start = 2; + nrecords = 3; + if ( H5TBwrite_fields_index(fid, "table11", nfields, field_index_pre, start, nrecords, sizeof( float ), 0, field_sizes_pre, pressure_in ) < 0 ) goto out; /* write the new longitude and latitude information starting at record 2 */ nfields = 2; - start = 2; - nrecords = 3; - if ( H5TBwrite_fields_index(fid, "table11", nfields, field_index_pos, start, nrecords, + start = 2; + nrecords = 3; + if ( H5TBwrite_fields_index(fid, "table11", nfields, field_index_pos, start, nrecords, sizeof( position_t ), field_offset_pos, field_sizes_pos, position_in ) < 0 ) goto out; /* read back the all table */ nfields = 5; - start = 0; - nrecords = NRECORDS; - if ( H5TBread_fields_index(fid, "table11", nfields, field_index, + start = 0; + nrecords = NRECORDS; + if ( H5TBread_fields_index(fid, "table11", nfields, field_index, start, nrecords, type_size_mem, field_offset, field_size, rbuf ) < 0 ) goto out; /* Compare the extracted table with the initial values */ - for( i = 0; i < NRECORDS; i++ ) + for( i = 0; i < NRECORDS; i++ ) { if ( i >= 2 && i <= 4 ) { if ( rbuf[i].lati != position_in[i].lati || rbuf[i].longi != position_in[i].longi || - rbuf[i].pressure != pressure_in[i] ) + rbuf[i].pressure != pressure_in[i] ) goto out; } } @@ -1145,7 +1145,7 @@ int test_table(hid_t fid, int write) * *------------------------------------------------------------------------- */ - + TESTING2("reading fields by index"); if (write) @@ -1153,9 +1153,9 @@ int test_table(hid_t fid, int write) /* make an empty table */ if (H5TBmake_table(TITLE,fid,"table12",NFIELDS,NRECORDS,type_size_mem, field_names,field_offset,field_type, - chunk_size,fill,compress,NULL)<0) + chunk_size,fill,compress,NULL)<0) goto out; - + /*------------------------------------------------------------------------- * write and read the "Pressure" field *------------------------------------------------------------------------- @@ -1163,29 +1163,29 @@ int test_table(hid_t fid, int write) /* write the pressure field to all the records */ nfields = 1; - start = 0; - nrecords = NRECORDS; - if ( H5TBwrite_fields_index(fid, "table12", nfields, field_index_pre, start, nrecords, + start = 0; + nrecords = NRECORDS; + if ( H5TBwrite_fields_index(fid, "table12", nfields, field_index_pre, start, nrecords, sizeof( float ), 0, field_sizes_pre, pressure_in ) < 0 ) goto out; } - + /* read the "Pressure" field */ nfields = 1; - start = 0; - nrecords = NRECORDS; - if ( H5TBread_fields_index(fid, "table12", nfields, field_index_pre, + start = 0; + nrecords = NRECORDS; + if ( H5TBread_fields_index(fid, "table12", nfields, field_index_pre, start, nrecords, sizeof(float), 0, field_sizes_pre, pressure_out ) < 0 ) goto out; /* compare the extracted table with the initial values */ - for( i = 0; i < NRECORDS; i++ ) + for( i = 0; i < NRECORDS; i++ ) { if ( pressure_out[i] != pressure_in[i] ) { goto out; } } - + /*------------------------------------------------------------------------- * write and read the "Latitude,Longitude" fields *------------------------------------------------------------------------- @@ -1194,23 +1194,23 @@ int test_table(hid_t fid, int write) { /* write the new longitude and latitude information to all the records */ nfields = 2; - start = 0; - nrecords = NRECORDS; - if ( H5TBwrite_fields_index(fid, "table12", nfields, field_index_pos, start, nrecords, + start = 0; + nrecords = NRECORDS; + if ( H5TBwrite_fields_index(fid, "table12", nfields, field_index_pos, start, nrecords, sizeof( position_t ), field_offset_pos, field_sizes_pos, position_in ) < 0 ) goto out; } /*write*/ /* read the "Latitude,Longitude" fields */ nfields = 2; - start = 0; - nrecords = NRECORDS; - if ( H5TBread_fields_index(fid, "table12", nfields, field_index_pos, + start = 0; + nrecords = NRECORDS; + if ( H5TBread_fields_index(fid, "table12", nfields, field_index_pos, start, nrecords, sizeof(position_t), field_offset_pos, field_sizes_pos, position_out ) < 0 ) goto out; /* compare the extracted table with the initial values */ - for( i = 0; i < NRECORDS; i++ ) + for( i = 0; i < NRECORDS; i++ ) { if ( position_out[i].lati != position_in[i].lati || position_out[i].longi != position_in[i].longi ) { @@ -1227,24 +1227,24 @@ int test_table(hid_t fid, int write) { /* write the new name and pressure information to all the records */ nfields = 2; - start = 0; - nrecords = NRECORDS; - if ( H5TBwrite_fields_index(fid, "table12", nfields, field_index_namepre, start, nrecords, + start = 0; + nrecords = NRECORDS; + if ( H5TBwrite_fields_index(fid, "table12", nfields, field_index_namepre, start, nrecords, sizeof( namepressure_t ), field_offset_namepre, field_sizes_namepre, namepre_in ) < 0 ) goto out; } /* read the "Name,Pressure" fields */ nfields = 2; - start = 0; - nrecords = NRECORDS; - if ( H5TBread_fields_index(fid, "table12", nfields, field_index_namepre, - start, nrecords, sizeof(namepressure_t), field_offset_namepre, + start = 0; + nrecords = NRECORDS; + if ( H5TBread_fields_index(fid, "table12", nfields, field_index_namepre, + start, nrecords, sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre, namepre_out ) < 0 ) goto out; /* compare the extracted table with the initial values */ - for( i = 0; i < NRECORDS; i++ ) + for( i = 0; i < NRECORDS; i++ ) { if ( ( strcmp( namepre_out[i].name, namepre_in[i].name ) != 0 ) || namepre_out[i].pressure != namepre_in[i].pressure ) { @@ -1253,7 +1253,7 @@ int test_table(hid_t fid, int write) } /* reset buffer */ - for( i = 0; i < NRECORDS; i++ ) + for( i = 0; i < NRECORDS; i++ ) { strcpy( namepre_out[i].name, "\0" ); namepre_out[i].pressure = -1; @@ -1263,18 +1263,18 @@ int test_table(hid_t fid, int write) * read only 3 records of the "Name,Pressure" fields, starting at record 2 *------------------------------------------------------------------------- */ - + /* write the new name and pressure information to all the records */ nfields = 2; - start = 2; - nrecords = 3; - if ( H5TBread_fields_index(fid, "table12", nfields, field_index_namepre, - start, nrecords, sizeof(namepressure_t), field_offset_namepre, + start = 2; + nrecords = 3; + if ( H5TBread_fields_index(fid, "table12", nfields, field_index_namepre, + start, nrecords, sizeof(namepressure_t), field_offset_namepre, field_sizes_namepre, namepre_out ) < 0 ) goto out; /* compare the extracted table with the initial values */ - for( i = 0; i < 3; i++ ) + for( i = 0; i < 3; i++ ) { if ( ( strcmp( namepre_out[i].name, wbuf[start+i].name ) != 0 ) || namepre_out[i].pressure != wbuf[start+i].pressure ) { @@ -1293,7 +1293,7 @@ int test_table(hid_t fid, int write) * *------------------------------------------------------------------------- */ - + if (write) { TESTING2("inserting fields"); @@ -1301,12 +1301,12 @@ int test_table(hid_t fid, int write) /* make a table */ if (H5TBmake_table(TITLE,fid,"table13",NFIELDS,NRECORDS,type_size_mem, field_names,field_offset,field_type, - chunk_size,fill1,compress,wbuf)<0) + chunk_size,fill1,compress,wbuf)<0) goto out; - + /* insert the new field at the end of the field list */ position = NFIELDS; - if ( H5TBinsert_field( fid, "table13", "New Field", field_type_new, position, + if ( H5TBinsert_field( fid, "table13", "New Field", field_type_new, position, fill1_new, buf_new ) < 0 ) goto out; @@ -1315,7 +1315,7 @@ int test_table(hid_t fid, int write) goto out; /* compare the extracted table with the original array */ - for( i = 0; i < NRECORDS; i++ ) + for( i = 0; i < NRECORDS; i++ ) { if ( ( strcmp( rbuf2[i].name, wbuf[i].name ) != 0 ) || rbuf2[i].lati != wbuf[i].lati || @@ -1345,7 +1345,7 @@ int test_table(hid_t fid, int write) /* make a table */ if (H5TBmake_table(TITLE,fid,"table14",NFIELDS,NRECORDS,type_size_mem, field_names,field_offset,field_type, - chunk_size,fill,compress,wbuf)<0) + chunk_size,fill,compress,wbuf)<0) goto out; @@ -1356,9 +1356,9 @@ int test_table(hid_t fid, int write) /* read the table */ if ( H5TBread_table(fid, "table14", dst_size3, dst_offset3, dst_sizes3, rbuf3 ) < 0 ) goto out; - + /* compare the extracted table with the original array */ - for( i = 0; i < NRECORDS; i++ ) + for( i = 0; i < NRECORDS; i++ ) { if ( ( strcmp( rbuf3[i].name, wbuf[i].name ) != 0 ) || rbuf3[i].lati != wbuf[i].lati || @@ -1403,10 +1403,10 @@ int test_table(hid_t fid, int write) */ TESTING2("getting field info"); - + /* alocate */ names_out = malloc( sizeof(char*) * (size_t)NFIELDS ); - for ( i = 0; i < NFIELDS; i++) + for ( i = 0; i < NFIELDS; i++) { names_out[i] = malloc( sizeof(char) * 255 ); } @@ -1415,7 +1415,7 @@ int test_table(hid_t fid, int write) if ( H5TBget_field_info(fid, "table1", names_out, sizes_out, offset_out, &size_out ) < 0 ) goto out; - for ( i = 0; i < NFIELDS; i++) + for ( i = 0; i < NFIELDS; i++) { if ( (strcmp( field_names[i], names_out[i] ) != 0)) { goto out; @@ -1423,7 +1423,7 @@ int test_table(hid_t fid, int write) } /* release */ - for ( i = 0; i < NFIELDS; i++) + for ( i = 0; i < NFIELDS; i++) { free ( names_out[i] ); } @@ -1451,11 +1451,11 @@ int main(void) { hid_t fid; /* identifier for the file */ unsigned flags=H5F_ACC_RDONLY; - + /*------------------------------------------------------------------------- * test1: create a file for the write/read test *------------------------------------------------------------------------- - */ + */ /* create a file using default properties */ fid=H5Fcreate("test_table.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT); @@ -1472,7 +1472,7 @@ int main(void) /*------------------------------------------------------------------------- * test2: open a file written in test1 on a big-endian machine *------------------------------------------------------------------------- - */ + */ puts("Testing table with file open mode (read big-endian data):"); fid=h5file_open(TEST_FILE_BE,flags); @@ -1527,18 +1527,18 @@ out: */ static hid_t h5file_open(const char *fname, unsigned flags) { - + hid_t fid; /* identifier for the file */ char *srcdir = getenv("srcdir"); /* the source directory */ char data_file[512]=""; /* buffer to hold name of existing file */ - + /* compose the name of the file to open, using the srcdir, if appropriate */ if (srcdir){ strcpy(data_file,srcdir); strcat(data_file,"/"); - } + } strcat(data_file,fname); - + /* open */ if((fid=H5Fopen(data_file,flags,H5P_DEFAULT))<0) { fprintf(stderr,"Error: Cannot open file <%s>\n",data_file ); @@ -1573,21 +1573,21 @@ static int cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf ) * function to compare deleted records *------------------------------------------------------------------------- */ -static int compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords, +static int compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords, particle_t *rbuf, particle_t *wbuf) { hsize_t i,j; - for( i=0; i<rrecords; i++) + for( i=0; i<rrecords; i++) { if (i<dstart) { - if (cmp_par(i,i,rbuf,wbuf)<0) + if (cmp_par(i,i,rbuf,wbuf)<0) return -1; } else { j=i+drecords; - if (cmp_par(i,j,rbuf,wbuf)<0) + if (cmp_par(i,j,rbuf,wbuf)<0) return -1; } } |