Hi.

> Tidy up test

Hmm. Not convinced.
Factorizing that way all the CM unit tests is a lot of work for a dubious
(IMO) improvement in readability.
I find it clearer to have a single "@Test" named "testPreconditions()" that
groups all the preconditions.
Also, sometimes, setting up the data to be passed (here to the constructor)
is not as easy to set up as in this case, so that you'd have to the setup in
every method (or use instance variables).

Gilles

> 
> Modified:
>     
> commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/function/StepFunctionTest.java
> 
> Modified: 
> commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/function/StepFunctionTest.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/function/StepFunctionTest.java?rev=1066176&r1=1066175&r2=1066176&view=diff
> ==============================================================================
> --- 
> commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/function/StepFunctionTest.java
>  (original)
> +++ 
> commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/function/StepFunctionTest.java
>  Tue Feb  1 19:52:05 2011
> @@ -32,48 +32,34 @@ import org.junit.Test;
>  public class StepFunctionTest {
>      private final double EPS = Math.ulp(1d);
>  
> -    @Test
> -    public void testPreconditions() {
> -        try {
> -            final UnivariateRealFunction f = new StepFunction(null,
> -                                                              new double[] 
> {0, -1, -2});
> -        } catch (NullArgumentException e) {
> -            // Expected.
> -        }
> -        try {
> -            final UnivariateRealFunction f = new StepFunction(new double[] 
> {0, 1},
> -                                                              null);
> -        } catch (NullArgumentException e) {
> -            // Expected.
> -        }
> -
> -        try {
> -            final UnivariateRealFunction f = new StepFunction(new double[] 
> {0},
> -                                                              new double[] 
> {});
> -        } catch (NoDataException e) {
> -            // Expected.
> -        }
> -
> -        try {
> -            final UnivariateRealFunction f = new StepFunction(new double[] 
> {},
> -                                                              new double[] 
> {0});
> -        } catch (NoDataException e) {
> -            // Expected.
> -        }
> -
> -        try {
> -            final UnivariateRealFunction f = new StepFunction(new double[] 
> {0, 1},
> -                                                              new double[] 
> {0, -1, -2});
> -        } catch (DimensionMismatchException e) {
> -            // Expected.
> -        }
> -
> -        try {
> -            final UnivariateRealFunction f = new StepFunction(new double[] 
> {1, 0, 1},
> -                                                              new double[] 
> {0, -1, -2});
> -        } catch (NonMonotonousSequenceException e) {
> -            // Expected.
> -        }
> +    @Test(expected=NullArgumentException.class)
> +    public void testPreconditions1() {
> +        new StepFunction(null, new double[] {0, -1, -2});
> +    }
> +
> +    @Test(expected=NullArgumentException.class)
> +    public void testPreconditions2() {
> +        new StepFunction(new double[] {0, 1}, null);
> +    }
> +
> +    @Test(expected=NoDataException.class)
> +    public void testPreconditions3() {
> +        new StepFunction(new double[] {0}, new double[] {});
> +    }
> +
> +    @Test(expected=NoDataException.class)
> +    public void testPreconditions4() {
> +        new StepFunction(new double[] {}, new double[] {0});
> +    }
> +
> +    @Test(expected=DimensionMismatchException.class)
> +    public void testPreconditions5() {
> +        new StepFunction(new double[] {0, 1}, new double[] {0, -1, -2});
> +    }
> +
> +    @Test(expected=NonMonotonousSequenceException.class)
> +    public void testPreconditions6() {
> +        new StepFunction(new double[] {1, 0, 1}, new double[] {0, -1, -2});
>      }
>  
>      @Test
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to