commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r816654 - /commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/LoessInterpolatorTest.java
Date Fri, 18 Sep 2009 14:39:18 GMT
Author: luc
Date: Fri Sep 18 14:39:18 2009
New Revision: 816654

URL: http://svn.apache.org/viewvc?rev=816654&view=rev
Log:
cleaned up tests wrt Junit 4

Modified:
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/LoessInterpolatorTest.java

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/LoessInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/LoessInterpolatorTest.java?rev=816654&r1=816653&r2=816654&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/LoessInterpolatorTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/interpolation/LoessInterpolatorTest.java
Fri Sep 18 14:39:18 2009
@@ -16,9 +16,7 @@
  */
 package org.apache.commons.math.analysis.interpolation;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import org.junit.Assert;
 
 import org.apache.commons.math.MathException;
 import org.junit.Test;
@@ -33,8 +31,8 @@
         double[] xval = {0.5};
         double[] yval = {0.7};
         double[] res = new LoessInterpolator().smooth(xval, yval);
-        assertEquals(1, res.length);
-        assertEquals(0.7, res[0], 0.0);
+        Assert.assertEquals(1, res.length);
+        Assert.assertEquals(0.7, res[0], 0.0);
     }
 
     @Test
@@ -42,9 +40,9 @@
         double[] xval = {0.5, 0.6};
         double[] yval = {0.7, 0.8};
         double[] res = new LoessInterpolator().smooth(xval, yval);
-        assertEquals(2, res.length);
-        assertEquals(0.7, res[0], 0.0);
-        assertEquals(0.8, res[1], 0.0);
+        Assert.assertEquals(2, res.length);
+        Assert.assertEquals(0.7, res[0], 0.0);
+        Assert.assertEquals(0.8, res[1], 0.0);
     }
 
     @Test
@@ -53,9 +51,9 @@
         double[] yval = {2,4,6,8,10};
         LoessInterpolator li = new LoessInterpolator(0.6, 2);
         double[] res = li.smooth(xval, yval);
-        assertEquals(5, res.length);
+        Assert.assertEquals(5, res.length);
         for(int i = 0; i < 5; ++i) {
-            assertEquals(yval[i], res[i], 1e-8);
+            Assert.assertEquals(yval[i], res[i], 1e-8);
         }
     }
 
@@ -88,7 +86,7 @@
             fitResidualSum += Math.pow(fit - expected, 2);
         }
 
-        assertTrue(fitResidualSum < noisyResidualSum);
+        Assert.assertTrue(fitResidualSum < noisyResidualSum);
     }
 
     @Test
@@ -118,7 +116,7 @@
         }
 
         for(int i = 1; i < variances.length; ++i) {
-            assertTrue(variances[i] < variances[i-1]);
+            Assert.assertTrue(variances[i] < variances[i-1]);
         }
     }
 
@@ -151,111 +149,74 @@
         }
 
         for(int i = 1; i < variances.length; ++i) {
-            assertTrue(variances[i] < variances[i-1]);
+            Assert.assertTrue(variances[i] < variances[i-1]);
         }
     }
 
-    @Test
-    public void testUnequalSizeArguments() {
-        try {
-            new LoessInterpolator().smooth(new double[] {1,2,3}, new double[] {1,2,3,4});
-            fail();
-        } catch(MathException e) {
-            // Expected
-        }
+    @Test(expected=MathException.class)
+    public void testUnequalSizeArguments() throws MathException {
+        new LoessInterpolator().smooth(new double[] {1,2,3}, new double[] {1,2,3,4});
     }
 
-    @Test
-    public void testEmptyData() {
-        try {
-            new LoessInterpolator().smooth(new double[] {}, new double[] {});
-            fail();
-        } catch(MathException e) {
-            // Expected
-        }
+    @Test(expected=MathException.class)
+    public void testEmptyData() throws MathException {
+        new LoessInterpolator().smooth(new double[] {}, new double[] {});
     }
 
-    @Test
-    public void testNonStrictlyIncreasing() {
-        try {
-            new LoessInterpolator().smooth(new double[] {4,3,1,2}, new double[] {3,4,5,6});
-            fail();
-        } catch(MathException e) {
-            // Expected
-        }
-        try {
-            new LoessInterpolator().smooth(new double[] {1,2,2,3}, new double[] {3,4,5,6});
-            fail();
-        } catch(MathException e) {
-            // Expected
-        }
+    @Test(expected=MathException.class)
+    public void testNonStrictlyIncreasing1() throws MathException {
+        new LoessInterpolator().smooth(new double[] {4,3,1,2}, new double[] {3,4,5,6});
     }
 
-    @Test
-    public void testNotAllFiniteReal() {
-        try {
-            new LoessInterpolator().smooth(new double[] {1,2,Double.NaN}, new double[] {3,4,5});
-            fail();
-        } catch(MathException e) {
-            // Expected
-        }
-        try {
-            new LoessInterpolator().smooth(new double[] {1,2,Double.POSITIVE_INFINITY}, new
double[] {3,4,5});
-            fail();
-        } catch(MathException e) {
-            // Expected
-        }
-        try {
-            new LoessInterpolator().smooth(new double[] {1,2,Double.NEGATIVE_INFINITY}, new
double[] {3,4,5});
-            fail();
-        } catch(MathException e) {
-            // Expected
-        }
-        try {
-            new LoessInterpolator().smooth(new double[] {3,4,5}, new double[] {1,2,Double.NaN});
-            fail();
-        } catch(MathException e) {
-            // Expected
-        }
-        try {
-            new LoessInterpolator().smooth(new double[] {3,4,5}, new double[] {1,2,Double.POSITIVE_INFINITY});
-            fail();
-        } catch(MathException e) {
-            // Expected
-        }
-        try {
-            new LoessInterpolator().smooth(new double[] {3,4,5}, new double[] {1,2,Double.NEGATIVE_INFINITY});
-            fail();
-        } catch(MathException e) {
-            // Expected
-        }
+    @Test(expected=MathException.class)
+    public void testNonStrictlyIncreasing2() throws MathException {
+        new LoessInterpolator().smooth(new double[] {1,2,2,3}, new double[] {3,4,5,6});
     }
 
-    @Test
-    public void testInsufficientBandwidth() {
-        try {
-            LoessInterpolator li = new LoessInterpolator(0.1, 3);
-            li.smooth(new double[] {1,2,3,4,5,6,7,8,9,10,11,12}, new double[] {1,2,3,4,5,6,7,8,9,10,11,12});
-            fail();
-        } catch(MathException e) {
-            // Expected
-        }
+    @Test(expected=MathException.class)
+    public void testNotAllFiniteReal1() throws MathException {
+        new LoessInterpolator().smooth(new double[] {1,2,Double.NaN}, new double[] {3,4,5});
     }
 
-    @Test
-    public void testCompletelyIncorrectBandwidth() {
-        try {
-            new LoessInterpolator(-0.2, 3);
-            fail();
-        } catch(MathException e) {
-            // Expected
-        }
-        try {
-            new LoessInterpolator(1.1, 3);
-            fail();
-        } catch(MathException e) {
-            // Expected
-        }
+    @Test(expected=MathException.class)
+    public void testNotAllFiniteReal2() throws MathException {
+        new LoessInterpolator().smooth(new double[] {1,2,Double.POSITIVE_INFINITY}, new double[]
{3,4,5});
+    }
+
+    @Test(expected=MathException.class)
+    public void testNotAllFiniteReal3() throws MathException {
+        new LoessInterpolator().smooth(new double[] {1,2,Double.NEGATIVE_INFINITY}, new double[]
{3,4,5});
+    }
+
+    @Test(expected=MathException.class)
+    public void testNotAllFiniteReal4() throws MathException {
+        new LoessInterpolator().smooth(new double[] {3,4,5}, new double[] {1,2,Double.NaN});
+    }
+
+    @Test(expected=MathException.class)
+    public void testNotAllFiniteReal5() throws MathException {
+        new LoessInterpolator().smooth(new double[] {3,4,5}, new double[] {1,2,Double.POSITIVE_INFINITY});
+    }
+
+    @Test(expected=MathException.class)
+    public void testNotAllFiniteReal6() throws MathException {
+        new LoessInterpolator().smooth(new double[] {3,4,5}, new double[] {1,2,Double.NEGATIVE_INFINITY});
+    }
+
+    @Test(expected=MathException.class)
+    public void testInsufficientBandwidth() throws MathException {
+        LoessInterpolator li = new LoessInterpolator(0.1, 3);
+        li.smooth(new double[] {1,2,3,4,5,6,7,8,9,10,11,12}, new double[] {1,2,3,4,5,6,7,8,9,10,11,12});
+    }
+
+    @Test(expected=MathException.class)
+    public void testCompletelyIncorrectBandwidth1() throws MathException {
+        new LoessInterpolator(-0.2, 3);
+    }
+
+    @Test(expected=MathException.class)
+    public void testCompletelyIncorrectBandwidth2() throws MathException {
+        new LoessInterpolator(1.1, 3);
     }
 
     private void generateSineData(double[] xval, double[] yval, double xnoise, double ynoise)
{



Mime
View raw message