diff options
Diffstat (limited to 'plugins/base/src/test/kotlin/utils')
-rw-r--r-- | plugins/base/src/test/kotlin/utils/TestUtils.kt | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt index e4bc4a1e..8cb126d5 100644 --- a/plugins/base/src/test/kotlin/utils/TestUtils.kt +++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt @@ -7,6 +7,7 @@ import org.jetbrains.dokka.model.doc.P import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue import kotlin.collections.orEmpty +import kotlin.test.asserter @DslMarker annotation class TestDSL @@ -38,6 +39,16 @@ interface AssertDSL { assert(count() == n) { "${prefix}Expected $n, got ${count()}" } } +/* + * TODO replace with kotlin.test.assertContains after migrating to Kotlin 1.5+ + */ +internal fun <T> assertContains(iterable: Iterable<T>, element: T, ) { + asserter.assertTrue( + { "Expected the collection to contain the element.\nCollection <$iterable>, element <$element>." }, + iterable.contains(element) + ) +} + inline fun <reified T : Any> Any?.assertIsInstance(name: String): T = this.let { it as? T } ?: throw AssertionError("$name should not be null") |