diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2009-04-21 16:10:02 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2009-04-21 16:10:02 (GMT) |
commit | 9e504250bf0fb9355cf1ec661b021995bbfc04b9 (patch) | |
tree | 29f6cd5056d1fb53bccdf1f2c2da08f2edb9dc11 | |
parent | 2f094f5ba15c6154f58d50b1535b8311777f7fa3 (diff) | |
download | hdf5-9e504250bf0fb9355cf1ec661b021995bbfc04b9.zip hdf5-9e504250bf0fb9355cf1ec661b021995bbfc04b9.tar.gz hdf5-9e504250bf0fb9355cf1ec661b021995bbfc04b9.tar.bz2 |
[svn-r16821] Description:
Added member function Attribute::getInMemDataSize() to simplify
getting the attribute's data size in memory. Used this new function
in Attribute::read to get the fixed-len string attribute data.
Added to tests in tattr.cpp.
Platforms tested:
Linux/32 2.6 (jam)
FreeBSD/64 6.3 (liberty)
SunOS 5.10 (linew)
-rw-r--r-- | c++/test/tattr.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index 00adb84..f6dccfe 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -356,7 +356,7 @@ static void test_attr_basic_read(void) for(i=0; i<ATTR2_DIM1; i++) for(j=0; j<ATTR2_DIM2; j++) if(attr_data2[i][j]!=read_data2[i][j]) { - TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",__LINE__, i,j,attr_data2[i][j],i,j,read_data1[i]); + TestErrPrintf("%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",__LINE__, i,j,attr_data2[i][j],i,j,read_data2[i][j]); } PASSED(); } // end try block @@ -1043,7 +1043,7 @@ static void test_attr_dtype_shared(void) h5_stat_size_t empty_filesize; // Size of empty file empty_filesize = h5_get_file_size(FILENAME.c_str()); if (empty_filesize < 0) - TestErrPrintf("Line %d: file size wrong!\n",__LINE__); + TestErrPrintf("Line %d: file size wrong!\n",__LINE__); // Open the file again fid1.openFile(FILENAME, H5F_ACC_RDWR); @@ -1217,6 +1217,16 @@ static void test_string_attr(void) if(HDstrcmp(flstring_att_check, ATTRSTR_DATA.c_str())!=0) TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), flstring_att_check); + // Read and verify the attribute string as a string of chars; buffer + // is dynamically allocated. + size_t attr_size = gr_flattr1.getInMemDataSize(); + char *fl_dyn_string_att_check; + fl_dyn_string_att_check = new char[attr_size+1]; + gr_flattr1.read(fls_type, fl_dyn_string_att_check); + if(HDstrcmp(fl_dyn_string_att_check, ATTRSTR_DATA.c_str())!=0) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,flstring_att_check=%s\n",__LINE__, ATTRSTR_DATA.c_str(), fl_dyn_string_att_check); + delete []fl_dyn_string_att_check; + /* Test Attribute::read(...,H5std_string& strg) with FL string */ // Read and verify the attribute string as an std::string. |