summaryrefslogtreecommitdiffstats
path: root/c++/test
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2016-12-28 14:44:01 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2016-12-28 14:44:01 (GMT)
commitcd3bd5576f048ce1ca413921c76dcacf137d2110 (patch)
tree164e5f59fae1b339018f518560f89cd1c90a584b /c++/test
parentb00962ac8694b14b74382f77d1cf849b93383fb5 (diff)
downloadhdf5-cd3bd5576f048ce1ca413921c76dcacf137d2110.zip
hdf5-cd3bd5576f048ce1ca413921c76dcacf137d2110.tar.gz
hdf5-cd3bd5576f048ce1ca413921c76dcacf137d2110.tar.bz2
Purpose: Add new wrappers
Description: Added wrappers H5Location::exists() for H5Lexists. Added wrapper H5Object::objVersion() to return the header version of an HDF5 object. Added new class LinkAccPropList to be used by H5Location::exists() Added new exception: ObjHeaderIException for H5Object::objVersion() Rearranged source files in Makefile.am Platforms tested: Linux/32 2.6 (jam) Linux/64 (platypus) Darwin (osx1010test)
Diffstat (limited to 'c++/test')
-rw-r--r--c++/test/tfile.cpp12
-rw-r--r--c++/test/tlinks.cpp8
-rw-r--r--c++/test/tobject.cpp115
3 files changed, 105 insertions, 30 deletions
diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp
index 47b9a85..e9c865f 100644
--- a/c++/test/tfile.cpp
+++ b/c++/test/tfile.cpp
@@ -639,6 +639,10 @@ const H5std_string SUBGROUP3("/G1/G3");
static void test_libver_bounds_real(
H5F_libver_t libver_create, unsigned oh_vers_create,
H5F_libver_t libver_mod, unsigned oh_vers_mod)
+ /* (H5F_LIBVER_EARLIEST, H5O_VERSION_1, H5F_LIBVER_LATEST, H5O_VERSION_2);
+(H5F_LIBVER_LATEST, H5O_VERSION_2, H5F_LIBVER_EARLIEST, H5O_VERSION_2);
+ */
+
{
try {
@@ -674,8 +678,8 @@ static void test_libver_bounds_real(
*/
Group group = file.createGroup(GROUP1);
- obj_version = file.childObjVersion(GROUP1);
- verify_val(obj_version, oh_vers_mod, "H5File::childObjVersion", __LINE__, __FILE__);
+ obj_version = group.objVersion();
+ verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__);
group.close(); // close "/G1"
@@ -685,8 +689,8 @@ static void test_libver_bounds_real(
*/
group = file.createGroup(SUBGROUP3);
- obj_version = group.childObjVersion(SUBGROUP3);
- verify_val(obj_version, oh_vers_mod, "H5File::childObjVersion", __LINE__, __FILE__);
+ obj_version = group.objVersion();
+ verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__);
group.close(); // close "/G1/G3"
diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp
index 1f7d14e..3acf4e1 100644
--- a/c++/test/tlinks.cpp
+++ b/c++/test/tlinks.cpp
@@ -419,10 +419,10 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format)
H5File file(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl);
// Verify link existence
- if(H5Lexists(file.getId(), "dset1", H5P_DEFAULT) != TRUE)
- throw InvalidActionException("H5Lexists", "dset1 doesn't exist");
- if(H5Lexists(file.getId(), "grp1/soft", H5P_DEFAULT) != TRUE)
- throw InvalidActionException("H5Lexists", "grp1/soft doesn't exist");
+ if(file.exists("dset1", LinkAccPropList::DEFAULT) != TRUE)
+ throw InvalidActionException("H5File::exists", "dset1 doesn't exist");
+ if(file.exists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE)
+ throw InvalidActionException("H5File::exists", "grp1/soft doesn't exist");
// Verify link values
H5std_string softlink_val = file.getLinkval("grp1/soft");
diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp
index e142f02..72dc106 100644
--- a/c++/test/tobject.cpp
+++ b/c++/test/tobject.cpp
@@ -23,6 +23,8 @@
#else
#include <iostream>
#endif
+using std::cerr;
+using std::endl;
#include <string>
#include "H5Cpp.h" // C++ API header file
@@ -41,16 +43,26 @@ const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2");
const H5std_string DSET_DEFAULT_NAME("default");
const H5std_string DSET_IN_FILE("Dataset in File");
const H5std_string DSET_IN_FILE_PATH("/Dataset in File");
-const H5std_string DSET_IN_GRP1("Dataset in Group 1");
-const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset in Group 1");
-const H5std_string DSET_IN_GRP1_2("Dataset in Group 1.2");
-const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset in Group 1.2");
+const H5std_string DSET_IN_GRP1("Dataset_in_Group_1");
+const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset_in_Group_1");
+const H5std_string DSET_IN_GRP1_2("Dataset_in_Group_1.2");
+const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset_in_Group_1.2");
/*-------------------------------------------------------------------------
* Function: test_get_objname
*
* Purpose: Tests getting object name of groups and datasets.
*
+ * Description:
+ * File structure:
+ * GROUP1
+ * GROUP1_1
+ * GROUP1_2
+ * DSET_IN_GRP1_2
+ * DSET_IN_GRP1
+ * DSET_IN_FILE
+ *
+ *
* Return: Success: 0
* Failure: -1
*
@@ -143,6 +155,81 @@ static void test_get_objname()
issue_fail_msg("test_get_objname", __LINE__, __FILE__);
}
} // test_get_objname
+/*-------------------------------------------------------------------------
+ * Function: test_existance
+ *
+ * Purpose: Tests getting object name of groups and datasets.
+ *
+ * Description:
+ * File structure:
+ * GROUP1
+ * GROUP1_1
+ * GROUP1_2
+ * DSET_IN_GRP1_2
+ * DSET_IN_GRP1
+ * DSET_IN_FILE
+ *
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Binh-Minh Ribler
+ * Friday, March 4, 2014
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void test_existance()
+{
+ SUBTEST("H5File::exists and Group::exists");
+
+ try {
+ // Open file
+ H5File file(FILE_OBJECTS, H5F_ACC_RDONLY);
+
+ // Check if GROUP1 exists in the file
+ bool exists = file.exists(GROUP1);
+
+ // Open GROUP1
+ Group grp1 = file.openGroup(GROUP1);
+
+ // Check if GROUP1_1 and GROUP1_2 exist in GROUP1
+ exists = grp1.exists(GROUP1_1);
+ verify_val(exists, TRUE, "Group::exists GROUP1_1", __LINE__, __FILE__);
+ exists = grp1.exists(GROUP1_2);
+ verify_val(exists, TRUE, "Group::exists GROUP1_2", __LINE__, __FILE__);
+
+ // Check if DSET_IN_GRP1 exists in GROUP1
+ exists = grp1.exists(DSET_IN_GRP1);
+ verify_val(exists, TRUE, "Group::exists DSET_IN_GRP1", __LINE__, __FILE__);
+
+ // Open GROUP1_2
+ Group grp1_2 = grp1.openGroup(GROUP1_2);
+
+ // Check if DSET_IN_GRP1_2 exists in GROUP1_2
+ exists = grp1_2.exists(DSET_IN_GRP1_2);
+ verify_val(exists, TRUE, "Group::exists DSET_IN_GRP1_2", __LINE__, __FILE__);
+
+ // Check if a dataset exists given dataset as location with full path name
+ DataSet dset1 = file.openDataSet(DSET_IN_FILE);
+ exists = dset1.exists("/Top Group/Dataset_in_Group_1");
+ verify_val(exists, TRUE, "Group::exists given dataset with full path name", __LINE__, __FILE__);
+
+ exists = grp1_2.exists(DSET_IN_GRP1);
+ verify_val(exists, FALSE, "Group::exists DSET_IN_GRP1", __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_existance", __LINE__, __FILE__);
+ }
+} // test_existance
/*-------------------------------------------------------------------------
* Function: test_get_objname_ontypes
@@ -182,16 +269,6 @@ static void test_get_objname_ontypes()
H5std_string inttype_name = inttype.getObjName();
verify_val(inttype_name, "/INT type of STD_B8LE", "DataType::getObjName", __LINE__, __FILE__);
- // Close the type then open it again to test getting its name with
- // the constructor
- inttype.close();
- IntType newtype(file, "INT type of STD_B8LE");
-
- // Get and verify its name
- H5std_string type_name = newtype.getObjName();
- verify_val(type_name, "/INT type of STD_B8LE", "DataType::getObjName tests constructor", __LINE__, __FILE__);
- newtype.close();
-
// Make copy of a predefined type and save it
DataType dtype(PredType::STD_B8LE);
dtype.commit(file, "STD_B8LE");
@@ -205,14 +282,7 @@ static void test_get_objname_ontypes()
dtype = file.openDataType("STD_B8LE");
// Get and verify its name
- type_name = dtype.getObjName();
- verify_val(type_name, "/STD_B8LE", "DataType::getObjName", __LINE__, __FILE__);
-
- // Repeat the test with openDataType's replacement
- DataType dtype2(file, "STD_B8LE");
-
- // Get and verify its name
- type_name = dtype2.getObjName();
+ H5std_string type_name = dtype.getObjName();
verify_val(type_name, "/STD_B8LE", "DataType::getObjName", __LINE__, __FILE__);
// Test getting type's name from copied type
@@ -333,6 +403,7 @@ void test_object()
MESSAGE(5, ("Testing Object Functions\n"));
test_get_objname(); // Test get object name from groups/datasets
+ test_existance(); // Test check for object existance
test_get_objname_ontypes(); // Test get object name from types
test_get_objtype(); // Test get object type