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 21:19:27 UTC

[commons-math] branch master updated: JUnit5 assertThrows ExponentialDecayFunctionTest (#222)

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 5e497dd70 JUnit5 assertThrows ExponentialDecayFunctionTest (#222)
5e497dd70 is described below

commit 5e497dd7040a8e15c789776f45f8bedccea80fbc
Author: John Patrick <14...@users.noreply.github.com>
AuthorDate: Thu Oct 20 22:19:22 2022 +0100

    JUnit5 assertThrows ExponentialDecayFunctionTest (#222)
---
 .../sofm/util/ExponentialDecayFunctionTest.java    | 27 +++++++++++++++-------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/commons-math-neuralnet/src/test/java/org/apache/commons/math4/neuralnet/sofm/util/ExponentialDecayFunctionTest.java b/commons-math-neuralnet/src/test/java/org/apache/commons/math4/neuralnet/sofm/util/ExponentialDecayFunctionTest.java
index e4ac612ff..407a17a74 100644
--- a/commons-math-neuralnet/src/test/java/org/apache/commons/math4/neuralnet/sofm/util/ExponentialDecayFunctionTest.java
+++ b/commons-math-neuralnet/src/test/java/org/apache/commons/math4/neuralnet/sofm/util/ExponentialDecayFunctionTest.java
@@ -20,25 +20,35 @@ package org.apache.commons.math4.neuralnet.sofm.util;
 import org.junit.Test;
 import org.junit.Assert;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 /**
  * Tests for {@link ExponentialDecayFunction} class
  */
 public class ExponentialDecayFunctionTest {
-    @Test(expected = IllegalArgumentException.class)
+
+    @Test
     public void testPrecondition1() {
-        new ExponentialDecayFunction(0d, 0d, 2);
+        assertThrows(IllegalArgumentException.class, () ->
+                new ExponentialDecayFunction(0d, 0d, 2));
     }
-    @Test(expected = IllegalArgumentException.class)
+
+    @Test
     public void testPrecondition2() {
-        new ExponentialDecayFunction(1d, 0d, 2);
+        assertThrows(IllegalArgumentException.class, () ->
+                new ExponentialDecayFunction(1d, 0d, 2));
     }
-    @Test(expected = IllegalArgumentException.class)
+
+    @Test
     public void testPrecondition3() {
-        new ExponentialDecayFunction(1d, 1d, 100);
+        assertThrows(IllegalArgumentException.class, () ->
+                new ExponentialDecayFunction(1d, 1d, 100));
     }
-    @Test(expected = IllegalArgumentException.class)
+
+    @Test
     public void testPrecondition4() {
-        new ExponentialDecayFunction(1d, 0.2, 0);
+        assertThrows(IllegalArgumentException.class, () ->
+                new ExponentialDecayFunction(1d, 0.2, 0));
     }
 
     @Test
@@ -52,4 +62,5 @@ public class ExponentialDecayFunctionTest {
         Assert.assertEquals(valueAtN, f.applyAsDouble(n), 0d);
         Assert.assertEquals(0, f.applyAsDouble(Long.MAX_VALUE), 0d);
     }
+
 }