diff options
author | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2009-04-28 19:41:42 (GMT) |
---|---|---|
committer | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2009-04-28 19:41:42 (GMT) |
commit | 665f528813749ce6b1ce9afdf104262a65a4a2cd (patch) | |
tree | 5839f00d5537981ae08fad294dc46a7a9a0f4efd /c++/test | |
parent | 75a7a98214a0a408adff8b90b697682f10a4de77 (diff) | |
download | hdf5-665f528813749ce6b1ce9afdf104262a65a4a2cd.zip hdf5-665f528813749ce6b1ce9afdf104262a65a4a2cd.tar.gz hdf5-665f528813749ce6b1ce9afdf104262a65a4a2cd.tar.bz2 |
[svn-r16875] Merged changes from the trunk into the branch:
svn merge -r16602:16869 https://svn.hdfgroup.uiuc.edu/hdf5/trunk
Tested on: smirom
Diffstat (limited to 'c++/test')
-rw-r--r-- | c++/test/Makefile.in | 8 | ||||
-rw-r--r-- | c++/test/dsets.cpp | 2 | ||||
-rw-r--r-- | c++/test/tattr.cpp | 90 | ||||
-rw-r--r-- | c++/test/tfilter.cpp | 2 |
4 files changed, 86 insertions, 16 deletions
diff --git a/c++/test/Makefile.in b/c++/test/Makefile.in index 9bbb475..0452ea0 100644 --- a/c++/test/Makefile.in +++ b/c++/test/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.10.1 from Makefile.am. +# Makefile.in generated by automake 1.10.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -382,8 +382,8 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ @@ -471,7 +471,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index 319f894..6a5f223 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -352,7 +352,7 @@ test_tconv( H5File& file) } // test_tconv /* This message derives from H5Z */ -const H5Z_class_t H5Z_BOGUS[1] = {{ +const H5Z_class2_t H5Z_BOGUS[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version number */ H5Z_FILTER_BOGUS, /* Filter id number */ 1, 1, /* Encode and decode enabled */ diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index 73b5a91..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 @@ -1180,20 +1180,26 @@ static void test_attr_dtype_shared() ** ****************************************************************/ /* Info for a string attribute */ -const H5std_string ATTRSTR_NAME("String_attr"); +const H5std_string ATTR1_FL_STR_NAME("String_attr 1"); +const H5std_string ATTR2_FL_STR_NAME("String_attr 2"); +const H5std_string ATTR_VL_STR_NAME("String_attr"); const H5std_string ATTRSTR_DATA("String Attribute"); +const int ATTR_LEN = 17; static void test_string_attr() { // Output message about test being performed - SUBTEST("Testing Basic Attribute Writing Functions"); + SUBTEST("Testing I/O on FL and VL String Attributes"); try { // Create file H5File fid1(FILENAME, H5F_ACC_RDWR); - // Create a variable length string datatype to refer to. - StrType type(0, H5T_VARIABLE); + // + // Fixed-lenth string attributes + // + // Create a fixed-length string datatype to refer to. + StrType fls_type(0, ATTR_LEN); // Open the root group. Group root = fid1.openGroup("/"); @@ -1201,24 +1207,88 @@ static void test_string_attr() // Create dataspace for the attribute. DataSpace att_space (H5S_SCALAR); + /* Test Attribute::write(...,const void *buf) with Fixed len string */ + + // Create an attribute for the root group. + Attribute gr_flattr1 = root.createAttribute(ATTR1_FL_STR_NAME, fls_type, att_space); + + // Write data to the attribute. + gr_flattr1.write(fls_type, ATTRSTR_DATA.c_str()); + + /* Test Attribute::write(...,const H5std_string& strg) with FL string */ + + // Create an attribute for the root group. + Attribute gr_flattr2 = root.createAttribute(ATTR2_FL_STR_NAME, fls_type, att_space); + + // Write data to the attribute. + gr_flattr2.write(fls_type, ATTRSTR_DATA); + + /* Test Attribute::read(...,void *buf) with FL string */ + + // Read and verify the attribute string as a string of chars. + char flstring_att_check[ATTR_LEN]; + gr_flattr1.read(fls_type, flstring_att_check); + 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. + H5std_string read_flstr1; + gr_flattr1.read(fls_type, read_flstr1); + if (read_flstr1 != ATTRSTR_DATA) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr1=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_flstr1.c_str()); + + // Read and verify the attribute string as a string of chars. + HDstrcpy(flstring_att_check, ""); + gr_flattr2.read(fls_type, flstring_att_check); + 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); + + /* Test Attribute::read(...,H5std_string& strg) with FL string */ + + // Read and verify the attribute string as an std::string. + H5std_string read_flstr2; + gr_flattr2.read(fls_type, read_flstr2); + if (read_flstr2 != ATTRSTR_DATA) + TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,read_flstr2=%s\n",__LINE__, ATTRSTR_DATA.c_str(), read_flstr2.c_str()); + + // + // Variable-lenth string attributes + // + // Create a variable length string datatype to refer to. + StrType vls_type(0, H5T_VARIABLE); + // Create an attribute for the root group. - Attribute gr_attr = root.createAttribute(ATTRSTR_NAME, type, att_space); + Attribute gr_vlattr = root.createAttribute(ATTR_VL_STR_NAME, vls_type, att_space); // Write data to the attribute. - gr_attr.write(type, ATTRSTR_DATA); + gr_vlattr.write(vls_type, ATTRSTR_DATA); + /* Test Attribute::read(...,void *buf) with Variable len string */ // Read and verify the attribute string as a string of chars. char *string_att_check; - gr_attr.read(type, &string_att_check); + gr_vlattr.read(vls_type, &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); + HDfree(string_att_check); + /* Test Attribute::read(...,H5std_string& strg) with VL string */ // Read and verify the attribute string as an std::string. H5std_string read_str; - gr_attr.read(type, read_str); + gr_vlattr.read(vls_type, 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()); - PASSED(); } // end try block diff --git a/c++/test/tfilter.cpp b/c++/test/tfilter.cpp index 2f87feb..1d3cec2 100644 --- a/c++/test/tfilter.cpp +++ b/c++/test/tfilter.cpp @@ -60,7 +60,7 @@ static herr_t test_filter_internal(hid_t fid, const char *name, hid_t dcpl, static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); /* This message derives from H5Z */ -const H5Z_class_t H5Z_BOGUS[1] = {{ +const H5Z_class2_t H5Z_BOGUS[1] = {{ H5Z_CLASS_T_VERS, /* H5Z_class_t version */ H5Z_FILTER_BOGUS, /* Filter id number */ 1, 1, /* Encoding and decoding enabled */ |