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