toEqualNumerically

infix fun <T : BigDecimal> Expect<T>.toEqualNumerically(expected: T): Expect<T>(source)

Expects that the subject of this expectation (a BigDecimal) is numerically equal to expected.

By numerically is meant that it will not compare BigDecimal.scale (or in other words, it uses compareTo(expected) == 0)

Most of the time you want to use this function instead of toEqualIncludingScale because toEqualIncludingScale compares BigDecimal.scale. Following the two functions compared:

  • expect(BigDecimal("10")).toEqualIncludingScale(BigDecimal("10.0")) does not hold.

  • expect(BigDecimal("10")).toEqualNumerically(BigDecimal("10.0")) holds.

Return

an Expect for the subject of this expectation.

Since

0.17.0

Samples

// Use toEqualNumerically to compare subject and target are numerically equal
expect(BigDecimal("-12345.67890")) toEqualNumerically BigDecimal("-12345.6789")

fails{
    expect(BigDecimal("-12345.678")) toEqualNumerically BigDecimal("-12345.6789")
}