aherbert commented on code in PR #326:
URL: https://github.com/apache/commons-math/pull/326#discussion_r3378964678


##########
commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/util/ComplexFormatAbstractTest.java:
##########
@@ -277,6 +277,22 @@ public void testPaseNegativeInfinity() {
         Assert.assertEquals(expected, actual);
     }
 
+    @Test
+    public void testParseRealNan() {
+        // a real-only special value runs to the last character of the string
+        Complex expected = Complex.ofCartesian(Double.NaN, 0);
+        Assert.assertEquals(expected, complexFormat.parse("(NaN)"));
+        Assert.assertEquals(expected, 
complexFormat.parse(complexFormat.format(expected)));
+    }
+
+    @Test
+    public void testParseRealInfinity() {
+        Complex positive = Complex.ofCartesian(Double.POSITIVE_INFINITY, 0);
+        Assert.assertEquals(positive, complexFormat.parse("(Infinity)"));
+        Complex negative = Complex.ofCartesian(Double.NEGATIVE_INFINITY, 0);

Review Comment:
   This should test the round-trip:
   ```java
   Assert.assertEquals(positive, 
complexFormat.parse(complexFormat.format(positive)));
   Assert.assertEquals(negative, 
complexFormat.parse(complexFormat.format(negative)));
   ```
   
   Parsing should also test special values in the imaginary part:
   ```java
   Complex.ofCartesian(1.23, Double.NaN);
   Complex.ofCartesian(1.23, Double.POSITIVE_INFINITY);
   Complex.ofCartesian(1.23, Double.NEGATIVE_INFINITY);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to