This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit ebbbf929bd0745a1cd3f27e1092f9636439a7f92
Author: aherbert <aherb...@apache.org>
AuthorDate: Mon Jun 29 16:18:29 2020 +0100

    Use assertThrows
---
 .../java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java | 8 ++------
 .../org/apache/commons/numbers/rootfinder/BrentSolverTest.java    | 2 +-
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git 
a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java
 
b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java
index a86ae4c..dc9ef9b 100644
--- 
a/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java
+++ 
b/commons-numbers-core/src/test/java/org/apache/commons/numbers/core/ArithmeticUtilsTest.java
@@ -304,12 +304,8 @@ public class ArithmeticUtilsTest {
 
         Assertions.assertEquals(BigInteger.valueOf(1801088541L), 
ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(7L)));
         Assertions.assertEquals(BigInteger.ONE, ArithmeticUtils.pow(twentyOne, 
BigInteger.ZERO));
-        try {
-            ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(-7L));
-            Assertions.fail("Expecting IllegalArgumentException");
-        } catch (IllegalArgumentException e) {
-            // expected behavior
-        }
+        Assertions.assertThrows(IllegalArgumentException.class, () ->
+            ArithmeticUtils.pow(twentyOne, BigInteger.valueOf(-7L)));
 
         BigInteger bigOne =
             new BigInteger("1543786922199448028351389769265814882661837148" +
diff --git 
a/commons-numbers-rootfinder/src/test/java/org/apache/commons/numbers/rootfinder/BrentSolverTest.java
 
b/commons-numbers-rootfinder/src/test/java/org/apache/commons/numbers/rootfinder/BrentSolverTest.java
index 516aaef..40cf641 100644
--- 
a/commons-numbers-rootfinder/src/test/java/org/apache/commons/numbers/rootfinder/BrentSolverTest.java
+++ 
b/commons-numbers-rootfinder/src/test/java/org/apache/commons/numbers/rootfinder/BrentSolverTest.java
@@ -153,7 +153,7 @@ public class BrentSolverTest {
         Assertions.assertTrue(f.getCallsCount() <= 15);
 
         final MonitoredFunction f2 = new MonitoredFunction(func, 10);
-        final IllegalArgumentException ex = 
Assertions.assertThrows(IllegalArgumentException.class,
+        final IllegalStateException ex = 
Assertions.assertThrows(IllegalStateException.class,
             () -> solver.findRoot(f2, 0.85, 5), "Expected too many calls 
condition");
         // Ensure expected error condition.
         Assertions.assertNotEquals(-1, ex.getMessage().indexOf("too many 
calls"));

Reply via email to