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