doc / ch.tutteli.atrium.api.fluent.en_GB / toBeWithErrorTolerance

toBeWithErrorTolerance

fun Expect<Float>.toBeWithErrorTolerance(expected: Float, tolerance: Float): Expect<Float>

Expects that the subject of the assertion (a Float) is equal to expected with an error tolerance (range including bounds).

In detail, It compares the absolute difference between the subject and expected; as long as it is less than or equal the tolerance the assertion holds; otherwise it fails. A more mathematical way of expressing the assertion is the following inequality:

| subject of the assertion - expected | ≤ tolerance

expect(12.001F).toBeWithErrorTolerance(12.0F, 0.01F)

fails {
    expect(12.1F).toBeWithErrorTolerance(12.0F, 0.01F)
}

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
An Expect for the current subject of the assertion.

fun Expect<Double>.toBeWithErrorTolerance(expected: Double, tolerance: Double): Expect<Double>

Expects that the subject of the assertion (a Double) is equal to expected with an error tolerance (range including bounds).

In detail, It compares the absolute difference between the subject and expected; as long as it is less than or equal the tolerance the assertion holds; otherwise it fails. A more mathematical way of expressing the assertion is the following inequality:

| subject of the assertion - expected | ≤ tolerance

expect(12.001).toBeWithErrorTolerance(12.0, 0.01)

fails {
    expect(12.1).toBeWithErrorTolerance(12.0, 0.01)
}

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
An Expect for the current subject of the assertion.

fun <T : BigDecimal> Expect<T>.toBeWithErrorTolerance(expected: BigDecimal, tolerance: BigDecimal): Expect<T>

Expects that the subject of the assertion is equal to expected with an error tolerance (range including bounds).

In detail, It compares the absolute difference between the subject and expected; as long as it is less than or equal the tolerance the assertion holds; otherwise it fails. A more mathematical way of expressing the assertion is the following inequality:

| subject of the assertion - expected | ≤ tolerance

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
An Expect for the current subject of the assertion.