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


##########
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:
   Done. The infinity test now checks the round trip for both signs, and I 
added testParseImaginarySpecialValue covering NaN, +Infinity and -Infinity in 
the imaginary part (parsed back from format output). All pass with the patch.



-- 
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