diff options
author | Allen Byrne <50328838+byrnHDF@users.noreply.github.com> | 2022-04-19 18:08:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-19 18:08:09 (GMT) |
commit | 03c3a5469542688a52d5a20242d2334408f8ba33 (patch) | |
tree | 46e30ea4aa99b68279fe80c9ad56b1a6bbfcfe7c /java/test/TestH5Dplist.java | |
parent | 32ef796e470da3e4de364d8dc469b03f5f6fafdc (diff) | |
download | hdf5-03c3a5469542688a52d5a20242d2334408f8ba33.zip hdf5-03c3a5469542688a52d5a20242d2334408f8ba33.tar.gz hdf5-03c3a5469542688a52d5a20242d2334408f8ba33.tar.bz2 |
Develop clang format java (#1653)
Diffstat (limited to 'java/test/TestH5Dplist.java')
-rw-r--r-- | java/test/TestH5Dplist.java | 268 |
1 files changed, 145 insertions, 123 deletions
diff --git a/java/test/TestH5Dplist.java b/java/test/TestH5Dplist.java index 774b9dd..b9e97f4 100644 --- a/java/test/TestH5Dplist.java +++ b/java/test/TestH5Dplist.java @@ -30,35 +30,42 @@ import org.junit.Test; import org.junit.rules.TestName; public class TestH5Dplist { - @Rule public TestName testname = new TestName(); + @Rule + public TestName testname = new TestName(); private static final String H5_FILE = "testDp.h5"; - private static final int DIM_X = 4; - private static final int DIM_Y = 7; - private static final int EDIM_X = 6; - private static final int EDIM_Y = 10; - private static final int CHUNK_X = 4; - private static final int CHUNK_Y = 4; - private static final int NDIMS = 2; - private static final int FILLVAL = 99; - private static final int RANK = 2; - long H5fid = HDF5Constants.H5I_INVALID_HID; - long H5dsid = HDF5Constants.H5I_INVALID_HID; - long H5did = HDF5Constants.H5I_INVALID_HID; - long H5dcpl_id = HDF5Constants.H5I_INVALID_HID; - long[] H5dims = { DIM_X, DIM_Y }; - long[] H5extdims = { EDIM_X, EDIM_Y }; - long[] H5chunk_dims = { CHUNK_X, CHUNK_Y }; - long[] H5maxdims = { HDF5Constants.H5S_UNLIMITED, HDF5Constants.H5S_UNLIMITED }; - - private final void _deleteFile(String filename) { + private static final int DIM_X = 4; + private static final int DIM_Y = 7; + private static final int EDIM_X = 6; + private static final int EDIM_Y = 10; + private static final int CHUNK_X = 4; + private static final int CHUNK_Y = 4; + private static final int NDIMS = 2; + private static final int FILLVAL = 99; + private static final int RANK = 2; + long H5fid = HDF5Constants.H5I_INVALID_HID; + long H5dsid = HDF5Constants.H5I_INVALID_HID; + long H5did = HDF5Constants.H5I_INVALID_HID; + long H5dcpl_id = HDF5Constants.H5I_INVALID_HID; + long[] H5dims = {DIM_X, DIM_Y}; + long[] H5extdims = {EDIM_X, EDIM_Y}; + long[] H5chunk_dims = {CHUNK_X, CHUNK_Y}; + long[] H5maxdims = {HDF5Constants.H5S_UNLIMITED, HDF5Constants.H5S_UNLIMITED}; + + 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); } @@ -78,7 +85,7 @@ public class TestH5Dplist { // Set the fill value for the dataset try { - int[] fill_value = { FILLVAL }; + int[] fill_value = {FILLVAL}; H5.H5Pset_fill_value(H5dcpl_id, HDF5Constants.H5T_NATIVE_INT, fill_value); } catch (Exception e) { @@ -98,136 +105,151 @@ public class TestH5Dplist { _createDataset(H5fid, H5dsid, "dset", H5dcpl_id, HDF5Constants.H5P_DEFAULT); } - private final void _createDataset(long fid, long dsid, String name, long dcpl, long dapl) { + private final void _createDataset(long fid, long dsid, String name, long dcpl, long dapl) + { try { - H5did = H5.H5Dcreate(fid, name, - HDF5Constants.H5T_STD_I32BE, dsid, - HDF5Constants.H5P_DEFAULT, dcpl, dapl); + H5did = H5.H5Dcreate(fid, name, HDF5Constants.H5T_STD_I32BE, dsid, HDF5Constants.H5P_DEFAULT, + dcpl, dapl); } catch (Throwable err) { err.printStackTrace(); fail("H5.H5Dcreate: " + err); } - assertTrue("TestH5Dplist._createDataset: ",H5did > 0); + assertTrue("TestH5Dplist._createDataset: ", H5did > 0); } @Before - public void createH5file() throws NullPointerException, HDF5Exception { - assertTrue("H5 open ids is 0",H5.getOpenIDCount()==0); + public void createH5file() throws NullPointerException, HDF5Exception + { + assertTrue("H5 open ids is 0", H5.getOpenIDCount() == 0); System.out.print(testname.getMethodName()); try { - H5fid = H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_TRUNC, - HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); + H5fid = H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_TRUNC, HDF5Constants.H5P_DEFAULT, + HDF5Constants.H5P_DEFAULT); H5dsid = H5.H5Screate_simple(RANK, H5dims, H5maxdims); } catch (Throwable err) { err.printStackTrace(); fail("TestH5Dplist.createH5file: " + err); } - assertTrue("TestH5Dplist.createH5file: H5.H5Fcreate: ",H5fid > 0); - assertTrue("TestH5Dplist.createH5file: H5.H5Screate_simple: ",H5dsid > 0); + assertTrue("TestH5Dplist.createH5file: H5.H5Fcreate: ", H5fid > 0); + assertTrue("TestH5Dplist.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 (H5did > 0) - try {H5.H5Dclose(H5did);} catch (Exception ex) {} + try { + H5.H5Dclose(H5did); + } + 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) { + } _deleteFile(H5_FILE); System.out.println(); } - @Test - public void testH5Dset_extent() { - int[][] write_dset_data = new int[DIM_X][DIM_Y]; - int[][] read_dset_data = new int[DIM_X][DIM_Y]; - int[][] extend_dset_data = new int[EDIM_X][EDIM_Y]; - - // Initialize the dataset. - for (int indx = 0; indx < DIM_X; indx++) - for (int jndx = 0; jndx < DIM_Y; jndx++) - write_dset_data[indx][jndx] = indx * jndx - jndx; - - _createPDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DATASET_CREATE); - - // Read values from the dataset, which has not been written to yet. - try { - H5.H5Dread(H5did, HDF5Constants.H5T_NATIVE_INT, - HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, - HDF5Constants.H5P_DEFAULT, read_dset_data); - } - catch (Exception e) { - e.printStackTrace(); - } - assertTrue("testH5Dset_extent - H5.H5Dread: ", read_dset_data[0][0] == 99); - - // Write the data to the dataset. - try { - H5.H5Dwrite(H5did, HDF5Constants.H5T_NATIVE_INT, - HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, - HDF5Constants.H5P_DEFAULT, write_dset_data); - } - catch (Exception e) { - e.printStackTrace(); - } - - // Read the data back. - try { - H5.H5Dread(H5did, HDF5Constants.H5T_NATIVE_INT, - HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, - HDF5Constants.H5P_DEFAULT, read_dset_data); - } - catch (Exception e) { - e.printStackTrace(); - } - assertTrue("testH5Dset_extent - H5.H5Dread: ", read_dset_data[3][6] == 12); - - // Extend the dataset. - try { - H5.H5Dset_extent(H5did, H5extdims); - } - catch (Exception e) { - e.printStackTrace(); - } - - // Read from the extended dataset. - try { - H5.H5Dread(H5did, HDF5Constants.H5T_NATIVE_INT, - HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, - HDF5Constants.H5P_DEFAULT, extend_dset_data); - } - catch (Exception e) { - e.printStackTrace(); - } - assertTrue("testH5Dset_extent - H5.H5Dread: ", extend_dset_data[3][6] == 12); - assertTrue("testH5Dset_extent - H5.H5Dread: ", extend_dset_data[4][8] == 99); - } - - @Test - public void testH5P_dset_no_attrs_hint() { - boolean ret_val_id = true; - - _createPDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DATASET_CREATE); - - try { - ret_val_id = H5.H5Pget_dset_no_attrs_hint(H5dcpl_id); - assertFalse("H5P_dset_no_attrs_hint", ret_val_id); - H5.H5Pset_dset_no_attrs_hint(H5dcpl_id, true); - ret_val_id = H5.H5Pget_dset_no_attrs_hint(H5dcpl_id); - assertTrue("H5P_dset_no_attrs_hint", ret_val_id); - } - catch (Throwable err) { - err.printStackTrace(); - fail("H5P_dset_no_attrs_hint: " + err); - } - } + @Test + public void testH5Dset_extent() + { + int[][] write_dset_data = new int[DIM_X][DIM_Y]; + int[][] read_dset_data = new int[DIM_X][DIM_Y]; + int[][] extend_dset_data = new int[EDIM_X][EDIM_Y]; + // Initialize the dataset. + for (int indx = 0; indx < DIM_X; indx++) + for (int jndx = 0; jndx < DIM_Y; jndx++) + write_dset_data[indx][jndx] = indx * jndx - jndx; + + _createPDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DATASET_CREATE); + + // Read values from the dataset, which has not been written to yet. + try { + H5.H5Dread(H5did, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, + HDF5Constants.H5P_DEFAULT, read_dset_data); + } + catch (Exception e) { + e.printStackTrace(); + } + assertTrue("testH5Dset_extent - H5.H5Dread: ", read_dset_data[0][0] == 99); + + // Write the data to the dataset. + try { + H5.H5Dwrite(H5did, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, + HDF5Constants.H5P_DEFAULT, write_dset_data); + } + catch (Exception e) { + e.printStackTrace(); + } + + // Read the data back. + try { + H5.H5Dread(H5did, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, + HDF5Constants.H5P_DEFAULT, read_dset_data); + } + catch (Exception e) { + e.printStackTrace(); + } + assertTrue("testH5Dset_extent - H5.H5Dread: ", read_dset_data[3][6] == 12); + + // Extend the dataset. + try { + H5.H5Dset_extent(H5did, H5extdims); + } + catch (Exception e) { + e.printStackTrace(); + } + + // Read from the extended dataset. + try { + H5.H5Dread(H5did, HDF5Constants.H5T_NATIVE_INT, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, + HDF5Constants.H5P_DEFAULT, extend_dset_data); + } + catch (Exception e) { + e.printStackTrace(); + } + assertTrue("testH5Dset_extent - H5.H5Dread: ", extend_dset_data[3][6] == 12); + assertTrue("testH5Dset_extent - H5.H5Dread: ", extend_dset_data[4][8] == 99); + } + + @Test + public void testH5P_dset_no_attrs_hint() + { + boolean ret_val_id = true; + + _createPDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DATASET_CREATE); + + try { + ret_val_id = H5.H5Pget_dset_no_attrs_hint(H5dcpl_id); + assertFalse("H5P_dset_no_attrs_hint", ret_val_id); + H5.H5Pset_dset_no_attrs_hint(H5dcpl_id, true); + ret_val_id = H5.H5Pget_dset_no_attrs_hint(H5dcpl_id); + assertTrue("H5P_dset_no_attrs_hint", ret_val_id); + } + catch (Throwable err) { + err.printStackTrace(); + fail("H5P_dset_no_attrs_hint: " + err); + } + } } |