diff options
Diffstat (limited to 'c++/test/tvlstr.cpp')
-rw-r--r-- | c++/test/tvlstr.cpp | 369 |
1 files changed, 218 insertions, 151 deletions
diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp index 0abab1b..01033be 100644 --- a/c++/test/tvlstr.cpp +++ b/c++/test/tvlstr.cpp @@ -18,7 +18,6 @@ tvlstr.cpp - HDF5 C++ testing the Variable-Length String functionality EXTERNAL ROUTINES/VARIABLES: - These routines are in the test directory of the C library: ***************************************************************************/ @@ -52,7 +51,7 @@ const H5std_string FILENAME("tvlstr.h5"); const int SPACE1_RANK = 1; const hsize_t SPACE1_DIM1 = 4; -// Utility functions +// Utility functions - not used now, later though. void *test_vlstr_alloc_custom(size_t size, void *info); void test_vlstr_free_custom(void *mem, void *info); @@ -119,9 +118,9 @@ void test_vlstr_free_custom(void *_mem, void *info) } /*------------------------------------------------------------------------- - * Function: test_vlstrings_basic + * Function: test_vlstring_dataset * - * Purpose: Test simple VL string I/O. + * Purpose: Test writing/reading VL strings on datasets. * * Return: None * @@ -130,98 +129,171 @@ void test_vlstr_free_custom(void *_mem, void *info) * *------------------------------------------------------------------------- */ -static void test_vlstrings_basic() +// String for testing datasets +static char *dynstring_ds_write=NULL; +static char stastring_ds_write[1]={'A'}; + +// Info for a string dataset +const H5std_string DSET1_NAME("String_ds"); +const H5std_string DSET1_DATA("String Dataset"); + +static void test_vlstring_dataset() +{ + // Output message about test being performed + SUBTEST("Testing VL String on Datasets"); + + try { + // Open the file + H5File file1(FILENAME, H5F_ACC_TRUNC); + + // Create a datatype to refer to. + StrType vlst(0, H5T_VARIABLE); + + // Open the root group. + Group root = file1.openGroup("/"); + + // Create dataspace for the dataset. + DataSpace ds_space (H5S_SCALAR); + + // Create an dataset in the root group. + DataSet dset1 = root.createDataSet(DSET1_NAME, vlst, ds_space); + + // Write data to the dataset. + dset1.write(DSET1_DATA, vlst); + + // Read and verify the dataset string as a string of chars. + char *string_ds_check; + dset1.read(&string_ds_check, vlst); + if(HDstrcmp(string_ds_check, DSET1_DATA.c_str())!=0) + TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,string_ds_check=%s\n",__LINE__, DSET1_DATA.c_str(), string_ds_check); + + HDfree(string_ds_check); // note: no need for std::string test + + // Read and verify the dataset string as an std::string. + H5std_string read_str; + dset1.read(read_str, vlst); + if (read_str != DSET1_DATA) + TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,read_str=%s\n",__LINE__, DSET1_DATA.c_str(), read_str.c_str()); + + // Close the dataset. + dset1.close(); + + // Test scalar type dataset with 1 value. + dset1 = root.createDataSet("test_scalar_small", vlst, ds_space); + + dynstring_ds_write = (char*)HDcalloc(1, sizeof(char)); + HDmemset(dynstring_ds_write, 'A', 1); + + // Write data to the dataset, then read it back. + dset1.write(&dynstring_ds_write, vlst); + dset1.read(&string_ds_check, vlst); + + // Verify data read. + if(HDstrcmp(string_ds_check,dynstring_ds_write)!=0) + TestErrPrintf("VL string datasets don't match!, dynstring_ds_write=%s, string_ds_check=%s\n",dynstring_ds_write,string_ds_check); + HDfree(string_ds_check); + dset1.close(); + + // Open dataset DSET1_NAME again. + dset1 = root.openDataSet(DSET1_NAME); + + // Close dataset and file + dset1.close(); + file1.close(); + + PASSED(); + } // end try block + + // Catch all exceptions. + catch (Exception E) { + issue_fail_msg("test_vlstring_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); + } +} // test_vlstring_dataset() + +/*------------------------------------------------------------------------- + * Function: test_vlstring_array_dataset + * + * Purpose: Test writing/reading VL string array to/from datasets. + * + * Return: None + * + * Programmer: Binh-Minh Ribler + * July, 2009 + * + *------------------------------------------------------------------------- + */ +const H5std_string DSSTRARR_NAME("StringArray_dset"); +static void test_vlstring_array_dataset() { - const char *wdata[SPACE1_DIM1]= { - "Four score and seven years ago our forefathers brought forth on this continent a new nation,", - "conceived in liberty and dedicated to the proposition that all men are created equal.", - "Now we are engaged in a great civil war,", - "testing whether that nation or any nation so conceived and so dedicated can long endure." + const char *string_ds_array[SPACE1_DIM1]= { + "Line 1", "Line 2", "Line 3", "Line 4" }; // Information to write // Output message about test being performed - SUBTEST("Testing Basic VL String Functionality"); + SUBTEST("Testing VL String Array on Datasets"); - H5File* file1 = NULL; + H5File* file1; try { // Create file. - file1 = new H5File (FILENAME, H5F_ACC_TRUNC); + file1 = new H5File (FILENAME, H5F_ACC_RDWR); - // Create dataspace for datasets. - hsize_t dims1[] = {SPACE1_DIM1}; - DataSpace sid1(SPACE1_RANK, dims1); + // Create dataspace for datasets. + hsize_t dims1[] = {SPACE1_DIM1}; + DataSpace ds_space(SPACE1_RANK, dims1); // Create a datatype to refer to. - StrType tid1(0, H5T_VARIABLE); + StrType vlst(0, H5T_VARIABLE); // Create and write a dataset. - DataSet dataset(file1->createDataSet("Dataset1", tid1, sid1)); - dataset.write(wdata, tid1); + DataSet dataset(file1->createDataSet(DSSTRARR_NAME, vlst, ds_space)); + dataset.write(string_ds_array, vlst); + + // Read and verify the dataset using strings of chars as buffer. + // Note: reading by array of H5std_string doesn't work yet. + char *string_ds_check[SPACE1_DIM1]; + dataset.read(string_ds_check, vlst); + + int ii; + for (ii = 0; ii < SPACE1_DIM1; ii++) + { + if(HDstrcmp(string_ds_check[ii], string_ds_array[ii])!=0) + TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, string_ds_array[ii], string_ds_check[ii]); + + HDfree(string_ds_check[ii]); + } + + // Close objects that are no longer needed. + dataset.close(); + ds_space.close(); + + // + // Test with scalar data space. + // // Create H5S_SCALAR data space. DataSpace scalar_space; // Create and write another dataset. - DataSet dataset2(file1->createDataSet("Dataset2", tid1, scalar_space)); + DataSet dataset2(file1->createDataSet("Dataset2", vlst, scalar_space)); char *wdata2 = (char*)HDcalloc(65534, sizeof(char)); HDmemset(wdata2, 'A', 65533); - dataset2.write(&wdata2, tid1); + dataset2.write(&wdata2, vlst); + + char *rdata2 = (char*)HDcalloc(65534, sizeof(char)); + HDmemset(rdata2, 0, 65533); + dataset2.read(&rdata2, vlst); + if (HDstrcmp(wdata2, rdata2)!=0) + TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, wdata2, rdata2); // Release resources from second dataset operation. scalar_space.close(); dataset2.close(); HDfree(wdata2); - - // Change to the custom memory allocation routines for reading - // VL string. - DSetMemXferPropList xfer; - size_t mem_used = 0; // Memory used during allocation - xfer.setVlenMemManager(test_vlstr_alloc_custom, &mem_used, test_vlstr_free_custom, &mem_used); - - // Make certain the correct amount of memory will be used. - hsize_t vlsize = dataset.getVlenBufSize(tid1, sid1); - - // Count the actual number of bytes used by the strings. - size_t str_used; // String data in memory - hsize_t i; // counting variable - for (i=0,str_used=0; i<SPACE1_DIM1; i++) - str_used+=HDstrlen(wdata[i])+1; - - // Compare against the strings actually written. - verify_val((int)vlsize,str_used,"DataSet::getVlenBufSize", __LINE__, __FILE__); - - // Read dataset from disk. - char *rdata[SPACE1_DIM1]; // Data read in - dataset.read(rdata, tid1, DataSpace::ALL, DataSpace::ALL, xfer); - - // Make certain the correct amount of memory has been used. - verify_val(mem_used, str_used, "DataSet::read", __LINE__, __FILE__); - - // Compare data read in. - for(i = 0; i < SPACE1_DIM1; i++) { - size_t wlen = HDstrlen(wdata[i]); - size_t rlen = HDstrlen(rdata[i]); - if(wlen != rlen) { - TestErrPrintf("VL data lengths don't match!, strlen(wdata[%d])=%u, strlen(rdata[%d])=%u\n", (int)i, (unsigned)wlen, (int)i, (unsigned)rlen); - 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; - } // end if - } // end for - - // Reclaim the read VL data. - DataSet::vlenReclaim((void *)rdata, tid1, sid1, xfer); - - // Make certain the VL memory has been freed. - verify_val(mem_used, 0, "DataSet::vlenReclaim", __LINE__, __FILE__); + HDfree(rdata2); // Close objects and file. - dataset.close(); - tid1.close(); - sid1.close(); - xfer.close(); + dataset2.close(); + vlst.close(); file1->close(); PASSED(); @@ -230,11 +302,10 @@ static void test_vlstrings_basic() // Catch all exceptions. catch (Exception E) { - issue_fail_msg("test_vlstrings_basic()", __LINE__, __FILE__, E.getCDetailMsg()); - if (file1 != NULL) // clean up - delete file1; + issue_fail_msg("test_vlstring_array_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); + delete file1; } -} // end test_vlstrings_basic() +} // end test_vlstring_array_dataset() /*------------------------------------------------------------------------- * Function: test_vlstrings_special @@ -267,13 +338,13 @@ static void test_vlstrings_special() DataSpace sid1(SPACE1_RANK, dims1); // Create a datatype to refer to. - StrType tid1(0, H5T_VARIABLE); + StrType vlst(0, H5T_VARIABLE); // Create a dataset. - DataSet dataset(file1.createDataSet("Dataset3", tid1, sid1)); + DataSet dataset(file1.createDataSet("Dataset3", vlst, sid1)); // Read from the dataset before writing data. - dataset.read(rdata, tid1); + dataset.read(rdata, vlst); // Check data read in. hsize_t i; // counting variable @@ -282,8 +353,8 @@ static void test_vlstrings_special() TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)i,rdata[i]); // Write dataset to disk, then read it back. - dataset.write(wdata, tid1); - dataset.read(rdata, tid1); + dataset.write(wdata, vlst); + dataset.read(rdata, vlst); // Compare data read in. for(i = 0; i < SPACE1_DIM1; i++) { @@ -300,7 +371,7 @@ static void test_vlstrings_special() } // end for // Reclaim the read VL data. - DataSet::vlenReclaim((void *)rdata, tid1, sid1); + DataSet::vlenReclaim((void *)rdata, vlst, sid1); // Close Dataset. dataset.close(); @@ -313,14 +384,14 @@ static void test_vlstrings_special() // dataset. DSetCreatPropList dcpl; char *fill = NULL; // Fill value - dcpl.setFillValue(tid1, &fill); - dataset = file1.createDataSet("Dataset4", tid1, sid1, dcpl); + dcpl.setFillValue(vlst, &fill); + dataset = file1.createDataSet("Dataset4", vlst, sid1, dcpl); // Close dataset creation property list. dcpl.close(); // Read from dataset before writing data. - dataset.read(rdata, tid1); + dataset.read(rdata, vlst); // Check data read in. for (i=0; i<SPACE1_DIM1; i++) @@ -328,10 +399,10 @@ static void test_vlstrings_special() TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n",(int)i, rdata[i]); // Try to write nil strings to disk. - dataset.write(wdata2, tid1); + dataset.write(wdata2, vlst); // Read nil strings back from disk. - dataset.read(rdata, tid1); + dataset.read(rdata, vlst); // Check data read in. for (i=0; i<SPACE1_DIM1; i++) @@ -340,7 +411,7 @@ static void test_vlstrings_special() // Close objects and file. dataset.close(); - tid1.close(); + vlst.close(); sid1.close(); file1.close(); @@ -370,7 +441,7 @@ const H5std_string VLSTR_TYPE("vl_string_type"); static void test_vlstring_type() { // Output message about test being performed. - SUBTEST("Testing VL String type"); + SUBTEST("Testing VL String Type"); H5File* file1 = NULL; try { @@ -378,55 +449,55 @@ static void test_vlstring_type() file1 = new H5File(FILENAME, H5F_ACC_RDWR); // Create a datatype to refer to. - StrType vlstr_type(PredType::C_S1); + StrType vlst(PredType::C_S1); // Change padding and verify it. - vlstr_type.setStrpad(H5T_STR_NULLPAD); - H5T_str_t pad = vlstr_type.getStrpad(); + vlst.setStrpad(H5T_STR_NULLPAD); + H5T_str_t pad = vlst.getStrpad(); verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__); // Convert to variable-length string. - vlstr_type.setSize(H5T_VARIABLE); + vlst.setSize(H5T_VARIABLE); // Check if datatype is VL string. - H5T_class_t type_class = vlstr_type.getClass(); + H5T_class_t type_class = vlst.getClass(); verify_val(type_class, H5T_STRING, "DataType::getClass", __LINE__, __FILE__); - bool is_variable_str = vlstr_type.isVariableStr(); + bool is_variable_str = vlst.isVariableStr(); verify_val(is_variable_str, TRUE, "DataType::isVariableStr", __LINE__, __FILE__); // Check default character set and padding. - H5T_cset_t cset = vlstr_type.getCset(); + H5T_cset_t cset = vlst.getCset(); verify_val(cset, H5T_CSET_ASCII, "StrType::getCset", __LINE__, __FILE__); - pad = vlstr_type.getStrpad(); + pad = vlst.getStrpad(); verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__); // Commit variable-length string datatype to storage. - vlstr_type.commit(*file1, VLSTR_TYPE); + vlst.commit(*file1, VLSTR_TYPE); // Close datatype. - vlstr_type.close(); + vlst.close(); // Try opening datatype again. - vlstr_type = file1->openStrType(VLSTR_TYPE); + vlst = file1->openStrType(VLSTR_TYPE); // Close datatype and file. - vlstr_type.close(); + vlst.close(); file1->close(); // Open file. file1 = new H5File(FILENAME, H5F_ACC_RDWR); // Open the variable-length string datatype just created - vlstr_type = file1->openStrType(VLSTR_TYPE); + vlst = file1->openStrType(VLSTR_TYPE); // Verify character set and padding - cset = vlstr_type.getCset(); + cset = vlst.getCset(); verify_val(cset, H5T_CSET_ASCII, "StrType::getCset", __LINE__, __FILE__); - pad = vlstr_type.getStrpad(); + pad = vlst.getStrpad(); verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__); // Close datatype and file - vlstr_type.close(); + vlst.close(); file1->close(); PASSED(); @@ -436,6 +507,7 @@ static void test_vlstring_type() catch (Exception E) { issue_fail_msg("test_vlstring_type()", __LINE__, __FILE__, E.getCDetailMsg()); + delete file1; } } // end test_vlstring_type() @@ -454,7 +526,7 @@ static void test_vlstring_type() static void test_compact_vlstring() { // Output message about test being performed - SUBTEST("Testing VL Strings in compact dataset"); + SUBTEST("Testing VL Strings on Compact Dataset"); try { // Create file @@ -465,22 +537,22 @@ static void test_compact_vlstring() DataSpace sid1(SPACE1_RANK, dims1); // Create a datatype to refer to - StrType tid1(0, H5T_VARIABLE); + StrType vlst(0, H5T_VARIABLE); // Create dataset create property list and set layout DSetCreatPropList plist; plist.setLayout(H5D_COMPACT); // Create a dataset - DataSet dataset(file1.createDataSet("Dataset5", tid1, sid1, plist)); + DataSet dataset(file1.createDataSet("Dataset5", vlst, sid1, plist)); // Write dataset to disk const char *wdata[SPACE1_DIM1] = {"one", "two", "three", "four"}; - dataset.write(wdata, tid1); + dataset.write(wdata, vlst); // Read dataset from disk char *rdata[SPACE1_DIM1]; // Information read in - dataset.read(rdata, tid1); + dataset.read(rdata, vlst); // Compare data read in hsize_t i; @@ -496,11 +568,11 @@ static void test_compact_vlstring() } // end for // Reclaim the read VL data - DataSet::vlenReclaim((void *)rdata, tid1, sid1); + DataSet::vlenReclaim((void *)rdata, vlst, sid1); // Close objects and file dataset.close(); - tid1.close(); + vlst.close(); sid1.close(); plist.close(); file1.close(); @@ -516,9 +588,9 @@ static void test_compact_vlstring() } // test_compact_vlstrings /*------------------------------------------------------------------------- - * Function: test_write_vl_string_attribute + * Function: test_vlstring_attribute * - * Purpose: Test writing VL strings as attributes. + * Purpose: Test writing/reading VL strings on attributes. * * Return: None * @@ -534,17 +606,17 @@ static char *string_att_write=NULL; const H5std_string ATTRSTR_NAME("String_attr"); const H5std_string ATTRSTR_DATA("String Attribute"); -static void test_write_vl_string_attribute() +static void test_vlstring_attribute() { // Output message about test being performed - SUBTEST("Testing writing VL String as attributes"); + SUBTEST("Testing VL String on Attributes"); try { // Open the file H5File file1(FILENAME, H5F_ACC_RDWR); // Create a datatype to refer to. - StrType tid1(0, H5T_VARIABLE); + StrType vlst(0, H5T_VARIABLE); // Open the root group. Group root = file1.openGroup("/"); @@ -553,14 +625,14 @@ static void test_write_vl_string_attribute() DataSpace att_space (H5S_SCALAR); // Create an attribute for the root group. - Attribute gr_attr = root.createAttribute(ATTRSTR_NAME, tid1, att_space); + Attribute gr_attr = root.createAttribute(ATTRSTR_NAME, vlst, att_space); // Write data to the attribute. - gr_attr.write(tid1, ATTRSTR_DATA); + gr_attr.write(vlst, ATTRSTR_DATA); // Read and verify the attribute string as a string of chars. char *string_att_check; - gr_attr.read(tid1, &string_att_check); + gr_attr.read(vlst, &string_att_check); if(HDstrcmp(string_att_check, ATTRSTR_DATA.c_str())!=0) TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), string_att_check); @@ -568,7 +640,7 @@ static void test_write_vl_string_attribute() // Read and verify the attribute string as an std::string. H5std_string read_str; - gr_attr.read(tid1, read_str); + gr_attr.read(vlst, read_str); if (read_str != ATTRSTR_DATA) TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_str=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_str.c_str()); @@ -576,28 +648,22 @@ static void test_write_vl_string_attribute() gr_attr.close(); // Test creating a "large" sized string attribute - gr_attr = root.createAttribute("test_scalar_large", tid1, att_space); + gr_attr = root.createAttribute("test_scalar_large", vlst, att_space); string_att_write = (char*)HDcalloc(8192, sizeof(char)); HDmemset(string_att_write, 'A', 8191); // Write data to the attribute, then read it back. - gr_attr.write(tid1, &string_att_write); - gr_attr.read(tid1, &string_att_check); + gr_attr.write(vlst, &string_att_write); + gr_attr.read(vlst, &string_att_check); // Verify data read. if(HDstrcmp(string_att_check,string_att_write)!=0) TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); - HDfree(string_att_check); - gr_attr.close(); - - // Open attribute ATTRSTR_NAME again. - gr_attr = root.openAttribute(ATTRSTR_NAME); - // The attribute string written is freed below, in the - // test_read_vl_string_attribute() test - - // Close attribute and file + // Release resources. + HDfree(string_att_check); + HDfree(string_att_write); gr_attr.close(); file1.close(); @@ -606,9 +672,9 @@ static void test_write_vl_string_attribute() // Catch all exceptions. catch (Exception E) { - issue_fail_msg("test_string_attr()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_vlstring_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_string_attr() +} // test_vlstring_attribute() /*------------------------------------------------------------------------- * Function: test_read_vl_string_attribute @@ -633,7 +699,7 @@ static void test_read_vl_string_attribute() H5File file1(FILENAME, H5F_ACC_RDONLY); // Create a datatype to refer to. - StrType tid1(0, H5T_VARIABLE); + StrType vlst(0, H5T_VARIABLE); // Open the root group and its attribute named ATTRSTR_NAME. Group root = file1.openGroup("/"); @@ -641,7 +707,7 @@ static void test_read_vl_string_attribute() // Test reading "normal" sized string attribute char *string_att_check; - att.read(tid1, &string_att_check); + att.read(vlst, &string_att_check); if(HDstrcmp(string_att_check,ATTRSTR_DATA.c_str())!=0) TestErrPrintf("VL string attributes don't match!, string_att=%s, string_att_check=%s\n",ATTRSTR_DATA.c_str(),string_att_check); HDfree(string_att_check); @@ -649,7 +715,7 @@ static void test_read_vl_string_attribute() // Test reading "large" sized string attribute att = root.openAttribute("test_scalar_large"); - att.read(tid1, &string_att_check); + att.read(vlst, &string_att_check); if(HDstrcmp(string_att_check,string_att_write)!=0) TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); HDfree(string_att_check); @@ -657,7 +723,7 @@ static void test_read_vl_string_attribute() // Close objects and file. att.close(); - tid1.close(); + vlst.close(); root.close(); file1.close(); @@ -672,7 +738,7 @@ static void test_read_vl_string_attribute() /*------------------------------------------------------------------------- - * Function: test_vl_stringarray_attribute + * Function: test_vlstring_array_attribute * * Purpose: Test writing/reading VL string array to/from attributes. * @@ -685,21 +751,21 @@ static void test_read_vl_string_attribute() */ const H5std_string ATTRSTRARR_NAME("StringArray_attr"); -static void test_vl_stringarray_attribute() +static void test_vlstring_array_attribute() { const char *string_att_array[SPACE1_DIM1]= { "Line 1", "Line 2", "Line 3", "Line 4" }; // Information to write // Output message about test being performed - SUBTEST("Testing writing/reading VL String Array on attribute"); + SUBTEST("Testing VL String Array on Attributes"); try { // Open the file H5File file1(FILENAME, H5F_ACC_RDWR); // Create a datatype to refer to. - StrType tid1(0, H5T_VARIABLE); + StrType vlst(0, H5T_VARIABLE); // Open the root group. Group root = file1.openGroup("/"); @@ -709,15 +775,15 @@ static void test_vl_stringarray_attribute() DataSpace att_space(SPACE1_RANK, dims1); // Create an attribute for the root group. - Attribute gr_attr = root.createAttribute(ATTRSTRARR_NAME, tid1, att_space); + Attribute gr_attr = root.createAttribute(ATTRSTRARR_NAME, vlst, att_space); // Write data to the attribute. - gr_attr.write(tid1, string_att_array); + gr_attr.write(vlst, string_att_array); // Read and verify the attribute string as a string of chars. // Note: reading by array of H5std_string doesn't work yet. char *string_att_check[SPACE1_DIM1]; - gr_attr.read(tid1, &string_att_check); + gr_attr.read(vlst, &string_att_check); int ii; for (ii = 0; ii < SPACE1_DIM1; ii++) @@ -737,9 +803,9 @@ static void test_vl_stringarray_attribute() // Catch all exceptions. catch (Exception E) { - issue_fail_msg("test_string_attr()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_vlstring_array_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } -} // test_vl_stringarray_attribute() +} // test_vlstring_array_attribute() /* Helper routine for test_vl_rewrite() */ static void write_scalar_dset(H5File& file, DataType& type, DataSpace& space, @@ -885,17 +951,18 @@ void test_vlstrings() // These tests use the same file // Test basic VL string datatype - test_vlstrings_basic(); + test_vlstring_dataset(); test_vlstrings_special(); test_vlstring_type(); test_compact_vlstring(); // Test using VL strings in attributes - test_write_vl_string_attribute(); - test_read_vl_string_attribute(); + test_vlstring_attribute(); + // test_read_vl_string_attribute(); - // Test using VL string array in attributes - test_vl_stringarray_attribute(); + // Test using VL string array in attributes and datasets + test_vlstring_array_attribute(); + test_vlstring_array_dataset(); // Test writing VL datasets in files with lots of unlinking test_vl_rewrite(); |