Add test cases for Serialization of subclasses of Complex
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@787521 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0c9be1c546
commit
fee5df4e6f
|
@ -28,6 +28,7 @@ import junit.framework.TestCase;
|
|||
*/
|
||||
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 @@ public class ComplexTest extends TestCase {
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue