summaryrefslogtreecommitdiffstats
path: root/c++/test/tfile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c++/test/tfile.cpp')
-rw-r--r--c++/test/tfile.cpp116
1 files changed, 116 insertions, 0 deletions
diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp
index ad5e6fc..6d5dc23 100644
--- a/c++/test/tfile.cpp
+++ b/c++/test/tfile.cpp
@@ -501,6 +501,7 @@ 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 */
+
static void test_file_attribute()
{
int rdata[ATTR1_DIM1];
@@ -602,6 +603,119 @@ static void test_file_attribute()
}
} // test_file_attribute()
+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
+ *
+ * Purpose: Verify that a file created and modified with the
+ * specified libver bounds has the specified object header
+ * versions for the right objects.
+ *
+ * Return: None
+ *
+ * Programmer: Binh-Minh Ribler (use C version)
+ * March, 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+static void test_libver_bounds_real(
+ H5F_libver_t libver_create, unsigned oh_vers_create,
+ H5F_libver_t libver_mod, unsigned oh_vers_mod)
+{
+ try {
+
+ /*
+ * Create a new file using the default creation property and access property
+ * with latest library version.
+ */
+ FileAccPropList fapl;
+ fapl.setLibverBounds(libver_create, H5F_LIBVER_LATEST);
+ H5File file(FILE6, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
+
+ /*
+ * Make sure the root group has the correct object header version
+ */
+ unsigned obj_version = file.childObjVersion(ROOTGROUP);
+ verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__);
+
+ /*
+ * Reopen the file and make sure the root group still has the correct version
+ */
+ file.close();
+
+ fapl.setLibverBounds(libver_mod, H5F_LIBVER_LATEST);
+
+ file.openFile(FILE6, H5F_ACC_RDWR, fapl);
+
+ obj_version = file.childObjVersion(ROOTGROUP);
+ verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__);
+
+ /*
+ * Create a group named "/G1" in the file, and make sure it has the correct
+ * object header version
+ */
+ Group group = file.createGroup(GROUP1);
+
+ obj_version = file.childObjVersion(GROUP1);
+ verify_val(obj_version, oh_vers_mod, "H5File::childObjVersion", __LINE__, __FILE__);
+
+ group.close(); // close "/G1"
+
+ /*
+ * Create a group named "/G1/G3" in the file, and make sure it has the
+ * correct object header version
+ */
+ group = file.createGroup(SUBGROUP3);
+
+ obj_version = group.childObjVersion(SUBGROUP3);
+ verify_val(obj_version, oh_vers_mod, "H5File::childObjVersion", __LINE__, __FILE__);
+
+ group.close(); // close "/G1/G3"
+
+ /*
+ * Make sure the root group still has the correct object header version
+ */
+ obj_version = file.childObjVersion(ROOTGROUP);
+ verify_val(obj_version, oh_vers_create, "H5File::childObjVersion", __LINE__, __FILE__);
+
+ // Everything should be closed as they go out of scope
+ } // end of try block
+
+ catch (Exception E) {
+ issue_fail_msg("test_libver_bounds_real()", __LINE__, __FILE__, E.getCDetailMsg());
+ }
+
+} /* end test_libver_bounds_real() */
+
+/*-------------------------------------------------------------------------
+ *
+ * Function: test_libver_bounds
+ *
+ * Purpose: Verify that a file created and modified with various
+ * libver bounds is handled correctly.
+ *
+ * Return: None
+ *
+ * Programmer: Binh-Minh Ribler (use C version)
+ * March 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+static void test_libver_bounds()
+{
+ // Output message about test being performed
+ SUBTEST("Setting library version bounds");
+
+ /* Run the tests */
+ test_libver_bounds_real(H5F_LIBVER_EARLIEST, H5O_VERSION_1, H5F_LIBVER_LATEST, H5O_VERSION_2);
+ test_libver_bounds_real(H5F_LIBVER_LATEST, H5O_VERSION_2, H5F_LIBVER_EARLIEST, H5O_VERSION_1);
+ PASSED();
+} /* end test_libver_bounds() */
+
/*-------------------------------------------------------------------------
* Function: test_file
*
@@ -629,6 +743,7 @@ void test_file()
test_file_size(); // Test file size
test_file_name(); // Test getting file's name
test_file_attribute(); // Test file attribute feature
+ test_libver_bounds(); // Test format version
} // test_file()
@@ -655,4 +770,5 @@ void cleanup_file()
HDremove(FILE3.c_str());
HDremove(FILE4.c_str());
HDremove(FILE5.c_str());
+ HDremove(FILE6.c_str());
} // cleanup_file