toEqual
Expects that the subject of this
expectation is equal to expected where the comparison is carried out based on Any.equals.
Use toBeEqualComparingTo if you want a comparison based on Comparable.compareTo.
Return
an Expect for the subject of this
expectation.
Since
0.17.0
Samples
expect(12).toEqual(12) // holds
fails {
expect(12).toEqual(11)
}
// holds, toEqual is based on equality, use toBeTheInstance for identity
expect(listOf(1)).toEqual(listOf(1))
fails { // because array has not implemented equals, so is the same as using toBeTheInstance
expect(arrayOf(1)).toEqual(arrayOf(1))
}
Expects that the subject of this
expectation (a BigDecimal) is null
.
Return
an Expect for the subject of this
expectation.
Since
0.17.0
Samples
// only use toEqual to check against null, otherwise use toEqualNumerically or toEqualIncludingScale
expect(null as BigDecimal?).toEqual(null)
Deprecated
Use `toEqualNumerically` if you expect that the following assertion holds: `expect(BigDecimal("10")).toEqual(BigDecimal("10.0"))` However, if you expect it to be wrong (because `BigDecimal.scale` differ), then use `toEqualIncludingScale`.
Replace with
toEqualNumerically(expected) or toEqualIncludingScale(expected)
Deprecated as it would compare the subject against expected including scale -- many developers are not aware of that.
Use toEqualNumerically if you expect that the following assertion holds:
expect(BigDecimal("10").toEqual(BigDecimal("10.0"))
However, if you expect it to be wrong (because BigDecimal.scale
differ), then use toEqualIncludingScale.
Since
0.17.0