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 00a1482 Additional tests for SafeNorm
00a1482 is described below
commit 00a14829720144fd48c97c999fd5bd76298033a9
Author: Alex Herbert <[email protected]>
AuthorDate: Thu May 20 22:32:00 2021 +0100
Additional tests for SafeNorm
---
.../apache/commons/numbers/arrays/SafeNormTest.java | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
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 169c498..de81135 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
@@ -66,6 +66,24 @@ class SafeNormTest {
}
@Test
+ void testNaN() {
+ final double[] v = new double[] {0, Double.NaN, 0};
+ Assertions.assertEquals(Double.NaN, SafeNorm.value(v));
+ }
+
+ @Test
+ void testInf() {
+ final double[] v = new double[] {0, Double.NEGATIVE_INFINITY, 0};
+ Assertions.assertEquals(Double.POSITIVE_INFINITY, SafeNorm.value(v));
+ }
+
+ @Test
+ void testOverflow() {
+ final double[] v = new double[] {0, Double.MAX_VALUE,
Double.MAX_VALUE, 0};
+ Assertions.assertEquals(Double.POSITIVE_INFINITY, SafeNorm.value(v));
+ }
+
+ @Test
void testTinyAndSmallNormal() {
// Ensure the sum of the squared values for 'normal' values
(1e-19*1e-19)
// is less than largest tiny value (1e-20)