You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2011/02/03 23:45:06 UTC

svn commit: r1067018 - /commons/proper/math/trunk/src/test/java/org/apache/commons/math/analysis/function/StepFunctionTest.java

Author: erans
Date: Thu Feb  3 22:45:06 2011
New Revision: 1067018

URL: http://svn.apache.org/viewvc?rev=1067018&view=rev
Log:
Another unit test.

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=1067018&r1=1067017&r2=1067018&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 Thu Feb  3 22:45:06 2011
@@ -78,4 +78,18 @@ public class StepFunctionTest {
         Assert.assertEquals(51.2, f.value(30), EPS);
         Assert.assertEquals(51.2, f.value(Double.POSITIVE_INFINITY), EPS);
     }
+
+    @Test
+    public void testHeaviside() {   
+        final UnivariateRealFunction h = new StepFunction(new double[] {-1, 0},
+                                                          new double[] {0, 1});
+
+        Assert.assertEquals(0, h.value(Double.NEGATIVE_INFINITY), 0);
+        Assert.assertEquals(0, h.value(-Double.MAX_VALUE), 0);
+        Assert.assertEquals(0, h.value(-2), 0);
+        Assert.assertEquals(0, h.value(-Double.MIN_VALUE), 0);
+        Assert.assertEquals(1, h.value(0), 0);
+        Assert.assertEquals(1, h.value(2), 0);
+        Assert.assertEquals(1, h.value(Double.POSITIVE_INFINITY), 0);
+    }
 }