diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2022-04-21 05:24:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-21 05:24:35 (GMT) |
commit | ec14985c8555bda02021568ea20295384a2cef7e (patch) | |
tree | 491c1f08a68d92e400d939d96fefdc7bfef57ddc /java/test/TestH5Tbasic.java | |
parent | bc62da7eb911727497475d1cc90991230f33fa3d (diff) | |
download | hdf5-ec14985c8555bda02021568ea20295384a2cef7e.zip hdf5-ec14985c8555bda02021568ea20295384a2cef7e.tar.gz hdf5-ec14985c8555bda02021568ea20295384a2cef7e.tar.bz2 |
VFD SWMR: Merges from develop (#1670)
* Cleans up SWMR test scripts (both legacy and VFD)
* Brings over format source changes for Java
* Normalization of HL, Fortran, C++, Java w/ develop
* Removes the STATIC flavor of FUNC_ENTER macros (#1622)
* Removes the STATIC flavor of FUNC_ENTER macros
* Remove H5_NO_ALIGNMENT_RESTRICTIONS (#1426)
* Do not conditionally compile code that uses a pointer dereference
and assignment to copy a potentially unaligned variable to aligned
automatic storage, or vice versa. Instead, always use naked `memcpy(3)`s.
Disassembling the generated code reveals that the `memcpy(3)`s optimize
(`-O3`) to a single `mov` instruction for x86_64, which is not strict
about alignment.
This change reduces the size of code and scripts by 143 lines, eases
our way to cross-compilation, and avoids invoking undefined behavior.
* Committing clang-format changes
* Per discussion, use HD and add comments.
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
* Removes unused definitions from module headers (#1624)
* Misc stuff from develop (includes some parallel things)
* Brings over SWMR test quiet mode changes from develop
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'java/test/TestH5Tbasic.java')
-rw-r--r-- | java/test/TestH5Tbasic.java | 99 |
1 files changed, 66 insertions, 33 deletions
diff --git a/java/test/TestH5Tbasic.java b/java/test/TestH5Tbasic.java index 7aac2ab..8fb1e58 100644 --- a/java/test/TestH5Tbasic.java +++ b/java/test/TestH5Tbasic.java @@ -15,6 +15,7 @@ package test; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; + import hdf.hdf5lib.H5; import hdf.hdf5lib.HDF5Constants; @@ -25,24 +26,28 @@ import org.junit.Test; import org.junit.rules.TestName; public class TestH5Tbasic { - @Rule public TestName testname = new TestName(); + @Rule + public TestName testname = new TestName(); @Before - public void checkOpenIDs() { - assertTrue("H5 open ids is 0",H5.getOpenIDCount()==0); + public void checkOpenIDs() + { + assertTrue("H5 open ids is 0", H5.getOpenIDCount() == 0); System.out.print(testname.getMethodName()); } @After - public void nextTestName() { + public void nextTestName() + { System.out.println(); } @Test - public void testH5Tcopy() { + public void testH5Tcopy() + { long H5strdid = HDF5Constants.H5I_INVALID_HID; try { H5strdid = H5.H5Tcopy(HDF5Constants.H5T_C_S1); - assertTrue("H5.H5Tcopy",H5strdid > 0); + assertTrue("H5.H5Tcopy", H5strdid > 0); } catch (Throwable err) { err.printStackTrace(); @@ -50,18 +55,23 @@ public class TestH5Tbasic { } finally { if (H5strdid >= 0) - try {H5.H5Tclose(H5strdid);} catch (Exception ex) {} + try { + H5.H5Tclose(H5strdid); + } + catch (Exception ex) { + } } } @Test - public void testH5Tequal() { + public void testH5Tequal() + { long H5strdid = HDF5Constants.H5I_INVALID_HID; try { H5strdid = H5.H5Tcopy(HDF5Constants.H5T_C_S1); - assertTrue("H5.H5Tcopy",H5strdid > 0); + assertTrue("H5.H5Tcopy", H5strdid > 0); boolean teq = H5.H5Tequal(HDF5Constants.H5T_C_S1, H5strdid); - assertTrue("H5.H5Tequal",teq); + assertTrue("H5.H5Tequal", teq); } catch (Throwable err) { err.printStackTrace(); @@ -69,18 +79,23 @@ public class TestH5Tbasic { } finally { if (H5strdid >= 0) - try {H5.H5Tclose(H5strdid);} catch (Exception ex) {} + try { + H5.H5Tclose(H5strdid); + } + catch (Exception ex) { + } } } @Test - public void testH5Tequal_not() { + public void testH5Tequal_not() + { long H5strdid = HDF5Constants.H5I_INVALID_HID; try { H5strdid = H5.H5Tcopy(HDF5Constants.H5T_STD_U64LE); - assertTrue("H5.H5Tcopy",H5strdid > 0); + assertTrue("H5.H5Tcopy", H5strdid > 0); boolean teq = H5.H5Tequal(HDF5Constants.H5T_IEEE_F32BE, H5strdid); - assertFalse("H5.H5Tequal",teq); + assertFalse("H5.H5Tequal", teq); } catch (Throwable err) { err.printStackTrace(); @@ -88,22 +103,27 @@ public class TestH5Tbasic { } finally { if (H5strdid >= 0) - try {H5.H5Tclose(H5strdid);} catch (Exception ex) {} + try { + H5.H5Tclose(H5strdid); + } + catch (Exception ex) { + } } } @Test - public void testH5Tconvert() { - String[] strs = {"a1234","b1234"}; - int srcLen = 5; - int dstLen = 10; - long srcId = HDF5Constants.H5I_INVALID_HID; - long dstId = HDF5Constants.H5I_INVALID_HID; - int dimSize = strs.length; - byte[] buf = new byte[dimSize*dstLen]; - - for (int i=0; i<dimSize; i++) - System.arraycopy(strs[i].getBytes(), 0, buf, i*srcLen, 5); + public void testH5Tconvert() + { + String[] strs = {"a1234", "b1234"}; + int srcLen = 5; + int dstLen = 10; + long srcId = HDF5Constants.H5I_INVALID_HID; + long dstId = HDF5Constants.H5I_INVALID_HID; + int dimSize = strs.length; + byte[] buf = new byte[dimSize * dstLen]; + + for (int i = 0; i < dimSize; i++) + System.arraycopy(strs[i].getBytes(), 0, buf, i * srcLen, 5); try { srcId = H5.H5Tcopy(HDF5Constants.H5T_C_S1); @@ -119,22 +139,31 @@ public class TestH5Tbasic { fail("testH5Tconvert: " + err); } finally { - try {H5.H5Tclose(srcId);} catch (Exception ex) {} - try {H5.H5Tclose(dstId);} catch (Exception ex) {} + try { + H5.H5Tclose(srcId); + } + catch (Exception ex) { + } + try { + H5.H5Tclose(dstId); + } + catch (Exception ex) { + } } - for (int i=0; i<strs.length; i++) { - assertTrue((new String(buf, i*dstLen, dstLen)).startsWith(strs[i])); + for (int i = 0; i < strs.length; i++) { + assertTrue((new String(buf, i * dstLen, dstLen)).startsWith(strs[i])); } } @Test - public void testH5Torder_size() { + public void testH5Torder_size() + { long H5strdid = HDF5Constants.H5I_INVALID_HID; try { // Fixed length string H5strdid = H5.H5Tcopy(HDF5Constants.H5T_C_S1); - assertTrue("H5.H5Tcopy",H5strdid > 0); + assertTrue("H5.H5Tcopy", H5strdid > 0); H5.H5Tset_size(H5strdid, (long)5); assertTrue(HDF5Constants.H5T_ORDER_NONE == H5.H5Tget_order(H5strdid)); H5.H5Tset_order(H5strdid, HDF5Constants.H5T_ORDER_NONE); @@ -152,7 +181,11 @@ public class TestH5Tbasic { } finally { if (H5strdid >= 0) - try {H5.H5Tclose(H5strdid);} catch (Exception ex) {} + try { + H5.H5Tclose(H5strdid); + } + catch (Exception ex) { + } } } } |