summaryrefslogtreecommitdiffstats
path: root/java/test/TestH5D.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/test/TestH5D.java')
-rw-r--r--java/test/TestH5D.java555
1 files changed, 315 insertions, 240 deletions
diff --git a/java/test/TestH5D.java b/java/test/TestH5D.java
index dac3a9c..4bab1a9 100644
--- a/java/test/TestH5D.java
+++ b/java/test/TestH5D.java
@@ -33,46 +33,50 @@ import org.junit.Test;
import org.junit.rules.TestName;
public class TestH5D {
- @Rule public TestName testname = new TestName();
+ @Rule
+ public TestName testname = new TestName();
private static final String H5_FILE = "testD.h5";
- private static final int DIM_X = 4;
- private static final int DIM_Y = 6;
- private static final int RANK = 2;
- long H5fid = HDF5Constants.H5I_INVALID_HID;
- long H5faplid = HDF5Constants.H5I_INVALID_HID;
- long H5dsid = HDF5Constants.H5I_INVALID_HID;
- long H5dtid = HDF5Constants.H5I_INVALID_HID;
- long H5did = HDF5Constants.H5I_INVALID_HID;
- long H5did0 = HDF5Constants.H5I_INVALID_HID;
- long H5dcpl_id = HDF5Constants.H5I_INVALID_HID;
- long[] H5dims = { DIM_X, DIM_Y };
+ private static final int DIM_X = 4;
+ private static final int DIM_Y = 6;
+ private static final int RANK = 2;
+ long H5fid = HDF5Constants.H5I_INVALID_HID;
+ long H5faplid = HDF5Constants.H5I_INVALID_HID;
+ long H5dsid = HDF5Constants.H5I_INVALID_HID;
+ long H5dtid = HDF5Constants.H5I_INVALID_HID;
+ long H5did = HDF5Constants.H5I_INVALID_HID;
+ long H5did0 = HDF5Constants.H5I_INVALID_HID;
+ long H5dcpl_id = HDF5Constants.H5I_INVALID_HID;
+ long[] H5dims = {DIM_X, DIM_Y};
// Values for the status of space allocation
enum H5D_space_status {
- H5D_SPACE_STATUS_ERROR(-1), H5D_SPACE_STATUS_NOT_ALLOCATED(0), H5D_SPACE_STATUS_PART_ALLOCATED(
- 1), H5D_SPACE_STATUS_ALLOCATED(2);
+ H5D_SPACE_STATUS_ERROR(-1),
+ H5D_SPACE_STATUS_NOT_ALLOCATED(0),
+ H5D_SPACE_STATUS_PART_ALLOCATED(1),
+ H5D_SPACE_STATUS_ALLOCATED(2);
private int code;
- H5D_space_status(int space_status) {
- this.code = space_status;
- }
+ H5D_space_status(int space_status) { this.code = space_status; }
- public int getCode() {
- return this.code;
- }
+ public int getCode() { return this.code; }
}
- private final void _deleteFile(String filename) {
+ private final void _deleteFile(String filename)
+ {
File file = new File(filename);
if (file.exists()) {
- try {file.delete();}
- catch (SecurityException e) {}
+ try {
+ file.delete();
+ }
+ catch (SecurityException e) {
+ }
}
}
- private final void _createPDataset(long fid, long dsid, String name, long dcpl_val) {
+ private final void _createPDataset(long fid, long dsid, String name, long dcpl_val)
+ {
try {
H5dcpl_id = H5.H5Pcreate(dcpl_val);
@@ -94,9 +98,8 @@ public class TestH5D {
}
try {
- H5did0 = H5.H5Dcreate(fid, name,
- HDF5Constants.H5T_STD_I32BE, dsid,
- HDF5Constants.H5P_DEFAULT, H5dcpl_id, HDF5Constants.H5P_DEFAULT);
+ H5did0 = H5.H5Dcreate(fid, name, HDF5Constants.H5T_STD_I32BE, dsid, HDF5Constants.H5P_DEFAULT,
+ H5dcpl_id, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
err.printStackTrace();
@@ -105,7 +108,8 @@ public class TestH5D {
assertTrue("TestH5D._createPDataset.H5Dcreate: ", H5did0 >= 0);
}
- private final void _createChunkDataset(long fid, long dsid, String name, long dapl) {
+ private final void _createChunkDataset(long fid, long dsid, String name, long dapl)
+ {
try {
H5dcpl_id = H5.H5Pcreate(HDF5Constants.H5P_DATASET_CREATE);
@@ -127,9 +131,8 @@ public class TestH5D {
}
try {
- H5did = H5.H5Dcreate(fid, name,
- HDF5Constants.H5T_STD_I32BE, dsid,
- HDF5Constants.H5P_DEFAULT, H5dcpl_id, dapl);
+ H5did = H5.H5Dcreate(fid, name, HDF5Constants.H5T_STD_I32BE, dsid, HDF5Constants.H5P_DEFAULT,
+ H5dcpl_id, dapl);
}
catch (Throwable err) {
err.printStackTrace();
@@ -138,11 +141,11 @@ public class TestH5D {
assertTrue("TestH5D._createChunkDataset.H5Dcreate: ", H5did >= 0);
}
- private final void _createDataset(long fid, long dsid, String name, long dapl) {
+ private final void _createDataset(long fid, long dsid, String name, long dapl)
+ {
try {
- H5did = H5.H5Dcreate(fid, name,
- HDF5Constants.H5T_STD_I32BE, dsid,
- HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, dapl);
+ H5did = H5.H5Dcreate(fid, name, HDF5Constants.H5T_STD_I32BE, dsid, HDF5Constants.H5P_DEFAULT,
+ HDF5Constants.H5P_DEFAULT, dapl);
}
catch (Throwable err) {
err.printStackTrace();
@@ -151,7 +154,8 @@ public class TestH5D {
assertTrue("TestH5D._createDataset.H5Dcreate: ", H5did >= 0);
}
- private final void _createVLDataset(long fid, long dsid, String name, long dapl) {
+ private final void _createVLDataset(long fid, long dsid, String name, long dapl)
+ {
try {
H5dtid = H5.H5Tcopy(HDF5Constants.H5T_C_S1);
}
@@ -169,8 +173,8 @@ public class TestH5D {
fail("H5.H5Tset_size: " + err);
}
try {
- H5did = H5.H5Dcreate(fid, name, H5dtid, dsid,
- HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, dapl);
+ H5did = H5.H5Dcreate(fid, name, H5dtid, dsid, HDF5Constants.H5P_DEFAULT,
+ HDF5Constants.H5P_DEFAULT, dapl);
}
catch (Throwable err) {
err.printStackTrace();
@@ -179,99 +183,153 @@ public class TestH5D {
assertTrue("TestH5D._createVLDataset.H5Dcreate: ", H5did >= 0);
}
- private final void _closeH5file() throws HDF5LibraryException {
+ private final void _closeH5file() throws HDF5LibraryException
+ {
if (H5dcpl_id >= 0)
- try {H5.H5Pclose(H5dcpl_id);} catch (Exception ex) {}
+ try {
+ H5.H5Pclose(H5dcpl_id);
+ }
+ catch (Exception ex) {
+ }
if (H5did0 >= 0)
- try {H5.H5Dclose(H5did0);} catch (Exception ex) {}
+ try {
+ H5.H5Dclose(H5did0);
+ }
+ catch (Exception ex) {
+ }
if (H5did >= 0)
- try {H5.H5Dclose(H5did);} catch (Exception ex) {}
+ try {
+ H5.H5Dclose(H5did);
+ }
+ catch (Exception ex) {
+ }
if (H5dtid > 0)
- try {H5.H5Tclose(H5dtid);} catch (Exception ex) {}
+ try {
+ H5.H5Tclose(H5dtid);
+ }
+ catch (Exception ex) {
+ }
if (H5dsid > 0)
- try {H5.H5Sclose(H5dsid);} catch (Exception ex) {}
+ try {
+ H5.H5Sclose(H5dsid);
+ }
+ catch (Exception ex) {
+ }
if (H5fid > 0)
- try {H5.H5Fclose(H5fid);} catch (Exception ex) {}
+ try {
+ H5.H5Fclose(H5fid);
+ }
+ catch (Exception ex) {
+ }
}
- private final void _openH5file(String filename, String dsetname, long dapl) {
- try {
- H5fid = H5.H5Fopen(filename,
- HDF5Constants.H5F_ACC_RDONLY, HDF5Constants.H5P_DEFAULT);
- }
- catch (Throwable err) {
- err.printStackTrace();
- fail("TestH5D._openH5file: " + err);
- }
- assertTrue("TestH5D._openH5file: H5.H5Fopen: ",H5fid >= 0);
- try {
- H5did = H5.H5Dopen(H5fid, dsetname, dapl);
- }
- catch (Throwable err) {
- err.printStackTrace();
- fail("TestH5D._openH5file: " + err);
- }
- assertTrue("TestH5D._openH5file: H5.H5Dopen: ",H5did >= 0);
- try {
- H5dsid = H5.H5Dget_space(H5did);
- }
- catch (Throwable err) {
- err.printStackTrace();
- fail("TestH5D._openH5file: " + err);
- }
- assertTrue("TestH5D._openH5file: H5.H5Screate_simple: ",H5dsid > 0);
+ private final void _openH5file(String filename, String dsetname, long dapl)
+ {
+ try {
+ H5fid = H5.H5Fopen(filename, HDF5Constants.H5F_ACC_RDONLY, HDF5Constants.H5P_DEFAULT);
+ }
+ catch (Throwable err) {
+ err.printStackTrace();
+ fail("TestH5D._openH5file: " + err);
+ }
+ assertTrue("TestH5D._openH5file: H5.H5Fopen: ", H5fid >= 0);
+ try {
+ H5did = H5.H5Dopen(H5fid, dsetname, dapl);
+ }
+ catch (Throwable err) {
+ err.printStackTrace();
+ fail("TestH5D._openH5file: " + err);
+ }
+ assertTrue("TestH5D._openH5file: H5.H5Dopen: ", H5did >= 0);
+ try {
+ H5dsid = H5.H5Dget_space(H5did);
+ }
+ catch (Throwable err) {
+ err.printStackTrace();
+ fail("TestH5D._openH5file: " + err);
+ }
+ assertTrue("TestH5D._openH5file: H5.H5Screate_simple: ", H5dsid > 0);
}
@Before
- public void createH5file()
- throws NullPointerException, HDF5Exception {
- assertTrue("H5 open ids is 0",H5.getOpenIDCount()==0);
- System.out.print(testname.getMethodName());
+ public void createH5file() throws NullPointerException, HDF5Exception
+ {
+ assertTrue("H5 open ids is 0", H5.getOpenIDCount() == 0);
+ System.out.print(testname.getMethodName());
try {
H5faplid = H5.H5Pcreate(HDF5Constants.H5P_FILE_ACCESS);
- H5fid = H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_TRUNC,
- HDF5Constants.H5P_DEFAULT, H5faplid);
+ H5fid = H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT, H5faplid);
H5dsid = H5.H5Screate_simple(RANK, H5dims, null);
}
catch (Throwable err) {
err.printStackTrace();
fail("TestH5D.createH5file: " + err);
}
- assertTrue("TestH5D.createH5file: H5.H5Fcreate: ",H5fid >= 0);
- assertTrue("TestH5D.createH5file: H5.H5Screate_simple: ",H5dsid >= 0);
+ assertTrue("TestH5D.createH5file: H5.H5Fcreate: ", H5fid >= 0);
+ assertTrue("TestH5D.createH5file: H5.H5Screate_simple: ", H5dsid >= 0);
H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL);
}
@After
- public void deleteH5file() throws HDF5LibraryException {
+ public void deleteH5file() throws HDF5LibraryException
+ {
if (H5dcpl_id >= 0)
- try {H5.H5Pclose(H5dcpl_id);} catch (Exception ex) {}
+ try {
+ H5.H5Pclose(H5dcpl_id);
+ }
+ catch (Exception ex) {
+ }
if (H5did0 >= 0)
- try {H5.H5Dclose(H5did0);} catch (Exception ex) {}
+ try {
+ H5.H5Dclose(H5did0);
+ }
+ catch (Exception ex) {
+ }
if (H5did >= 0)
- try {H5.H5Dclose(H5did);} catch (Exception ex) {}
+ try {
+ H5.H5Dclose(H5did);
+ }
+ catch (Exception ex) {
+ }
if (H5dtid > 0)
- try {H5.H5Tclose(H5dtid);} catch (Exception ex) {}
+ try {
+ H5.H5Tclose(H5dtid);
+ }
+ catch (Exception ex) {
+ }
if (H5dsid > 0)
- try {H5.H5Sclose(H5dsid);} catch (Exception ex) {}
+ try {
+ H5.H5Sclose(H5dsid);
+ }
+ catch (Exception ex) {
+ }
if (H5faplid >= 0)
- try {H5.H5Pclose(H5faplid);} catch (Exception ex) {}
+ try {
+ H5.H5Pclose(H5faplid);
+ }
+ catch (Exception ex) {
+ }
if (H5fid > 0)
- try {H5.H5Fclose(H5fid);} catch (Exception ex) {}
+ try {
+ H5.H5Fclose(H5fid);
+ }
+ catch (Exception ex) {
+ }
_deleteFile(H5_FILE);
System.out.println();
}
@Test
- public void testH5Dcreate() {
+ public void testH5Dcreate()
+ {
long dataset_id = HDF5Constants.H5I_INVALID_HID;
try {
- dataset_id = H5.H5Dcreate(H5fid, "dset",
- HDF5Constants.H5T_STD_I32BE, H5dsid,
- HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
+ dataset_id =
+ H5.H5Dcreate(H5fid, "dset", HDF5Constants.H5T_STD_I32BE, H5dsid, HDF5Constants.H5P_DEFAULT,
+ HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
}
catch (Exception err) {
err.printStackTrace();
@@ -290,11 +348,12 @@ public class TestH5D {
}
@Test
- public void testH5Dcreate_anon() {
+ public void testH5Dcreate_anon()
+ {
long dataset_id = HDF5Constants.H5I_INVALID_HID;
try {
- dataset_id = H5.H5Dcreate_anon(H5fid, HDF5Constants.H5T_STD_I32BE,
- H5dsid, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
+ dataset_id = H5.H5Dcreate_anon(H5fid, HDF5Constants.H5T_STD_I32BE, H5dsid,
+ HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
}
catch (Exception err) {
err.printStackTrace();
@@ -313,13 +372,14 @@ public class TestH5D {
}
@Test
- public void testH5Dopen() {
+ public void testH5Dopen()
+ {
long dataset_id = HDF5Constants.H5I_INVALID_HID;
_createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT);
try {
H5.H5Dclose(H5did);
- H5did = HDF5Constants.H5I_INVALID_HID;
+ H5did = HDF5Constants.H5I_INVALID_HID;
dataset_id = H5.H5Dopen(H5fid, "dset", HDF5Constants.H5P_DEFAULT);
}
catch (Exception err) {
@@ -339,7 +399,8 @@ public class TestH5D {
}
@Test
- public void testH5Dget_storage_size_empty() {
+ public void testH5Dget_storage_size_empty()
+ {
long storage_size = 0;
_createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT);
@@ -354,10 +415,11 @@ public class TestH5D {
}
@Test
- public void testH5Dget_storage_size() {
+ public void testH5Dget_storage_size()
+ {
long storage_size = 0;
int[][] dset_data = new int[DIM_X][DIM_Y];
- int FILLVAL = 99;
+ int FILLVAL = 99;
_createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT);
// Initialize the dataset.
@@ -367,9 +429,8 @@ public class TestH5D {
try {
if (H5did >= 0)
- H5.H5Dwrite(H5did, HDF5Constants.H5T_NATIVE_INT,
- HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
- HDF5Constants.H5P_DEFAULT, dset_data[0]);
+ H5.H5Dwrite(H5did, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
+ HDF5Constants.H5P_DEFAULT, dset_data[0]);
}
catch (Exception e) {
e.printStackTrace();
@@ -382,21 +443,22 @@ public class TestH5D {
err.printStackTrace();
fail("testH5Dget_storage_size: " + err);
}
- assertTrue("testH5Dget_storage_size: "+storage_size, storage_size == DIM_X*DIM_Y*4);
+ assertTrue("testH5Dget_storage_size: " + storage_size, storage_size == DIM_X * DIM_Y * 4);
}
@Test
- public void testH5Dget_access_plist() {
- long dapl_id = HDF5Constants.H5I_INVALID_HID;
- long test_dapl_id = HDF5Constants.H5I_INVALID_HID;
- int[] mdc_nelmts1 = {0};
- int[] mdc_nelmts2 = {0};
+ public void testH5Dget_access_plist()
+ {
+ long dapl_id = HDF5Constants.H5I_INVALID_HID;
+ long test_dapl_id = HDF5Constants.H5I_INVALID_HID;
+ int[] mdc_nelmts1 = {0};
+ int[] mdc_nelmts2 = {0};
long[] rdcc_nelmts1 = {0};
long[] rdcc_nelmts2 = {0};
long[] rdcc_nbytes1 = {0};
long[] rdcc_nbytes2 = {0};
- double[] rdcc_w01 = {0};
- double[] rdcc_w02 = {0};
+ double[] rdcc_w01 = {0};
+ double[] rdcc_w02 = {0};
try {
test_dapl_id = H5.H5Pcreate(HDF5Constants.H5P_DATASET_ACCESS);
@@ -442,14 +504,15 @@ public class TestH5D {
catch (Exception err) {
err.printStackTrace();
}
- assertTrue("testH5Dget_access_plist: ", rdcc_nelmts2==rdcc_nelmts2 && rdcc_nbytes2==rdcc_nbytes2);
+ assertTrue("testH5Dget_access_plist: ", rdcc_nelmts2 == rdcc_nelmts2 && rdcc_nbytes2 == rdcc_nbytes2);
}
@Test
- public void testH5Dget_space_status() {
+ public void testH5Dget_space_status()
+ {
int[][] write_dset_data = new int[DIM_X][DIM_Y];
- int space_status = -1;
- int space_status0 = -1;
+ int space_status = -1;
+ int space_status0 = -1;
// Initialize the dataset.
for (int indx = 0; indx < DIM_X; indx++)
@@ -466,7 +529,8 @@ public class TestH5D {
catch (Exception e) {
e.printStackTrace();
}
- assertTrue("testH5Dget_space_status0 - H5.H5Dget_space_status: ", space_status0 == H5D_space_status.H5D_SPACE_STATUS_ALLOCATED.getCode());
+ assertTrue("testH5Dget_space_status0 - H5.H5Dget_space_status: ",
+ space_status0 == H5D_space_status.H5D_SPACE_STATUS_ALLOCATED.getCode());
// Retrieve and print space status and storage size for dset.
try {
@@ -475,12 +539,12 @@ public class TestH5D {
catch (Exception e) {
e.printStackTrace();
}
- assertFalse("testH5Dget_space_status - H5.H5Dget_space_status: ", space_status == H5D_space_status.H5D_SPACE_STATUS_ALLOCATED.getCode());
+ assertFalse("testH5Dget_space_status - H5.H5Dget_space_status: ",
+ space_status == H5D_space_status.H5D_SPACE_STATUS_ALLOCATED.getCode());
// Write the data to the dataset.
try {
- H5.H5Dwrite(H5did, HDF5Constants.H5T_NATIVE_INT,
- HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
+ H5.H5Dwrite(H5did, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
HDF5Constants.H5P_DEFAULT, write_dset_data);
}
catch (Exception e) {
@@ -494,16 +558,18 @@ public class TestH5D {
catch (Exception e) {
e.printStackTrace();
}
- assertTrue("testH5Dget_space_status - H5.H5Dget_space_status: ", space_status == H5D_space_status.H5D_SPACE_STATUS_ALLOCATED.getCode());
+ assertTrue("testH5Dget_space_status - H5.H5Dget_space_status: ",
+ space_status == H5D_space_status.H5D_SPACE_STATUS_ALLOCATED.getCode());
}
@Test(expected = HDF5LibraryException.class)
- public void testH5Dget_space_closed() throws Throwable {
+ public void testH5Dget_space_closed() throws Throwable
+ {
long dataset_id = HDF5Constants.H5I_INVALID_HID;
try {
- dataset_id = H5.H5Dcreate(H5fid, "dset",
- HDF5Constants.H5T_STD_I32BE, H5dsid,
- HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
+ dataset_id =
+ H5.H5Dcreate(H5fid, "dset", HDF5Constants.H5T_STD_I32BE, H5dsid, HDF5Constants.H5P_DEFAULT,
+ HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
err.printStackTrace();
@@ -516,7 +582,8 @@ public class TestH5D {
}
@Test
- public void testH5Dget_space() {
+ public void testH5Dget_space()
+ {
long dataspace_id = HDF5Constants.H5I_INVALID_HID;
_createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT);
@@ -540,12 +607,13 @@ public class TestH5D {
}
@Test(expected = HDF5LibraryException.class)
- public void testH5Dget_type_closed() throws Throwable {
+ public void testH5Dget_type_closed() throws Throwable
+ {
long dataset_id = HDF5Constants.H5I_INVALID_HID;
try {
- dataset_id = H5.H5Dcreate(H5fid, "dset",
- HDF5Constants.H5T_STD_I32BE, H5dsid,
- HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
+ dataset_id =
+ H5.H5Dcreate(H5fid, "dset", HDF5Constants.H5T_STD_I32BE, H5dsid, HDF5Constants.H5P_DEFAULT,
+ HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
err.printStackTrace();
@@ -558,7 +626,8 @@ public class TestH5D {
}
@Test
- public void testH5Dget_type() {
+ public void testH5Dget_type()
+ {
long datatype_id = HDF5Constants.H5I_INVALID_HID;
_createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT);
@@ -582,9 +651,10 @@ public class TestH5D {
}
@Test
- public void testH5Dget_offset() {
+ public void testH5Dget_offset()
+ {
int[][] write_dset_data = new int[DIM_X][DIM_Y];
- long dset_address = 0;
+ long dset_address = 0;
_createDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT);
try {
@@ -600,8 +670,7 @@ public class TestH5D {
}
// Write the data to the dataset.
try {
- H5.H5Dwrite(H5did, HDF5Constants.H5T_NATIVE_INT,
- HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
+ H5.H5Dwrite(H5did, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
HDF5Constants.H5P_DEFAULT, write_dset_data);
}
catch (Exception e) {
@@ -621,15 +690,16 @@ public class TestH5D {
}
@Test
- public void testH5Dfill_null() {
- int[] buf_data = new int[DIM_X*DIM_Y];
+ public void testH5Dfill_null()
+ {
+ int[] buf_data = new int[DIM_X * DIM_Y];
// Initialize memory buffer
for (int indx = 0; indx < DIM_X; indx++)
for (int jndx = 0; jndx < DIM_Y; jndx++) {
buf_data[(indx * DIM_Y) + jndx] = indx * jndx - jndx;
}
- byte[] buf_array = HDFNativeData.intToByte(0, DIM_X*DIM_Y, buf_data);
+ byte[] buf_array = HDFNativeData.intToByte(0, DIM_X * DIM_Y, buf_data);
// Fill selection in memory
try {
@@ -644,12 +714,13 @@ public class TestH5D {
// Verify memory buffer the hard way
for (int indx = 0; indx < DIM_X; indx++)
for (int jndx = 0; jndx < DIM_Y; jndx++)
- assertTrue("H5.H5Dfill: [" + indx+","+jndx + "] ", buf_data[(indx * DIM_Y) + jndx] == 0);
+ assertTrue("H5.H5Dfill: [" + indx + "," + jndx + "] ", buf_data[(indx * DIM_Y) + jndx] == 0);
}
@Test
- public void testH5Dfill() {
- int[] buf_data = new int[DIM_X*DIM_Y];
+ public void testH5Dfill()
+ {
+ int[] buf_data = new int[DIM_X * DIM_Y];
byte[] fill_value = HDFNativeData.intToByte(254);
// Initialize memory buffer
@@ -657,11 +728,12 @@ public class TestH5D {
for (int jndx = 0; jndx < DIM_Y; jndx++) {
buf_data[(indx * DIM_Y) + jndx] = indx * jndx - jndx;
}
- byte[] buf_array = HDFNativeData.intToByte(0, DIM_X*DIM_Y, buf_data);
+ byte[] buf_array = HDFNativeData.intToByte(0, DIM_X * DIM_Y, buf_data);
// Fill selection in memory
try {
- H5.H5Dfill(fill_value, HDF5Constants.H5T_NATIVE_UINT, buf_array, HDF5Constants.H5T_NATIVE_UINT, H5dsid);
+ H5.H5Dfill(fill_value, HDF5Constants.H5T_NATIVE_UINT, buf_array, HDF5Constants.H5T_NATIVE_UINT,
+ H5dsid);
}
catch (Exception err) {
err.printStackTrace();
@@ -672,46 +744,51 @@ public class TestH5D {
// Verify memory buffer the hard way
for (int indx = 0; indx < DIM_X; indx++)
for (int jndx = 0; jndx < DIM_Y; jndx++)
- assertTrue("H5.H5Dfill: [" + indx+","+jndx + "] ", buf_data[(indx * DIM_Y) + jndx] == 254);
+ assertTrue("H5.H5Dfill: [" + indx + "," + jndx + "] ",
+ buf_data[(indx * DIM_Y) + jndx] == 254);
}
@Test
- public void testH5Diterate() {
+ public void testH5Diterate()
+ {
final int SPACE_RANK = 2;
final int SPACE_FILL = 254;
class H5D_iter_data implements H5D_iterate_t {
- public int fill_value; /* The fill value to check */
- public long fill_curr_coord; /* Current coordinate to examine */
- public long[] fill_coords; /* Pointer to selection's coordinates */
+ public int fill_value; /* The fill value to check */
+ public long fill_curr_coord; /* Current coordinate to examine */
+ public long[] fill_coords; /* Pointer to selection's coordinates */
}
H5D_iterate_t iter_data = new H5D_iter_data();
class H5D_iter_callback implements H5D_iterate_cb {
- public int callback(byte[] elem_buf, long elem_id, int ndim, long[] point, H5D_iterate_t op_data) {
- //Check value in current buffer location
+ public int callback(byte[] elem_buf, long elem_id, int ndim, long[] point, H5D_iterate_t op_data)
+ {
+ // Check value in current buffer location
int element = HDFNativeData.byteToInt(elem_buf, 0);
- if(element != ((H5D_iter_data)op_data).fill_value)
+ if (element != ((H5D_iter_data)op_data).fill_value)
return -1;
- //Check number of dimensions
- if(ndim != SPACE_RANK)
- return(-1);
- //Check Coordinates
+ // Check number of dimensions
+ if (ndim != SPACE_RANK)
+ return (-1);
+ // Check Coordinates
long[] fill_coords = new long[2];
- fill_coords[0] = ((H5D_iter_data)op_data).fill_coords[(int) (2 * ((H5D_iter_data)op_data).fill_curr_coord)];
- fill_coords[1] = ((H5D_iter_data)op_data).fill_coords[(int) (2 * ((H5D_iter_data)op_data).fill_curr_coord) + 1];
+ fill_coords[0] =
+ ((H5D_iter_data)op_data).fill_coords[(int)(2 * ((H5D_iter_data)op_data).fill_curr_coord)];
+ fill_coords[1] = ((H5D_iter_data)op_data)
+ .fill_coords[(int)(2 * ((H5D_iter_data)op_data).fill_curr_coord) + 1];
((H5D_iter_data)op_data).fill_curr_coord++;
- if(fill_coords[0] != point[0])
- return(-1);
- if(fill_coords[1] != point[1])
- return(-1);
+ if (fill_coords[0] != point[0])
+ return (-1);
+ if (fill_coords[1] != point[1])
+ return (-1);
- return(0);
+ return (0);
}
}
- int[] buf_data = new int[DIM_X*DIM_Y];
+ int[] buf_data = new int[DIM_X * DIM_Y];
byte[] fill_value = HDFNativeData.intToByte(SPACE_FILL);
// Initialize memory buffer
@@ -719,11 +796,12 @@ public class TestH5D {
for (int jndx = 0; jndx < DIM_Y; jndx++) {
buf_data[(indx * DIM_Y) + jndx] = indx * jndx - jndx;
}
- byte[] buf_array = HDFNativeData.intToByte(0, DIM_X*DIM_Y, buf_data);
+ byte[] buf_array = HDFNativeData.intToByte(0, DIM_X * DIM_Y, buf_data);
// Fill selection in memory
try {
- H5.H5Dfill(fill_value, HDF5Constants.H5T_NATIVE_UINT, buf_array, HDF5Constants.H5T_NATIVE_UINT, H5dsid);
+ H5.H5Dfill(fill_value, HDF5Constants.H5T_NATIVE_UINT, buf_array, HDF5Constants.H5T_NATIVE_UINT,
+ H5dsid);
}
catch (Exception err) {
err.printStackTrace();
@@ -731,19 +809,20 @@ public class TestH5D {
}
// Initialize the iterator structure
- ((H5D_iter_data)iter_data).fill_value = SPACE_FILL;
+ ((H5D_iter_data)iter_data).fill_value = SPACE_FILL;
((H5D_iter_data)iter_data).fill_curr_coord = 0;
// Set the coordinates of the selection
- ((H5D_iter_data)iter_data).fill_coords = new long[DIM_X*DIM_Y*SPACE_RANK]; /* Coordinates of selection */
+ ((H5D_iter_data)iter_data).fill_coords =
+ new long[DIM_X * DIM_Y * SPACE_RANK]; /* Coordinates of selection */
for (int indx = 0; indx < DIM_X; indx++)
for (int jndx = 0; jndx < DIM_Y; jndx++) {
- ((H5D_iter_data)iter_data).fill_coords[2*(indx * DIM_Y + jndx)] = indx;
- ((H5D_iter_data)iter_data).fill_coords[2*(indx * DIM_Y + jndx) + 1] = jndx;
+ ((H5D_iter_data)iter_data).fill_coords[2 * (indx * DIM_Y + jndx)] = indx;
+ ((H5D_iter_data)iter_data).fill_coords[2 * (indx * DIM_Y + jndx) + 1] = jndx;
} /* end for */
// Iterate through selection, verifying correct data
H5D_iterate_cb iter_cb = new H5D_iter_callback();
- int op_status = -1;
+ int op_status = -1;
try {
op_status = H5.H5Diterate(buf_array, HDF5Constants.H5T_NATIVE_UINT, H5dsid, iter_cb, iter_data);
}
@@ -755,47 +834,51 @@ public class TestH5D {
}
@Test
- public void testH5Diterate_write() {
+ public void testH5Diterate_write()
+ {
final int SPACE_RANK = 2;
final int SPACE_FILL = 254;
class H5D_iter_data implements H5D_iterate_t {
- public int fill_value; /* The fill value to check */
- public long fill_curr_coord; /* Current coordinate to examine */
- public long[] fill_coords; /* Pointer to selection's coordinates */
+ public int fill_value; /* The fill value to check */
+ public long fill_curr_coord; /* Current coordinate to examine */
+ public long[] fill_coords; /* Pointer to selection's coordinates */
}
H5D_iterate_t iter_data = new H5D_iter_data();
class H5D_iter_callback implements H5D_iterate_cb {
- public int callback(byte[] elem_buf, long elem_id, int ndim, long[] point, H5D_iterate_t op_data) {
- //Check value in current buffer location
+ public int callback(byte[] elem_buf, long elem_id, int ndim, long[] point, H5D_iterate_t op_data)
+ {
+ // Check value in current buffer location
int element = HDFNativeData.byteToInt(elem_buf, 0);
- if(element != ((H5D_iter_data)op_data).fill_value)
+ if (element != ((H5D_iter_data)op_data).fill_value)
return -1;
- //Check number of dimensions
- if(ndim != SPACE_RANK)
- return(-1);
- //Check Coordinates
+ // Check number of dimensions
+ if (ndim != SPACE_RANK)
+ return (-1);
+ // Check Coordinates
long[] fill_coords = new long[2];
- fill_coords[0] = ((H5D_iter_data)op_data).fill_coords[(int) (2 * ((H5D_iter_data)op_data).fill_curr_coord)];
- fill_coords[1] = ((H5D_iter_data)op_data).fill_coords[(int) (2 * ((H5D_iter_data)op_data).fill_curr_coord) + 1];
+ fill_coords[0] =
+ ((H5D_iter_data)op_data).fill_coords[(int)(2 * ((H5D_iter_data)op_data).fill_curr_coord)];
+ fill_coords[1] = ((H5D_iter_data)op_data)
+ .fill_coords[(int)(2 * ((H5D_iter_data)op_data).fill_curr_coord) + 1];
((H5D_iter_data)op_data).fill_curr_coord++;
- if(fill_coords[0] != point[0])
- return(-1);
- if(fill_coords[1] != point[1])
- return(-1);
+ if (fill_coords[0] != point[0])
+ return (-1);
+ if (fill_coords[1] != point[1])
+ return (-1);
element -= 128;
byte[] new_elembuf = HDFNativeData.intToByte(element);
- elem_buf[0] = new_elembuf[0];
- elem_buf[1] = new_elembuf[1];
- elem_buf[2] = new_elembuf[2];
- elem_buf[3] = new_elembuf[3];
- return(0);
+ elem_buf[0] = new_elembuf[0];
+ elem_buf[1] = new_elembuf[1];
+ elem_buf[2] = new_elembuf[2];
+ elem_buf[3] = new_elembuf[3];
+ return (0);
}
}
- int[] buf_data = new int[DIM_X*DIM_Y];
+ int[] buf_data = new int[DIM_X * DIM_Y];
byte[] fill_value = HDFNativeData.intToByte(SPACE_FILL);
// Initialize memory buffer
@@ -803,11 +886,12 @@ public class TestH5D {
for (int jndx = 0; jndx < DIM_Y; jndx++) {
buf_data[(indx * DIM_Y) + jndx] = indx * jndx - jndx;
}
- byte[] buf_array = HDFNativeData.intToByte(0, DIM_X*DIM_Y, buf_data);
+ byte[] buf_array = HDFNativeData.intToByte(0, DIM_X * DIM_Y, buf_data);
// Fill selection in memory
try {
- H5.H5Dfill(fill_value, HDF5Constants.H5T_NATIVE_UINT, buf_array, HDF5Constants.H5T_NATIVE_UINT, H5dsid);
+ H5.H5Dfill(fill_value, HDF5Constants.H5T_NATIVE_UINT, buf_array, HDF5Constants.H5T_NATIVE_UINT,
+ H5dsid);
}
catch (Exception err) {
err.printStackTrace();
@@ -815,19 +899,20 @@ public class TestH5D {
}
// Initialize the iterator structure
- ((H5D_iter_data)iter_data).fill_value = SPACE_FILL;
+ ((H5D_iter_data)iter_data).fill_value = SPACE_FILL;
((H5D_iter_data)iter_data).fill_curr_coord = 0;
// Set the coordinates of the selection
- ((H5D_iter_data)iter_data).fill_coords = new long[DIM_X*DIM_Y*SPACE_RANK]; /* Coordinates of selection */
+ ((H5D_iter_data)iter_data).fill_coords =
+ new long[DIM_X * DIM_Y * SPACE_RANK]; /* Coordinates of selection */
for (int indx = 0; indx < DIM_X; indx++)
for (int jndx = 0; jndx < DIM_Y; jndx++) {
- ((H5D_iter_data)iter_data).fill_coords[2*(indx * DIM_Y + jndx)] = indx;
- ((H5D_iter_data)iter_data).fill_coords[2*(indx * DIM_Y + jndx) + 1] = jndx;
+ ((H5D_iter_data)iter_data).fill_coords[2 * (indx * DIM_Y + jndx)] = indx;
+ ((H5D_iter_data)iter_data).fill_coords[2 * (indx * DIM_Y + jndx) + 1] = jndx;
} /* end for */
// Iterate through selection, verifying correct data
H5D_iterate_cb iter_cb = new H5D_iter_callback();
- int op_status = -1;
+ int op_status = -1;
try {
op_status = H5.H5Diterate(buf_array, HDF5Constants.H5T_NATIVE_UINT, H5dsid, iter_cb, iter_data);
}
@@ -842,29 +927,27 @@ public class TestH5D {
// Verify memory buffer the hard way
for (int indx = 0; indx < DIM_X; indx++)
for (int jndx = 0; jndx < DIM_Y; jndx++)
- assertTrue("H5.H5Diterate: [" + indx+","+jndx + "] "+buf_data[(indx * DIM_Y) + jndx], buf_data[(indx * DIM_Y) + jndx] == 126);
+ assertTrue("H5.H5Diterate: [" + indx + "," + jndx + "] " + buf_data[(indx * DIM_Y) + jndx],
+ buf_data[(indx * DIM_Y) + jndx] == 126);
}
@Test
- public void testH5Dvlen_get_buf_size() {
- String[] str_data = { "Parting", "is such", "sweet", "sorrow.",
- "Testing", "one", "two", "three.",
- "Dog,", "man's", "best", "friend.",
- "Diamonds", "are", "a", "girls!",
- "S A", "T U R", "D A Y", "night",
- "That's", "all", "folks", "!!!" };
- long vl_size = -1; /* Number of bytes used */
+ public void testH5Dvlen_get_buf_size()
+ {
+ String[] str_data = {"Parting", "is such", "sweet", "sorrow.", "Testing", "one", "two", "three.",
+ "Dog,", "man's", "best", "friend.", "Diamonds", "are", "a", "girls!",
+ "S A", "T U R", "D A Y", "night", "That's", "all", "folks", "!!!"};
+ long vl_size = -1; /* Number of bytes used */
long str_data_bytes = 0;
for (int idx = 0; idx < str_data.length; idx++)
- str_data_bytes += str_data[idx].length() + 1; //Account for terminating null
+ str_data_bytes += str_data[idx].length() + 1; // Account for terminating null
_createVLDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT);
try {
if ((H5did >= 0) && (H5dtid >= 0))
- H5.H5Dwrite_VLStrings(H5did, H5dtid,
- HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
- HDF5Constants.H5P_DEFAULT, str_data);
+ H5.H5Dwrite_VLStrings(H5did, H5dtid, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
+ HDF5Constants.H5P_DEFAULT, str_data);
}
catch (Exception e) {
e.printStackTrace();
@@ -879,63 +962,55 @@ public class TestH5D {
}
@Test(expected = IllegalArgumentException.class)
- public void testH5Dvlen_read_invalid_buffer() throws Throwable {
- String[] str_data = { "Parting", "is such", "sweet", "sorrow.",
- "Testing", "one", "two", "three.",
- "Dog,", "man's", "best", "friend.",
- "Diamonds", "are", "a", "girls!",
- "S A", "T U R", "D A Y", "night",
- "That's", "all", "folks", "!!!" };
- byte[] read_data = new byte[512];
+ public void testH5Dvlen_read_invalid_buffer() throws Throwable
+ {
+ String[] str_data = {"Parting", "is such", "sweet", "sorrow.", "Testing", "one", "two", "three.",
+ "Dog,", "man's", "best", "friend.", "Diamonds", "are", "a", "girls!",
+ "S A", "T U R", "D A Y", "night", "That's", "all", "folks", "!!!"};
+ byte[] read_data = new byte[512];
_createVLDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT);
try {
- H5.H5Dwrite_VLStrings(H5did, H5dtid,
- HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
- HDF5Constants.H5P_DEFAULT, str_data);
+ H5.H5Dwrite_VLStrings(H5did, H5dtid, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
+ HDF5Constants.H5P_DEFAULT, str_data);
}
catch (Exception e) {
e.printStackTrace();
}
- H5.H5Dread(H5did, H5dtid,
- HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
- HDF5Constants.H5P_DEFAULT, read_data);
+ H5.H5Dread(H5did, H5dtid, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, HDF5Constants.H5P_DEFAULT,
+ read_data);
}
@Test
- public void testH5Dvlen_write_read() {
- String[] str_wdata = { "Parting", "is such", "sweet", "sorrow.",
- "Testing", "one", "two", "three.",
- "Dog,", "man's", "best", "friend.",
- "Diamonds", "are", "a", "girls!",
- "S A", "T U R", "D A Y", "night",
- "That's", "all", "folks", "!!!" };
+ public void testH5Dvlen_write_read()
+ {
+ String[] str_wdata = {"Parting", "is such", "sweet", "sorrow.", "Testing", "one", "two", "three.",
+ "Dog,", "man's", "best", "friend.", "Diamonds", "are", "a", "girls!",
+ "S A", "T U R", "D A Y", "night", "That's", "all", "folks", "!!!"};
String[] str_rdata = new String[DIM_X * DIM_Y];
_createVLDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DEFAULT);
try {
if ((H5did >= 0) && (H5dtid >= 0))
- H5.H5Dwrite_VLStrings(H5did, H5dtid,
- HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
- HDF5Constants.H5P_DEFAULT, str_wdata);
+ H5.H5Dwrite_VLStrings(H5did, H5dtid, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
+ HDF5Constants.H5P_DEFAULT, str_wdata);
}
catch (Exception e) {
e.printStackTrace();
}
try {
if ((H5did >= 0) && (H5dtid >= 0))
- H5.H5Dread_VLStrings(H5did, H5dtid,
- HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
- HDF5Constants.H5P_DEFAULT, str_rdata);
+ H5.H5Dread_VLStrings(H5did, H5dtid, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
+ HDF5Constants.H5P_DEFAULT, str_rdata);
}
catch (Exception e) {
e.printStackTrace();
}
for (int v = 0; v < DIM_X * DIM_Y; v++)
- assertTrue("testH5Dvlen_write_read " + str_wdata[v] + " == " + str_rdata[v], str_wdata[v] == str_wdata[v]);
+ assertTrue("testH5Dvlen_write_read " + str_wdata[v] + " == " + str_rdata[v],
+ str_wdata[v] == str_wdata[v]);
}
-
}