diff options
Diffstat (limited to 'c++')
-rw-r--r-- | c++/examples/testh5c++.sh.in | 2 | ||||
-rw-r--r-- | c++/src/H5DataType.cpp | 4 | ||||
-rw-r--r-- | c++/src/H5DcreatProp.cpp | 2 | ||||
-rw-r--r-- | c++/src/H5IdComponent.cpp | 2 | ||||
-rw-r--r-- | c++/src/H5Library.h | 2 | ||||
-rw-r--r-- | c++/src/H5Object.cpp | 124 | ||||
-rw-r--r-- | c++/src/H5Object.h | 20 | ||||
-rw-r--r-- | c++/src/H5PropList.cpp | 2 | ||||
-rw-r--r-- | c++/src/H5PropList.h | 2 | ||||
-rw-r--r-- | c++/src/cpp_doc_config | 6 | ||||
-rw-r--r-- | c++/src/h5c++.in | 6 | ||||
-rw-r--r-- | c++/test/dsets.cpp | 62 | ||||
-rw-r--r-- | c++/test/tattr.cpp | 19 | ||||
-rw-r--r-- | c++/test/tfile.cpp | 18 | ||||
-rw-r--r-- | c++/test/th5s.cpp | 12 | ||||
-rw-r--r-- | c++/test/tlinks.cpp | 7 | ||||
-rw-r--r-- | c++/test/tobject.cpp | 98 | ||||
-rw-r--r-- | c++/test/trefer.cpp | 15 |
18 files changed, 371 insertions, 32 deletions
diff --git a/c++/examples/testh5c++.sh.in b/c++/examples/testh5c++.sh.in index 42cb0df..907a980 100644 --- a/c++/examples/testh5c++.sh.in +++ b/c++/examples/testh5c++.sh.in @@ -56,7 +56,7 @@ applib=libapp${H5TOOL}.a # short hands # Caution: if some *.h5 files must be cleaned here, list them by names. # Don't use the wildcard form of *.h5 as it will wipe out even *.h5 generated -# by otehr test programs. This will cause a racing condition error when +# by other test programs. This will cause a racing condition error when # parallel make (e.g., gmake -j 4) is used. temp_SRC="$hdf5main $appmain $prog1 $prog2" temp_OBJ=`echo $temp_SRC | sed -e "s/\.${suffix}/.o/g"` diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index a6b8c24..e460871 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -532,7 +532,7 @@ H5T_conv_t DataType::find(const DataType& dest, H5T_cdata_t **pcdata) const ///\param nelmts - IN: Size of array \a buf ///\param buf - IN/OUT: Array containing pre- and post-conversion /// values -///\param background - IN: Optional backgroud buffer +///\param background - IN: Optional background buffer ///\param plist - IN: Property list - default to PropList::DEFAULT ///\return Pointer to a suitable conversion function ///\exception H5::DataTypeIException @@ -558,7 +558,7 @@ void DataType::convert(const DataType& dest, size_t nelmts, void *buf, void *bac ///\brief Locks a datatype, making it read-only and non-destructible. /// ///\exception H5::DataTypeIException -///\par Descrition +///\par Description /// This is normally done by the library for predefined data /// types so the application doesn't inadvertently change or /// delete a predefined type. diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index 0c2a8c0..c704f85 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -666,7 +666,7 @@ void DSetCreatPropList::setFletcher32() const ///\param size - IN: Number of bytes reserved in the file for the data ///\exception H5::PropListIException ///\par Description -/// If a dataset is splitted across multiple files then the files +/// If a dataset is split across multiple files then the files /// should be defined in order. The total size of the dataset is /// the sum of the \a size arguments for all the external files. If /// the total size is larger than the size of a dataset then the diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index fe2d27e..a041273 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -322,7 +322,7 @@ IdComponent::~IdComponent() {} // // Implementation of protected functions for HDF5 Reference Interface -// and miscelaneous helpers. +// and miscellaneous helpers. // #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5Library.h b/c++/src/H5Library.h index 9b4150e..b9be3d0 100644 --- a/c++/src/H5Library.h +++ b/c++/src/H5Library.h @@ -20,7 +20,7 @@ namespace H5 { /*! \class H5Library \brief Class H5Library operates the HDF5 library globably. - It is not neccessary to construct an instance of H5Library to use the + It is not necessary to construct an instance of H5Library to use the methods. */ class H5_DLLCPP H5Library { diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index b95e222..a33acb3 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -227,6 +227,130 @@ int H5Object::iterateAttrs(attr_operator_t user_op, unsigned *_idx, void *op_dat } //-------------------------------------------------------------------------- +// Function: H5Object::getInfo +///\brief Retrieves information about an HDF5 object. +///\param objinfo - OUT: Struct containing the object info +///\param fields - IN: Indicates the group of information to be retrieved +///\par Description +/// Valid values of \a fields are as follows: +/// \li \c H5O_INFO_BASIC (default) +/// \li \c H5O_INFO_TIME +/// \li \c H5O_INFO_NUM_ATTRS +/// \li \c H5O_INFO_HDR +/// \li \c H5O_INFO_META_SIZE +/// \li \c H5O_INFO_ALL +// July, 2018 +//-------------------------------------------------------------------------- +void H5Object::getInfo(H5O_info_t& objinfo, unsigned fields) const +{ + + // Use C API to get information of the object + herr_t ret_value = H5Oget_info2(getId(), &objinfo, fields); + + // Throw exception if C API returns failure + if (ret_value < 0) + throwException(inMemFunc("getInfo"), "H5Oget_info2 failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Object::getInfo +///\brief Retrieves information about an HDF5 object given its name. +///\param name - IN: Name of the object to be queried - \c char * +///\param objinfo - OUT: Struct containing the object info +///\param fields - IN: Indicates the group of information to be retrieved +/// - default to H5O_INFO_BASIC +///\param lapl - IN: Link access property list +///\par Description +/// Valid values of \a fields are as follows: +/// \li \c H5O_INFO_BASIC (default) +/// \li \c H5O_INFO_TIME +/// \li \c H5O_INFO_NUM_ATTRS +/// \li \c H5O_INFO_HDR +/// \li \c H5O_INFO_META_SIZE +/// \li \c H5O_INFO_ALL +// July, 2018 +//-------------------------------------------------------------------------- +void H5Object::getInfo(const char* name, H5O_info_t& objinfo, unsigned fields, const LinkAccPropList& lapl) const +{ + // Use C API to get information of the object + herr_t ret_value = H5Oget_info_by_name2(getId(), name, &objinfo, fields, lapl.getId()); + + // Throw exception if C API returns failure + if (ret_value < 0) + throwException(inMemFunc("getInfo"), "H5Oget_info_by_name2 failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Object::getInfo +///\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 object to be queried - \c H5std_string +///\param objinfo - OUT: Struct containing the object info +///\param fields - IN: Indicates the group of information to be retrieved +/// - default to H5O_INFO_BASIC +///\param lapl - IN: Link access property list +// July, 2018 +//-------------------------------------------------------------------------- +void H5Object::getInfo(const H5std_string& name, H5O_info_t& objinfo, unsigned fields, const LinkAccPropList& lapl) const +{ + getInfo(name.c_str(), objinfo, fields, lapl); +} + +//-------------------------------------------------------------------------- +// Function: H5Object::getInfo +///\brief Retrieves information about an HDF5 object given its index. +///\param grp_name - IN: Group name where the object belongs - \c char * +///\param idx_type - IN: Type of index +///\param order - IN: Order to traverse +///\param idx - IN: Object position +///\param objinfo - OUT: Struct containing the object info +///\param fields - IN: Indicates the group of information to be retrieved +/// - default to H5O_INFO_BASIC +///\param lapl - IN: Link access property list +///\par Description +/// Valid values of \a fields are as follows: +/// \li \c H5O_INFO_BASIC (default) +/// \li \c H5O_INFO_TIME +/// \li \c H5O_INFO_NUM_ATTRS +/// \li \c H5O_INFO_HDR +/// \li \c H5O_INFO_META_SIZE +/// \li \c H5O_INFO_ALL +// July, 2018 +//-------------------------------------------------------------------------- +void H5Object::getInfo(const char* grp_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t idx, H5O_info_t& objinfo, unsigned fields, + const LinkAccPropList& lapl) const +{ + // Use C API to get information of the object + herr_t ret_value = H5Oget_info_by_idx2(getId(), grp_name, idx_type, order, + idx, &objinfo, fields, lapl.getId()); + + // Throw exception if C API returns failure + if (ret_value < 0) + throwException(inMemFunc("getInfo"), "H5Oget_info_by_idx2 failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Object::getInfo +///\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 object to be queried - \c H5std_string +///\param objinfo - OUT: Struct containing the object info +///\param fields - IN: Indicates a group of information to be retrieved +/// - default to H5O_INFO_BASIC +///\param lapl - IN: Link access property list +// July, 2018 +//-------------------------------------------------------------------------- +void H5Object::getInfo(const H5std_string& grp_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t idx, H5O_info_t& objinfo, unsigned fields, + const LinkAccPropList& lapl) const +{ + getInfo(grp_name.c_str(), idx_type, order, idx, objinfo, fields, lapl); +} + +//-------------------------------------------------------------------------- // Function: H5Object::objVersion ///\brief Returns the header version of this HDF5 object. ///\return Object version, which can have the following values: diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h index 10b3865..268fe58 100644 --- a/c++/src/H5Object.h +++ b/c++/src/H5Object.h @@ -92,6 +92,26 @@ class H5_DLLCPP H5Object : public H5Location { // Returns an identifier. virtual hid_t getId() const = 0; + // Returns information about an HDF5 object. + void getInfo(H5O_info_t& objinfo, unsigned fields = H5O_INFO_BASIC) const; + // Returns information about an HDF5 object, given its name. + void getInfo(const char* name, H5O_info_t& objinfo, + unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + void getInfo(const H5std_string& name, H5O_info_t& objinfo, + unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + + // Retrieves information about an HDF5 object, given its index. + void getInfo(const char* grp_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t idx, H5O_info_t& objinfo, + unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + void getInfo(const H5std_string& grp_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t idx, H5O_info_t& objinfo, + unsigned fields = H5O_INFO_BASIC, + const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const; + // Gets the name of this HDF5 object, i.e., Group, DataSet, or // DataType. ssize_t getObjName(char *obj_name, size_t buf_size = 0) const; diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index ef9e16d..1918d27 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -468,7 +468,7 @@ H5std_string PropList::getProperty(const char* name) const throw PropListIException(inMemFunc("getProperty"), "H5Pget failed"); } - // Return propety value as a string after deleting temp C-string + // Return property value as a string after deleting temp C-string H5std_string prop_strg(prop_strg_C); delete []prop_strg_C; return (prop_strg); diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h index e0244c1..d704775 100644 --- a/c++/src/H5PropList.h +++ b/c++/src/H5PropList.h @@ -92,7 +92,7 @@ class H5_DLLCPP PropList : public IdComponent { // Determines whether a property list is a certain class. bool isAClass(const PropList& prop_class) const; - /// Query the existance of a property in a property object. + /// Query the existence of a property in a property object. bool propExist(const char* name) const; bool propExist(const H5std_string& name) const; diff --git a/c++/src/cpp_doc_config b/c++/src/cpp_doc_config index 3943f7b..4bba5d5 100644 --- a/c++/src/cpp_doc_config +++ b/c++/src/cpp_doc_config @@ -1010,7 +1010,7 @@ USE_HTAGS = NO VERBATIM_HEADERS = YES # If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the -# clang parser (see: http://clang.llvm.org/) for more acurate parsing at the +# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the # cost of reduced performance. This can be particularly helpful with template # rich C++ code for which doxygen's built-in parser lacks the necessary type # information. @@ -1124,7 +1124,7 @@ HTML_STYLESHEET = # defined cascading style sheet that is included after the standard style sheets # created by doxygen. Using this option one can overrule certain style aspects. # This is preferred over using HTML_STYLESHEET since it does not replace the -# standard style sheet and is therefor more robust against future updates. +# standard style sheet and is therefore more robust against future updates. # Doxygen will copy the style sheet file to the output directory. For an example # see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -2009,7 +2009,7 @@ PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will -# remove all refrences to function-like macros that are alone on a line, have an +# remove all references to function-like macros that are alone on a line, have an # all uppercase name, and do not end with a semicolon. Such function macros are # typically used for boiler-plate code, and will confuse the parser if not # removed. diff --git a/c++/src/h5c++.in b/c++/src/h5c++.in index 00502d9..f068f51 100644 --- a/c++/src/h5c++.in +++ b/c++/src/h5c++.in @@ -38,7 +38,7 @@ HL="@HL@" ## $CLINKER $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CXXFLAGS $CXXFLAGS ## ## $LDFLAGS $LIBS $clibpath $link_objs $link_args $shared_link ## ## ## -## These settings can be overriden by setting HDF5_CXXFLAGS, ## +## These settings can be overridden by setting HDF5_CXXFLAGS, ## ## HDF5_CPPFLAGS, HDF5_LDFLAGS, or HDF5_LIBS in the environment. ## ## ## ############################################################################ @@ -140,7 +140,7 @@ usage() { echo " [default: no except when built with only" echo " shared libraries]" echo " You can also add or change paths and flags to the compile line using" - echo " the following environment varibles or by assigning them to their counterparts" + echo " the following environment variables or by assigning them to their counterparts" echo " in the 'Things You Can Modify to Override...'" section of $prog_name echo " " echo " Variable Current value to be replaced" @@ -311,7 +311,7 @@ fi if test "x$do_link" = "xyes"; then shared_link="" - # conditionnaly link with the hl library + # conditionally link with the hl library if test "X$HL" = "Xhl"; then libraries=" $libraries -lhdf5_hl_cpp -lhdf5_cpp -lhdf5_hl -lhdf5 " else diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index 250ce90..e86052b 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -1116,6 +1116,67 @@ static herr_t test_types(H5File& file) /*------------------------------------------------------------------------- + * Function: test_getinfo + * + * Purpose Tests getInfo() + * + * Return Success: 0 + * + * Failure: -1 + * + * July, 2018 + *------------------------------------------------------------------------- + */ +static herr_t test_getinfo(H5File& file) +{ + SUBTEST("Getting object information"); + + try { + // Create a data space + hsize_t dims[2]; + dims[0] = 256; + dims[1] = 512; + DataSpace space (2, dims, NULL); + + // Create a dataset using the default dataset creation properties. + // We're not sure what they are, so we won't check. + DataSet dataset(file.openDataSet(DSET_CHUNKED_NAME)); + + // Get dataset header info + H5O_info_t oinfo; + HDmemset(&oinfo, 0, sizeof(oinfo)); + dataset.getInfo(oinfo, H5O_INFO_HDR); + verify_val(oinfo.hdr.nchunks, 1, "DataSet::getInfo", __LINE__, __FILE__); + dataset.close(); + + // Open the dataset we created above and then close it. This is one + // way to open an existing dataset for accessing. + dataset = file.openDataSet(DSET_DEFAULT_NAME); + HDmemset(&oinfo, 0, sizeof(oinfo)); + dataset.getInfo(oinfo, H5O_INFO_ALL); + verify_val(oinfo.hdr.nchunks, 1, "DataSet::getInfo", __LINE__, __FILE__); + dataset.close(); + + PASSED(); + return 0; + } // outer most try block + + catch (InvalidActionException& E) + { + cerr << " FAILED" << endl; + cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; + return -1; + } + // catch all other exceptions + catch (Exception& E) + { + issue_fail_msg("test_getinfo", __LINE__, __FILE__); + return -1; + } +} // test_getinfo + + +/*------------------------------------------------------------------------- * Function: test_virtual * * Purpose Tests fixed, unlimited, and printf selections in the same @@ -1237,6 +1298,7 @@ void test_dset() nerrors += test_create(file) < 0 ? 1:0; nerrors += test_simple_io(file) < 0 ? 1:0; + nerrors += test_getinfo(file) < 0 ? 1:0; nerrors += test_tconv(file) < 0 ? 1:0; nerrors += test_compression(file) < 0 ? 1:0; nerrors += test_nbit_compression(file) < 0 ? 1:0; diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index 5aa4bf5..94c811a 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -518,6 +518,12 @@ static void test_attr_basic_read() int num_attrs = dataset.getNumAttrs(); verify_val(num_attrs, 3, "DataSet::getNumAttrs", __LINE__, __FILE__); + // Verify the correct number of attributes another way + H5O_info_t oinfo; + HDmemset(&oinfo, 0, sizeof(oinfo)); + dataset.getInfo(oinfo, H5O_INFO_NUM_ATTRS); + verify_val(oinfo.num_attrs, 3, "DataSet::getInfo", __LINE__, __FILE__); + // Open an attribute for the dataset Attribute ds_attr=dataset.openAttribute(ATTR1_NAME); @@ -538,7 +544,12 @@ static void test_attr_basic_read() // Verify the correct number of attributes num_attrs = group.getNumAttrs(); - verify_val(num_attrs, 1, "H5Group::getNumAttrs", __LINE__, __FILE__); + verify_val(num_attrs, 1, "Group::getNumAttrs", __LINE__, __FILE__); + + // Verify the correct number of attributes another way + HDmemset(&oinfo, 0, sizeof(oinfo)); + group.getInfo(oinfo, H5O_INFO_NUM_ATTRS); + verify_val(oinfo.num_attrs, 1, "Group::getInfo", __LINE__, __FILE__); // Open an attribute for the group Attribute gr_attr = group.openAttribute(ATTR2_NAME); @@ -658,6 +669,12 @@ static void test_attr_compound_read() int num_attrs = dataset.getNumAttrs(); verify_val(num_attrs, 1, "DataSet::getNumAttrs", __LINE__, __FILE__); + // Verify the correct number of attributes another way + H5O_info_t oinfo; + HDmemset(&oinfo, 0, sizeof(oinfo)); + dataset.getInfo(oinfo, H5O_INFO_NUM_ATTRS); + verify_val(oinfo.num_attrs, 1, "DataSet::getInfo", __LINE__, __FILE__); + // Open 1st attribute for the dataset Attribute attr = dataset.openAttribute((unsigned)0); diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index ba5b486..dd32364 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -76,7 +76,7 @@ const H5std_string FILE4("tfile4.h5"); * 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 + * arises later, this will have to be specifically handled * with a special routine. *------------------------------------------------------------------------- */ @@ -282,7 +282,7 @@ static void test_file_create() * 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 + * arises later, this will have to be specifically handled * with a special routine. *------------------------------------------------------------------------- */ @@ -657,8 +657,15 @@ static void test_libver_bounds_real( unsigned obj_version = file.childObjVersion(ROOTGROUP); verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__); + // Verify object header version another way + H5O_info_t oinfo; + HDmemset(&oinfo, 0, sizeof(oinfo)); + file.getInfo(oinfo, H5O_INFO_HDR); + verify_val(oinfo.hdr.version, oh_vers_create, "H5File::getInfo", __LINE__, __FILE__); + /* - * Reopen the file and make sure the root group still has the correct version + * Reopen the file and make sure the root group still has the correct + * version */ file.close(); @@ -678,6 +685,11 @@ static void test_libver_bounds_real( obj_version = group.objVersion(); verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__); + // Verify object header version another way + HDmemset(&oinfo, 0, sizeof(oinfo)); + group.getInfo(oinfo, H5O_INFO_HDR); + verify_val(oinfo.hdr.version, oh_vers_mod, "Group::getInfo", __LINE__, __FILE__); + group.close(); // close "/G1" /* diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp index 9c92b64..d4853da 100644 --- a/c++/test/th5s.cpp +++ b/c++/test/th5s.cpp @@ -98,7 +98,7 @@ int space5_data = 7; * cases. Since there are no operator<< for 'long long' * or int64 in VS C++ ostream, I casted the hssize_t values * passed to verify_val to 'long' as well. If problems - * arises later, this will have to be specificly handled + * arises later, this will have to be specifically handled * with a special routine. * April 12, 2011: Raymond Lu * Starting from the 1.8.7 release, we allow dimension @@ -230,7 +230,7 @@ static void test_h5s_basic() * cases. Since there are no operator<< for 'long long' * or int64 in VS C++ ostream, I casted the hssize_t values * passed to verify_val to 'long' as well. If problems - * arises later, this will have to be specificly handled + * arises later, this will have to be specifically handled * with a special routine. *------------------------------------------------------------------------- */ @@ -294,7 +294,7 @@ static void test_h5s_scalar_write() * cases. Since there are no operator<< for 'long long' * or int64 in VS C++ ostream, I casted the hssize_t values * passed to verify_val to 'long' as well. If problems - * arises later, this will have to be specificly handled + * arises later, this will have to be specifically handled * with a special routine. *------------------------------------------------------------------------- */ @@ -356,7 +356,7 @@ static void test_h5s_scalar_read() * cases. Since there are no operator<< for 'long long' * or int64 in VS C++ ostream, I casted the hssize_t values * passed to verify_val to 'long' as well. If problems - * arises later, this will have to be specificly handled + * arises later, this will have to be specifically handled * with a special routine. *------------------------------------------------------------------------- */ @@ -411,7 +411,7 @@ static void test_h5s_null() * cases. Since there are no operator<< for 'long long' * or int64 in VS C++ ostream, I casted the hssize_t values * passed to verify_val to 'long' as well. If problems - * arises later, this will have to be specificly handled + * arises later, this will have to be specifically handled * with a special routine. *------------------------------------------------------------------------- */ @@ -484,7 +484,7 @@ static void test_h5s_compound_scalar_write() * cases. Since there are no operator<< for 'long long' * or int64 in VS C++ ostream, I casted the hssize_t values * passed to verify_val to 'long' as well. If problems - * arises later, this will have to be specificly handled + * arises later, this will have to be specifically handled * with a special routine. *------------------------------------------------------------------------- */ diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp index b8560aa..f8d7089 100644 --- a/c++/test/tlinks.cpp +++ b/c++/test/tlinks.cpp @@ -515,7 +515,7 @@ test_lcpl(hid_t fapl_id, hbool_t new_format) } // end of try block catch (Exception& E) { - issue_fail_msg("test_num_links()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_lcpl()", __LINE__, __FILE__, E.getCDetailMsg()); } } // end test_lcpl() @@ -657,7 +657,7 @@ test_move(hid_t fapl_id, hbool_t new_format) } // end of try block catch (Exception& E) { - issue_fail_msg("test_num_links()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_move()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_move @@ -792,7 +792,7 @@ static void test_copy(hid_t fapl_id, hbool_t new_format) } // end of try block catch (Exception& E) { - issue_fail_msg("test_num_links()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_copy()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_copy @@ -892,6 +892,7 @@ void test_links() /* General tests... (on both old & new format groups */ // FileAccPropList may be passed in instead of fapl id test_basic_links(my_fapl_id, new_format); + test_num_links(my_fapl_id, new_format); test_move(my_fapl_id, new_format); test_copy(my_fapl_id, new_format); test_lcpl(my_fapl_id, new_format); diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp index 9980ce0..bfc13a0 100644 --- a/c++/test/tobject.cpp +++ b/c++/test/tobject.cpp @@ -523,19 +523,106 @@ static void test_open_object_header() cerr << " in Exception" << endl; issue_fail_msg("test_file_name()", __LINE__, __FILE__, E.getCDetailMsg()); } -} /* test_open_object_header() */ +} // test_open_object_header /*------------------------------------------------------------------------- - * Function: test_objects + * Function: test_getobjectinfo_same_file + * + * Purpose Test that querying the object info for objects in the same + * file will return the same file "number". + * + * Return None + * + * July, 2018 + *------------------------------------------------------------------------- + */ +const H5std_string FILE_OBJINFO("tobject_getinfo.h5"); +const H5std_string GROUP1NAME("group1"); +const H5std_string GROUP2NAME("group2"); +static void test_getobjectinfo_same_file() +{ + H5O_info_t oinfo1, oinfo2; /* Object info structs */ + + // Output message about test being performed + SUBTEST("Group::getInfo"); + + try { + // Create a new HDF5 file + H5File file1(FILE_OBJINFO, H5F_ACC_TRUNC); + + // Create two groups in the file + Group grp1(file1.createGroup(GROUP1NAME)); + Group grp2(file1.createGroup(GROUP2NAME)); + + // Reset object info + HDmemset(&oinfo1, 0, sizeof(oinfo1)); + HDmemset(&oinfo2, 0, sizeof(oinfo2)); + + // Query the info of two groups and verify that they have the same + // file number + grp1.getInfo(oinfo1); + grp2.getInfo(oinfo2); + verify_val(oinfo1.fileno, oinfo2.fileno, "file number from getInfo", __LINE__, __FILE__); + + // Close groups and file + grp1.close(); + grp2.close(); + file1.close(); + + // Open the file twice + file1.openFile(FILE_OBJINFO, H5F_ACC_RDWR); + H5File file2(FILE_OBJINFO, H5F_ACC_RDWR); + + // Create two groups in the file + grp1 = file1.openGroup(GROUP1NAME); + grp2 = file2.openGroup(GROUP2NAME); + + // Reset object info + HDmemset(&oinfo1, 0, sizeof(oinfo1)); + HDmemset(&oinfo2, 0, sizeof(oinfo2)); + + // Query the info of two groups and verify that they have the same + // file number + grp1.getInfo(oinfo1); + grp2.getInfo(oinfo2); + verify_val(oinfo1.fileno, oinfo2.fileno, "file number from getInfo", __LINE__, __FILE__); + + + // Reset object info + HDmemset(&oinfo1, 0, sizeof(oinfo1)); + HDmemset(&oinfo2, 0, sizeof(oinfo2)); + + file1.getInfo(GROUP1NAME, oinfo1); + file1.getInfo(GROUP2NAME, oinfo2); + verify_val(oinfo1.fileno, oinfo2.fileno, "file number from getObjectInfo", __LINE__, __FILE__); + + // Close groups and files + grp1.close(); + grp2.close(); + file1.close(); + file2.close(); + + PASSED(); + } // end of try block + // catch all other exceptions + catch (Exception& E) + { + cerr << " in Exception " << E.getCFuncName() << "detail: " << E.getCDetailMsg() << endl; + issue_fail_msg("test_file_name()", __LINE__, __FILE__, E.getCDetailMsg()); + } + +} // test_h5o_getinfo_same_file + +/*------------------------------------------------------------------------- + * Function: test_object * * Purpose Tests HDF5 object related functionality * * Return Success: 0 * Failure: -1 * - * Programmer Binh-Minh Ribler - * Friday, Mar 4, 2014 + * March 4, 2014 *------------------------------------------------------------------------- */ extern "C" @@ -549,8 +636,9 @@ void test_object() test_get_objname_ontypes(); // Test get object name from types test_get_objtype(); // Test get object type test_open_object_header(); // Test object header functions (H5O) + test_getobjectinfo_same_file(); // Test object info in same file -} // test_objects +} // test_object /*------------------------------------------------------------------------- diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index bb09616..fa214df 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -481,6 +481,21 @@ static void test_reference_group() fname = group.getFileName(); verify_val(fname, FILE1, "H5Group::getFileName",__LINE__,__FILE__); + // Check object type using Group::getInfo() + H5O_info_t oinfo; + HDmemset(&oinfo, 0, sizeof(oinfo)); + group.getInfo(".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, oinfo); + verify_val(oinfo.type, H5O_TYPE_DATASET, "Group::getInfo",__LINE__,__FILE__); + + // Check for out of bound query by index + try { + HDmemset(&oinfo, 0, sizeof(oinfo)); + group.getInfo(".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)9, oinfo); + + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("Group::getInfo", "Out of bound index."); + } catch (Exception& err) {} // do nothing, failure expected + // Unlink one of the objects in the dereferenced group, and re-check refgroup.unlink(GROUPNAME2); nobjs = refgroup.getNumObjs(); |