Interval { public Location checkPoint(final double point, final double tolerance) { if (point < lower - tolerance || point > upper + tolerance) { return Location.OUTSIDE; } else if (point > lower + tolerance && point < upper - tolerance) { return Location.INSIDE; } else { return Location.BOUNDARY; } } Interval(final double lower, final double upper); double getInf(); @Deprecated double getLower(); double getSup(); @Deprecated double getUpper(); double getSize(); @Deprecated double getLength(); double getBarycenter(); @Deprecated double getMidPoint(); Location checkPoint(final double point, final double tolerance);  }
@Test public void testTolerance() { Interval interval = new Interval(2.3, 5.7); Assert.assertEquals(Region.Location.OUTSIDE, interval.checkPoint(1.2, 1.0)); Assert.assertEquals(Region.Location.BOUNDARY, interval.checkPoint(1.2, 1.2)); Assert.assertEquals(Region.Location.OUTSIDE, interval.checkPoint(8.7, 2.9)); Assert.assertEquals(Region.Location.BOUNDARY, interval.checkPoint(8.7, 3.1)); Assert.assertEquals(Region.Location.INSIDE, interval.checkPoint(3.0, 0.6)); Assert.assertEquals(Region.Location.BOUNDARY, interval.checkPoint(3.0, 0.8)); }