commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1200365 - /commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/regression/MillerUpdatingRegressionTest.java
Date Thu, 10 Nov 2011 15:07:47 GMT
Author: sebb
Date: Thu Nov 10 15:07:47 2011
New Revision: 1200365

URL: http://svn.apache.org/viewvc?rev=1200365&view=rev
Log:
Use asserNotNull(var) instead of if (var != null) and avoid subsequent NPE warnings

Modified:
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/regression/MillerUpdatingRegressionTest.java

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/regression/MillerUpdatingRegressionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/regression/MillerUpdatingRegressionTest.java?rev=1200365&r1=1200364&r2=1200365&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/regression/MillerUpdatingRegressionTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/regression/MillerUpdatingRegressionTest.java
Thu Nov 10 15:07:47 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.math.stat.regression;
 
+import junit.framework.Assert;
+
 import org.apache.commons.math.linear.RealMatrix;
 import org.apache.commons.math.stat.correlation.PearsonsCorrelation;
 import org.apache.commons.math.TestUtils;
@@ -178,9 +180,7 @@ public class MillerUpdatingRegressionTes
         instance.addObservations(x, y);
         try {
             RegressionResults result = instance.regress();
-            if (result == null) {
-                fail("The test case is a prototype.");
-            }
+            Assert.assertNotNull("The test case is a prototype.", result);
             TestUtils.assertEquals(
                     new double[]{9.5169, 0.8827, 0.4540, -1.6275},
                     result.getParameterEstimates(), 1e-4);
@@ -212,9 +212,7 @@ public class MillerUpdatingRegressionTes
         instance.addObservations(x, y);
         try {
             RegressionResults result = instance.regress();
-            if (result == null) {
-                fail("The test case is a prototype.");
-            }
+            Assert.assertNotNull("The test case is a prototype.", result);
             TestUtils.assertEquals(
                     new double[]{9.5169, 0.8827, 0.4540, -1.6275},
                     result.getParameterEstimates(), 1e-4);
@@ -783,15 +781,11 @@ public class MillerUpdatingRegressionTes
 
         instance.addObservations(x, y);
         RegressionResults result = instance.regress();
-        if (result == null) {
-            fail("Could not estimate initial regression");
-        }
+        Assert.assertNotNull("Could not estimate initial regression", result);
 
         instance2.addObservations(x2, y);
         RegressionResults resultRedundant = instance2.regress();
-        if (resultRedundant == null) {
-            fail("Could not estimate redundant regression");
-        }
+        Assert.assertNotNull("Could not estimate redundant regression", resultRedundant);
         double[] beta = result.getParameterEstimates();
         double[] betar = resultRedundant.getParameterEstimates();
         double[] se = result.getStdErrorOfEstimates();
@@ -849,15 +843,11 @@ public class MillerUpdatingRegressionTes
 
         instance.addObservations(x, y);
         RegressionResults result = instance.regress();
-        if (result == null) {
-            fail("Could not estimate initial regression");
-        }
+        Assert.assertNotNull("Could not estimate initial regression", result);
 
         instance2.addObservations(x2, y);
         RegressionResults resultRedundant = instance2.regress();
-        if (resultRedundant == null) {
-            fail("Could not estimate redundant regression");
-        }
+        Assert.assertNotNull("Could not estimate redundant regression", resultRedundant);
         double[] beta = result.getParameterEstimates();
         double[] betar = resultRedundant.getParameterEstimates();
         double[] se = result.getStdErrorOfEstimates();



Mime
View raw message