mirror of
https://github.com/apache/commons-math.git
synced 2025-03-03 23:19:05 +00:00
added test for BigFraction serialization
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@795900 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
56b70eb138
commit
d1d32776df
@ -31,9 +31,9 @@ import org.apache.commons.math.util.MathUtils;
|
||||
* @version $Revision$ $Date$
|
||||
* @since 2.0
|
||||
*/
|
||||
public class BigFraction extends Number implements FieldElement<BigFraction>, Comparable<BigFraction>, Serializable {
|
||||
// TODO: Add Serializable documentation
|
||||
// TODO: Check Serializable implementation
|
||||
public class BigFraction
|
||||
extends Number
|
||||
implements FieldElement<BigFraction>, Comparable<BigFraction>, Serializable {
|
||||
|
||||
/** A fraction representing "2 / 1". */
|
||||
public static final BigFraction TWO = new BigFraction(2);
|
||||
|
@ -20,6 +20,7 @@ import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import org.apache.commons.math.ConvergenceException;
|
||||
import org.apache.commons.math.TestUtils;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@ -550,4 +551,15 @@ public class BigFractionTest extends TestCase {
|
||||
assertEquals(new BigFraction(1594323, 8192), new BigFraction(2, 3).pow(BigInteger.valueOf(-13l)));
|
||||
}
|
||||
|
||||
public void testSerial() throws FractionConversionException {
|
||||
BigFraction[] fractions = {
|
||||
new BigFraction(3, 4), BigFraction.ONE, BigFraction.ZERO,
|
||||
new BigFraction(17), new BigFraction(Math.PI, 1000),
|
||||
new BigFraction(-5, 2)
|
||||
};
|
||||
for (BigFraction fraction : fractions) {
|
||||
assertEquals(fraction, TestUtils.serializeAndRecover(fraction));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user