fun <T> Expect<T>.toBe(expected: T): Expect<T>
Expects that the subject of the assertion is (equal to) expected.
expect(12).toBe(12) // holds
fails {
expect(12).toBe(11)
}
// holds, toBe is based on equality, use isSameAs for identity
expect(listOf(1)).toBe(listOf(1))
fails { // because array has not implemented equals, so is equivalent to isSameAs
expect(arrayOf(1)).toBe(arrayOf(1))
}
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
An Expect for the current subject of the assertion.
@JvmName("toBeNull") fun <T : BigDecimal> Expect<T?>.toBe(expected: Nothing?): Expect<T?>
Expects that the subject of the assertion (a BigDecimal) is null
.
// only use toBe to check against null, otherwise use isNumericallyEqualTo or isEqualIncludingScale
expect(null as BigDecimal?).toBe(null)
AssertionError
- Might throw an AssertionError if the assertion made is not correct.
Return
An Expect for the current subject of the assertion.