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

toEqual

fun <T> Expect<T>.toEqual(expected: T): Expect<T> (source)

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.

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))
}

Return
an Expect for the subject of this expectation.

Since
0.17.0

@JvmName("toBeNull") fun <T : BigDecimal> Expect<T?>.toEqual(expected: Nothing?): Expect<T?> (source)

Expects that the subject of this expectation (a BigDecimal) is null.

// only use toEqual to check against null, otherwise use toEqualNumerically or toEqualIncludingScale
expect(null as BigDecimal?).toEqual(null)

Return
an Expect for the subject of this expectation.

Since
0.17.0