diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2014-04-12 03:34:19 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2014-04-12 03:34:19 (GMT) |
commit | 53a50fa7c8802f7f964ccf082b5fa8646cf61287 (patch) | |
tree | 54421d8dd4c9dce0a663515577c820e9c4385272 /c++/test | |
parent | 19c485a128e4d860a537a14c91e38bc87dc6db25 (diff) | |
download | hdf5-53a50fa7c8802f7f964ccf082b5fa8646cf61287.zip hdf5-53a50fa7c8802f7f964ccf082b5fa8646cf61287.tar.gz hdf5-53a50fa7c8802f7f964ccf082b5fa8646cf61287.tar.bz2 |
[svn-r25028] Purpose: Fix HDFFV-8367
Description:
- Added wrappers to CommomFG for H5Oget_info_by_name() to get a child
object's type (requested by user)
H5O_type_t childObjType(const H5std_string& objname) const;
H5O_type_t childObjType(const char* objname) const;
H5O_type_t childObjType(hsize_t index, H5_index_t index_type=H5_INDEX_NAME, H5_iter_order_t order=H5_ITER_INC, const char* objname=".") const;
- Added tests to tobject.cpp
(merged from trunk-r24983)
Platforms tested:
Linux/ppc64 (ostrich)
Linux/32 2.6 (jam)
SunOS 5.11 (emu)
Diffstat (limited to 'c++/test')
-rw-r--r-- | c++/test/tobject.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp index e6ef69c..b86d7cb 100644 --- a/c++/test/tobject.cpp +++ b/c++/test/tobject.cpp @@ -220,6 +220,71 @@ static void test_get_objname_ontypes() } // test_get_objname_ontypes /*------------------------------------------------------------------------- + * Function: test_get_objtype + * + * Purpose: Tests getting object type + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Binh-Minh Ribler + * Friday, March 4, 2014 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void test_get_objtype() +{ + SUBTEST("H5File::childObjType and H5Group::childObjType"); + + try { + // Open file + H5File file(FILE_OBJECTS, H5F_ACC_RDWR); + + // Open the top group + Group grp1 = file.openGroup(GROUP1); + + // Create a datatype and save it + DataType dtype(PredType::STD_I32LE); + dtype.commit(grp1, "STD_I32LE"); + + // Get and verify object type with + // H5O_type_t childObjType(const H5std_string& objname) + H5O_type_t objtype = file.childObjType(DSET_IN_FILE); + verify_val(objtype, H5O_TYPE_DATASET, "DataSet::childObjType", __LINE__, __FILE__); + + // Get and verify object type with + // H5O_type_t childObjType(const char* objname) + objtype = grp1.childObjType(GROUP1_1.c_str()); + verify_val(objtype, H5O_TYPE_GROUP, "DataSet::childObjType", __LINE__, __FILE__); + + // Get and verify object type with + // H5O_type_t childObjType(hsize_t index, H5_index_t index_type, + // H5_iter_order_t order, const char* objname=".") + objtype = grp1.childObjType((hsize_t)1, H5_INDEX_NAME, H5_ITER_INC); + verify_val(objtype, H5O_TYPE_NAMED_DATATYPE, "DataSet::childObjType", __LINE__, __FILE__); + + // Get and verify object type with + // H5O_type_t childObjType(hsize_t index, + // H5_index_t index_type=H5_INDEX_NAME, + // H5_iter_order_t order=H5_ITER_INC, const char* objname=".") + objtype = grp1.childObjType((hsize_t)2); + verify_val(objtype, H5O_TYPE_GROUP, "DataSet::childObjType", __LINE__, __FILE__); + + // Everything will be closed as they go out of scope + + PASSED(); + } // try block + + // catch all other exceptions + catch (Exception E) + { + issue_fail_msg("test_get_objtype", __LINE__, __FILE__); + } +} // test_get_objtype + +/*------------------------------------------------------------------------- * Function: test_objects * * Purpose: Tests HDF5 object related functionality @@ -244,6 +309,7 @@ void test_object() test_get_objname(); // Test get object name from groups/datasets test_get_objname_ontypes(); // Test get object name from types + test_get_objtype(); // Test get object type } // test_objects |