HeavisideFunction extends Function1D<Double, Double> { @Override public Double evaluate(final Double x) { Validate.notNull(x); if (x < 0) { return 0.; } if (x > 0) { return 1.; } throw new IllegalArgumentException("Heaviside function is not defined for x = 0"); }  @Override Double evaluate(final Double x);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNull() { F.evaluate((Double) null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testZero() { F.evaluate(0.); }
@Test public void test() { assertEquals(F.evaluate(-2.), 0, 0); assertEquals(F.evaluate(-1e-15), 0, 0); assertEquals(F.evaluate(1e-15), 1, 0); assertEquals(F.evaluate(2.), 1, 0); }