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:16:17 UTC

[commons-math] branch master updated: JUnit5 assertThrows NeighbourhoodSizeFunctionFactoryTest (#218)

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 9b1d7c5f8 JUnit5 assertThrows NeighbourhoodSizeFunctionFactoryTest (#218)
9b1d7c5f8 is described below

commit 9b1d7c5f8a6e77efb5f65ce40a17fc88e060af9e
Author: John Patrick <14...@users.noreply.github.com>
AuthorDate: Thu Oct 20 22:16:12 2022 +0100

    JUnit5 assertThrows NeighbourhoodSizeFunctionFactoryTest (#218)
---
 .../sofm/NeighbourhoodSizeFunctionFactoryTest.java | 44 +++++++++++++++-------
 1 file changed, 30 insertions(+), 14 deletions(-)

diff --git a/commons-math-neuralnet/src/test/java/org/apache/commons/math4/neuralnet/sofm/NeighbourhoodSizeFunctionFactoryTest.java b/commons-math-neuralnet/src/test/java/org/apache/commons/math4/neuralnet/sofm/NeighbourhoodSizeFunctionFactoryTest.java
index d91a5a8f5..082e5d613 100644
--- a/commons-math-neuralnet/src/test/java/org/apache/commons/math4/neuralnet/sofm/NeighbourhoodSizeFunctionFactoryTest.java
+++ b/commons-math-neuralnet/src/test/java/org/apache/commons/math4/neuralnet/sofm/NeighbourhoodSizeFunctionFactoryTest.java
@@ -20,25 +20,35 @@ package org.apache.commons.math4.neuralnet.sofm;
 import org.junit.Test;
 import org.junit.Assert;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 /**
  * Tests for {@link NeighbourhoodSizeFunctionFactory} class.
  */
 public class NeighbourhoodSizeFunctionFactoryTest {
-    @Test(expected = IllegalArgumentException.class)
+
+    @Test
     public void testExponentialDecayPrecondition1() {
-        NeighbourhoodSizeFunctionFactory.exponentialDecay(0, 0, 2);
+        assertThrows(IllegalArgumentException.class, () ->
+                NeighbourhoodSizeFunctionFactory.exponentialDecay(0, 0, 2));
     }
-    @Test(expected = IllegalArgumentException.class)
+
+    @Test
     public void testExponentialDecayPrecondition2() {
-        NeighbourhoodSizeFunctionFactory.exponentialDecay(1, 0, 2);
+        assertThrows(IllegalArgumentException.class, () ->
+                NeighbourhoodSizeFunctionFactory.exponentialDecay(1, 0, 2));
     }
-    @Test(expected = IllegalArgumentException.class)
+
+    @Test
     public void testExponentialDecayPrecondition3() {
-        NeighbourhoodSizeFunctionFactory.exponentialDecay(1, 1, 100);
+        assertThrows(IllegalArgumentException.class, () ->
+                NeighbourhoodSizeFunctionFactory.exponentialDecay(1, 1, 100));
     }
-    @Test(expected = IllegalArgumentException.class)
+
+    @Test
     public void testExponentialDecayPrecondition4() {
-        NeighbourhoodSizeFunctionFactory.exponentialDecay(2, 1, 0);
+        assertThrows(IllegalArgumentException.class, () ->
+                NeighbourhoodSizeFunctionFactory.exponentialDecay(2, 1, 0));
     }
 
     @Test
@@ -54,17 +64,22 @@ public class NeighbourhoodSizeFunctionFactoryTest {
         Assert.assertEquals(0, f.value(Long.MAX_VALUE));
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testQuasiSigmoidDecayPrecondition1() {
-        NeighbourhoodSizeFunctionFactory.quasiSigmoidDecay(0d, -1d, 2);
+        assertThrows(IllegalArgumentException.class, () ->
+                NeighbourhoodSizeFunctionFactory.quasiSigmoidDecay(0d, -1d, 2));
     }
-    @Test(expected = IllegalArgumentException.class)
+
+    @Test
     public void testQuasiSigmoidDecayPrecondition3() {
-        NeighbourhoodSizeFunctionFactory.quasiSigmoidDecay(1d, 0d, 100);
+        assertThrows(IllegalArgumentException.class, () ->
+                NeighbourhoodSizeFunctionFactory.quasiSigmoidDecay(1d, 0d, 100));
     }
-    @Test(expected = IllegalArgumentException.class)
+
+    @Test
     public void testQuasiSigmoidDecayPrecondition4() {
-        NeighbourhoodSizeFunctionFactory.quasiSigmoidDecay(1d, -1d, 0);
+        assertThrows(IllegalArgumentException.class, () ->
+                NeighbourhoodSizeFunctionFactory.quasiSigmoidDecay(1d, -1d, 0));
     }
 
     @Test
@@ -78,4 +93,5 @@ public class NeighbourhoodSizeFunctionFactoryTest {
         Assert.assertEquals(init, f.value(0), 0d);
         Assert.assertEquals(0, f.value(Long.MAX_VALUE), 0d);
     }
+
 }