doc / ch.tutteli.atrium.api.infix.en_GB / toBeNullIfNullGivenElse

toBeNullIfNullGivenElse

inline infix fun <reified T : Any> Expect<T?>.toBeNullIfNullGivenElse(noinline assertionCreatorOrNull: (Expect<T>.() -> Unit)?): Expect<T?> (source)

Expects that the subject of the assertion is either null in case assertionCreatorOrNull is null or is not null and holds all assertions assertionCreatorOrNull creates.

Depending on the implementation, it is not much more than a shortcut for

if (assertionCreatorOrNull == null) toBe(null)
else notToBeNull(assertionCreatorOrNull)

Exceptions

AssertionError - Might throw an AssertionError if the assertion made is not correct.

Return
An Expect for the current subject of the assertion.