commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billbar...@apache.org
Subject svn commit: r787521 - /commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexTest.java
Date Tue, 23 Jun 2009 02:35:50 GMT
Author: billbarker
Date: Tue Jun 23 02:35:50 2009
New Revision: 787521

URL: http://svn.apache.org/viewvc?rev=787521&view=rev
Log:
Add test cases for Serialization of subclasses of Complex

Modified:
    commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexTest.java

Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexTest.java?rev=787521&r1=787520&r2=787521&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexTest.java (original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/complex/ComplexTest.java Tue
Jun 23 02:35:50 2009
@@ -28,6 +28,7 @@
  */
 public class ComplexTest extends TestCase {
     
+
     private double inf = Double.POSITIVE_INFINITY;
     private double neginf = Double.NEGATIVE_INFINITY;
     private double nan = Double.NaN;
@@ -912,6 +913,38 @@
         Complex infcmplx = (Complex)TestUtils.serializeAndRecover(infInf);
         assertEquals(infInf, infcmplx);
         assertTrue(infcmplx.isInfinite());
+        TestComplex tz = new TestComplex(3.0, 4.0);
+        assertEquals(tz, TestUtils.serializeAndRecover(tz));
+        TestComplex ntcmplx = (TestComplex)TestUtils.serializeAndRecover(new TestComplex(oneNaN));
+        assertEquals(nanZero, ntcmplx);
+        assertTrue(ntcmplx.isNaN());
+        TestComplex inftcmplx = (TestComplex)TestUtils.serializeAndRecover(new TestComplex(infInf));
+        assertEquals(infInf, inftcmplx);
+        assertTrue(inftcmplx.isInfinite());
+    }
+    
+    /**
+     * Class to test extending Complex
+     */
+    public static class TestComplex extends Complex {
+
+        /**
+         * Serialization identifier.
+         */
+        private static final long serialVersionUID = 3268726724160389237L;
+
+        public TestComplex(double real, double imaginary) {
+            super(real, imaginary);
+        }
+        
+        public TestComplex(Complex other){
+            this(other.getReal(), other.getImaginary());
+        }
+        
+        protected TestComplex createComplex(double real, double imaginary){
+            return new TestComplex(real, imaginary);
+        }
+
     }
 
 }



Mime
View raw message