DoubleCondition extends BasicCondition<Double, DoubleCondition> implements FloatingPointChecks<Double, DoubleCondition> { @Override public DoubleCondition isNearZeroWithTolerance(Double tolerance) { require(this.subject).isNotNull(); require(tolerance).isNotNull(); if (!(Math.abs(this.subject) < tolerance)) { DbcAssertionError.throwNew(new IllegalArgumentException("Expected double <" + this.subject + "> to be near zero with epsilon <" + tolerance + ">"), this.message); } return result(); } DoubleCondition(Double subject); @Override DoubleCondition isGreaterThan(Double number); @Override DoubleCondition isGreaterThanOrEqual(Double number); @Override DoubleCondition isLessThan(Double number); @Override DoubleCondition isLessThanOrEqual(Double number); @Override DoubleCondition isNear(Double floatingPointNumber); @Override DoubleCondition isNearWithTolerance(Double floatingPointNumber, Double tolerance); @Override DoubleCondition isNearZero(); @Override DoubleCondition isNearZeroWithTolerance(Double tolerance); @Deprecated @Override DoubleCondition isEqualTo(Double toCompare);  }
@Test public void isNearZeroCustomTolerance() throws Exception { DoubleCondition condition = new DoubleCondition(1D); condition.isNearZeroWithTolerance(1.5D); DoubleCondition badCondition = new DoubleCondition(2D); assertThatThrownBy(() -> badCondition.isNearZeroWithTolerance(1.5D)) .isInstanceOf(DbcAssertionError.class) .hasCauseInstanceOf(IllegalArgumentException.class); }