diff --git a/src/main/java/org/apache/datasketches/thetacommon/BinomialBoundsN.java b/src/main/java/org/apache/datasketches/thetacommon/BinomialBoundsN.java index 1f06d5702..767a43e92 100644 --- a/src/main/java/org/apache/datasketches/thetacommon/BinomialBoundsN.java +++ b/src/main/java/org/apache/datasketches/thetacommon/BinomialBoundsN.java @@ -272,7 +272,7 @@ static void checkArgs(final long numSamples, final double theta, final int numSD "numSDev must only be 1,2, or 3 and numSamples must >= 0: numSDev=" + numSDev + ", numSamples=" + numSamples); } - if ((theta < 0.0) || (theta > 1.0)) { + if ((theta <= 0.0) || (theta > 1.0)) { throw new SketchesArgumentException("0.0 < theta <= 1.0: " + theta); } } diff --git a/src/test/java/org/apache/datasketches/thetacommon/BinomialBoundsNTest.java b/src/test/java/org/apache/datasketches/thetacommon/BinomialBoundsNTest.java index c991432a9..f0decae19 100644 --- a/src/test/java/org/apache/datasketches/thetacommon/BinomialBoundsNTest.java +++ b/src/test/java/org/apache/datasketches/thetacommon/BinomialBoundsNTest.java @@ -22,9 +22,7 @@ import static org.apache.datasketches.thetacommon.BinomialBoundsN.checkArgs; import static org.apache.datasketches.thetacommon.BinomialBoundsN.getLowerBound; import static org.apache.datasketches.thetacommon.BinomialBoundsN.getUpperBound; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +import static org.testng.Assert.*; import org.apache.datasketches.common.SketchesArgumentException; import org.apache.datasketches.thetacommon.BinomialBoundsN; @@ -119,17 +117,17 @@ public static void checkBounds() { @Test public static void checkCheckArgs() { - try { - checkArgs(-1L, 1.0, 1); - checkArgs(10L, 0.0, 1); - checkArgs(10L, 1.01, 1); - checkArgs(10L, 1.0, 3); - checkArgs(10L, 1.0, 0); - checkArgs(10L, 1.0, 4); - fail("Expected SketchesArgumentException"); - } catch (final SketchesArgumentException e) { - //pass - } + assertThrows(SketchesArgumentException.class, + () -> checkArgs(-1L, 1.0, 1)); + assertThrows(SketchesArgumentException.class, + () -> checkArgs(10L, 0.0, 1)); + assertThrows(SketchesArgumentException.class, + () -> checkArgs(10L, 1.01, 1)); + checkArgs(10L, 1.0, 3); + assertThrows(SketchesArgumentException.class, + () -> checkArgs(10L, 1.0, 0)); + assertThrows(SketchesArgumentException.class, + () -> checkArgs(10L, 1.0, 4)); } @Test