summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorJordan Henderson <jhenderson@hdfgroup.org>2017-08-11 19:25:33 (GMT)
committerJordan Henderson <jhenderson@hdfgroup.org>2017-08-11 19:25:33 (GMT)
commitc34ee0b2a5fe8c142f58f31e44fd6eb53ecf8ba6 (patch)
tree8cc64cb219d19230d8f9454e19693610cb33a2b0 /java
parent1eb775801535d787c521caaf72d68856eeb3b09c (diff)
parenta6d5bf1a86250cc660cd1ed420eeda6940792be5 (diff)
downloadhdf5-c34ee0b2a5fe8c142f58f31e44fd6eb53ecf8ba6.zip
hdf5-c34ee0b2a5fe8c142f58f31e44fd6eb53ecf8ba6.tar.gz
hdf5-c34ee0b2a5fe8c142f58f31e44fd6eb53ecf8ba6.tar.bz2
Merge branch 'develop' of https://bitbucket.hdfgroup.org/scm/hdffv/hdf5 into develop
Diffstat (limited to 'java')
-rw-r--r--java/src/jni/h5Constants.c1
-rw-r--r--java/test/TestH5PL.java88
2 files changed, 69 insertions, 20 deletions
diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c
index d4511e1..f6f8bfa 100644
--- a/java/src/jni/h5Constants.c
+++ b/java/src/jni/h5Constants.c
@@ -26,6 +26,7 @@ extern "C" {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+#pragma GCC diagnostic ignored "-Wunused-parameter"
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5_1QUARTER_1HADDR_1MAX(JNIEnv *env, jclass cls) { return (hsize_t)HADDR_MAX/4; }
diff --git a/java/test/TestH5PL.java b/java/test/TestH5PL.java
index aa59478..8ce708b 100644
--- a/java/test/TestH5PL.java
+++ b/java/test/TestH5PL.java
@@ -70,26 +70,74 @@ public class TestH5PL {
@Test
public void TestH5PLpaths() {
try {
- int original_entries = H5.H5PLsize();
- H5.H5PLappend("path_one");
- int plugin_entries = H5.H5PLsize();
- assertTrue("H5.H5PLsize: "+plugin_entries, (original_entries+1) == plugin_entries);
- H5.H5PLprepend("path_two");
- plugin_entries = H5.H5PLsize();
- assertTrue("H5.H5PLsize: "+plugin_entries, (original_entries+2) == plugin_entries);
- H5.H5PLinsert("path_three", original_entries);
- plugin_entries = H5.H5PLsize();
- assertTrue("H5.H5PLsize: "+plugin_entries, (original_entries+3) == plugin_entries);
- String first_path = H5.H5PLget(original_entries);
- assertTrue("First path was : "+first_path + " ",first_path.compareToIgnoreCase("path_three")==0);
- H5.H5PLreplace("path_four", original_entries);
- first_path = H5.H5PLget(original_entries);
- assertTrue("First path changed to : "+first_path + " ",first_path.compareToIgnoreCase("path_four")==0);
- H5.H5PLremove(original_entries);
- first_path = H5.H5PLget(original_entries);
- assertTrue("First path now : "+first_path + " ",first_path.compareToIgnoreCase("path_two")==0);
- plugin_entries = H5.H5PLsize();
- assertTrue("H5.H5PLsize: "+plugin_entries, (original_entries+2) == plugin_entries);
+ // Get the original number of paths
+ int nStartPaths = H5.H5PLsize();
+
+ int nPaths; /* # paths from H5PLSize() */
+ int nTruePaths = nStartPaths; /* What the # paths should be */
+ int index; /* Path table index */
+ String path; /* Path from H5PLget() */
+
+ // APPEND a path and ensure it was added correctly
+ String pathAppend = "path_append";
+ H5.H5PLappend(pathAppend);
+
+ nPaths = H5.H5PLsize();
+ nTruePaths++;
+ assertTrue("# paths should be " + nTruePaths + " but was " + nPaths, nTruePaths == nPaths);
+
+ index = nTruePaths - 1;
+ path = H5.H5PLget(index);
+ assertTrue("Path should be " + pathAppend + " but was " + path, path.compareToIgnoreCase(pathAppend) == 0);
+
+ // PREPEND a path and ensure it was added correctly
+ String pathPrepend = "path_prepend";
+ H5.H5PLprepend(pathPrepend);
+
+ nPaths = H5.H5PLsize();
+ nTruePaths++;
+ assertTrue("# paths should be " + nTruePaths + " but was " + nPaths, nTruePaths == nPaths);
+
+ index = 0;
+ path = H5.H5PLget(index);
+ assertTrue("Path should be " + pathPrepend + " but was " + path, path.compareToIgnoreCase(pathPrepend) == 0);
+
+ // INSERT a path and ensure it was added correctly
+ // Inserting at the index == # of start paths ensures we're in the middle
+ String pathInsert = "path_insert";
+ index = nStartPaths;
+ H5.H5PLinsert(pathInsert, index);
+
+ nPaths = H5.H5PLsize();
+ nTruePaths++;
+ assertTrue("# paths should be " + nTruePaths + " but was " + nPaths, nTruePaths == nPaths);
+
+ path = H5.H5PLget(index);
+ assertTrue("Path should be " + pathInsert + " but was " + path, path.compareToIgnoreCase(pathInsert) == 0);
+
+ // REPLACE the path we just added and ensure it updated correctly
+ String pathReplace = "path_replace";
+ index = nStartPaths;
+ H5.H5PLreplace(pathReplace, index);
+
+ nPaths = H5.H5PLsize();
+ assertTrue("# paths should be " + nTruePaths + " but was " + nPaths, nTruePaths == nPaths);
+
+ path = H5.H5PLget(index);
+ assertTrue("Path should be " + pathReplace + " but was " + path, path.compareToIgnoreCase(pathReplace) == 0);
+
+ // REMOVE the path we just replaced and check that the table was compacted
+ // The (index+1) path should move down to fill the space when the path is removed.
+ index = nStartPaths;
+ String pathRemove = H5.H5PLget(index + 1);
+ H5.H5PLremove(index);
+
+ nPaths = H5.H5PLsize();
+ nTruePaths--;
+ assertTrue("# paths should be " + nTruePaths + " but was " + nPaths, nTruePaths == nPaths);
+
+ path = H5.H5PLget(index);
+ assertTrue("Path should be " + pathRemove + " but was " + path, path.compareToIgnoreCase(pathRemove) == 0);
}
catch (Throwable err) {
err.printStackTrace();