diff options
author | Quincey Koziol <koziol@lbl.gov> | 2019-04-14 04:06:38 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@lbl.gov> | 2019-04-14 04:06:38 (GMT) |
commit | 5696c02a3cceec73cfb404b7415ca33ca1a48718 (patch) | |
tree | c25d0985895862053d6b9d1eb1fce4fa94d471e3 /java/test | |
parent | 52276f3713eec584044bc72d4724507848cfeba0 (diff) | |
parent | d7e1464058515d07b838741f65a77977224814de (diff) | |
download | hdf5-5696c02a3cceec73cfb404b7415ca33ca1a48718.zip hdf5-5696c02a3cceec73cfb404b7415ca33ca1a48718.tar.gz hdf5-5696c02a3cceec73cfb404b7415ca33ca1a48718.tar.bz2 |
Merge pull request #1653 in HDFFV/hdf5 from ~KOZIOL/hdf5:get_fileno to develop
* commit 'd7e1464058515d07b838741f65a77977224814de':
Add C++, Java, and FORTRAN wrappers and tests for H5Fget_fileno
Add trace macro.
Add H5Fget_fileno() API routine.
Diffstat (limited to 'java/test')
-rw-r--r-- | java/test/TestH5F.java | 130 | ||||
-rw-r--r-- | java/test/testfiles/JUnit-TestH5F.txt | 4 |
2 files changed, 133 insertions, 1 deletions
diff --git a/java/test/TestH5F.java b/java/test/TestH5F.java index e4f9a30..a86fddb 100644 --- a/java/test/TestH5F.java +++ b/java/test/TestH5F.java @@ -14,6 +14,7 @@ package test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -32,6 +33,7 @@ import org.junit.rules.TestName; public class TestH5F { @Rule public TestName testname = new TestName(); private static final String H5_FILE = "testF.h5"; + private static final String H5_FILE2 = "testF2.h5"; private static final int COUNT_OBJ_FILE = 1; private static final int COUNT_OBJ_DATASET = 0; @@ -48,6 +50,7 @@ public class TestH5F { HDF5Constants.H5F_OBJ_DATATYPE, HDF5Constants.H5F_OBJ_ATTR, HDF5Constants.H5F_OBJ_ALL }; long H5fid = -1; + long H5fid2 = -1; private final void _deleteFile(String filename) { File file = new File(filename); @@ -66,6 +69,10 @@ public class TestH5F { H5fid = H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); + + H5fid2 = H5.H5Fcreate(H5_FILE2, HDF5Constants.H5F_ACC_TRUNC, + HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); + H5.H5Fflush(H5fid2, HDF5Constants.H5F_SCOPE_LOCAL); } @After @@ -74,7 +81,12 @@ public class TestH5F { try {H5.H5Fclose(H5fid);} catch (Exception ex) {} H5fid = -1; } + if (H5fid2 > 0) { + try {H5.H5Fclose(H5fid2);} catch (Exception ex) {} + H5fid2 = -1; + } _deleteFile(H5_FILE); + _deleteFile(H5_FILE2); System.out.println(); } @@ -223,6 +235,124 @@ public class TestH5F { } @Test + public void testH5Fget_fileno_same() { + long fileno1 = 0; + long fileno2 = 0; + long fid1 = -1; + long fid2 = -1; + + if (H5fid > 0) { + try {H5.H5Fclose(H5fid);} catch (Exception ex) {} + H5fid = -1; + } + + try { + fid1 = H5.H5Fopen(H5_FILE, HDF5Constants.H5F_ACC_RDWR, + HDF5Constants.H5P_DEFAULT); + } + catch (Throwable err) { + fail("H5.H5Fopen: " + err); + } + + try { + fid2 = H5.H5Fopen(H5_FILE, HDF5Constants.H5F_ACC_RDWR, + HDF5Constants.H5P_DEFAULT); + } + catch (Throwable err) { + fail("H5.H5Fopen: " + err); + } + + try { + fileno1 = H5.H5Fget_fileno(fid1); + } + catch (Throwable err) { + fail("H5.H5Fget_fileno: " + err); + } + + try { + fileno2 = H5.H5Fget_fileno(fid2); + } + catch (Throwable err) { + fail("H5.H5Fget_fileno: " + err); + } + + assertEquals(fileno1, fileno2); + + try { + H5.H5Fclose(fid1); + } + catch (Exception ex) { + } + + try { + H5.H5Fclose(fid2); + } + catch (Exception ex) { + } + } + + @Test + public void testH5Fget_fileno_diff() { + long fileno1 = 0; + long fileno2 = 0; + long fid1 = -1; + long fid2 = -1; + + if (H5fid > 0) { + try {H5.H5Fclose(H5fid);} catch (Exception ex) {} + H5fid = -1; + } + if (H5fid2 > 0) { + try {H5.H5Fclose(H5fid2);} catch (Exception ex) {} + H5fid2 = -1; + } + + try { + fid1 = H5.H5Fopen(H5_FILE, HDF5Constants.H5F_ACC_RDWR, + HDF5Constants.H5P_DEFAULT); + } + catch (Throwable err) { + fail("H5.H5Fopen: " + err); + } + + try { + fid2 = H5.H5Fopen(H5_FILE2, HDF5Constants.H5F_ACC_RDWR, + HDF5Constants.H5P_DEFAULT); + } + catch (Throwable err) { + fail("H5.H5Fopen: " + err); + } + + try { + fileno1 = H5.H5Fget_fileno(fid1); + } + catch (Throwable err) { + fail("H5.H5Fget_fileno: " + err); + } + + try { + fileno2 = H5.H5Fget_fileno(fid2); + } + catch (Throwable err) { + fail("H5.H5Fget_fileno: " + err); + } + + assertNotEquals(fileno1, fileno2); + + try { + H5.H5Fclose(fid1); + } + catch (Exception ex) { + } + + try { + H5.H5Fclose(fid2); + } + catch (Exception ex) { + } + } + + @Test public void testH5Fget_obj_count() { long count = -1; diff --git a/java/test/testfiles/JUnit-TestH5F.txt b/java/test/testfiles/JUnit-TestH5F.txt index 16a423e..791e82d 100644 --- a/java/test/testfiles/JUnit-TestH5F.txt +++ b/java/test/testfiles/JUnit-TestH5F.txt @@ -7,8 +7,10 @@ JUnit version 4.11 .testH5Fget_intent_rdonly .testH5Fget_create_plist .testH5Fget_obj_count +.testH5Fget_fileno_same +.testH5Fget_fileno_diff Time: XXXX -OK (8 tests) +OK (10 tests) |