Replaced obsolete exceptions.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1178195 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2011-10-02 15:05:26 +00:00
parent a08f9179d3
commit 7c81ac50a2
9 changed files with 82 additions and 102 deletions

View File

@ -22,6 +22,7 @@ import java.math.BigDecimal;
import org.apache.commons.math.exception.MathArithmeticException;
import org.apache.commons.math.exception.NotStrictlyPositiveException;
import org.apache.commons.math.exception.NumberIsTooLargeException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.fraction.BigFraction;
import org.apache.commons.math.fraction.BigFractionField;
@ -263,7 +264,8 @@ public class KolmogorovSmirnovDistributionImpl implements KolmogorovSmirnovDistr
*
* @param d statistic
* @return H matrix
* @throws MathArithmeticException
* @throws NumberIsTooLargeException if fractional part is greater than 1
* @throws FractionConversionException
* if algorithm fails to convert {@code h} to a
* {@link org.apache.commons.math.fraction.BigFraction} in
* expressing {@code d} as {@code (k - h) / m} for integer
@ -278,7 +280,7 @@ public class KolmogorovSmirnovDistributionImpl implements KolmogorovSmirnovDistr
double hDouble = k - n * d;
if (hDouble >= 1) {
throw new ArithmeticException("Could not ");
throw new NumberIsTooLargeException(hDouble, 1.0, false);
}
BigFraction h = null;
@ -289,12 +291,7 @@ public class KolmogorovSmirnovDistributionImpl implements KolmogorovSmirnovDistr
try {
h = new BigFraction(hDouble, 1.0e-10, 10000);
} catch (FractionConversionException e2) {
try {
h = new BigFraction(hDouble, 1.0e-5, 10000);
} catch (FractionConversionException e3) {
//throw new MathArithmeticException(hDouble, 10000);
throw new MathArithmeticException(LocalizedFormats.CANNOT_CONVERT_OBJECT_TO_FRACTION, hDouble);
}
h = new BigFraction(hDouble, 1.0e-5, 10000);
}
}

View File

@ -56,7 +56,6 @@ public enum LocalizedFormats implements Localizable {
CANNOT_COMPUTE_BETA_DENSITY_AT_0_FOR_SOME_ALPHA("cannot compute beta density at 0 when alpha = {0,number}"),
CANNOT_COMPUTE_BETA_DENSITY_AT_1_FOR_SOME_BETA("cannot compute beta density at 1 when beta = %.3g"),
CANNOT_COMPUTE_NTH_ROOT_FOR_NEGATIVE_N("cannot compute nth root for null or negative n: {0}"),
CANNOT_CONVERT_OBJECT_TO_FRACTION("cannot convert given object to a fraction number: {0}"),
CANNOT_DISCARD_NEGATIVE_NUMBER_OF_ELEMENTS("cannot discard a negative number of elements ({0})"),
CANNOT_FORMAT_INSTANCE_AS_3D_VECTOR("cannot format a {0} instance as a 3D vector"),
CANNOT_FORMAT_INSTANCE_AS_COMPLEX("cannot format a {0} instance as a complex number"),
@ -317,11 +316,10 @@ public enum LocalizedFormats implements Localizable {
UNKNOWN_MODE("unknown mode {0}, known modes: {1} ({2}), {3} ({4}), {5} ({6}), {7} ({8}), {9} ({10}) and {11} ({12})"),
UNKNOWN_PARAMETER("unknown parameter {0}"),
UNMATCHED_ODE_IN_EXPANDED_SET("ode does not match the main ode set in the extended set"),
CANNOT_PARSE_AS_TYPE("string {0} unparseable (from position {1}) as an object of type {2}"), /* keep */
CANNOT_PARSE("string {0} unparseable (from position {1})"), /* keep */
CANNOT_PARSE_AS_TYPE("string \"{0}\" unparseable (from position {1}) as an object of type {2}"), /* keep */
CANNOT_PARSE("string \"{0}\" unparseable (from position {1})"), /* keep */
UNPARSEABLE_3D_VECTOR("unparseable 3D vector: \"{0}\""),
UNPARSEABLE_COMPLEX_NUMBER("unparseable complex number: \"{0}\""),
UNPARSEABLE_FRACTION_NUMBER("unparseable fraction number: \"{0}\""),
UNPARSEABLE_REAL_VECTOR("unparseable real vector: \"{0}\""),
UNSUPPORTED_EXPANSION_MODE("unsupported expansion mode {0}, supported modes are {1} ({2}) and {3} ({4})"),
UNSUPPORTED_OPERATION("unsupported operation"), /* keep */

View File

@ -21,11 +21,12 @@ import java.math.BigDecimal;
import java.math.BigInteger;
import org.apache.commons.math.FieldElement;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.exception.MathIllegalArgumentException;
import org.apache.commons.math.exception.NullArgumentException;
import org.apache.commons.math.util.MathUtils;
import org.apache.commons.math.exception.ZeroException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.util.FastMath;
import org.apache.commons.math.util.MathUtils;
/**
* Representation of a rational number without any overflow. This class is
@ -111,18 +112,14 @@ public class BigFraction
*
* @param num the numerator, must not be {@code null}.
* @param den the denominator, must not be {@code null}.
* @throws ArithmeticException if the denominator is zero.
* @throws ZeroException if the denominator is zero.
* @throws NullArgumentException if either of the arguments is null
*/
public BigFraction(BigInteger num, BigInteger den) {
if (num == null) {
throw new NullArgumentException(LocalizedFormats.NUMERATOR);
}
if (den == null) {
throw new NullArgumentException(LocalizedFormats.DENOMINATOR);
}
MathUtils.checkNotNull(num, LocalizedFormats.NUMERATOR);
MathUtils.checkNotNull(den, LocalizedFormats.DENOMINATOR);
if (BigInteger.ZERO.equals(den)) {
throw MathRuntimeException.createArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
throw new ZeroException(LocalizedFormats.ZERO_DENOMINATOR);
}
if (BigInteger.ZERO.equals(num)) {
numerator = BigInteger.ZERO;
@ -168,14 +165,14 @@ public class BigFraction
* </p>
* @see #BigFraction(double, double, int)
* @param value the double value to convert to a fraction.
* @exception IllegalArgumentException if value is NaN or infinite
* @exception MathIllegalArgumentException if value is NaN or infinite
*/
public BigFraction(final double value) throws IllegalArgumentException {
if (Double.isNaN(value)) {
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NAN_VALUE_CONVERSION);
throw new MathIllegalArgumentException(LocalizedFormats.NAN_VALUE_CONVERSION);
}
if (Double.isInfinite(value)) {
throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.INFINITE_VALUE_CONVERSION);
throw new MathIllegalArgumentException(LocalizedFormats.INFINITE_VALUE_CONVERSION);
}
// compute m and k such that value = m * 2^k
@ -609,12 +606,12 @@ public class BigFraction
* <code>null</code>.
* @return a {@link BigFraction} instance with the resulting values.
* @throws NullArgumentException if the {@code BigInteger} is {@code null}.
* @throws ArithmeticException
* @throws ZeroException
* if the fraction to divide by is zero.
*/
public BigFraction divide(final BigInteger bg) {
if (BigInteger.ZERO.equals(bg)) {
throw MathRuntimeException.createArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
throw new ZeroException(LocalizedFormats.ZERO_DENOMINATOR);
}
return new BigFraction(numerator, denominator.multiply(bg));
}
@ -660,14 +657,14 @@ public class BigFraction
* @param fraction Fraction to divide by, must not be {@code null}.
* @return a {@link BigFraction} instance with the resulting values.
* @throws NullArgumentException if the {@code fraction} is {@code null}.
* @throws ArithmeticException if the fraction to divide by is zero.
* @throws ZeroException if the fraction to divide by is zero.
*/
public BigFraction divide(final BigFraction fraction) {
if (fraction == null) {
throw new NullArgumentException(LocalizedFormats.FRACTION);
}
if (BigInteger.ZERO.equals(fraction.numerator)) {
throw MathRuntimeException.createArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
throw new ZeroException(LocalizedFormats.ZERO_DENOMINATOR);
}
return multiply(fraction.reciprocal());

View File

@ -21,11 +21,11 @@ import java.io.Serializable;
import java.math.BigInteger;
import java.text.FieldPosition;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.util.Locale;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.exception.MathIllegalArgumentException;
import org.apache.commons.math.exception.MathParseException;
import org.apache.commons.math.exception.util.LocalizedFormats;
/**
@ -159,7 +159,7 @@ public class BigFractionFormat extends AbstractFormat implements Serializable {
* offsets of the alignment field
* @return the value passed in as toAppendTo.
* @see java.text.Format#format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)
* @throws IllegalArgumentException is <code>obj</code> is not a valid type.
* @throws MathIllegalArgumentException is <code>obj</code> is not a valid type.
*/
@Override
public StringBuffer format(final Object obj,
@ -174,8 +174,7 @@ public class BigFractionFormat extends AbstractFormat implements Serializable {
ret = format(new BigFraction(((Number) obj).doubleValue()),
toAppendTo, pos);
} else {
throw MathRuntimeException.createIllegalArgumentException(
LocalizedFormats.CANNOT_FORMAT_OBJECT_TO_FRACTION);
throw new MathIllegalArgumentException(LocalizedFormats.CANNOT_FORMAT_OBJECT_TO_FRACTION);
}
return ret;
@ -185,17 +184,15 @@ public class BigFractionFormat extends AbstractFormat implements Serializable {
* Parses a string to produce a {@link BigFraction} object.
* @param source the string to parse
* @return the parsed {@link BigFraction} object.
* @exception ParseException if the beginning of the specified string
* @exception MathParseException if the beginning of the specified string
* cannot be parsed.
*/
@Override
public BigFraction parse(final String source) throws ParseException {
public BigFraction parse(final String source) throws MathParseException {
final ParsePosition parsePosition = new ParsePosition(0);
final BigFraction result = parse(source, parsePosition);
if (parsePosition.getIndex() == 0) {
throw MathRuntimeException.createParseException(
parsePosition.getErrorIndex(),
LocalizedFormats.UNPARSEABLE_FRACTION_NUMBER, source);
throw new MathParseException(source, parsePosition.getErrorIndex(), BigFraction.class);
}
return result;
}

View File

@ -19,12 +19,11 @@ package org.apache.commons.math.fraction;
import java.text.FieldPosition;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.util.Locale;
import org.apache.commons.math.exception.ConvergenceException;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.exception.MathIllegalArgumentException;
import org.apache.commons.math.exception.MathParseException;
import org.apache.commons.math.exception.util.LocalizedFormats;
/**
@ -166,27 +165,21 @@ public class FractionFormat extends AbstractFormat {
* offsets of the alignment field
* @return the value passed in as toAppendTo.
* @see java.text.Format#format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)
* @throws IllegalArgumentException is <code>obj</code> is not a valid type.
* @throws FractionConversionException if the numbrer cannot be converted to a fraction
* @throws MathIllegalArgumentException is <code>obj</code> is not a valid type.
*/
@Override
public StringBuffer format(final Object obj,
final StringBuffer toAppendTo, final FieldPosition pos) {
final StringBuffer toAppendTo, final FieldPosition pos)
throws FractionConversionException, MathIllegalArgumentException {
StringBuffer ret = null;
if (obj instanceof Fraction) {
ret = format((Fraction) obj, toAppendTo, pos);
} else if (obj instanceof Number) {
try {
ret = format(new Fraction(((Number) obj).doubleValue()),
toAppendTo, pos);
} catch (ConvergenceException ex) {
throw MathRuntimeException.createIllegalArgumentException(
LocalizedFormats.CANNOT_CONVERT_OBJECT_TO_FRACTION,
ex.getLocalizedMessage());
}
ret = format(new Fraction(((Number) obj).doubleValue()), toAppendTo, pos);
} else {
throw MathRuntimeException.createIllegalArgumentException(
LocalizedFormats.CANNOT_FORMAT_OBJECT_TO_FRACTION);
throw new MathIllegalArgumentException(LocalizedFormats.CANNOT_FORMAT_OBJECT_TO_FRACTION);
}
return ret;
@ -196,17 +189,15 @@ public class FractionFormat extends AbstractFormat {
* Parses a string to produce a {@link Fraction} object.
* @param source the string to parse
* @return the parsed {@link Fraction} object.
* @exception ParseException if the beginning of the specified string
* @exception MathParseException if the beginning of the specified string
* cannot be parsed.
*/
@Override
public Fraction parse(final String source) throws ParseException {
public Fraction parse(final String source) throws MathParseException {
final ParsePosition parsePosition = new ParsePosition(0);
final Fraction result = parse(source, parsePosition);
if (parsePosition.getIndex() == 0) {
throw MathRuntimeException.createParseException(
parsePosition.getErrorIndex(),
LocalizedFormats.UNPARSEABLE_FRACTION_NUMBER, source);
throw new MathParseException(source, parsePosition.getErrorIndex(), Fraction.class);
}
return result;
}

View File

@ -27,7 +27,6 @@ CANNOT_COMPUTE_0TH_ROOT_OF_UNITY = impossible de calculer la racine z\u00e9roi\u
CANNOT_COMPUTE_BETA_DENSITY_AT_0_FOR_SOME_ALPHA = impossible de calculer la densit\u00e9 beta en 0 lorsque alpha = {0,number}
CANNOT_COMPUTE_BETA_DENSITY_AT_1_FOR_SOME_BETA = impossible de calculer la densit\u00e9 beta en 1 lorsque beta = %.3g
CANNOT_COMPUTE_NTH_ROOT_FOR_NEGATIVE_N = impossible de calculer la racine ni\u00e8me pour n n\u00e9gatif ou nul : {0}
CANNOT_CONVERT_OBJECT_TO_FRACTION = impossible de convertir l''objet sous forme d''un nombre rationnel : {0}
CANNOT_DISCARD_NEGATIVE_NUMBER_OF_ELEMENTS = impossible d''enlever un nombre d''\u00e9l\u00e9ments{0} n\u00e9gatif
CANNOT_FORMAT_INSTANCE_AS_3D_VECTOR = impossible de formater une instance de {0} comme un vecteur de dimension 3
CANNOT_FORMAT_INSTANCE_AS_COMPLEX = impossible de formater une instance de {0} comme un nombre complexe
@ -282,11 +281,10 @@ UNKNOWN_MODE = mode {0} inconnu, modes connus : {1} ({2}), {3} ({4}), {5} ({6}),
UNKNOWN_ADDITIONAL_EQUATION = \u00e9quation additionnelle inconnue
UNKNOWN_PARAMETER = param\u00e8tre {0} inconnu
UNMATCHED_ODE_IN_EXPANDED_SET = l''\u00e9quation diff\u00e9rentielle ne correspond pas \u00e0 l''\u00e9quation principale du jeu \u00e9tendu
CANNOT_PARSE_AS_TYPE = cha\u00eene {0} non analysable (\u00e0 partir de la position {1}) en un objet de type {2}
CANNOT_PARSE = cha\u00eene {0} non analysable (\u00e0 partir de la position {1})
CANNOT_PARSE_AS_TYPE = cha\u00eene "{0}" non analysable (\u00e0 partir de la position {1}) en un objet de type {2}
CANNOT_PARSE = cha\u00eene "{0}" non analysable (\u00e0 partir de la position {1})
UNPARSEABLE_3D_VECTOR = vecteur 3D non analysable : "{0}"
UNPARSEABLE_COMPLEX_NUMBER = nombre complexe non analysable : "{0}"
UNPARSEABLE_FRACTION_NUMBER = nombre fractionnaire non analysable : "{0}"
UNPARSEABLE_REAL_VECTOR = vecteur r\u00e9el non analysable : "{0}"
UNSUPPORTED_EXPANSION_MODE = mode d''extension {0} non support\u00e9, les modes support\u00e9s sont {1} ({2}) et {3} ({4})
UNSUPPORTED_OPERATION = op\u00e9ration non disponible
@ -298,11 +296,11 @@ VALUES_ADDED_BEFORE_CONFIGURING_STATISTIC = {0} valeurs ont \u00e9t\u00e9 ajout\
VECTOR_LENGTH_MISMATCH = taille de vecteur invalide : {0} au lieu de {1} attendue
VECTOR_MUST_HAVE_AT_LEAST_ONE_ELEMENT = un vecteur doit comporter au moins un \u00e9l\u00e9ment
WEIGHT_AT_LEAST_ONE_NON_ZERO = le tableau des poids doit contenir au moins une valeur non nulle
WRONG_BLOCK_LENGTH = forme de tableau erron\u00e9e (bloc de longueur {0} au lieu des {1} attendus
WRONG_BLOCK_LENGTH = forme de tableau erron\u00e9e (bloc de longueur {0} au lieu des {1} attendus)
WRONG_NUMBER_OF_POINTS = {0} sont n\u00e9cessaires, seuls {1} ont \u00e9t\u00e9 fournis
NUMBER_OF_POINTS = nombre de points ({0})
ZERO_DENOMINATOR = le d\u00e9nominateur doit \u00eatre diff\u00e9rent de 0
ZERO_DENOMINATOR_IN_FRACTION = d\u00e9nominateur null dans le nombre rationnel {0}/{1}
ZERO_DENOMINATOR_IN_FRACTION = d\u00e9nominateur nul dans le nombre rationnel {0}/{1}
ZERO_FRACTION_TO_DIVIDE_BY = division par un nombre rationnel nul : {0}/{1}
ZERO_NORM = norme nulle
ZERO_NORM_FOR_ROTATION_AXIS = norme nulle pour un axe de rotation

View File

@ -23,6 +23,7 @@ import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
import org.apache.commons.math.exception.MathParseException;
import org.apache.commons.math.util.FastMath;
import org.junit.Assert;
import org.junit.Before;
@ -116,7 +117,7 @@ public class BigFractionFormatTest {
Assert.assertNotNull(c);
Assert.assertEquals(BigInteger.ONE, c.getNumerator());
Assert.assertEquals(BigInteger.valueOf(2l), c.getDenominator());
} catch (ParseException ex) {
} catch (MathParseException ex) {
Assert.fail(ex.getMessage());
}
}
@ -129,7 +130,7 @@ public class BigFractionFormatTest {
Assert.assertNotNull(c);
Assert.assertEquals(BigInteger.TEN, c.getNumerator());
Assert.assertEquals(BigInteger.ONE, c.getDenominator());
} catch (ParseException ex) {
} catch (MathParseException ex) {
Assert.fail(ex.getMessage());
}
try {
@ -137,7 +138,7 @@ public class BigFractionFormatTest {
Assert.assertNotNull(c);
Assert.assertEquals(BigInteger.TEN, c.getNumerator());
Assert.assertEquals(BigInteger.ONE, c.getDenominator());
} catch (ParseException ex) {
} catch (MathParseException ex) {
Assert.fail(ex.getMessage());
}
}
@ -149,13 +150,13 @@ public class BigFractionFormatTest {
try {
properFormat.parse(source);
Assert.fail(msg);
} catch (ParseException ex) {
} catch (MathParseException ex) {
// success
}
try {
improperFormat.parse(source);
Assert.fail(msg);
} catch (ParseException ex) {
} catch (MathParseException ex) {
// success
}
}
@ -167,13 +168,13 @@ public class BigFractionFormatTest {
try {
properFormat.parse(source);
Assert.fail(msg);
} catch (ParseException ex) {
} catch (MathParseException ex) {
// success
}
try {
improperFormat.parse(source);
Assert.fail(msg);
} catch (ParseException ex) {
} catch (MathParseException ex) {
// success
}
}
@ -203,7 +204,7 @@ public class BigFractionFormatTest {
Assert.assertNotNull(c);
Assert.assertEquals(-1, c.getNumeratorAsInt());
Assert.assertEquals(2, c.getDenominatorAsInt());
} catch (ParseException ex) {
} catch (MathParseException ex) {
Assert.fail(ex.getMessage());
}
}
@ -217,14 +218,14 @@ public class BigFractionFormatTest {
Assert.assertNotNull(c);
Assert.assertEquals(5, c.getNumeratorAsInt());
Assert.assertEquals(3, c.getDenominatorAsInt());
} catch (ParseException ex) {
} catch (MathParseException ex) {
Assert.fail(ex.getMessage());
}
try {
improperFormat.parse(source);
Assert.fail("invalid improper fraction.");
} catch (ParseException ex) {
} catch (MathParseException ex) {
// success
}
}
@ -237,14 +238,14 @@ public class BigFractionFormatTest {
Assert.assertNotNull(c);
Assert.assertEquals(-5, c.getNumeratorAsInt());
Assert.assertEquals(3, c.getDenominatorAsInt());
} catch (ParseException ex) {
} catch (MathParseException ex) {
Assert.fail(ex.getMessage());
}
try {
improperFormat.parse(source);
Assert.fail("invalid improper fraction.");
} catch (ParseException ex) {
} catch (MathParseException ex) {
// success
}
}
@ -255,14 +256,14 @@ public class BigFractionFormatTest {
try {
properFormat.parse(source);
Assert.fail("invalid minus in improper fraction.");
} catch (ParseException ex) {
} catch (MathParseException ex) {
// expected
}
source = "2 2 / -3";
try {
properFormat.parse(source);
Assert.fail("invalid minus in improper fraction.");
} catch (ParseException ex) {
} catch (MathParseException ex) {
// expected
}
}

View File

@ -22,6 +22,7 @@ import java.math.BigInteger;
import org.apache.commons.math.TestUtils;
import org.apache.commons.math.exception.ConvergenceException;
import org.apache.commons.math.exception.NullArgumentException;
import org.apache.commons.math.exception.ZeroException;
import org.apache.commons.math.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@ -77,8 +78,8 @@ public class BigFractionTest {
}
try {
new BigFraction(BigInteger.ONE, BigInteger.ZERO);
Assert.fail("Expecting ArithmeticException");
} catch (ArithmeticException npe) {
Assert.fail("Expecting ZeroException");
} catch (ZeroException npe) {
// expected
}
try {
@ -286,8 +287,8 @@ public class BigFractionTest {
f = new BigFraction(0, 3);
try {
f = f.reciprocal();
Assert.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {
Assert.fail("expecting ZeroException");
} catch (ZeroException ex) {
}
// large values
@ -405,7 +406,7 @@ public class BigFractionTest {
try {
f1.divide(f2);
Assert.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {
} catch (ZeroException ex) {
}
f1 = new BigFraction(0, 5);
@ -554,8 +555,8 @@ public class BigFractionTest {
Assert.assertTrue(BigFraction.ZERO.equals(BigFraction.getReducedFraction(0, -1)));
try {
BigFraction.getReducedFraction(1, 0);
Assert.fail("expecting ArithmeticException");
} catch (ArithmeticException ex) {
Assert.fail("expecting ZeroException");
} catch (ZeroException ex) {
// expected
}
Assert.assertEquals(BigFraction.getReducedFraction(2, Integer.MIN_VALUE).getNumeratorAsInt(), -1);

View File

@ -18,9 +18,9 @@
package org.apache.commons.math.fraction;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
import org.apache.commons.math.exception.MathParseException;
import org.apache.commons.math.util.FastMath;
import org.junit.Assert;
import org.junit.Before;
@ -114,7 +114,7 @@ public class FractionFormatTest {
Assert.assertNotNull(c);
Assert.assertEquals(1, c.getNumerator());
Assert.assertEquals(2, c.getDenominator());
} catch (ParseException ex) {
} catch (MathParseException ex) {
Assert.fail(ex.getMessage());
}
}
@ -127,7 +127,7 @@ public class FractionFormatTest {
Assert.assertNotNull(c);
Assert.assertEquals(10, c.getNumerator());
Assert.assertEquals(1, c.getDenominator());
} catch (ParseException ex) {
} catch (MathParseException ex) {
Assert.fail(ex.getMessage());
}
try {
@ -135,7 +135,7 @@ public class FractionFormatTest {
Assert.assertNotNull(c);
Assert.assertEquals(10, c.getNumerator());
Assert.assertEquals(1, c.getDenominator());
} catch (ParseException ex) {
} catch (MathParseException ex) {
Assert.fail(ex.getMessage());
}
}
@ -147,13 +147,13 @@ public class FractionFormatTest {
try {
properFormat.parse(source);
Assert.fail(msg);
} catch (ParseException ex) {
} catch (MathParseException ex) {
// success
}
try {
improperFormat.parse(source);
Assert.fail(msg);
} catch (ParseException ex) {
} catch (MathParseException ex) {
// success
}
}
@ -165,13 +165,13 @@ public class FractionFormatTest {
try {
properFormat.parse(source);
Assert.fail(msg);
} catch (ParseException ex) {
} catch (MathParseException ex) {
// success
}
try {
improperFormat.parse(source);
Assert.fail(msg);
} catch (ParseException ex) {
} catch (MathParseException ex) {
// success
}
}
@ -201,7 +201,7 @@ public class FractionFormatTest {
Assert.assertNotNull(c);
Assert.assertEquals(-1, c.getNumerator());
Assert.assertEquals(2, c.getDenominator());
} catch (ParseException ex) {
} catch (MathParseException ex) {
Assert.fail(ex.getMessage());
}
}
@ -215,14 +215,14 @@ public class FractionFormatTest {
Assert.assertNotNull(c);
Assert.assertEquals(5, c.getNumerator());
Assert.assertEquals(3, c.getDenominator());
} catch (ParseException ex) {
} catch (MathParseException ex) {
Assert.fail(ex.getMessage());
}
try {
improperFormat.parse(source);
Assert.fail("invalid improper fraction.");
} catch (ParseException ex) {
} catch (MathParseException ex) {
// success
}
}
@ -235,14 +235,14 @@ public class FractionFormatTest {
Assert.assertNotNull(c);
Assert.assertEquals(-5, c.getNumerator());
Assert.assertEquals(3, c.getDenominator());
} catch (ParseException ex) {
} catch (MathParseException ex) {
Assert.fail(ex.getMessage());
}
try {
improperFormat.parse(source);
Assert.fail("invalid improper fraction.");
} catch (ParseException ex) {
} catch (MathParseException ex) {
// success
}
}
@ -253,14 +253,14 @@ public class FractionFormatTest {
try {
properFormat.parse(source);
Assert.fail("invalid minus in improper fraction.");
} catch (ParseException ex) {
} catch (MathParseException ex) {
// expected
}
source = "2 2 / -3";
try {
properFormat.parse(source);
Assert.fail("invalid minus in improper fraction.");
} catch (ParseException ex) {
} catch (MathParseException ex) {
// expected
}
}