Author: sebb
Date: Wed Feb 2 01:57:12 2011
New Revision: 1066303
URL: http://svn.apache.org/viewvc?rev=1066303&view=rev
Log:
No point catching and then calling fail - just let JUnit do the work
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/FractionTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/Vector3DFormatAbstractTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/FrequencyTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/ContinuedFractionTest.java
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java?rev=1066303&r1=1066302&r2=1066303&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java
Wed Feb 2 01:57:12 2011
@@ -38,7 +38,7 @@ public class BigFractionTest extends Tes
assertEquals(expectedDenominator, actual.getDenominatorAsLong());
}
- public void testConstructor() {
+ public void testConstructor() throws Exception {
assertFraction(0, 1, new BigFraction(0, 1));
assertFraction(0, 1, new BigFraction(0l, 2l));
assertFraction(0, 1, new BigFraction(0, -1));
@@ -52,13 +52,10 @@ public class BigFractionTest extends Tes
assertFraction(11, 1, new BigFraction(11l));
assertFraction(11, 1, new BigFraction(new BigInteger("11")));
- try {
- assertFraction(0, 1, new BigFraction(0.00000000000001, 1.0e-5,
100));
- assertFraction(2, 5, new BigFraction(0.40000000000001, 1.0e-5,
100));
- assertFraction(15, 1, new BigFraction(15.0000000000001, 1.0e-5,
100));
- } catch (ConvergenceException ex) {
- fail(ex.getMessage());
- }
+ assertFraction(0, 1, new BigFraction(0.00000000000001, 1.0e-5, 100));
+ assertFraction(2, 5, new BigFraction(0.40000000000001, 1.0e-5, 100));
+ assertFraction(15, 1, new BigFraction(15.0000000000001, 1.0e-5, 100));
+
assertEquals(0.00000000000001, new
BigFraction(0.00000000000001).doubleValue(), 0.0);
assertEquals(0.40000000000001, new
BigFraction(0.40000000000001).doubleValue(), 0.0);
assertEquals(15.0000000000001, new
BigFraction(15.0000000000001).doubleValue(), 0.0);
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/FractionTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/FractionTest.java?rev=1066303&r1=1066302&r2=1066303&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/FractionTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math/fraction/FractionTest.java
Wed Feb 2 01:57:12 2011
@@ -34,7 +34,7 @@ public class FractionTest extends TestCa
assertEquals(expectedDenominator, actual.getDenominator());
}
- public void testConstructor() {
+ public void testConstructor() throws Exception {
assertFraction(0, 1, new Fraction(0, 1));
assertFraction(0, 1, new Fraction(0, 2));
assertFraction(0, 1, new Fraction(0, -1));
@@ -58,14 +58,9 @@ public class FractionTest extends TestCa
} catch (MathArithmeticException ex) {
// success
}
- try {
- assertFraction(0, 1, new Fraction(0.00000000000001));
- assertFraction(2, 5, new Fraction(0.40000000000001));
- assertFraction(15, 1, new Fraction(15.0000000000001));
-
- } catch (ConvergenceException ex) {
- fail(ex.getMessage());
- }
+ assertFraction(0, 1, new Fraction(0.00000000000001));
+ assertFraction(2, 5, new Fraction(0.40000000000001));
+ assertFraction(15, 1, new Fraction(15.0000000000001));
}
public void testGoldenRatio() {
@@ -212,19 +207,15 @@ public class FractionTest extends TestCa
assertEquals(1L, second.longValue());
}
- public void testConstructorDouble() {
- try {
- assertFraction(1, 2, new Fraction(0.5));
- assertFraction(1, 3, new Fraction(1.0 / 3.0));
- assertFraction(17, 100, new Fraction(17.0 / 100.0));
- assertFraction(317, 100, new Fraction(317.0 / 100.0));
- assertFraction(-1, 2, new Fraction(-0.5));
- assertFraction(-1, 3, new Fraction(-1.0 / 3.0));
- assertFraction(-17, 100, new Fraction(17.0 / -100.0));
- assertFraction(-317, 100, new Fraction(-317.0 / 100.0));
- } catch (ConvergenceException ex) {
- fail(ex.getMessage());
- }
+ public void testConstructorDouble() throws Exception {
+ assertFraction(1, 2, new Fraction(0.5));
+ assertFraction(1, 3, new Fraction(1.0 / 3.0));
+ assertFraction(17, 100, new Fraction(17.0 / 100.0));
+ assertFraction(317, 100, new Fraction(317.0 / 100.0));
+ assertFraction(-1, 2, new Fraction(-0.5));
+ assertFraction(-1, 3, new Fraction(-1.0 / 3.0));
+ assertFraction(-17, 100, new Fraction(17.0 / -100.0));
+ assertFraction(-317, 100, new Fraction(-317.0 / 100.0));
}
public void testAbs() {
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/Vector3DFormatAbstractTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/Vector3DFormatAbstractTest.java?rev=1066303&r1=1066302&r2=1066303&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/Vector3DFormatAbstractTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math/geometry/Vector3DFormatAbstractTest.java
Wed Feb 2 01:57:12 2011
@@ -163,12 +163,8 @@ public abstract class Vector3DFormatAbst
public void testParseSimpleNoDecimals() {
String source = "{1; 1; 1}";
Vector3D expected = new Vector3D(1, 1, 1);
- try {
- Vector3D actual = vector3DFormat.parse(source);
- Assert.assertEquals(expected, actual);
- } catch (MathParseException ex) {
- Assert.fail(ex.getMessage());
- }
+ Vector3D actual = vector3DFormat.parse(source);
+ Assert.assertEquals(expected, actual);
}
@Test
@@ -192,12 +188,8 @@ public abstract class Vector3DFormatAbst
"43; 1" + getDecimalCharacter() +
"63}";
Vector3D expected = new Vector3D(1.23, 1.43, 1.63);
- try {
- Vector3D actual = vector3DFormat.parse(source);
- Assert.assertEquals(expected, actual);
- } catch (MathParseException ex) {
- Assert.fail(ex.getMessage());
- }
+ Vector3D actual = vector3DFormat.parse(source);
+ Assert.assertEquals(expected, actual);
}
@Test
@@ -208,12 +200,8 @@ public abstract class Vector3DFormatAbst
"4343; 1" + getDecimalCharacter() +
"6333}";
Vector3D expected = new Vector3D(1.2323, 1.4343, 1.6333);
- try {
- Vector3D actual = vector3DFormat.parse(source);
- Assert.assertEquals(expected, actual);
- } catch (MathParseException ex) {
- Assert.fail(ex.getMessage());
- }
+ Vector3D actual = vector3DFormat.parse(source);
+ Assert.assertEquals(expected, actual);
}
@Test
@@ -224,12 +212,8 @@ public abstract class Vector3DFormatAbst
"4343; 1" + getDecimalCharacter() +
"6333}";
Vector3D expected = new Vector3D(-1.2323, 1.4343, 1.6333);
- try {
- Vector3D actual = vector3DFormat.parse(source);
- Assert.assertEquals(expected, actual);
- } catch (MathParseException ex) {
- Assert.fail(ex.getMessage());
- }
+ Vector3D actual = vector3DFormat.parse(source);
+ Assert.assertEquals(expected, actual);
}
@Test
@@ -240,12 +224,8 @@ public abstract class Vector3DFormatAbst
"4343; 1" + getDecimalCharacter() +
"6333}";
Vector3D expected = new Vector3D(1.2323, -1.4343, 1.6333);
- try {
- Vector3D actual = vector3DFormat.parse(source);
- Assert.assertEquals(expected, actual);
- } catch (MathParseException ex) {
- Assert.fail(ex.getMessage());
- }
+ Vector3D actual = vector3DFormat.parse(source);
+ Assert.assertEquals(expected, actual);
}
@Test
@@ -256,12 +236,8 @@ public abstract class Vector3DFormatAbst
"4343; -1" + getDecimalCharacter() +
"6333}";
Vector3D expected = new Vector3D(1.2323, 1.4343, -1.6333);
- try {
- Vector3D actual = vector3DFormat.parse(source);
- Assert.assertEquals(expected, actual);
- } catch (MathParseException ex) {
- Assert.fail(ex.getMessage());
- }
+ Vector3D actual = vector3DFormat.parse(source);
+ Assert.assertEquals(expected, actual);
}
@Test
@@ -272,12 +248,8 @@ public abstract class Vector3DFormatAbst
"4343; -1" + getDecimalCharacter() +
"6333}";
Vector3D expected = new Vector3D(-1.2323, -1.4343, -1.6333);
- try {
- Vector3D actual = vector3DFormat.parse(source);
- Assert.assertEquals(expected, actual);
- } catch (MathParseException ex) {
- Assert.fail(ex.getMessage());
- }
+ Vector3D actual = vector3DFormat.parse(source);
+ Assert.assertEquals(expected, actual);
}
@Test
@@ -288,12 +260,8 @@ public abstract class Vector3DFormatAbst
"4343; 1" + getDecimalCharacter() +
"6333}";
Vector3D expected = new Vector3D(0.0, -1.4343, 1.6333);
- try {
- Vector3D actual = vector3DFormat.parse(source);
- Assert.assertEquals(expected, actual);
- } catch (MathParseException ex) {
- Assert.fail(ex.getMessage());
- }
+ Vector3D actual = vector3DFormat.parse(source);
+ Assert.assertEquals(expected, actual);
}
@Test
@@ -304,45 +272,29 @@ public abstract class Vector3DFormatAbst
"4343 : 1" + getDecimalCharacter() +
"6333]";
Vector3D expected = new Vector3D(1.2323, 1.4343, 1.6333);
- try {
- Vector3D actual = vector3DFormatSquare.parse(source);
- Assert.assertEquals(expected, actual);
- } catch (MathParseException ex) {
- Assert.fail(ex.getMessage());
- }
+ Vector3D actual = vector3DFormatSquare.parse(source);
+ Assert.assertEquals(expected, actual);
}
@Test
public void testParseNan() {
String source = "{(NaN); (NaN); (NaN)}";
- try {
- Vector3D actual = vector3DFormat.parse(source);
- Assert.assertEquals(Vector3D.NaN, actual);
- } catch (MathParseException ex) {
- Assert.fail(ex.getMessage());
- }
+ Vector3D actual = vector3DFormat.parse(source);
+ Assert.assertEquals(Vector3D.NaN, actual);
}
@Test
public void testParsePositiveInfinity() {
String source = "{(Infinity); (Infinity); (Infinity)}";
- try {
- Vector3D actual = vector3DFormat.parse(source);
- Assert.assertEquals(Vector3D.POSITIVE_INFINITY, actual);
- } catch (MathParseException ex) {
- Assert.fail(ex.getMessage());
- }
+ Vector3D actual = vector3DFormat.parse(source);
+ Assert.assertEquals(Vector3D.POSITIVE_INFINITY, actual);
}
@Test
public void testParseNegativeInfinity() {
String source = "{(-Infinity); (-Infinity); (-Infinity)}";
- try {
- Vector3D actual = vector3DFormat.parse(source);
- Assert.assertEquals(Vector3D.NEGATIVE_INFINITY, actual);
- } catch (MathParseException ex) {
- Assert.fail(ex.getMessage());
- }
+ Vector3D actual = vector3DFormat.parse(source);
+ Assert.assertEquals(Vector3D.NEGATIVE_INFINITY, actual);
}
@Test
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/FrequencyTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/FrequencyTest.java?rev=1066303&r1=1066302&r2=1066303&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/FrequencyTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/FrequencyTest.java
Wed Feb 2 01:57:12 2011
@@ -197,7 +197,7 @@ public final class FrequencyTest extends
/**
* Tests toString()
*/
- public void testToString(){
+ public void testToString() throws Exception {
f.addValue(oneL);
f.addValue(twoL);
f.addValue(oneI);
@@ -207,21 +207,17 @@ public final class FrequencyTest extends
//System.out.println(s);
assertNotNull(s);
BufferedReader reader = new BufferedReader(new StringReader(s));
- try {
- String line = reader.readLine(); // header line
- assertNotNull(line);
-
- line = reader.readLine(); // one's or two's line
- assertNotNull(line);
-
- line = reader.readLine(); // one's or two's line
- assertNotNull(line);
-
- line = reader.readLine(); // no more elements
- assertNull(line);
- } catch(IOException ex){
- fail(ex.getMessage());
- }
+ String line = reader.readLine(); // header line
+ assertNotNull(line);
+
+ line = reader.readLine(); // one's or two's line
+ assertNotNull(line);
+
+ line = reader.readLine(); // one's or two's line
+ assertNotNull(line);
+
+ line = reader.readLine(); // no more elements
+ assertNull(line);
}
public void testIntegerValues() {
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/ContinuedFractionTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/ContinuedFractionTest.java?rev=1066303&r1=1066302&r2=1066303&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/ContinuedFractionTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/ContinuedFractionTest.java
Wed Feb 2 01:57:12 2011
@@ -32,7 +32,7 @@ public class ContinuedFractionTest exten
super(name);
}
- public void testGoldenRatio(){
+ public void testGoldenRatio() throws Exception {
ContinuedFraction cf = new ContinuedFraction() {
@Override
@@ -46,11 +46,7 @@ public class ContinuedFractionTest exten
}
};
- try {
- double gr = cf.evaluate(0.0, 10e-9);
- assertEquals(1.61803399, gr, 10e-9);
- } catch (MathException e) {
- fail(e.getMessage());
- }
+ double gr = cf.evaluate(0.0, 10e-9);
+ assertEquals(1.61803399, gr, 10e-9);
}
}