diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2007-03-26 18:55:36 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2007-03-26 18:55:36 (GMT) |
commit | 4eed634bcf57fc1253f77bea2256d407db098d51 (patch) | |
tree | f80a785164f1ecdc39aa16e9c3554eef259953a3 /test | |
parent | 00f32db756d2f11f9fddb8edc67850944aa5ee1d (diff) | |
download | hdf5-4eed634bcf57fc1253f77bea2256d407db098d51.zip hdf5-4eed634bcf57fc1253f77bea2256d407db098d51.tar.gz hdf5-4eed634bcf57fc1253f77bea2256d407db098d51.tar.bz2 |
[svn-r13542] Added a detection for zero-length VL data in H5T_conv_vlen to handle the case properly. This fix
was discovered by the user while Bug #717 was being fixed. Modefied the test, too.
Diffstat (limited to 'test')
-rw-r--r-- | test/tvlstr.c | 6 | ||||
-rw-r--r-- | test/tvltypes.c | 70 |
2 files changed, 48 insertions, 28 deletions
diff --git a/test/tvlstr.c b/test/tvlstr.c index 8212206..a7b2a32 100644 --- a/test/tvlstr.c +++ b/test/tvlstr.c @@ -256,7 +256,7 @@ test_vlstrings_basic(void) static void test_vlstrings_special(void) { - const char *wdata[SPACE1_DIM1] = {"one", "two", "", "four"}; + const char *wdata[SPACE1_DIM1] = {"one", "two", "", "\0"}; const char *wdata2[SPACE1_DIM1] = {NULL, NULL, NULL, NULL}; char *rdata[SPACE1_DIM1]; /* Information read in */ char *fill; /* Fill value */ @@ -314,6 +314,10 @@ test_vlstrings_special(void) TestErrPrintf("VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",(int)i,(int)strlen(wdata[i]),(int)i,(int)strlen(rdata[i])); continue; } /* end if */ + if((wdata[i]==NULL && rdata[i]!=NULL) || (rdata[i]==NULL && wdata[i]!=NULL)) { + TestErrPrintf("VL data values don't match!\n"); + continue; + } /* end if */ if( HDstrcmp(wdata[i],rdata[i]) != 0 ) { TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",(int)i,wdata[i],(int)i,rdata[i]); continue; diff --git a/test/tvltypes.c b/test/tvltypes.c index de51f4a..b6a5509 100644 --- a/test/tvltypes.c +++ b/test/tvltypes.c @@ -2397,16 +2397,19 @@ static void test_vltypes_fill_value(void) { typedef struct dtype1_struct { - int i1; - char *str; - int i2; - int i3; - int i4; - int i5; - int i6; - int i7; - int i8; - float f1; + unsigned int gui; + unsigned int pgui; + char *str_id; + char *str_name; + char *str_desc; + char *str_orig; + char *str_stat; + unsigned int ver; + double val; + double ma; + double mi; + char *str_form; + char *str_unit; } dtype1_struct; herr_t ret; @@ -2417,7 +2420,7 @@ test_vltypes_fill_value(void) hid_t dcpl_id, xfer_pid; hid_t dset_id; hsize_t dim1[] = {SPACE1_DIM1}; - const dtype1_struct fill1 = {1, "foobar", 2, 3, 4, 5, 6, 7, 8, 9.0}; + const dtype1_struct fill1 = {1, 2, "foobar", "", NULL, "\0", "dead", 3, 4.0, 100.0, 1.0, "liquid", "meter"}; dtype1_struct buf[SPACE1_DIM1]; size_t mem_used=0; /* Memory used during allocation */ int i; @@ -2429,41 +2432,54 @@ test_vltypes_fill_value(void) dtype1_id = H5Tcreate(H5T_COMPOUND, sizeof(struct dtype1_struct)); CHECK(dtype1_id, FAIL, "H5Tcreate"); - ret = H5Tinsert(dtype1_id,"i1",HOFFSET(struct dtype1_struct,i1),H5T_NATIVE_INT); + ret = H5Tinsert(dtype1_id,"guid",HOFFSET(struct dtype1_struct,gui),H5T_NATIVE_UINT); CHECK(ret, FAIL, "H5Tinsert"); + ret = H5Tinsert(dtype1_id,"pguid",HOFFSET(struct dtype1_struct,pgui),H5T_NATIVE_UINT); + CHECK(ret, FAIL, "H5Tinsert"); + + str_id = H5Tcopy(H5T_C_S1); CHECK(str_id, FAIL, "H5Tcopy"); ret = H5Tset_size(str_id,H5T_VARIABLE); CHECK(ret, FAIL, "H5Tset_size"); - ret = H5Tinsert(dtype1_id,"vl_string",HOFFSET(dtype1_struct,str),str_id); + ret = H5Tinsert(dtype1_id,"str_id",HOFFSET(dtype1_struct,str_id),str_id); + CHECK(ret, FAIL, "H5Tinsert"); + + ret = H5Tinsert(dtype1_id,"str_name",HOFFSET(dtype1_struct,str_name),str_id); + CHECK(ret, FAIL, "H5Tinsert"); + + ret = H5Tinsert(dtype1_id,"str_desc",HOFFSET(dtype1_struct,str_desc),str_id); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"i2",HOFFSET(struct dtype1_struct,i2),H5T_NATIVE_INT); + ret = H5Tinsert(dtype1_id,"str_orig",HOFFSET(dtype1_struct,str_orig),str_id); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"i3",HOFFSET(struct dtype1_struct,i3),H5T_NATIVE_INT); + ret = H5Tinsert(dtype1_id,"str_stat",HOFFSET(dtype1_struct,str_stat),str_id); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"i4",HOFFSET(struct dtype1_struct,i4),H5T_NATIVE_INT); + + ret = H5Tinsert(dtype1_id,"ver",HOFFSET(struct dtype1_struct,ver),H5T_NATIVE_UINT); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"i5",HOFFSET(struct dtype1_struct,i5),H5T_NATIVE_INT); + ret = H5Tinsert(dtype1_id,"val",HOFFSET(struct dtype1_struct,val),H5T_NATIVE_DOUBLE); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"i6",HOFFSET(struct dtype1_struct,i6),H5T_NATIVE_INT); + ret = H5Tinsert(dtype1_id,"ma",HOFFSET(struct dtype1_struct,ma),H5T_NATIVE_DOUBLE); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"i7",HOFFSET(struct dtype1_struct,i7),H5T_NATIVE_INT); + ret = H5Tinsert(dtype1_id,"mi",HOFFSET(struct dtype1_struct,mi),H5T_NATIVE_DOUBLE); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"i8",HOFFSET(struct dtype1_struct,i8),H5T_NATIVE_INT); + + ret = H5Tinsert(dtype1_id,"str_form",HOFFSET(dtype1_struct,str_form),str_id); CHECK(ret, FAIL, "H5Tinsert"); - ret = H5Tinsert(dtype1_id,"f1",HOFFSET(struct dtype1_struct,f1),H5T_NATIVE_FLOAT); + ret = H5Tinsert(dtype1_id,"str_unit",HOFFSET(dtype1_struct,str_unit),str_id); CHECK(ret, FAIL, "H5Tinsert"); + ret = H5Tclose(str_id); CHECK(ret, FAIL, "H5Tclose"); @@ -2526,9 +2542,9 @@ test_vltypes_fill_value(void) /* Compare data read in */ for(i=0; i<SPACE1_DIM1; i++) { - if(strcmp(buf[i].str, "foobar")) { - TestErrPrintf("%d: VL data doesn't match!, buf[%d].str=%s\n",__LINE__,(int)i,buf[i].str); - /*continue;*/ + if(strcmp(buf[i].str_id, "foobar") || strcmp(buf[i].str_name, "") || buf[i].str_desc || strcmp(buf[i].str_orig,"\0") || strcmp(buf[i].str_stat, "dead") || strcmp(buf[i].str_form, "liquid") || strcmp(buf[i].str_unit, "meter")) { + TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i); + continue; } /* end if */ } /* end for */ @@ -2548,9 +2564,9 @@ test_vltypes_fill_value(void) /* Compare data read in */ for(i=0; i<SPACE1_DIM1; i++) { - if(strcmp(buf[i].str, "foobar")) { - TestErrPrintf("%d: VL data doesn't match!, buf[%d].str=%s\n",__LINE__,(int)i,buf[i].str); - /*continue;*/ + if(strcmp(buf[i].str_id, "foobar") || strcmp(buf[i].str_name, "") || buf[i].str_desc || strcmp(buf[i].str_orig,"\0") || strcmp(buf[i].str_stat, "dead") || strcmp(buf[i].str_form, "liquid") || strcmp(buf[i].str_unit, "meter")) { + TestErrPrintf("%d: VL data doesn't match!, index(i)=%d\n",__LINE__,(int)i); + continue; } /* end if */ } /* end for */ |