diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2006-04-29 06:20:50 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2006-04-29 06:20:50 (GMT) |
commit | cc5b2ff93bc5b81993c104e64f3669a4d8f0c0a5 (patch) | |
tree | 67198d5997628d5a6640a7862ec5c96794e97244 /hl/test | |
parent | 27496ae0c7b8b1be7165d3720711b15c3a2d1288 (diff) | |
download | hdf5-cc5b2ff93bc5b81993c104e64f3669a4d8f0c0a5.zip hdf5-cc5b2ff93bc5b81993c104e64f3669a4d8f0c0a5.tar.gz hdf5-cc5b2ff93bc5b81993c104e64f3669a4d8f0c0a5.tar.bz2 |
[svn-r12314] Purpose:
Code cleanup
Description:
Big clean up on high-level library code, including:
- Removing include of HDF5 private header file(!)
- Reduce number of compiler warnings
- Untangle header files, etc.
Platforms tested:
FreeBSD 4.11 (sleipnir) w/C++
Linux 2.4/64 (mir) w/C++ & FORTRAN
Diffstat (limited to 'hl/test')
-rw-r--r-- | hl/test/h5hltest.h | 41 | ||||
-rw-r--r-- | hl/test/pal_rgb.h | 6 | ||||
-rw-r--r-- | hl/test/test_ds.c | 107 | ||||
-rw-r--r-- | hl/test/test_image.c | 18 | ||||
-rw-r--r-- | hl/test/test_lite.c | 32 | ||||
-rw-r--r-- | hl/test/test_packet.c | 101 | ||||
-rw-r--r-- | hl/test/test_table.c | 8 |
7 files changed, 176 insertions, 137 deletions
diff --git a/hl/test/h5hltest.h b/hl/test/h5hltest.h new file mode 100644 index 0000000..2776204 --- /dev/null +++ b/hl/test/h5hltest.h @@ -0,0 +1,41 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu> + * Friday, April 28, 2006 + * + * Purpose: Test support stuff. + */ + +#ifndef _H5HLTEST_H +#define _H5HLTEST_H + +/* Get the HDF5 public header */ +#include "hdf5.h" + +/* Include the High-Level private header */ +#include "H5HLprivate2.h" + +/* These are copied from the test/h5test.h header */ +#define TESTING(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);} +#define TESTING2(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);} +#define TESTING3(WHAT) {printf("%-70s", "" WHAT); fflush(stdout);} +#define PASSED() {puts(" PASSED");fflush(stdout);} +#define H5_FAILED() {puts("*FAILED*");fflush(stdout);} +#define SKIPPED() {puts(" -SKIP-");fflush(stdout);} +#define EXAMPLE(WHAT) {printf("%-70s", "Example " WHAT); fflush(stdout);} + +#endif /* _H5HLTEST_H */ + diff --git a/hl/test/pal_rgb.h b/hl/test/pal_rgb.h index 8fba910..0bc3905 100644 --- a/hl/test/pal_rgb.h +++ b/hl/test/pal_rgb.h @@ -270,9 +270,3 @@ const unsigned char pal_rgb[256*3] = {255,255,255, 127,0,0 }; - - - - - - diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c index 3e72766..e8caf10 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -14,9 +14,10 @@ #include <stdlib.h> #include <string.h> -#include "H5DSprivate.h" -#include "H5LTprivate.h" -#include "H5IMprivate.h" +#include "h5hltest.h" +#include "H5DSpublic.h" +#include "H5LTpublic.h" +#include "H5IMpublic.h" /* operator functions */ static herr_t verifiy_scale(hid_t dset, unsigned dim, hid_t scale, void *visitor_data); @@ -115,7 +116,7 @@ error: static int test_simple(void) { hid_t fid; /* file ID */ - hid_t did; /* dataset ID */ + hid_t did = -1; /* dataset ID */ hid_t dsid; /* DS dataset ID */ hid_t sid; /* space ID */ hid_t gid; /* group ID */ @@ -852,7 +853,7 @@ static int test_simple(void) */ /* create a group */ - if ((gid=H5Gcreate(fid,"grp",0))<0) + if ((gid=H5Gcreate(fid,"grp",(size_t)0))<0) goto out; /* create the data space for the dataset */ @@ -989,12 +990,12 @@ static int test_simple(void) { if ( i==1 ) { - if(H5DSdetach_scale(did,dsid,i)<0) + if(H5DSdetach_scale(did,dsid,(unsigned)i)<0) goto out; } else { - if(H5DSdetach_scale(did,dsid,i)!=FAIL) + if(H5DSdetach_scale(did,dsid,(unsigned)i)!=FAIL) goto out; } } @@ -1047,9 +1048,9 @@ static int test_simple(void) *------------------------------------------------------------------------- */ - if ((dim0_label_size=H5DSget_label(did,DIM0,NULL,0))<0) + if ((dim0_label_size=H5DSget_label(did,DIM0,NULL,(size_t)0))<0) goto out; - if ((dim1_label_size=H5DSget_label(did,DIM1,NULL,0))<0) + if ((dim1_label_size=H5DSget_label(did,DIM1,NULL,(size_t)0))<0) goto out; /* allocate */ @@ -1058,14 +1059,14 @@ static int test_simple(void) if ( dim0_labeld==NULL || dim1_labeld==NULL) goto out; - if (H5DSget_label(did,DIM0,dim0_labeld,dim0_label_size)<0) + if (H5DSget_label(did,DIM0,dim0_labeld,(size_t)dim0_label_size)<0) goto out; - if (H5DSget_label(did,DIM1,dim1_labeld,dim1_label_size)<0) + if (H5DSget_label(did,DIM1,dim1_labeld,(size_t)dim1_label_size)<0) goto out; - if (strncmp(DIM0_LABEL,dim0_labeld,dim0_label_size-1)!=0) + if (strncmp(DIM0_LABEL,dim0_labeld,(size_t)(dim0_label_size-1))!=0) goto out; - if (strncmp(DIM1_LABEL,dim1_labeld,dim1_label_size-1)!=0) + if (strncmp(DIM1_LABEL,dim1_labeld,(size_t)(dim1_label_size-1))!=0) goto out; if (dim0_labeld) @@ -1124,7 +1125,7 @@ static int test_simple(void) */ /* get the lenght of the scale name (pass NULL in name) */ - if ((name_len=H5DSget_scale_name(dsid,NULL,0))<0) + if ((name_len=H5DSget_scale_name(dsid,NULL,(size_t)0))<0) goto out; /* allocate a buffer */ @@ -1133,7 +1134,7 @@ static int test_simple(void) goto out; /* get the scale name using this buffer */ - if (H5DSget_scale_name(dsid,name_out,name_len)<0) + if (H5DSget_scale_name(dsid,name_out,(size_t)name_len)<0) goto out; if (strcmp(SCALE_1_NAME,name_out)!=0) @@ -1512,8 +1513,8 @@ static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor { int ret = 0; /* define a default zero value for return. This will cause the iterator to continue */ hid_t sid; /* space ID */ - hid_t tid; /* file type ID */ - hid_t mtid; /* memory type ID */ + hid_t tid = -1; /* file type ID */ + hid_t mtid = -1; /* memory type ID */ hssize_t nelmts; /* number of data elements */ char *buf=NULL; /* data buffer */ size_t size; @@ -1542,7 +1543,7 @@ static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor if (nelmts) { - buf=(char *) malloc((unsigned)(nelmts*size)); + buf=(char *) malloc((size_t)(nelmts*size)); if ( buf==NULL) goto out; if (H5Dread(scale_id,mtid,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) @@ -1610,6 +1611,9 @@ static herr_t match_dim_scale(hid_t did, unsigned dim, hid_t dsid, void *visitor hsize_t dims[H5S_MAX_RANK]; /* dimensions of dataset */ hsize_t storage_size; + /* Stop compiler from whining about "unused parameters" */ + visitor_data = visitor_data; + /*------------------------------------------------------------------------- * get DID (dataset) space info *------------------------------------------------------------------------- @@ -1682,15 +1686,14 @@ 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; - - /* unused */ - dset=dset; - dim=dim; - visitor_data=visitor_data; + /* Stop compiler from whining about "unused parameters" */ + dset = dset; + dim = dim; + scale_id = scale_id; + visitor_data = visitor_data; - return ret; + /* define a default zero value for return. This will cause the iterator to continue */ + return 0; } @@ -1711,11 +1714,11 @@ static int test_errors(void) int rankds = 1; /* rank of DS dataset */ hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */ hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */ - hid_t did; /* dataset ID */ - hid_t dsid; /* scale ID */ - hid_t gid; /* group ID */ - hid_t sid; /* space ID */ - hid_t sidds; /* space ID */ + hid_t did = -1; /* dataset ID */ + hid_t dsid = -1; /* scale ID */ + hid_t gid = -1; /* group ID */ + hid_t sid = -1; /* space ID */ + hid_t sidds = -1; /* space ID */ hsize_t pal_dims[] = {9,3}; printf("Testing error conditions\n"); @@ -1729,7 +1732,7 @@ static int test_errors(void) 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",(size_t)0))<0) goto out; /* create the data space for the dataset */ if ((sid=H5Screate_simple(rank,dims,NULL))<0) @@ -1911,7 +1914,7 @@ static int test_errors(void) TESTING2("attach to a dataset that is a reserved class dataset"); /* make an image */ - if (H5IMmake_image_8bit(fid,"image",100,50,NULL)<0) + if (H5IMmake_image_8bit(fid,"image",(hsize_t)100,(hsize_t)50,NULL)<0) goto out; /* make a palette */ @@ -2090,7 +2093,7 @@ static int test_iterators(void) int rankds = 1; /* rank of DS dataset */ hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */ hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */ - hid_t gid; /* group ID */ + hid_t gid = -1; /* group ID */ hid_t did; /* dataset ID */ hid_t dsid; /* scale ID */ char dname[30]; /* dataset name */ @@ -2107,7 +2110,7 @@ static int test_iterators(void) 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",(size_t)0))<0) goto out; /* close */ if (H5Gclose(gid)<0) @@ -2272,8 +2275,8 @@ out: static int test_rank(void) { hid_t fid; /* file ID */ - hid_t did; /* dataset ID */ - hid_t dsid; /* scale ID */ + hid_t did = -1; /* dataset ID */ + hid_t dsid = -1; /* scale ID */ hid_t sid; /* space ID */ hid_t sidds; /* space ID */ hsize_t dims1[1] = {DIM1_SIZE}; /* size of data dataset */ @@ -2329,9 +2332,9 @@ static int test_rank(void) sprintf(name,"ds_a_%d",i); if((dsid = H5Dopen(fid,name))<0) goto out; - if(H5DSattach_scale(did,dsid,i)<0) + if(H5DSattach_scale(did,dsid,(unsigned)i)<0) goto out; - if (H5DSis_attached(did,dsid,i)<=0) + if (H5DSis_attached(did,dsid,(unsigned)i)<=0) goto out; if (H5Dclose(dsid)<0) goto out; @@ -2358,9 +2361,9 @@ static int test_rank(void) sprintf(name,"ds_a_%d",i); if((dsid = H5Dopen(fid,name))<0) goto out; - if(H5DSdetach_scale(did,dsid,i)<0) + if(H5DSdetach_scale(did,dsid,(unsigned)i)<0) goto out; - if (H5DSis_attached(did,dsid,i)!=0) + if (H5DSis_attached(did,dsid,(unsigned)i)!=0) goto out; if (H5Dclose(dsid)<0) goto out; @@ -2387,17 +2390,17 @@ static int test_rank(void) goto out; if (H5DSset_scale(dsid,name)<0) goto out; - if(H5DSattach_scale(did,dsid,i)<0) + if(H5DSattach_scale(did,dsid,(unsigned)i)<0) goto out; - if (H5DSis_attached(did,dsid,i)<=0) + if (H5DSis_attached(did,dsid,(unsigned)i)<=0) goto out; if (H5DSget_scale_name(dsid,names,sizeof(names))<0) goto out; if (H5Dclose(dsid)<0) goto out; - if (H5DSset_label(did,i,name)<0) + if (H5DSset_label(did,(unsigned)i,name)<0) goto out; - if (H5DSget_label(did,i,namel,sizeof(namel))<0) + if (H5DSget_label(did,(unsigned)i,namel,sizeof(namel))<0) goto out; if (strcmp(name,names)!=0) goto out; @@ -2480,8 +2483,8 @@ out: static int test_types(void) { hid_t fid; /* file ID */ - hid_t did; /* dataset ID */ - hid_t dsid; /* DS dataset ID */ + hid_t did = -1; /* dataset ID */ + hid_t dsid = -1; /* DS dataset ID */ int rank = RANK; /* rank of data dataset */ int rankds = 1; /* rank of DS dataset */ hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */ @@ -2490,8 +2493,8 @@ static int test_types(void) hsize_t s2_dim[1] = {DIM2_SIZE}; /* size of DS 2 dataset */ float s1_float[DIM1_SIZE] = {10,20,30}; /* data of DS 1 dataset */ unsigned short s2_ushort[DIM2_SIZE] = {10,20,30,40}; /* data of DS 2 dataset */ - char *s1_str = "ABC"; - char *s2_str = "ABCD"; + const char *s1_str = "ABC"; + const char *s2_str = "ABCD"; printf("Testing scales with several datatypes\n"); @@ -2656,8 +2659,8 @@ out: static int test_data(void) { hid_t fid; /* file ID */ - hid_t did; /* dataset ID */ - hid_t dsid; /* DS dataset ID */ + hid_t did = -1; /* dataset ID */ + hid_t dsid = -1; /* DS dataset ID */ hid_t dcpl; /* dataset creation property list */ hid_t sid; /* dataspace ID */ float *vals=NULL; /* array to hold data values */ @@ -2845,7 +2848,7 @@ static int read_data( const char* fname, int ndims, hsize_t *dims, float **buf ) for (i=0, nelms=1; i < ndims; i++) { - fscanf( f, "%s %d", str, &j); + fscanf( f, "%s %u", str, &j); fscanf( f, "%d",&n ); dims[i] = n; nelms *= n; diff --git a/hl/test/test_image.c b/hl/test/test_image.c index 6d1f445..630b9c5 100644 --- a/hl/test/test_image.c +++ b/hl/test/test_image.c @@ -12,11 +12,12 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5LTprivate.h" -#include "H5IMprivate.h" -#include "pal_rgb.h" #include <stdlib.h> #include <string.h> +#include "h5hltest.h" +#include "H5LTpublic.h" +#include "H5IMpublic.h" +#include "pal_rgb.h" #define FILE1 "test_image1.h5" #define FILE2 "test_image2.h5" @@ -52,7 +53,7 @@ static int test_simple(void); static int test_data(void); static int test_generate(void); 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); +static int read_palette(const char* file_name, rgb_t *palette, size_t palette_size); /* globals */ unsigned char *image_data = NULL; @@ -103,7 +104,7 @@ static int test_simple(void) unsigned char image_out2[ WIDTH*HEIGHT*3 ]; unsigned char pal_data_out[PAL_ENTRIES*3]; unsigned char n; - int space; + hsize_t space; /* create a PAL_ENTRIES entry palette */ unsigned char pal_data_in[PAL_ENTRIES*3] = { 0,0,168, /* dark blue */ @@ -137,7 +138,6 @@ static int test_simple(void) n++; j=0; } - if (n>255) n=0; } /* create a file using default properties */ @@ -829,7 +829,7 @@ static int read_data( const char* fname, /*IN*/ static int read_palette(const char* fname, rgb_t *palette, - int palette_size) + size_t palette_size) { FILE *file; char buffer[80]; @@ -837,7 +837,7 @@ static int read_palette(const char* fname, unsigned int red; unsigned int green; unsigned int blue; - int nentries; + unsigned nentries; char *srcdir = getenv("srcdir"); /* the source directory */ char data_file[512]; /* buffer to hold name of existing data file */ @@ -912,7 +912,7 @@ static int read_palette(const char* fname, return -1; } - if (sscanf(buffer, "%d", &nentries) != 1) + if (sscanf(buffer, "%u", &nentries) != 1) { fclose(file); return -1; diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c index 1816f7f..705cf3a 100644 --- a/hl/test/test_lite.c +++ b/hl/test/test_lite.c @@ -14,8 +14,8 @@ #include <stdlib.h> #include <string.h> - -#include "H5LTprivate.h" +#include "h5hltest.h" +#include "H5LTpublic.h" #define FILE_NAME "test_lite1.h5" #define FILE_NAME2 "test_lite2.h5" @@ -70,8 +70,8 @@ static int test_dsets( void ) float data_float_out[DIM]; double data_double_in[DIM] = {1,2,3,4,5,6}; double data_double_out[DIM]; - char *data_string_in = "This is a string"; - char data_string_out[20]; + const char *data_string_in = "This is a string"; + char data_string_out[20]; int i; @@ -426,7 +426,7 @@ static int test_attr( void ) */ /* Create a group. */ - if ((group_id = H5Gcreate( file_id, "grp", 0 ))<0) + if ((group_id = H5Gcreate( file_id, "grp", (size_t)0 ))<0) goto out; /* Close */ @@ -554,7 +554,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) TESTING("H5LTset_attribute_char"); /* Set the attribute */ - if ( H5LTset_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_in, 5 ) < 0 ) + if ( H5LTset_attribute_char( loc_id, obj_name, ATTR2_NAME, attr_char_in, (size_t)5 ) < 0 ) return -1; PASSED(); @@ -598,7 +598,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) TESTING("H5LTset_attribute_short"); /* Set the attribute */ - if ( H5LTset_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_in, 5 ) < 0 ) + if ( H5LTset_attribute_short( loc_id, obj_name, ATTR3_NAME, attr_short_in, (size_t)5 ) < 0 ) return -1; PASSED(); @@ -644,7 +644,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) TESTING("H5LTset_attribute_int"); /* Set the attribute */ - if ( H5LTset_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_in, 5 ) < 0 ) + if ( H5LTset_attribute_int( loc_id, obj_name, ATTR4_NAME, attr_int_in, (size_t)5 ) < 0 ) return -1; PASSED(); @@ -688,7 +688,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) TESTING("H5LTset_attribute_long"); /* Set the attribute */ - if ( H5LTset_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_in, 5 ) < 0 ) + if ( H5LTset_attribute_long( loc_id, obj_name, ATTR5_NAME, attr_long_in, (size_t)5 ) < 0 ) return -1; PASSED(); @@ -732,7 +732,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) TESTING("H5LTset_attribute_uchar"); /* Set the attribute */ - if ( H5LTset_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_in, 5 ) < 0 ) + if ( H5LTset_attribute_uchar( loc_id, obj_name, ATTR6_NAME, attr_uchar_in, (size_t)5 ) < 0 ) return -1; PASSED(); @@ -776,7 +776,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) TESTING("H5LTset_attribute_ushort"); /* Set the attribute */ - if ( H5LTset_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_in, 5 ) < 0 ) + if ( H5LTset_attribute_ushort( loc_id, obj_name, ATTR7_NAME, attr_ushort_in, (size_t)5 ) < 0 ) return -1; PASSED(); @@ -822,7 +822,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) TESTING("H5LTset_attribute_uint"); /* Set the attribute */ - if ( H5LTset_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_in, 5 ) < 0 ) + if ( H5LTset_attribute_uint( loc_id, obj_name, ATTR8_NAME, attr_uint_in, (size_t)5 ) < 0 ) return -1; PASSED(); @@ -866,7 +866,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) TESTING("H5LTset_attribute_ulong"); /* Set the attribute */ - if ( H5LTset_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_in, 5 ) < 0 ) + if ( H5LTset_attribute_ulong( loc_id, obj_name, ATTR9_NAME, attr_ulong_in, (size_t)5 ) < 0 ) return -1; PASSED(); @@ -911,7 +911,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) TESTING("H5LTset_attribute_float"); /* Set the attribute */ - if ( H5LTset_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_in, 5 ) < 0 ) + if ( H5LTset_attribute_float( loc_id, obj_name, ATTR10_NAME, attr_float_in, (size_t)5 ) < 0 ) return -1; PASSED(); @@ -956,7 +956,7 @@ static herr_t make_attributes( hid_t loc_id, const char* obj_name ) TESTING("H5LTset_attribute_double"); /* Set the attribute */ - if ( H5LTset_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_in, 5 ) < 0 ) + if ( H5LTset_attribute_double( loc_id, obj_name, ATTR11_NAME, attr_double_in, (size_t)5 ) < 0 ) return -1; PASSED(); @@ -1289,7 +1289,7 @@ static int test_enums(void) size_t size = 16; char name1[16]; int value1 = 7; - char *name2 = "WHITE"; + const char *name2 = "WHITE"; int value2; H5T_class_t type_class; char* dt_str; diff --git a/hl/test/test_packet.c b/hl/test/test_packet.c index 739b0f7..7c7ab2c 100644 --- a/hl/test/test_packet.c +++ b/hl/test/test_packet.c @@ -12,11 +12,12 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5PTprivate.h" -#include "H5TBprivate.h" #include <stdlib.h> #include <assert.h> #include <string.h> +#include "h5hltest.h" +#include "H5PTpublic.h" +#include "H5TBpublic.h" /*------------------------------------------------------------------------- * Packet Table API test @@ -96,7 +97,7 @@ make_particle_type(void) /* Insert fields. */ string_type = H5Tcopy( H5T_C_S1 ); - H5Tset_size( string_type, 16 ); + H5Tset_size( string_type, (size_t)16 ); if ( H5Tinsert(type_id, "Name", HOFFSET(particle_t, name) , string_type ) < 0 ) return -1; @@ -134,7 +135,7 @@ static int create_hl_table(hid_t fid) /* Initialize the field field_type */ string_type = H5Tcopy( H5T_C_S1 ); - H5Tset_size( string_type, 16 ); + H5Tset_size( string_type, (size_t)16 ); field_type[0] = string_type; field_type[1] = H5T_NATIVE_INT; field_type[2] = H5T_NATIVE_INT; @@ -168,7 +169,7 @@ else *------------------------------------------------------------------------- */ -int test_create_close(hid_t fid) +static int test_create_close(hid_t fid) { herr_t err; hid_t table; @@ -182,7 +183,7 @@ int test_create_close(hid_t fid) assert(part_t != -1); /* Create the table */ - table = H5PTcreate_fl(fid, PT_NAME, part_t, 100); + table = H5PTcreate_fl(fid, PT_NAME, part_t, (hsize_t)100); H5Tclose(part_t); if( H5PTis_valid(table) < 0) goto out; @@ -209,7 +210,7 @@ int test_create_close(hid_t fid) * *------------------------------------------------------------------------- */ -int test_open(hid_t fid) +static int test_open(hid_t fid) { herr_t err; hid_t table; @@ -243,7 +244,7 @@ int test_open(hid_t fid) * *------------------------------------------------------------------------- */ -int test_append(hid_t fid) +static int test_append(hid_t fid) { herr_t err; hid_t table; @@ -265,17 +266,17 @@ int test_append(hid_t fid) goto out; /* Append one particle */ - err = H5PTappend(table, 1, &(testPart[0])); + err = H5PTappend(table, (hsize_t)1, &(testPart[0])); if( err < 0) goto out; /* Append several particles */ - err = H5PTappend(table, 6, &(testPart[1])); + err = H5PTappend(table, (hsize_t)6, &(testPart[1])); if( err < 0) goto out; /* Append one more particle */ - err = H5PTappend(table, 1, &(testPart[7])); + err = H5PTappend(table, (hsize_t)1, &(testPart[7])); if( err < 0) goto out; @@ -309,12 +310,12 @@ int test_append(hid_t fid) * *------------------------------------------------------------------------- */ -int test_read(hid_t fid) +static int test_read(hid_t fid) { herr_t err; hid_t table; particle_t readBuf[NRECORDS]; - int c; + hsize_t c; TESTING("H5PTread_packets"); @@ -324,17 +325,17 @@ int test_read(hid_t fid) goto out; /* Read several particles */ - err = H5PTread_packets(table, 0, 3, &(readBuf[0])); + err = H5PTread_packets(table, (hsize_t)0, (hsize_t)3, &(readBuf[0])); if( err < 0) goto out; /* Read one particle */ - err = H5PTread_packets(table, 3, 1, &(readBuf[3])); + err = H5PTread_packets(table, (hsize_t)3, (hsize_t)1, &(readBuf[3])); if( err < 0) goto out; /* Read several particles */ - err = H5PTread_packets(table, 4, (NRECORDS - 4 ), &(readBuf[4])); + err = H5PTread_packets(table, (hsize_t)4, (hsize_t)(NRECORDS - 4 ), &(readBuf[4])); if( err < 0) goto out; @@ -369,13 +370,13 @@ int test_read(hid_t fid) * *------------------------------------------------------------------------- */ -int test_get_next(hid_t fid) +static int test_get_next(hid_t fid) { herr_t err; hid_t table; particle_t readBuf[NRECORDS]; particle_t readBuf2[NRECORDS]; - int c; + hsize_t c; TESTING("H5PTget_next"); @@ -387,7 +388,7 @@ int test_get_next(hid_t fid) /* Read several particles consecutively */ for(c=0; c < NRECORDS; c++) { - err = H5PTget_next(table, 1, &readBuf[c]); + err = H5PTget_next(table, (hsize_t)1, &readBuf[c]); if(err < 0) goto out; } @@ -404,7 +405,7 @@ int test_get_next(hid_t fid) /* Read particles two by two */ for(c=0; c < NRECORDS / 2; c++) { - err = H5PTget_next(table, 2, &readBuf2[c * 2]); + err = H5PTget_next(table, (hsize_t)2, &readBuf2[c * 2]); if(err < 0) goto out; } @@ -439,12 +440,12 @@ int test_get_next(hid_t fid) * *------------------------------------------------------------------------- */ -int test_big_table(hid_t fid) +static int test_big_table(hid_t fid) { herr_t err; hid_t table; hid_t part_t; - int c; + hsize_t c; particle_t readPart; hsize_t count; @@ -456,7 +457,7 @@ int test_big_table(hid_t fid) assert(part_t != -1); /* Create a new table */ - table = H5PTcreate_fl(fid, "Packet Test Dataset2", part_t, 33); + table = H5PTcreate_fl(fid, "Packet Test Dataset2", part_t, (hsize_t)33); H5Tclose(part_t); if( H5PTis_valid(table) < 0) goto out; @@ -465,7 +466,7 @@ int test_big_table(hid_t fid) for(c = 0; c < BIG_TABLE_SIZE ; c+=8) { /* Append eight particles at once*/ - err = H5PTappend(table, 8, &(testPart[0])); + err = H5PTappend(table, (hsize_t)8, &(testPart[0])); if( err < 0) goto out; } @@ -482,12 +483,12 @@ int test_big_table(hid_t fid) /* the first packet in the table */ for(c = 0; c < BIG_TABLE_SIZE; c++) { - err = H5PTget_next(table, 1, &readPart); + err = H5PTget_next(table, (hsize_t)1, &readPart); if(err < 0) goto out; /* Ensure that particles were read correctly */ - if( cmp_par(c % 8, 0, testPart, &readPart) != 0) + if( cmp_par(c % 8, (hsize_t)0, testPart, &readPart) != 0) goto out; } @@ -514,7 +515,7 @@ int test_big_table(hid_t fid) * *------------------------------------------------------------------------- */ -int test_varlen(hid_t fid) +static int test_varlen(hid_t fid) { herr_t err; hid_t table=H5I_BADID; @@ -552,7 +553,7 @@ int test_varlen(hid_t fid) } /* Create the table */ - table = H5PTcreate_vl(fid, VL_TABLE_NAME, 1001); + table = H5PTcreate_vl(fid, VL_TABLE_NAME, (hsize_t)1001); if( H5PTis_valid(table) < 0) goto out; if( H5PTis_varlen(table) != 1) @@ -585,18 +586,18 @@ int test_varlen(hid_t fid) goto out; /* Add several variable-length packets */ - err = H5PTappend(table, 8, writeBuffer ); + err = H5PTappend(table, (hsize_t)8, writeBuffer ); if(err < 0) goto out; /* Read them back */ - err = H5PTread_packets(table, 0, 4, &(readBuffer[0])); + err = H5PTread_packets(table, (hsize_t)0, (hsize_t)4, &(readBuffer[0])); if( err < 0) goto out; - err = H5PTread_packets(table, 4, 1, &(readBuffer[4])); + err = H5PTread_packets(table, (hsize_t)4, (hsize_t)1, &(readBuffer[4])); if( err < 0) goto out; - err = H5PTread_packets(table, 5, (NRECORDS - 5 ), &(readBuffer[5])); + err = H5PTread_packets(table, (hsize_t)5, (hsize_t)(NRECORDS - 5 ), &(readBuffer[5])); if( err < 0) goto out; @@ -617,7 +618,7 @@ int test_varlen(hid_t fid) goto out; break; case 3: - if( cmp_par(0, 0, readBuffer[x].p, writeBuffer[x].p) < 0) + if( cmp_par((hsize_t)0, (hsize_t)0, readBuffer[x].p, writeBuffer[x].p) < 0) goto out; break; default: @@ -626,13 +627,13 @@ int test_varlen(hid_t fid) } /* Free memory used by read buffer */ - if(H5PTfree_vlen_readbuff(table, NRECORDS, readBuffer) <0) + if(H5PTfree_vlen_readbuff(table, (hsize_t)NRECORDS, readBuffer) <0) goto out; /* Read packets back using get_next */ for(x=0; x < NRECORDS; x++) { - err = H5PTget_next(table, 1, &readBuffer[x]); + err = H5PTget_next(table, (hsize_t)1, &readBuffer[x]); if(err < 0) goto out; } @@ -654,7 +655,7 @@ int test_varlen(hid_t fid) goto out; break; case 3: - if( cmp_par(0, 0, readBuffer[x].p, writeBuffer[x].p) < 0) + if( cmp_par((hsize_t)0, (hsize_t)0, readBuffer[x].p, writeBuffer[x].p) < 0) goto out; break; default: @@ -663,7 +664,7 @@ int test_varlen(hid_t fid) } /* Free memory used by read buffer */ - if(H5PTfree_vlen_readbuff(table, NRECORDS, readBuffer) <0) + if(H5PTfree_vlen_readbuff(table, (hsize_t)NRECORDS, readBuffer) <0) goto out; /* Close the table */ @@ -688,12 +689,12 @@ int test_varlen(hid_t fid) * *------------------------------------------------------------------------- */ -int test_opaque(hid_t fid) +static int test_opaque(hid_t fid) { herr_t err; hid_t table; hid_t part_t; - int c; + hsize_t c; particle_t readBuf[NRECORDS]; TESTING("opaque data"); @@ -709,18 +710,18 @@ int test_opaque(hid_t fid) return -1; /* Create a new table */ - table = H5PTcreate_fl(fid, "Packet Test Dataset3", part_t, 1); + table = H5PTcreate_fl(fid, "Packet Test Dataset3", part_t, (hsize_t)1); H5Tclose(part_t); if( H5PTis_valid(table) < 0) goto out; /* Append several particles, starting at particle 1 */ - err = H5PTappend(table, NRECORDS - 1, &(testPart[1])); + err = H5PTappend(table, (hsize_t)(NRECORDS - 1), &(testPart[1])); if( err < 0) goto out; /* Read the particles back */ - err = H5PTread_packets(table, 0, 7, &(readBuf[0])); + err = H5PTread_packets(table, (hsize_t)0, (hsize_t)7, &(readBuf[0])); if( err < 0) goto out; @@ -754,7 +755,7 @@ int test_opaque(hid_t fid) * *------------------------------------------------------------------------- */ -int test_error(hid_t fid) +static int test_error(hid_t fid) { hid_t id = H5I_BADID; int id_open=0; @@ -782,9 +783,9 @@ int test_error(hid_t fid) goto out; if(H5PTclose(id) >= 0) goto out; - if(H5PTappend(id, 1, testPart) >= 0) + if(H5PTappend(id, (hsize_t)1, testPart) >= 0) goto out; - if(H5PTread_packets(id, 0, 1, readBuf) >= 0) + if(H5PTread_packets(id, (hsize_t)0, (hsize_t)1, readBuf) >= 0) goto out; if(H5PTcreate_index(id) >= 0) goto out; @@ -803,9 +804,9 @@ int test_error(hid_t fid) goto out; if(H5PTclose(id) >= 0) goto out; - if(H5PTappend(id, 1, testPart) >= 0) + if(H5PTappend(id, (hsize_t)1, testPart) >= 0) goto out; - if(H5PTread_packets(id, 0, 1, readBuf) >= 0) + if(H5PTread_packets(id, (hsize_t)0, (hsize_t)1, readBuf) >= 0) goto out; if(H5PTcreate_index(id) >= 0) goto out; @@ -829,9 +830,9 @@ int test_error(hid_t fid) goto out; if(H5PTclose(id) >= 0) goto out; - if(H5PTappend(id, 1, testPart) >= 0) + if(H5PTappend(id, (hsize_t)1, testPart) >= 0) goto out; - if(H5PTread_packets(id, 0, 1, readBuf) >= 0) + if(H5PTread_packets(id, (hsize_t)0, (hsize_t)1, readBuf) >= 0) goto out; if(H5PTcreate_index(id) >= 0) goto out; @@ -848,7 +849,7 @@ out: } -int test_packet_table(hid_t fid) +static int test_packet_table(hid_t fid) { if( test_create_close(fid) < 0 ) diff --git a/hl/test/test_table.c b/hl/test/test_table.c index e3d248a..95d6a60 100644 --- a/hl/test/test_table.c +++ b/hl/test/test_table.c @@ -12,11 +12,11 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "H5TBprivate.h" - #include <stdlib.h> #include <string.h> #include <assert.h> +#include "h5hltest.h" +#include "H5TBpublic.h" #define TEST_FILE_BE "test_table_be.hdf5" #define TEST_FILE_LE "test_table_le.hdf5" @@ -126,7 +126,7 @@ static int compare_deleted(hsize_t rrecords, hsize_t dstart, hsize_t drecords, *------------------------------------------------------------------------- */ -int test_table(hid_t fid, int write) +static int test_table(hid_t fid, int write) { /* identifiers */ hid_t fid1; @@ -325,7 +325,7 @@ int test_table(hid_t fid, int write) { "Name","Longitude","Pressure","Temperature","Latitude" }; hid_t field_type[NFIELDS]; hid_t string_type = H5Tcopy( H5T_C_S1 ); - H5Tset_size( string_type, 16 ); + H5Tset_size( string_type, (size_t)16 ); field_type[0] = string_type; field_type[1] = H5T_NATIVE_LONG; field_type[2] = H5T_NATIVE_FLOAT; |