infix fun <T : Any> Expect<T?>.toEqualNullIfNullGivenElse(assertionCreatorOrNull: (Expect<T>.() -> Unit)?): Expect<T?>
(source)
Expects that the subject of this
expectation is either null
in case assertionCreatorOrNull
is null
or is not null
and holds all assertions assertionCreatorOrNull creates.
expect<Int?>(null) toEqualNullIfNullGivenElse null
expect<Int?>(1) toEqualNullIfNullGivenElse { // subject inside this block is of type Int (actually 1)
it toBeLessThan 2
} // subject here is back to type Int?
fails { // because sub-expectation fails
expect<Int?>(1) toEqualNullIfNullGivenElse {
it toBeLessThan 0
}
}
Return
an Expect for the subject of this
expectation.
Since
0.17.0