toEqualIncludingScale

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

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

Most of the time you want to use toEqualNumerically which does not compare BigDecimal.scale in contrast to this function. 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 toEqualIncludingScale to compare subject and target are numerically equal including scale
expect(BigDecimal("-12345.678912", MathContext(9))) toEqualIncludingScale BigDecimal("-12345.6789")

fails{
    expect(BigDecimal("-12345.67890")) toEqualIncludingScale BigDecimal("-12345.6789")
}