commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aherb...@apache.org
Subject [commons-numbers] branch master updated: Fix coverage in SafeNormTest
Date Sun, 05 Apr 2020 23:33:02 GMT
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


The following commit(s) were added to refs/heads/master by this push:
     new c0a449f  Fix coverage in SafeNormTest
c0a449f is described below

commit c0a449face3959bb0cf09c43402ba88a69d5b2ab
Author: Alex Herbert <aherbert@apache.org>
AuthorDate: Mon Apr 6 00:32:58 2020 +0100

    Fix coverage in SafeNormTest
    
    Drop the redundant 0d delta for assertEquals.
---
 .../apache/commons/numbers/arrays/SafeNormTest.java    | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/SafeNormTest.java
b/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/SafeNormTest.java
index 2b9aafe..82de37c 100644
--- a/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/SafeNormTest.java
+++ b/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/SafeNormTest.java
@@ -28,21 +28,21 @@ public class SafeNormTest {
     public void testTiny() {
         final double s = 1e-320;
         final double[] v = new double[] {s, s};
-        Assertions.assertEquals(Math.sqrt(2) * s, SafeNorm.value(v), 0d);
+        Assertions.assertEquals(Math.sqrt(2) * s, SafeNorm.value(v));
     }
 
     @Test
     public void testBig() {
         final double s = 1e300;
         final double[] v = new double[] {s, s};
-        Assertions.assertEquals(Math.sqrt(2) * s, SafeNorm.value(v), 0d);
+        Assertions.assertEquals(Math.sqrt(2) * s, SafeNorm.value(v));
     }
 
     @Test
     public void testOne3D() {
         final double s = 1;
         final double[] v = new double[] {s, s, s};
-        Assertions.assertEquals(Math.sqrt(3), SafeNorm.value(v), 0d);
+        Assertions.assertEquals(Math.sqrt(3), SafeNorm.value(v));
     }
 
     @Test
@@ -56,13 +56,21 @@ public class SafeNormTest {
     public void testSimple() {
         final double[] v = new double[] {-0.9, 8.7, -6.5, -4.3, -2.1, 0, 1.2, 3.4, -5.6,
7.8, 9.0};
         final double expected = direct(v);
-        Assertions.assertEquals(expected, SafeNorm.value(v), 0d);
+        Assertions.assertEquals(expected, SafeNorm.value(v));
     }
 
     @Test
     public void testZero() {
         final double[] v = new double[] {0, 0, 0, 0, 0};
-        Assertions.assertEquals(0d, SafeNorm.value(v), 0d);
+        Assertions.assertEquals(0d, SafeNorm.value(v));
+    }
+
+    @Test
+    public void testTinyAndSmallNormal() {
+        // Ensure the sum of the squared values for 'normal' values (1e-19*1e-19)
+        // is less than largest tiny value (1e-20)
+        final double[] v = new double[] {1e-20, 1e-19};
+        Assertions.assertEquals(Math.sqrt(101) * 1e-20, SafeNorm.value(v));
     }
 
     /**


Mime
View raw message