doc / ch.tutteli.atrium.api.cc.de_CH / istEin

istEin

inline fun <reified TSub : Any> Assert<Any>.istEin(noinline assertionCreator: AssertionPlant<TSub>.() -> Unit): Unit
Deprecated: api-cc-de_CH is discontinued, switch to api-fluent-en_GB; will be removed with 1.0.0

Makes the assertion that the Assert.subject is a TSub (the same type or a sub-type) and if so, uses assertionCreator which could create further assertions which are added as a group.

Notice, that asserting a function type is flawed. The actual types are ignored as function types erase to Function0, Function1 etc. on byte code level, which means the assertion holds as long as the Assert.subject is a function and has the same amount of arguments regardless if the types differ. For instance esGilt({x: Int -> "hello"}).istEin<String -> Unit>{} holds, even though (Int) -> String is clearly not a (String) -> Unit.

More generally speaking, the flaw applies to all generic types. For instance isA<List<String>> would only check if the Assert.subject is a List without checking if the element type is actually String. Or in other words esGilt(listOf(1, 2)).isA<List<String>>{} holds, even though List<Int> is clearly not a List<String>.

Exceptions

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

Return
Notice, that this assertion function cannot provide a fluent API because it depends on whether the first assertion (Assert.subject is a TSub) holds or not. Define subsequent assertions via the assertionCreator lambda.