You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2022/10/20 20:57:46 UTC

[commons-math] branch master updated: JUnit5 assertThrows TransformUtilsTest (#214)

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-math.git


The following commit(s) were added to refs/heads/master by this push:
     new e4d77683f JUnit5 assertThrows TransformUtilsTest (#214)
e4d77683f is described below

commit e4d77683f57f1e99ee99db7669ccf7660fff8696
Author: John Patrick <14...@users.noreply.github.com>
AuthorDate: Thu Oct 20 21:57:39 2022 +0100

    JUnit5 assertThrows TransformUtilsTest (#214)
---
 .../commons/math4/transform/TransformUtilsTest.java   | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/commons-math-transform/src/test/java/org/apache/commons/math4/transform/TransformUtilsTest.java b/commons-math-transform/src/test/java/org/apache/commons/math4/transform/TransformUtilsTest.java
index e273e71e0..c1b3599ab 100644
--- a/commons-math-transform/src/test/java/org/apache/commons/math4/transform/TransformUtilsTest.java
+++ b/commons-math-transform/src/test/java/org/apache/commons/math4/transform/TransformUtilsTest.java
@@ -23,26 +23,32 @@ import org.junit.Test;
 
 import org.apache.commons.math3.analysis.function.Sin;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 /**
  * Tests for {@link TransformUtils}.
  */
 public class TransformUtilsTest {
+
     private static final Sin SIN_FUNCTION = new Sin();
     private static final DoubleUnaryOperator SIN = x -> SIN_FUNCTION.value(x);
 
-    @Test(expected = TransformException.class)
+    @Test
     public void testSampleWrongBounds() {
-        TransformUtils.sample(SIN, Math.PI, 0.0, 10);
+        assertThrows(TransformException.class, () ->
+                TransformUtils.sample(SIN, Math.PI, 0.0, 10));
     }
 
-    @Test(expected = TransformException.class)
+    @Test
     public void testSampleNegativeNumberOfPoints() {
-        TransformUtils.sample(SIN, 0.0, Math.PI, -1);
+        assertThrows(TransformException.class, () ->
+                TransformUtils.sample(SIN, 0.0, Math.PI, -1));
     }
 
-    @Test(expected = TransformException.class)
+    @Test
     public void testSampleNullNumberOfPoints() {
-        TransformUtils.sample(SIN, 0.0, Math.PI, 0);
+        assertThrows(TransformException.class, () ->
+                TransformUtils.sample(SIN, 0.0, Math.PI, 0));
     }
 
     @Test
@@ -56,4 +62,5 @@ public class TransformUtilsTest {
             Assert.assertEquals("x = " + x, Math.sin(x), actual[i], 1e-15);
         }
     }
+
 }