From 70862d68a1c3689a181bc76b5aa768ada64dda11 Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Mon, 16 Dec 2002 11:34:27 -0500 Subject: [svn-r6207] Purpose: Add more test Description: More tests on nil and zero-sized VL strings. Platforms tested: arabica, eirene --- test/tvlstr.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/test/tvlstr.c b/test/tvlstr.c index 8ad3143..cd15fa8 100644 --- a/test/tvlstr.c +++ b/test/tvlstr.c @@ -246,6 +246,105 @@ test_vlstrings_basic(void) /**************************************************************** ** +** test_vlstrings_special(): Test VL string code for special +** string cases, nil and zero-sized. +** +****************************************************************/ +static void +test_vlstrings_special(void) +{ + const char *wdata[SPACE1_DIM1] = {"one", "two", "", "four"}; + const char *wdata2[SPACE1_DIM1] = {NULL, NULL, NULL, NULL}; + char *rdata[SPACE1_DIM1]; /* Information read in */ + hid_t dataspace, dataset2; + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + hid_t tid1; /* Datatype ID */ + hid_t xfer_pid; /* Dataset transfer property list ID */ + hsize_t dims1[] = {SPACE1_DIM1}; + hsize_t size; /* Number of bytes which will be used */ + unsigned i; /* counting variable */ + int str_used; /* String data in memory */ + int mem_used=0; /* Memory used during allocation */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Special VL Strings\n")); + + /* Create file */ + fid1 = H5Fcreate(DATAFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(fid1, FAIL, "H5Fcreate"); + + /* Create dataspace for datasets */ + sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); + CHECK(sid1, FAIL, "H5Screate_simple"); + + /* Create a datatype to refer to */ + tid1 = H5Tcopy (H5T_C_S1); + CHECK(tid1, FAIL, "H5Tcopy"); + + ret = H5Tset_size (tid1,H5T_VARIABLE); + CHECK(ret, FAIL, "H5Tset_size"); + + /* Create a dataset */ + dataset=H5Dcreate(fid1,"Dataset3",tid1,sid1,H5P_DEFAULT); + CHECK(dataset, FAIL, "H5Dcreate"); + + /* Write dataset to disk */ + ret=H5Dwrite(dataset,tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,wdata); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Read dataset from disk */ + ret=H5Dread(dataset,tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,rdata); + CHECK(ret, FAIL, "H5Dread"); + + /* Compare data read in */ + for(i=0; i