summaryrefslogtreecommitdiffstats
path: root/java/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@koziol.gov>2019-04-14 03:58:16 (GMT)
committerQuincey Koziol <koziol@koziol.gov>2019-04-14 03:58:16 (GMT)
commitd7e1464058515d07b838741f65a77977224814de (patch)
treec25d0985895862053d6b9d1eb1fce4fa94d471e3 /java/test
parent4918d443bb2f8406c3be9882a7945853c84760f6 (diff)
downloadhdf5-d7e1464058515d07b838741f65a77977224814de.zip
hdf5-d7e1464058515d07b838741f65a77977224814de.tar.gz
hdf5-d7e1464058515d07b838741f65a77977224814de.tar.bz2
Add C++, Java, and FORTRAN wrappers and tests for H5Fget_fileno
Diffstat (limited to 'java/test')
-rw-r--r--java/test/TestH5F.java130
-rw-r--r--java/test/testfiles/JUnit-TestH5F.txt4
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)