From 78ab45cb72cba95d2be5f12d9c44290696013741 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Tue, 17 Oct 2017 23:56:16 -0500 Subject: Adding new C++ wrappers Description: - Added overloaded wrappers for H5Oget_info and H5Oget_info_by_name // Retrieves information about an object void getObjectInfo(H5O_info_t *oinfo) const; void getObjectInfo(const char *name, H5O_info_t *oinfo, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; void getObjectInfo(const H5std_string& name, H5O_info_t *oinfo, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; - Many miscellaneous cleanup for consistent appearance Platforms tested: Linux/32 2.6 (jam) Linux/64 (platypus) Darwin (osx1010test) --- c++/src/H5Location.cpp | 125 +++++++++++++++++++++++++++--------- c++/src/H5Location.h | 9 +++ c++/test/dsets.cpp | 30 ++------- c++/test/h5cpputil.cpp | 19 ++---- c++/test/tarray.cpp | 33 +++++----- c++/test/tattr.cpp | 19 +++--- c++/test/tcompound.cpp | 144 ++++++++++++++++++------------------------ c++/test/tdspl.cpp | 11 ++-- c++/test/testhdf5.cpp | 10 +-- c++/test/tfile.cpp | 160 +++++++++++++++++++++++------------------------ c++/test/tfilter.cpp | 4 -- c++/test/th5s.cpp | 3 - c++/test/tlinks.cpp | 79 +++++++++++------------ c++/test/tobject.cpp | 29 ++------- c++/test/trefer.cpp | 2 +- c++/test/ttypes.cpp | 29 ++------- c++/test/tvlstr.cpp | 72 ++++++++++++--------- release_docs/RELEASE.txt | 27 +++++++- 18 files changed, 403 insertions(+), 402 deletions(-) diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index 4ef5d82..afeaca7 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -95,7 +95,8 @@ May, 2017 (1.8.19) //-------------------------------------------------------------------------- // Function: H5Location::createAttribute -///\brief Deprecated - Creates an attribute for a group, dataset, or named datatype. +///\brief Deprecated - replaced by H5Object::createAttribute +// brief Creates an attribute for a group, dataset, or named datatype. ///\param name - IN: Name of the attribute ///\param data_type - IN: Datatype for the attribute ///\param data_space - IN: Dataspace for the attribute - only simple @@ -134,7 +135,8 @@ Attribute H5Location::createAttribute(const char* name, const DataType& data_typ //-------------------------------------------------------------------------- // Function: H5Location::createAttribute -///\brief Deprecated - This is an overloaded member function, provided for convenience. +///\brief Deprecated - replaced by H5Object::createAttribute +// brief This is an overloaded member function, provided for convenience. /// It differs from the above function in that it takes /// a reference to an \c H5std_string for \a name. // Programmer Binh-Minh Ribler - 2000 @@ -146,7 +148,8 @@ Attribute H5Location::createAttribute(const H5std_string& name, const DataType& //-------------------------------------------------------------------------- // Function: H5Location::openAttribute -///\brief Deprecated - Opens an attribute given its name. +///\brief Deprecated - replaced by H5Object::openAttribute +// brief Opens an attribute given its name. ///\param name - IN: Name of the attribute ///\return Attribute instance ///\exception H5::AttributeIException @@ -169,9 +172,11 @@ Attribute H5Location::openAttribute(const char* name) const //-------------------------------------------------------------------------- // Function: H5Location::openAttribute -///\brief Deprecated - This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes -/// a reference to an \c H5std_string for \a name. +///\brief Deprecated - replaced by H5Object::openAttribute +// brief This is an overloaded member function, provided for convenience. +// It differs from the above function in that it takes +// a reference to an \c H5std_string for \a name. +///\param name - IN: Name of the attribute // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- Attribute H5Location::openAttribute(const H5std_string& name) const @@ -181,7 +186,8 @@ Attribute H5Location::openAttribute(const H5std_string& name) const //-------------------------------------------------------------------------- // Function: H5Location::openAttribute -///\brief Deprecated - Opens an attribute given its index. +///\brief Deprecated - replaced by H5Object::openAttribute +// brief Opens an attribute given its index. ///\param idx - IN: Index of the attribute, a 0-based, non-negative integer ///\return Attribute instance ///\exception H5::AttributeIException @@ -205,7 +211,7 @@ Attribute H5Location::openAttribute(const unsigned int idx) const //-------------------------------------------------------------------------- // Function: H5Location::iterateAttrs -///\brief Deprecated - Iterates a user's function over all the attributes of an H5 +///\brief Iterates a user's function over all the attributes of an H5 /// object, which may be a group, dataset or named datatype. ///\param user_op - IN: User's function to operate on each attribute ///\param _idx - IN/OUT: Starting (IN) and ending (OUT) attribute indices @@ -250,7 +256,8 @@ int H5Location::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_d //-------------------------------------------------------------------------- // Function: H5Location::attrExists -///\brief Deprecated - Checks whether the named attribute exists at this location. +///\brief Deprecated - replaced by H5Object::attrExists() +// brief Checks whether the named attribute exists at this location. ///\param name - IN: Name of the attribute to be queried ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2013 @@ -271,10 +278,12 @@ bool H5Location::attrExists(const char* name) const //-------------------------------------------------------------------------- // Function: H5Location::attrExists -///\brief Deprecated - This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes -/// a reference to an \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 +///\brief Deprecated - replaced by H5Object::attrExists() +// brief This is an overloaded member function, provided for convenience. +// It differs from the above function in that it takes +// a reference to an \c H5std_string for \a name. +///\param name - IN: Name of the attribute to be queried +// Programmer Binh-Minh Ribler - 2013 //-------------------------------------------------------------------------- bool H5Location::attrExists(const H5std_string& name) const { @@ -283,7 +292,8 @@ bool H5Location::attrExists(const H5std_string& name) const //-------------------------------------------------------------------------- // Function: H5Location::removeAttr -///\brief Deprecated - Removes the named attribute from this object. +///\brief Deprecated - replaced by H5Object::removeAttr() +// brief Removes the named attribute from this object. ///\param name - IN: Name of the attribute to be removed ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 @@ -297,9 +307,11 @@ void H5Location::removeAttr(const char* name) const //-------------------------------------------------------------------------- // Function: H5Location::removeAttr -///\brief Deprecated - This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes -/// a reference to an \c H5std_string for \a name. +///\brief Deprecated - replaced by H5Object::removeAttr() +// brief This is an overloaded member function, provided for convenience. +// It differs from the above function in that it takes +// a reference to an \c H5std_string for \a name. +///\param name - IN: Name of the attribute to be removed // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void H5Location::removeAttr(const H5std_string& name) const @@ -309,7 +321,8 @@ void H5Location::removeAttr(const H5std_string& name) const //-------------------------------------------------------------------------- // Function: H5Location::renameAttr -///\brief Deprecated - Renames the named attribute from this object. +///\brief Deprecated - replaced by H5Object::renameAttr() +// brief Renames the named attribute from this object. ///\param oldname - IN: Name of the attribute to be renamed ///\param newname - IN: New name ame of the attribute ///\exception H5::AttributeIException @@ -324,10 +337,13 @@ void H5Location::renameAttr(const char* oldname, const char* newname) const //-------------------------------------------------------------------------- // Function: H5Location::renameAttr -///\brief Deprecated - This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes -/// a reference to an \c H5std_string for the names. -/// +///\brief Deprecated - replaced by H5Object::renameAttr() +// brief This is an overloaded member function, provided for convenience. +// It differs from the above function in that it takes +// a reference to an \c H5std_string for the names. +// +///\param oldname - IN: Name of the attribute to be renamed +///\param newname - IN: New name ame of the attribute ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- @@ -338,8 +354,8 @@ void H5Location::renameAttr(const H5std_string& oldname, const H5std_string& new //-------------------------------------------------------------------------- // Function: H5Location::getNumAttrs -///\brief Deprecated - Returns the number of attributes attached to -/// this HDF5 object. +///\brief Deprecated - replaced by H5Object::getNumAttrs() +// brief Returns the number of attributes attached to this HDF5 object. ///\return Number of attributes ///\exception H5::AttributeIException // Programmer Binh-Minh Ribler - 2000 @@ -348,18 +364,18 @@ void H5Location::renameAttr(const H5std_string& oldname, const H5std_string& new //-------------------------------------------------------------------------- int H5Location::getNumAttrs() const { - H5O_info_t oinfo; /* Object info */ + H5O_info_t objinfo; /* Object info */ - if(H5Oget_info(getId(), &oinfo) < 0) + if(H5Oget_info(getId(), &objinfo) < 0) throw AttributeIException(inMemFunc("getNumAttrs"), "H5Oget_info failed"); else - return(static_cast(oinfo.num_attrs)); + return(static_cast(objinfo.num_attrs)); } //-------------------------------------------------------------------------- // Function: H5Location::nameExists -///\brief Checks if a link of a given name exists in a location -///\param name - IN: Searched name +///\brief Checks if a link of a given name exists in a location. +///\param name - IN: Searched name - \c char* ///\param lapl - IN: Link access property list ///\exception H5::LocationException // Programmer Binh-Minh Ribler - Nov, 2016 @@ -380,8 +396,8 @@ bool H5Location::nameExists(const char* name, const LinkAccPropList& lapl) const //-------------------------------------------------------------------------- // Function: H5Location::nameExists -///\brief Checks if a link of a given name exists in a location -///\param name - IN: Searched name +///\brief Checks if a link of a given name exists in a location. +///\param name - IN: Searched name - \c H5std_string ///\param lapl - IN: Link access property list ///\exception H5::LocationException // Programmer Binh-Minh Ribler - Dec, 2016 @@ -434,6 +450,53 @@ H5std_string H5Location::getFileName() const } //-------------------------------------------------------------------------- +// Function: H5Location::getObjectInfo +///\brief Retrieve information about an object, specified by location. +///\exception H5::LocationException +// Programmer Binh-Minh Ribler - Aug, 2017 +//-------------------------------------------------------------------------- +void H5Location::getObjectInfo(H5O_info_t *objinfo) const +{ + herr_t ret_value = H5Oget_info(getId(), objinfo); + if (ret_value < 0) + { + throw LocationException(inMemFunc("getObjectInfo"), "H5Oget_info failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: H5Location::getObjectInfo +///\brief Retrieve information about an object, specified by name. +///\exception H5::LocationException +// Programmer Binh-Minh Ribler - Aug, 2017 +//-------------------------------------------------------------------------- +void H5Location::getObjectInfo(const char *name, H5O_info_t *objinfo, + const LinkAccPropList& lapl) const +{ + herr_t ret_value = H5Oget_info_by_name(getId(), name, objinfo, lapl.getId()); + if (ret_value < 0) + { + throw LocationException(inMemFunc("getObjectInfo"), "H5Oget_info_by_name failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: H5Location::getObjectInfo +///\brief Retrieve information about an object, specified by name. +///\exception H5::LocationException +// Programmer Binh-Minh Ribler - Aug, 2017 +//-------------------------------------------------------------------------- +void H5Location::getObjectInfo(const H5std_string& name, H5O_info_t *objinfo, + const LinkAccPropList& lapl) const +{ + herr_t ret_value = H5Oget_info_by_name(getId(), name.c_str(), objinfo, lapl.getId()); + if (ret_value < 0) + { + throw LocationException(inMemFunc("getObjectInfo"), "H5Oget_info_by_name failed"); + } +} + +//-------------------------------------------------------------------------- // Function: H5Location::objVersion ///\brief Returns the header version of this HDF5 object. ///\return Object version, which can have the following values: diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h index 7a54c2b..12c3e8a 100644 --- a/c++/src/H5Location.h +++ b/c++/src/H5Location.h @@ -51,6 +51,15 @@ class H5_DLLCPP H5Location : public IdComponent { // Gets the name of the file, specified by this location. H5std_string getFileName() const; + // Retrieves information about an object at this location + // specified by location + void getObjectInfo(H5O_info_t *oinfo) const; + // specified by the object's name + void getObjectInfo(const char *name, H5O_info_t *oinfo, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + void getObjectInfo(const H5std_string& name, H5O_info_t *oinfo, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + // Determines the number of attributes at this location. // - moved to H5Object (1.8.20) int getNumAttrs() const; // Deprecated diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index f534e33..8d2618b 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -28,16 +28,12 @@ #else #include #endif -#include - -#ifndef H5_NO_STD - using std::cerr; - using std::endl; -#endif // H5_NO_STD +using std::cerr; +using std::endl; +#include #include "H5Cpp.h" // C++ API header file - - using namespace H5; +using namespace H5; #include "h5cpputil.h" // C++ utilility header file @@ -70,8 +66,6 @@ static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, * Programmer: Binh-Minh Ribler (using C version) * Friday, January 5, 2001 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -202,8 +196,6 @@ test_create( H5File& file) * Programmer: Binh-Minh Ribler (using C version) * Friday, January 5, 2001 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -288,8 +280,6 @@ test_simple_io( H5File& file) * Programmer: Binh-Minh Ribler * Thursday, March 22, 2012 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -358,8 +348,6 @@ test_datasize(FileAccPropList &fapl) * Programmer: Binh-Minh Ribler (using C version) * Friday, January 5, 2001 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -452,8 +440,6 @@ const H5Z_class2_t H5Z_BOGUS[1] = {{ * Programmer: Robb Matzke * Tuesday, April 21, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ static size_t @@ -481,8 +467,6 @@ filter_bogus(unsigned int flags, size_t cd_nelmts, * Programmer: Binh-Minh Ribler (using C version) * Friday, January 5, 2001 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -884,8 +868,6 @@ static herr_t test_nbit_compression(H5File& file) * Programmer: Binh-Minh Ribler (using C version) * Saturday, February 17, 2001 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -966,8 +948,6 @@ test_multiopen (H5File& file) * Programmer: Binh-Minh Ribler (using C version) * February 17, 2001 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -1223,8 +1203,6 @@ void test_dset() * * Programmer: (use C version) * - * Modifications: - * *------------------------------------------------------------------------- */ extern "C" diff --git a/c++/test/h5cpputil.cpp b/c++/test/h5cpputil.cpp index ec35821..9f81895 100644 --- a/c++/test/h5cpputil.cpp +++ b/c++/test/h5cpputil.cpp @@ -24,17 +24,14 @@ #else #include #endif -#include - -#ifndef H5_NO_STD - using std::cerr; - using std::endl; -#endif // H5_NO_STD +using std::cerr; +using std::endl; -#include "h5test.h" -#include "H5Cpp.h" +#include +#include "H5Cpp.h" // C++ API header file using namespace H5; +#include "h5test.h" #include "h5cpputil.h" @@ -52,8 +49,6 @@ using namespace H5; * Programmer: Binh-Minh Ribler (using C code segment for reporting tests) * Friday, February 6, 2001 * - * Modifications: - * *------------------------------------------------------------------------- */ int test_report( int nerrors, const H5std_string& testname ) @@ -140,8 +135,6 @@ void issue_fail_msg(const char* where, int line, const char* file_name, * Programmer: Binh-Minh Ribler (using C code segment for checking values) * Friday, February 6, 2001 * - * Modifications: - * *------------------------------------------------------------------------- */ int check_values (hsize_t i, hsize_t j, int apoint, int acheck) @@ -170,8 +163,6 @@ int check_values (hsize_t i, hsize_t j, int apoint, int acheck) * Programmer: Binh-Minh Ribler * May 2, 2010 * - * Modifications: - * *------------------------------------------------------------------------- */ void verify_val(const char* x, const char* value, const char* where, int line, const char* file_name) diff --git a/c++/test/tarray.cpp b/c++/test/tarray.cpp index c07ba42..218e4e5 100644 --- a/c++/test/tarray.cpp +++ b/c++/test/tarray.cpp @@ -22,19 +22,17 @@ #else #include #endif -#include - -#ifndef H5_NO_STD - using std::cerr; - using std::endl; -#endif // H5_NO_STD +using std::cerr; +using std::endl; +#include #include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5cpputil.h" // C++ utilility header file const H5std_string FILENAME("tarray.h5"); +const H5std_string ARRAYTYPE_NAME("/Array type 1"); const int SPACE1_RANK = 1; const hsize_t SPACE1_DIM1 = 4; const int ARRAY1_RANK = 1; @@ -60,8 +58,6 @@ typedef enum int_t { * Programmer: Binh-Minh Ribler (using C version) * January, 2016 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_array_compound_array() @@ -131,9 +127,22 @@ static void test_array_compound_array() // Write dataset to disk dataset.write(wdata, arrtype); + // Test opening ArrayType with opening constructor (Dec 2016) + + // Commit the arrtype to give it a name + arrtype.commit(file1, ARRAYTYPE_NAME); + + // Close it, then re-open with the opening constructor + arrtype.close(); + ArrayType named_type(file1, ARRAYTYPE_NAME); + + // Get and verify the type's name + H5std_string type_name = named_type.getObjName(); + verify_val(type_name, ARRAYTYPE_NAME, "DataType::getObjName tests constructor", __LINE__, __FILE__); + named_type.close(); + // Close all dataset.close(); - arrtype.close(); space.close(); file1.close(); @@ -282,8 +291,6 @@ static void test_array_compound_array() * Description: * Used user's sample code in HDFFV-9562 * - * Modifications: - * *------------------------------------------------------------------------- */ /* @@ -353,8 +360,6 @@ static void test_array_assignment() * Programmer: Binh-Minh Ribler * April, 2016 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_array_info() @@ -499,8 +504,6 @@ void test_array() * Programmer: Binh-Minh Ribler (using C version) * January, 2016 * - * Modifications: - * *------------------------------------------------------------------------- */ extern "C" diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index e3526c6..d97d478 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -23,13 +23,10 @@ #else #include #endif -#include - -#ifndef H5_NO_STD - using std::cerr; - using std::endl; -#endif // H5_NO_STD +using std::cerr; +using std::endl; +#include #include "H5Cpp.h" // C++ API header file using namespace H5; @@ -1290,6 +1287,14 @@ static void test_attr_dtype_shared() // Commit datatype to file dtype.commit(fid1, TYPE1_NAME); + // Retrieve and verify information about the type + H5O_info_t oinfo; + fid1.getObjectInfo(TYPE1_NAME, &oinfo); + if (oinfo.type != H5O_TYPE_NAMED_DATATYPE) + TestErrPrintf("Line %d: object type wrong!\n", __LINE__); + verify_val(oinfo.num_attrs, 0, "DataType::getObjinfo reference count", __LINE__, __FILE__); + verify_val((int)oinfo.rc, 1, "DataType::getObjinfo reference count", __LINE__, __FILE__); + #ifndef H5_NO_DEPRECATED_SYMBOLS // Check reference count on named datatype fid1.getObjinfo(TYPE1_NAME, statbuf); @@ -1879,8 +1884,6 @@ void test_attr() * Programmer: Albert Cheng * July 2, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ extern "C" diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp index 09134ed..ce2d061 100644 --- a/c++/test/tcompound.cpp +++ b/c++/test/tcompound.cpp @@ -22,24 +22,21 @@ #else #include #endif -#include - -#ifndef H5_NO_STD - using std::cerr; - using std::endl; -#endif // H5_NO_STD +using std::cerr; +using std::endl; +#include #include "H5Cpp.h" // C++ API header file using namespace H5; #include "h5cpputil.h" // C++ utilility header file /* Number of elements in each test */ -#define NTESTELEM 100000 +#define NTESTELEM 100000 typedef struct complex_t { - double re; - double im; + double re; + double im; } complex_t; @@ -53,8 +50,6 @@ typedef struct complex_t { * Programmer: Binh-Minh Ribler (using C version) * January, 2007 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_compound_1() @@ -90,8 +85,6 @@ static void test_compound_1() * Programmer: Binh-Minh Ribler (use C version) * January, 2007 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_compound_2() @@ -103,11 +96,11 @@ static void test_compound_2() int e, d, c[4], b, a; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - const int nelmts = NTESTELEM; - const hsize_t four = 4; - int i; + src_typ_t *s_ptr; + dst_typ_t *d_ptr; + const int nelmts = NTESTELEM; + const hsize_t four = 4; + int i; unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; ArrayType *array_dt = NULL; @@ -115,9 +108,9 @@ static void test_compound_2() SUBTEST("Compound Element Reordering"); try { // Sizes should be the same, but be careful just in case - buf = (unsigned char*)malloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)malloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)malloc(nelmts * sizeof(src_typ_t)); + buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); for (i=0; ia = i*8+0; @@ -183,9 +176,9 @@ static void test_compound_2() } } // Release resources - free(buf); - free(bkg); - free(orig); + HDfree(buf); + HDfree(bkg); + HDfree(orig); s_ptr = NULL; d_ptr = NULL; st.close(); @@ -215,8 +208,6 @@ static void test_compound_2() * Programmer: Binh-Minh Ribler (use C version) * January, 2007 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_compound_3() @@ -228,11 +219,11 @@ static void test_compound_3() int a, c[4], e; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - int i; - const int nelmts = NTESTELEM; - const hsize_t four = 4; + src_typ_t *s_ptr; + dst_typ_t *d_ptr; + int i; + const int nelmts = NTESTELEM; + const hsize_t four = 4; unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; ArrayType* array_dt = NULL; @@ -240,9 +231,9 @@ static void test_compound_3() SUBTEST("Compound Datatype Subset Conversions"); try { /* Initialize */ - buf = (unsigned char*)malloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)malloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)malloc(nelmts * sizeof(src_typ_t)); + buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); for (i=0; ia = i*8+0; @@ -305,9 +296,9 @@ static void test_compound_3() } // for /* Release resources */ - free(buf); - free(bkg); - free(orig); + HDfree(buf); + HDfree(bkg); + HDfree(orig); s_ptr = NULL; d_ptr = NULL; st.close(); @@ -337,8 +328,6 @@ static void test_compound_3() * Programmer: Binh-Minh Ribler (use C version) * January, 2007 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_compound_4() @@ -355,11 +344,11 @@ static void test_compound_4() int e; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - int i; - const int nelmts = NTESTELEM; - const hsize_t four = 4; + src_typ_t *s_ptr; + dst_typ_t *d_ptr; + int i; + const int nelmts = NTESTELEM; + const hsize_t four = 4; unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; ArrayType* array_dt = NULL; @@ -367,9 +356,9 @@ static void test_compound_4() SUBTEST("Compound Element Shrinking & Reordering"); try { /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char*)malloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)malloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)malloc(nelmts * sizeof(src_typ_t)); + buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); for (i=0; ia = i*8+0; @@ -378,7 +367,7 @@ static void test_compound_4() s_ptr->c[1] = i*8+3; s_ptr->c[2] = i*8+4; s_ptr->c[3] = i*8+5; - s_ptr->d = (i*8+6) & 0x7fff; + s_ptr->d = (i*8+6) & 0x7fff; s_ptr->e = i*8+7; } memcpy(buf, orig, nelmts*sizeof(src_typ_t)); @@ -437,9 +426,9 @@ static void test_compound_4() } // for /* Release resources */ - free(buf); - free(bkg); - free(orig); + HDfree(buf); + HDfree(bkg); + HDfree(orig); s_ptr = NULL; d_ptr = NULL; st.close(); @@ -470,8 +459,6 @@ static void test_compound_4() * Programmer: Binh-Minh Ribler (use C version) * January, 2007 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_compound_5() @@ -488,12 +475,12 @@ static void test_compound_5() int coll_ids[4]; } dst_typ_t; - hsize_t dims[1] = {4}; - src_typ_t src[2] = {{"one", 102, {104, 105, 106, 107}}, - {"two", 202, {204, 205, 206, 207}}}; - dst_typ_t *dst; - void *buf = calloc(2, sizeof(dst_typ_t)); - void *bkg = calloc(2, sizeof(dst_typ_t)); + hsize_t dims[1] = {4}; + src_typ_t src[2] = {{"one", 102, {104, 105, 106, 107}}, + {"two", 202, {204, 205, 206, 207}}}; + dst_typ_t *dst; + void *buf = HDcalloc(2, sizeof(dst_typ_t)); + void *bkg = HDcalloc(2, sizeof(dst_typ_t)); ArrayType* array_dt = NULL; // Output message about test being performed @@ -545,8 +532,8 @@ static void test_compound_5() { H5_FAILED(); } /* Free memory buffers */ - free(buf); - free(bkg); + HDfree(buf); + HDfree(bkg); dst = NULL; PASSED(); } // end of try block @@ -573,8 +560,6 @@ static void test_compound_5() * Programmer: Binh-Minh Ribler (use C version) * January, 2007 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_compound_6() @@ -589,23 +574,23 @@ static void test_compound_6() long d; } dst_typ_t; - src_typ_t *s_ptr; - dst_typ_t *d_ptr; - int i; - const int nelmts = NTESTELEM; + src_typ_t *s_ptr; + dst_typ_t *d_ptr; + int i; + const int nelmts = NTESTELEM; unsigned char *buf=NULL, *orig=NULL, *bkg=NULL; // Output message about test being performed SUBTEST("Compound Element Growing"); try { /* Sizes should be the same, but be careful just in case */ - buf = (unsigned char*)malloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); - bkg = (unsigned char*)malloc(nelmts * sizeof(dst_typ_t)); - orig = (unsigned char*)malloc(nelmts * sizeof(src_typ_t)); + buf = (unsigned char*)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))); + bkg = (unsigned char*)HDmalloc(nelmts * sizeof(dst_typ_t)); + orig = (unsigned char*)HDmalloc(nelmts * sizeof(src_typ_t)); for (i=0; ib = (i*8+1) & 0x7fff; - s_ptr->d = (i*8+6) & 0x7fff; + s_ptr->b = (i*8+1) & 0x7fff; + s_ptr->d = (i*8+6) & 0x7fff; } memcpy(buf, orig, nelmts*sizeof(src_typ_t)); @@ -638,9 +623,9 @@ static void test_compound_6() } // for /* Release resources */ - free(buf); - free(bkg); - free(orig); + HDfree(buf); + HDfree(bkg); + HDfree(orig); s_ptr = NULL; d_ptr = NULL; st.close(); @@ -665,8 +650,6 @@ static void test_compound_6() * Programmer: Binh-Minh Ribler (use C version) * January, 2007 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_compound_7() @@ -731,8 +714,6 @@ static void test_compound_7() * Programmer: Binh-Minh Ribler (use partial C version test_ooo_order) * March, 2014 * - * Modifications: - * *------------------------------------------------------------------------- */ const H5std_string COMPFILE("tcompound_types.h5"); @@ -821,15 +802,12 @@ static void test_compound_set_size() * Programmer: Binh-Minh Ribler * January 2007 * - * Modifications: - * *------------------------------------------------------------------------- */ extern "C" void test_compound() { // Output message about test being performed - //MESSAGE("Testing Compound Data Type operations\n"); MESSAGE(5, ("Testing Compound Data Type operations\n")); test_compound_1(); // various things about compound data types @@ -850,8 +828,6 @@ void test_compound() * * Return: none * - * Modifications: - * *------------------------------------------------------------------------- */ extern "C" diff --git a/c++/test/tdspl.cpp b/c++/test/tdspl.cpp index d54d541..0a60a86 100644 --- a/c++/test/tdspl.cpp +++ b/c++/test/tdspl.cpp @@ -14,7 +14,7 @@ /***************************************************************************** FILE tdspl.cpp - HDF5 C++ testing the dataset memory and transfer property - list functionality + list functionality ***************************************************************************/ @@ -23,13 +23,10 @@ #else #include #endif -#include - -#ifndef H5_NO_STD - using std::cerr; - using std::endl; -#endif // H5_NO_STD +using std::cerr; +using std::endl; +#include #include "H5Cpp.h" // C++ API header file using namespace H5; diff --git a/c++/test/testhdf5.cpp b/c++/test/testhdf5.cpp index 6a5b70d..b998f76 100644 --- a/c++/test/testhdf5.cpp +++ b/c++/test/testhdf5.cpp @@ -44,14 +44,10 @@ #else #include #endif -#include - -#ifndef H5_NO_STD - using std::cerr; - using std::endl; -#endif // H5_NO_STD +using std::cerr; +using std::endl; -#include "h5test.h" // C test header file +#include #include "H5Cpp.h" // C++ API header file using namespace H5; diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index 8c626aa..059c548 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -35,30 +35,30 @@ using namespace H5; #include "h5cpputil.h" // C++ utilility header file -const hsize_t F1_USERBLOCK_SIZE = (hsize_t)0; -const size_t F1_OFFSET_SIZE = sizeof(haddr_t); -const size_t F1_LENGTH_SIZE = sizeof(hsize_t); -const unsigned F1_SYM_LEAF_K = 4; -const unsigned F1_SYM_INTERN_K = 16; -const H5std_string FILE1("tfile1.h5"); - -const hsize_t F2_USERBLOCK_SIZE = (hsize_t)512; -const size_t F2_OFFSET_SIZE = 8; -const size_t F2_LENGTH_SIZE = 8; -const unsigned F2_SYM_LEAF_K = 8; -const unsigned F2_SYM_INTERN_K = 32; -const unsigned F2_ISTORE = 64; +const hsize_t F1_USERBLOCK_SIZE = (hsize_t)0; +const size_t F1_OFFSET_SIZE = sizeof(haddr_t); +const size_t F1_LENGTH_SIZE = sizeof(hsize_t); +const unsigned F1_SYM_LEAF_K = 4; +const unsigned F1_SYM_INTERN_K = 16; +const H5std_string FILE1("tfile1.h5"); + +const hsize_t F2_USERBLOCK_SIZE = (hsize_t)512; +const size_t F2_OFFSET_SIZE = 8; +const size_t F2_LENGTH_SIZE = 8; +const unsigned F2_SYM_LEAF_K = 8; +const unsigned F2_SYM_INTERN_K = 32; +const unsigned F2_ISTORE = 64; const H5std_string FILE2("tfile2.h5"); -const hsize_t F3_USERBLOCK_SIZE = (hsize_t)0; -const size_t F3_OFFSET_SIZE = F2_OFFSET_SIZE; -const size_t F3_LENGTH_SIZE = F2_LENGTH_SIZE; -const unsigned F3_SYM_LEAF_K = F2_SYM_LEAF_K; -const unsigned F3_SYM_INTERN_K = F2_SYM_INTERN_K; +const hsize_t F3_USERBLOCK_SIZE = (hsize_t)0; +const size_t F3_OFFSET_SIZE = F2_OFFSET_SIZE; +const size_t F3_LENGTH_SIZE = F2_LENGTH_SIZE; +const unsigned F3_SYM_LEAF_K = F2_SYM_LEAF_K; +const unsigned F3_SYM_INTERN_K = F2_SYM_INTERN_K; const H5std_string FILE3("tfile3.h5"); -const int KB = 1024; -const H5std_string FILE4("tfile4.h5"); +const int KB = 1024; +const H5std_string FILE4("tfile4.h5"); /*------------------------------------------------------------------------- @@ -73,11 +73,11 @@ const H5std_string FILE4("tfile4.h5"); * * Modifications: * January, 2005: C tests' macro VERIFY casts values to 'long' for all - * cases. Since there are no operator<< for 'long long' - * or int64 in VS C++ ostream, I casted the hsize_t values - * passed to verify_val to 'long' as well. If problems - * arises later, this will have to be specificly handled - * with a special routine. + * cases. Since there are no operator<< for 'long long' + * or int64 in VS C++ ostream, I casted the hsize_t values + * passed to verify_val to 'long' as well. If problems + * arises later, this will have to be specificly handled + * with a special routine. * *------------------------------------------------------------------------- */ @@ -99,7 +99,7 @@ static void test_file_create() // Create file FILE1 file1 = new H5File (FILE1, H5F_ACC_EXCL); - // try to create the same file with H5F_ACC_TRUNC. This should fail + // Try to create the same file with H5F_ACC_TRUNC. This should fail // because file1 is the same file and is currently open. try { H5File file2 (FILE1, H5F_ACC_TRUNC); // should throw E @@ -156,12 +156,12 @@ static void test_file_create() hsize_t ublock = tmpl1.getUserblock(); verify_val((long)ublock, (long)F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); - size_t parm1, parm2; // file-creation parameters + size_t parm1, parm2; // file-creation parameters tmpl1.getSizes( parm1, parm2); verify_val(parm1, F1_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); verify_val(parm2, F1_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - unsigned iparm1,iparm2; // file-creation parameters + unsigned iparm1,iparm2; // file-creation parameters tmpl1.getSymk( iparm1, iparm2); verify_val(iparm1, F1_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F1_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); @@ -214,12 +214,12 @@ static void test_file_create() hsize_t ublock = tmpl1->getUserblock(); verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); - size_t parm1, parm2; // file-creation parameters + size_t parm1, parm2; // file-creation parameters tmpl1->getSizes( parm1, parm2); verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - unsigned iparm1,iparm2; // file-creation parameters + unsigned iparm1,iparm2; // file-creation parameters tmpl1->getSymk( iparm1, iparm2); verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); @@ -280,11 +280,11 @@ static void test_file_create() * * Modifications: * January, 2005: C tests' macro VERIFY casts values to 'long' for all - * cases. Since there are no operator<< for 'long long' - * or int64 in VS C++ ostream, I casted the hsize_t values - * passed to verify_val to 'long' as well. If problems - * arises later, this will have to be specificly handled - * with a special routine. + * cases. Since there are no operator<< for 'long long' + * or int64 in VS C++ ostream, I casted the hsize_t values + * passed to verify_val to 'long' as well. If problems + * arises later, this will have to be specificly handled + * with a special routine. * *------------------------------------------------------------------------- */ @@ -305,13 +305,13 @@ static void test_file_open() hsize_t ublock = tmpl1.getUserblock(); verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__, __FILE__); - size_t parm1, parm2; // file-creation parameters - tmpl1.getSizes( parm1, parm2); + size_t parm1, parm2; // file-creation parameters + tmpl1.getSizes(parm1, parm2); verify_val(parm1, F2_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); verify_val(parm2, F2_LENGTH_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__); - unsigned iparm1,iparm2; // file-creation parameters - tmpl1.getSymk( iparm1, iparm2); + unsigned iparm1,iparm2; // file-creation parameters + tmpl1.getSymk(iparm1, iparm2); verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); @@ -361,8 +361,6 @@ static void test_file_open() * Programmer: Raymond Lu * June, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_file_size() @@ -370,7 +368,7 @@ static void test_file_size() // Output message about test being performed SUBTEST("File Size"); - hid_t fapl_id; + hid_t fapl_id; fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template try { @@ -408,8 +406,10 @@ static void test_file_size() issue_fail_msg("test_file_size()", __LINE__, __FILE__, E.getCDetailMsg()); } - // use C test utility routine to close property list. - H5Pclose(fapl_id); + // This fapl_id was returned from h5_fileaccess. + herr_t ret = H5Pclose(fapl_id); + if (ret < 0) + issue_fail_msg("test_file_size()", __LINE__, __FILE__, "H5Pclose failed"); } // test_file_size() @@ -424,18 +424,16 @@ static void test_file_size() * Programmer: Binh-Minh Ribler * July, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ -const int RANK = 2; -const int NX = 4; -const int NY = 5; -const H5std_string GROUPNAME ("group"); -const H5std_string DSETNAME ("dataset"); -const H5std_string DATTRNAME ("dataset attribute"); -const H5std_string FATTRNAME ("file attribute"); -const H5std_string DTYPENAME ("compound"); +const int RANK = 2; +const int NX = 4; +const int NY = 5; +const H5std_string GROUPNAME ("group"); +const H5std_string DSETNAME ("dataset"); +const H5std_string DATTRNAME ("dataset attribute"); +const H5std_string FATTRNAME ("file attribute"); +const H5std_string DTYPENAME ("compound"); // Compound datatype typedef struct s1_t { @@ -502,15 +500,14 @@ static void test_file_name() { issue_fail_msg("test_file_name()", __LINE__, __FILE__, E.getCDetailMsg()); } - } // test_file_name() -const int RANK1 = 1; -const int ATTR1_DIM1 = 3; -const H5std_string FILE5("tfattrs.h5"); -const H5std_string FATTR1_NAME ("file attribute 1"); -const H5std_string FATTR2_NAME ("file attribute 2"); +const int RANK1 = 1; +const int ATTR1_DIM1 = 3; +const H5std_string FILE5("tfattrs.h5"); +const H5std_string FATTR1_NAME ("file attribute 1"); +const H5std_string FATTR2_NAME ("file attribute 2"); int fattr_data[ATTR1_DIM1]={512,-234,98123}; // Test data for file attribute int dattr_data[ATTR1_DIM1]={256,-123,1000}; // Test data for dataset attribute @@ -627,11 +624,12 @@ static void test_file_attribute() issue_fail_msg("test_file_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_file_attribute() + -const H5std_string FILE6("tfile5.h5"); -const H5std_string ROOTGROUP("/"); -const H5std_string GROUP1("/G1"); -const H5std_string SUBGROUP3("/G1/G3"); +const H5std_string FILE6("tfile5.h5"); +const H5std_string ROOTGROUP("/"); +const H5std_string GROUP1("/G1"); +const H5std_string SUBGROUP3("/G1/G3"); /*------------------------------------------------------------------------- * Function: test_libver_bounds_real @@ -744,13 +742,13 @@ static void test_libver_bounds() /*------------------------------------------------------------------------- - * Function: test_commonfg + * Function: test_commonfg * - * Purpose Verify that H5File works as a root group. + * Purpose: Verify that H5File works as a root group. * - * Return None + * Return: None * - * Programmer Binh-Minh Ribler (use C version) + * Programmer: Binh-Minh Ribler (use C version) * March, 2015 * *------------------------------------------------------------------------- @@ -811,13 +809,13 @@ const H5std_string FILE7("tfile7.h5"); /*------------------------------------------------------------------------- * Function: test_file_info * - * Purpose Verify that various properties in a file creation property + * Purpose: Verify that various properties in a file creation property * lists are stored correctly in the file and can be retrieved * when the file is re-opened. * - * Return None + * Return: None * - * Programmer Binh-Minh Ribler + * Programmer: Binh-Minh Ribler * February, 2017 * *------------------------------------------------------------------------- @@ -862,7 +860,7 @@ static void test_file_info() fcpl.close(); // Get the file's version information. - file7.getFileInfo(finfo); // there's no C test for H5Fget_info + file7.getFileInfo(finfo); // there's no C test for H5Fget_info // Close the file. file7.close(); @@ -874,7 +872,7 @@ static void test_file_info() FileCreatPropList fcpl2 = file7.getCreatePlist(); // Get the file's version information. - file7.getFileInfo(finfo); // there's no C test for H5Fget_info + file7.getFileInfo(finfo); // there's no C test for H5Fget_info // Retrieve the property values & check them. hsize_t userblock = fcpl2.getUserblock(); @@ -905,15 +903,13 @@ static void test_file_info() /*------------------------------------------------------------------------- * Function: test_file * - * Purpose Main file testing routine + * Purpose: Main file testing routine * - * Return None + * Return: None * - * Programmer Binh-Minh Ribler (use C version) + * Programmer: Binh-Minh Ribler (use C version) * January 2001 * - * Modifications: - * *------------------------------------------------------------------------- */ extern "C" @@ -936,13 +932,11 @@ void test_file() /*------------------------------------------------------------------------- * Function: cleanup_file * - * Purpose Cleanup temporary test files + * Purpose: Cleanup temporary test files * - * Return none + * Return: none * - * Programmer (use C version) - * - * Modifications: + * Programmer: (use C version) * *------------------------------------------------------------------------- */ diff --git a/c++/test/tfilter.cpp b/c++/test/tfilter.cpp index 275bdb6..2e3c07c 100644 --- a/c++/test/tfilter.cpp +++ b/c++/test/tfilter.cpp @@ -80,8 +80,6 @@ const H5Z_class2_t H5Z_BOGUS[1] = {{ * Programmer: Robb Matzke * Tuesday, April 21, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ static size_t @@ -287,8 +285,6 @@ void test_filters() * Programmer: Quincey Koziol * September 10, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ extern "C" diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp index e511619..18cd460 100644 --- a/c++/test/th5s.cpp +++ b/c++/test/th5s.cpp @@ -556,7 +556,6 @@ static void test_h5s_compound_scalar_read() * Programmer: Binh-Minh Ribler (using C version) * Mar 2001 * - * Modifications: *------------------------------------------------------------------------- */ extern "C" @@ -584,8 +583,6 @@ void test_h5s() * Programmer: Albert Cheng * July 2, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ extern "C" diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp index 1328a19..b38ed39 100644 --- a/c++/test/tlinks.cpp +++ b/c++/test/tlinks.cpp @@ -22,13 +22,10 @@ #else #include #endif -#include - -#ifndef H5_NO_STD - using std::cerr; - using std::endl; -#endif // H5_NO_STD +using std::cerr; +using std::endl; +#include #include "H5Cpp.h" // C++ API header file using namespace H5; @@ -44,9 +41,9 @@ using namespace H5; //#define H5G_TESTING //#include "h5test.h" -//#include "H5Gpkg.h" /* Groups */ -//#include "H5Iprivate.h" /* IDs */ -//#include "H5Lprivate.h" /* Links */ +//#include "H5Gpkg.h" // Groups +//#include "H5Iprivate.h" // IDs +//#include "H5Lprivate.h" // Links /* File for external link test. Created with gen_udlinks.c */ #define LINKED_FILE "be_extlink2.h5" @@ -117,22 +114,22 @@ const char *FILENAME[] = { #define MAX_NAME_LEN ((64*1024)+1024) /* Link type IDs */ -#define UD_HARD_TYPE 201 -#define UD_CB_TYPE H5L_TYPE_MAX -#define UD_PLIST_TYPE 128 -#define UD_CBFAIL_TYPE UD_PLIST_TYPE -#define UD_ERROR_TYPE 189 -#define UD_BAD_TYPE1 H5L_TYPE_HARD -#define UD_BAD_TYPE2 (H5L_TYPE_UD_MIN - 5) -#define UD_BAD_VERS (H5L_LINK_CLASS_T_VERS + 1) - -#define DEST_PROP_NAME "destination_group" -#define REREG_TARGET_NAME "rereg_target" - -#define UD_CB_LINK_NAME "ud_callback_link" +#define UD_HARD_TYPE 201 +#define UD_CB_TYPE H5L_TYPE_MAX +#define UD_PLIST_TYPE 128 +#define UD_CBFAIL_TYPE UD_PLIST_TYPE +#define UD_ERROR_TYPE 189 +#define UD_BAD_TYPE1 H5L_TYPE_HARD +#define UD_BAD_TYPE2 (H5L_TYPE_UD_MIN - 5) +#define UD_BAD_VERS (H5L_LINK_CLASS_T_VERS + 1) + +#define DEST_PROP_NAME "destination_group" +#define REREG_TARGET_NAME "rereg_target" + +#define UD_CB_LINK_NAME "ud_callback_link" #define NEW_UD_CB_LINK_NAME "ud_callback_link2" -#define UD_CB_TARGET "ud_target" -#define UD_CB_TARGET_LEN 10 +#define UD_CB_TARGET "ud_target" +#define UD_CB_TARGET_LEN 10 #define LE_FILENAME "le_extlink1.h5" #define BE_FILENAME "be_extlink1.h5" @@ -145,9 +142,9 @@ const char *FILENAME[] = { /* Creation order macros */ #define CORDER_GROUP_NAME "corder_group" #define CORDER_SOFT_GROUP_NAME "corder_soft_group" -#define CORDER_NLINKS 18 -#define CORDER_ITER_STOP 3 -#define CORDER_EST_ENTRY_LEN 9 +#define CORDER_NLINKS 18 +#define CORDER_ITER_STOP 3 +#define CORDER_EST_ENTRY_LEN 9 /* Timestamp macros */ #define TIMESTAMP_GROUP_1 "timestamp1" @@ -328,21 +325,19 @@ static const char *FILENAME[] = { * * Purpose: Test building a file with assorted links. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * * Programmer: Binh-Minh Ribler * October 16, 2009 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_basic_links(hid_t fapl_id, hbool_t new_format) { - hsize_t size[1] = {1}; - char filename[NAME_BUF_SIZE]; + hsize_t size[1] = {1}; + char filename[NAME_BUF_SIZE]; // Use the file access template id to create a file access prop. list. FileAccPropList fapl(fapl_id); @@ -443,17 +438,15 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) /*------------------------------------------------------------------------- * Function: test_num_links * - * Purpose Test setting and getting limit of number of links + * Purpose: Test setting and getting limit of number of links * - * Return Success: 0 + * Return: Success: 0 * * Failure: -1 * - * Programmer Binh-Minh Ribler + * Programmer: Binh-Minh Ribler * Mar, 2017 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_num_links(hid_t fapl_id, hbool_t new_format) @@ -477,7 +470,7 @@ static void test_num_links(hid_t fapl_id, hbool_t new_format) size_t nlinks = 5; lapl.setNumLinks(nlinks); - // Read it back and verify + // Read it back and verify size_t read_nlinks = lapl.getNumLinks(); verify_val(read_nlinks, nlinks, "LinkAccPropList::setNumLinks", __LINE__, __FILE__); @@ -504,9 +497,9 @@ static void test_num_links(hid_t fapl_id, hbool_t new_format) extern "C" void test_links() { - hid_t fapl_id, fapl2_id; /* File access property lists */ - hbool_t new_format; /* Whether to use the new format or not */ - const char *envval; + hid_t fapl_id, fapl2_id; // File access property lists + hbool_t new_format; // Whether to use the new format or not + const char *envval; envval = HDgetenv("HDF5_DRIVER"); if(envval == NULL) @@ -687,8 +680,6 @@ void test_links() * Programmer: Binh-Minh Ribler * October 16, 2009 * - * Modifications: - * *------------------------------------------------------------------------- */ extern "C" diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp index 59716dd..c053604 100644 --- a/c++/test/tobject.cpp +++ b/c++/test/tobject.cpp @@ -22,13 +22,10 @@ #else #include #endif -#include - -#ifndef H5_NO_STD - using std::cerr; - using std::endl; -#endif // H5_NO_STD +using std::cerr; +using std::endl; +#include #include "H5Cpp.h" // C++ API header file using namespace H5; @@ -61,8 +58,6 @@ const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset in * Programmer: Binh-Minh Ribler * Friday, March 4, 2014 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_get_objname() @@ -159,8 +154,6 @@ static void test_get_objname() * Programmer: Binh-Minh Ribler * March 4, 2014 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_get_objname_ontypes() @@ -244,8 +237,6 @@ static void test_get_objname_ontypes() * Programmer: Binh-Minh Ribler * Friday, March 4, 2014 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_get_objtype() @@ -301,15 +292,13 @@ static void test_get_objtype() /*------------------------------------------------------------------------- * Function: test_open_object_header * - * Purpose Test H5Location::openObjId function. + * Purpose: Test H5Location::openObjId function. * - * Return None + * Return: None * - * Programmer Binh-Minh Ribler (use C version) + * Programmer: Binh-Minh Ribler (use C version) * May 15, 2017 * - * Modifications: - * *------------------------------------------------------------------------- */ const H5std_string GROUPNAME("group"); @@ -428,8 +417,6 @@ static void test_open_object_header() * Programmer: Binh-Minh Ribler * May 15, 2017 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_is_valid() @@ -483,8 +470,6 @@ static void test_is_valid() * Programmer: Binh-Minh Ribler * Friday, Mar 4, 2014 * - * Modifications: - * *------------------------------------------------------------------------- */ extern "C" @@ -510,8 +495,6 @@ void test_object() * * Programmer: (use C version) * - * Modifications: - * *------------------------------------------------------------------------- */ extern "C" diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index f088240..9f43054 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -23,8 +23,8 @@ #else #include #endif -#include +#include #include "H5Cpp.h" // C++ API header file using namespace H5; diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp index 43e85a9..a706197 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -22,13 +22,10 @@ #else #include #endif -#include - -#ifndef H5_NO_STD - using std::cerr; - using std::endl; -#endif // H5_NO_STD +using std::cerr; +using std::endl; +#include #include "H5Cpp.h" // C++ API header file using namespace H5; @@ -98,8 +95,6 @@ typedef struct { * Programmer: Binh-Minh Ribler (using C version) * January, 2007 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_classes() @@ -137,8 +132,6 @@ static void test_classes() * Programmer: Binh-Minh Ribler (using C version) * January, 2007 * - * Modifications: - * *------------------------------------------------------------------------- */ static void test_copy() @@ -192,8 +185,6 @@ static void test_copy() * Programmer: Binh-Minh Ribler (use C version) * January, 2007 * - * Modifications: - * *------------------------------------------------------------------------- */ @@ -312,8 +303,6 @@ static void test_query() * Programmer: Binh-Minh Ribler (use C version) * January, 2007 * - * Modifications: - * *------------------------------------------------------------------------- */ const char* filename1 = "dtypes1.h5"; @@ -389,8 +378,6 @@ static void test_transient () * Programmer: Binh-Minh Ribler (use C version) * January, 2007 * - * Modifications: - * *------------------------------------------------------------------------- */ const H5std_string filename2("dtypes2.h5"); @@ -545,15 +532,13 @@ static void test_named () /*------------------------------------------------------------------------- * Function: test_encode_decode * - * Purpose Test datatype encode/decode functionality. + * Purpose: Test datatype encode/decode functionality. * - * Return None + * Return: None * - * Programmer Binh-Minh Ribler (using C version) + * Programmer: Binh-Minh Ribler (using C version) * October, 2017 * - * Modifications: - * *------------------------------------------------------------------------- */ const H5std_string filename3("encode_decode.h5"); @@ -797,8 +782,6 @@ void test_types() * Programmer: Quincey Koziol * September 10, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ extern "C" diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp index f49dbc0..d5f2afe 100644 --- a/c++/test/tvlstr.cpp +++ b/c++/test/tvlstr.cpp @@ -24,13 +24,10 @@ #else #include #endif -#include - -#ifndef H5_NO_STD - using std::cerr; - using std::endl; -#endif // H5_NO_STD +using std::cerr; +using std::endl; +#include #include "H5Cpp.h" // C++ API header file using namespace H5; @@ -56,9 +53,9 @@ const hsize_t SPACE1_DIM1 = 4; #if 0 // not used now static void *test_vlstr_alloc_custom(size_t size, void *info) { - void *ret_value=NULL; // Pointer to return + void *ret_value=NULL; // Pointer to return size_t *mem_used=(size_t *)info; // Get the pointer to the memory used - size_t extra; // Extra space needed + size_t extra; // Extra space needed /* * This weird contortion is required on the DEC Alpha to keep the @@ -92,7 +89,7 @@ static void test_vlstr_free_custom(void *_mem, void *info) { unsigned char *mem; size_t *mem_used=(size_t *)info; // Get the pointer to the memory used - size_t extra; // Extra space needed + size_t extra; // Extra space needed /* * This weird contortion is required on the DEC Alpha to keep the @@ -349,7 +346,7 @@ static void test_vlstrings_special() dataset.read(rdata, vlst); // Check data read in. - hsize_t ii; // counting variable + hsize_t ii; // counting variable for (ii=0; iiopenStrType(VLSTR_TYPE); + vlst = file1->openStrType(VLSTR_TYPE); // deprecated - // Close datatype and file. + // Close again and reopen with constructor. vlst.close(); + StrType vlst1(*file1, VLSTR_TYPE); + + // Close datatype and file. + vlst1.close(); file1->close(); delete file1; // Open file. file1 = new H5File(FILENAME, H5F_ACC_RDWR); - // Open the variable-length string datatype just created + { // deprecated + // Open the variable-length string datatype just created. vlst = file1->openStrType(VLSTR_TYPE); - // Verify character set and padding + // Verify character set and padding. cset = vlst.getCset(); verify_val(cset, H5T_CSET_ASCII, "StrType::getCset", __LINE__, __FILE__); pad = vlst.getStrpad(); verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__); - // Close datatype and file + // Close type to test new function. vlst.close(); + } // deprecated + + // Open the variable-length string datatype just created. + StrType vlst2(*file1, VLSTR_TYPE); + + // Verify character set and padding. + cset = vlst2.getCset(); + verify_val(cset, H5T_CSET_ASCII, "StrType::getCset", __LINE__, __FILE__); + pad = vlst2.getStrpad(); + verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__); + + // Close datatype and file. + vlst2.close(); file1->close(); PASSED(); @@ -818,7 +836,7 @@ static void test_vlstring_array_attribute() /* Helper routine for test_vl_rewrite() */ static void write_scalar_dset(H5File& file, DataType& type, DataSpace& space, - char *name, char *data) + char *name, char *data) { DataSet dset; try { @@ -836,7 +854,7 @@ static void write_scalar_dset(H5File& file, DataType& type, DataSpace& space, /* Helper routine for test_vl_rewrite() */ static void read_scalar_dset(H5File& file, DataType& type, DataSpace& space, - char *name, char *data) + char *name, char *data) { char *data_read; DataSet dset; @@ -891,7 +909,7 @@ static void test_vl_rewrite() // Create in file 1. int i; - char name[256]; // Buffer for names & data + char name[256]; // Buffer for names & data for (i=0; i