From fe418f6c2389122bbab2404046513fac9d6dab7e Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 19 Sep 2018 08:06:05 -0500 Subject: Use constants for test comparisons --- java/test/TestH5E.java | 6 +++--- java/test/TestH5Edefault.java | 44 +++++++++++++++++++++++-------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/java/test/TestH5E.java b/java/test/TestH5E.java index 656069a..7810c74 100644 --- a/java/test/TestH5E.java +++ b/java/test/TestH5E.java @@ -168,7 +168,7 @@ public class TestH5E { fail("H5.H5Epop: " + err); } - assertTrue("H5.H5Epop #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Epop #:" + num_msg, num_msg == 3); try { H5.H5Epop(current_stackid, 1); @@ -186,7 +186,7 @@ public class TestH5E { fail("H5.H5Epop: " + err); } - assertTrue("H5.H5Epop", num_msg == 3); + assertTrue("H5.H5Epop", num_msg == 2); } @Test @@ -314,7 +314,7 @@ public class TestH5E { err.printStackTrace(); fail("testH5Ewalk:H5Eget_num " + err); } - assertTrue("testH5Ewalk #:" + num_msg, num_msg == 4); + assertTrue("testH5Ewalk #:" + num_msg, num_msg == 3); try { H5.H5Ewalk2(current_stackid, HDF5Constants.H5E_WALK_UPWARD, walk_cb, walk_data); diff --git a/java/test/TestH5Edefault.java b/java/test/TestH5Edefault.java index 5324d3a..e6ac7fa 100644 --- a/java/test/TestH5Edefault.java +++ b/java/test/TestH5Edefault.java @@ -27,6 +27,10 @@ import org.junit.Test; import org.junit.rules.TestName; public class TestH5Edefault { + public static final int ERRSTACK_CNT = 3; + public static final int ERRSTACK_MTY_CNT = 0; + public static final int ERRSTACK_POP_CNT = 2; + @Rule public TestName testname = new TestName(); @Before @@ -91,7 +95,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == 4); + assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_CNT); //Save a copy of the current stack and clears the current stack try { @@ -122,7 +126,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); try { H5.H5Eclose_stack(stack_id); @@ -153,7 +157,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == 4); + assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_CNT); //Save a copy of the current stack and clears the current stack try { @@ -174,7 +178,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == 0); + assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_MTY_CNT); //Verify the copy has the correct number of messages try { @@ -184,7 +188,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); //Generate errors on default stack try { @@ -202,7 +206,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == 4); + assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_CNT); //Remove one message from the current stack try { @@ -213,7 +217,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: pop #:" + num_msg_default, num_msg_default == 3); + assertTrue("H5.H5Eget_current_stack: pop #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_POP_CNT); //Verify the copy still has the correct number of messages try { @@ -223,7 +227,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); } @Test(expected = IllegalArgumentException.class) @@ -293,7 +297,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eset_current_stack: " + err); } - assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); //Save a copy of the current stack try { @@ -314,7 +318,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eset_current_stack: " + err); } - assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); //Generate errors on default stack try { @@ -332,7 +336,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); //Remove one message from the current stack try { @@ -343,7 +347,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eset_current_stack: " + err); } - assertTrue("H5.H5Eset_current_stack: pop #:" + num_msg, num_msg == 3); + assertTrue("H5.H5Eset_current_stack: pop #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_POP_CNT); //Verify the copy still has the correct number of messages try { @@ -353,7 +357,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eset_current_stack: " + err); } - assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); try { H5.H5Eset_current_stack(stack_id); @@ -363,7 +367,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eset_current_stack: " + err); } - assertTrue("H5.H5Eset_current_stack: get_num - " + num_msg, num_msg == 4); + assertTrue("H5.H5Eset_current_stack: get_num - " + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); } @Test(expected = IllegalArgumentException.class) @@ -386,7 +390,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Epop: " + err); } - assertTrue("H5.H5Epop before #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Epop before #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); try { H5.H5Epop(HDF5Constants.H5E_DEFAULT, 1); num_msg = H5.H5Eget_num(HDF5Constants.H5E_DEFAULT); @@ -395,7 +399,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Epop: " + err); } - assertTrue("H5.H5Epop after #:" + num_msg, num_msg == 3); + assertTrue("H5.H5Epop after #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_POP_CNT); } @Test(expected = IllegalArgumentException.class) @@ -471,7 +475,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eclear2_with_msg: " + err); } - assertTrue("H5.H5Eclear2_with_msg before #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Eclear2_with_msg before #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); try { H5.H5Eclear2(HDF5Constants.H5E_DEFAULT); num_msg = H5.H5Eget_num(HDF5Constants.H5E_DEFAULT); @@ -480,7 +484,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eclear2_with_msg: " + err); } - assertTrue("H5.H5Eclear2_with_msg after #:" + num_msg, num_msg == 0); + assertTrue("H5.H5Eclear2_with_msg after #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_MTY_CNT); } @Test(expected = IllegalArgumentException.class) @@ -516,7 +520,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_num: " + err); } - assertTrue("H5.H5Eget_num #:" + num_msg, num_msg == 0); + assertTrue("H5.H5Eget_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_MTY_CNT); } @Test @@ -534,7 +538,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_num_with_msg: " + err); } - assertTrue("H5.H5Eget_num_with_msg #:" + num_msg, num_msg > 0); + assertTrue("H5.H5Eget_num_with_msg #:" + num_msg, num_msg > TestH5Edefault.ERRSTACK_MTY_CNT); } } -- cgit v0.12 From cd290ddecb084a4496f57d60ca8db10d8abdf5ee Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 19 Sep 2018 08:58:08 -0500 Subject: Add Constants to all ERR STK checks --- java/test/TestH5E.java | 16 ++++++++++------ java/test/TestH5Edefault.java | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/java/test/TestH5E.java b/java/test/TestH5E.java index 7810c74..a1ca42c 100644 --- a/java/test/TestH5E.java +++ b/java/test/TestH5E.java @@ -37,6 +37,10 @@ import org.junit.rules.TestName; public class TestH5E { @Rule public TestName testname = new TestName(); + + public static final int ERRSTACK_CNT = 3; + public static final int ERRSTACK_MTY_CNT = 0; + long hdf_java_classid = -1; long current_stackid = -1; @@ -158,7 +162,7 @@ public class TestH5E { fail("H5.H5Epop: " + err); } - assertTrue("H5.H5Epop #:" + num_msg, num_msg == 0); + assertTrue("H5.H5Epop #:" + num_msg, num_msg == TestH5E.ERRSTACK_MTY_CNT); try { num_msg = H5.H5Eget_num(current_stackid); @@ -168,7 +172,7 @@ public class TestH5E { fail("H5.H5Epop: " + err); } - assertTrue("H5.H5Epop #:" + num_msg, num_msg == 3); + assertTrue("H5.H5Epop #:" + num_msg, num_msg == TestH5E.ERRSTACK_CNT); try { H5.H5Epop(current_stackid, 1); @@ -186,7 +190,7 @@ public class TestH5E { fail("H5.H5Epop: " + err); } - assertTrue("H5.H5Epop", num_msg == 2); + assertTrue("H5.H5Epop", num_msg == TestH5E.ERRSTACK_CNT - 1); } @Test @@ -227,7 +231,7 @@ public class TestH5E { try { num_msg = H5.H5Eget_num(estack_id); - assertTrue("testH5Epush #:" + num_msg, num_msg == 0); + assertTrue("testH5Epush #:" + num_msg, num_msg == TestH5E.ERRSTACK_MTY_CNT); } catch (Throwable err) { err.printStackTrace(); @@ -238,7 +242,7 @@ public class TestH5E { try { num_msg = H5.H5Eget_num(estack_id); - assertTrue("testH5Epush #:" + num_msg, num_msg == 1); + assertTrue("testH5Epush #:" + num_msg, num_msg == TestH5E.ERRSTACK_CNT + 1); } catch (Throwable err) { err.printStackTrace(); @@ -314,7 +318,7 @@ public class TestH5E { err.printStackTrace(); fail("testH5Ewalk:H5Eget_num " + err); } - assertTrue("testH5Ewalk #:" + num_msg, num_msg == 3); + assertTrue("testH5Ewalk #:" + num_msg, num_msg == TestH5E.ERRSTACK_CNT); try { H5.H5Ewalk2(current_stackid, HDF5Constants.H5E_WALK_UPWARD, walk_cb, walk_data); diff --git a/java/test/TestH5Edefault.java b/java/test/TestH5Edefault.java index e6ac7fa..8365027 100644 --- a/java/test/TestH5Edefault.java +++ b/java/test/TestH5Edefault.java @@ -27,12 +27,12 @@ import org.junit.Test; import org.junit.rules.TestName; public class TestH5Edefault { + @Rule public TestName testname = new TestName(); + public static final int ERRSTACK_CNT = 3; public static final int ERRSTACK_MTY_CNT = 0; public static final int ERRSTACK_POP_CNT = 2; - @Rule public TestName testname = new TestName(); - @Before public void H5Eset_default_stack() { assertTrue("H5 open ids is 0",H5.getOpenIDCount()==0); -- cgit v0.12 From bd1be52990553fa700c0aad09a3adcd28012af2f Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 19 Sep 2018 08:59:03 -0500 Subject: Fix typo --- java/test/TestH5E.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/test/TestH5E.java b/java/test/TestH5E.java index a1ca42c..f6db1ed 100644 --- a/java/test/TestH5E.java +++ b/java/test/TestH5E.java @@ -242,7 +242,7 @@ public class TestH5E { try { num_msg = H5.H5Eget_num(estack_id); - assertTrue("testH5Epush #:" + num_msg, num_msg == TestH5E.ERRSTACK_CNT + 1); + assertTrue("testH5Epush #:" + num_msg, num_msg == TestH5E.ERRSTACK_MTY_CNT + 1); } catch (Throwable err) { err.printStackTrace(); -- cgit v0.12 From 59f36c5cdef1899742feb1c06ee09886e2d0a220 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 19 Sep 2018 10:52:43 -0500 Subject: Remove extra constant --- java/test/TestH5Edefault.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/java/test/TestH5Edefault.java b/java/test/TestH5Edefault.java index 8365027..b510936 100644 --- a/java/test/TestH5Edefault.java +++ b/java/test/TestH5Edefault.java @@ -31,7 +31,6 @@ public class TestH5Edefault { public static final int ERRSTACK_CNT = 3; public static final int ERRSTACK_MTY_CNT = 0; - public static final int ERRSTACK_POP_CNT = 2; @Before public void H5Eset_default_stack() { @@ -217,7 +216,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: pop #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_POP_CNT); + assertTrue("H5.H5Eget_current_stack: pop #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_CNT - 1); //Verify the copy still has the correct number of messages try { @@ -347,7 +346,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eset_current_stack: " + err); } - assertTrue("H5.H5Eset_current_stack: pop #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_POP_CNT); + assertTrue("H5.H5Eset_current_stack: pop #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT - 1); //Verify the copy still has the correct number of messages try { @@ -399,7 +398,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Epop: " + err); } - assertTrue("H5.H5Epop after #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_POP_CNT); + assertTrue("H5.H5Epop after #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT - 1); } @Test(expected = IllegalArgumentException.class) -- cgit v0.12