diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2009-04-21 14:10:43 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2009-04-21 14:10:43 (GMT) |
commit | d301ea9246d16b067baee9f52cb8b31e802ecdcc (patch) | |
tree | e30bda6d3ea49be02581c1772a4a54730dc44254 /c++/test/tattr.cpp | |
parent | eed7245d7ca7b3f6478349a4b48e95a0ebdf26d8 (diff) | |
download | hdf5-d301ea9246d16b067baee9f52cb8b31e802ecdcc.zip hdf5-d301ea9246d16b067baee9f52cb8b31e802ecdcc.tar.gz hdf5-d301ea9246d16b067baee9f52cb8b31e802ecdcc.tar.bz2 |
[svn-r16816] Description:
Added member function Attribute::getInMemDataSize(), which is a wrapper
of several C calls, 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 tests to tattr.cpp.
Platforms tested:
Linux/32 2.6 (jam)
FreeBSD/64 6.3 (liberty)
SunOS 5.10 (linew)
Diffstat (limited to 'c++/test/tattr.cpp')
-rw-r--r-- | c++/test/tattr.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index fc39c2b..48a3200 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -356,7 +356,7 @@ static void test_attr_basic_read() 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 @@ -1231,6 +1231,16 @@ static void test_string_attr() 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. |