commonMain.korlibs.test.AnySubject.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ktruth-jvm Show documentation
Show all versions of ktruth-jvm Show documentation
Multiplatform testing library. Based off the truth API: https://truth.dev/
The newest version!
package korlibs.test
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
import kotlin.test.assertEquals
import kotlin.test.assertIs
open class AnySubject(val subject: T) {
fun isEqualTo(expected: T) {
assertEquals(expected, subject)
}
inline fun isInstanceOf(): E {
return isInstanceOf(subject)
}
@OptIn(ExperimentalContracts::class)
inline fun isInstanceOf(value: Any?): E {
contract { returns() implies (value is E) }
assertIs(subject)
return subject as E
}
}