diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2015-04-06 21:20:11 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2015-04-06 21:20:11 (GMT) |
commit | a586729afb1e25f82befc4b394f3e819a4f7a880 (patch) | |
tree | c145bbbd036c64ffd3f1613294d3b1461f42c73a /c++/test | |
parent | f809ee8ce7e68c156ace42970393aafa5350e387 (diff) | |
download | hdf5-a586729afb1e25f82befc4b394f3e819a4f7a880.zip hdf5-a586729afb1e25f82befc4b394f3e819a4f7a880.tar.gz hdf5-a586729afb1e25f82befc4b394f3e819a4f7a880.tar.bz2 |
[svn-r26741] Description:
Per user Jason Newton request, the following constructor is added:
H5File(hid_t existing_id);
Also, fixed H5File::openFile to close current file first before re-using
the object.
Platforms tested:
Linux/64 (platypus)
Linux/32 2.6 (jam)
SunOS 5.11 (emu)
Diffstat (limited to 'c++/test')
-rw-r--r-- | c++/test/tfile.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index e3ad74f..7c2811e 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -330,6 +330,32 @@ static void test_file_open() verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); + // Test H5File constructor with existing file id + H5File file2(file1.getId()); + file1.close(); + + // Try truncating the file, and it should fail because the file is + // still opened with file2. + try { + H5File file3 (FILE2, H5F_ACC_TRUNC); // should throw E + + // Should FAIL but didn't, so throw an invalid action exception + throw InvalidActionException("H5File constructor", "Attempt truncating an opened file."); + } + catch( FileIException E ) // catching H5F_ACC_TRUNC on opened file + {} // do nothing, FAIL expected + + // Now, really close the file. + file2.close(); + + // Truncating should succeed now. + H5File file3(FILE2, H5F_ACC_TRUNC); + + // Opening another file to file3 object, FILE2 should be closed, so + // the next attempt to truncate FILE2 should succeed. + file3.openFile(FILE1, H5F_ACC_RDONLY); + H5File file4(FILE2, H5F_ACC_TRUNC); + PASSED(); } // end of try block |