aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/utils/TestUtils.kt
diff options
context:
space:
mode:
authorSzymon Świstun <sswistun@virtuslab.com>2020-03-18 14:19:54 +0100
committerKamil Doległo <kamilok1965@users.noreply.github.com>2020-03-18 14:22:56 +0100
commit03329b0eb98b309d208839344052633028e00984 (patch)
treefb41aef63553562fe48e9ef39f9efe7f5824db71 /plugins/base/src/test/kotlin/utils/TestUtils.kt
parent9ac39176bee7c104ff350f968ee399ac97809ad9 (diff)
downloaddokka-03329b0eb98b309d208839344052633028e00984.tar.gz
dokka-03329b0eb98b309d208839344052633028e00984.tar.bz2
dokka-03329b0eb98b309d208839344052633028e00984.zip
Fix minor bugs and add core tests
Diffstat (limited to 'plugins/base/src/test/kotlin/utils/TestUtils.kt')
-rw-r--r--plugins/base/src/test/kotlin/utils/TestUtils.kt5
1 files changed, 5 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt
index 68ab7120..8a3053b3 100644
--- a/plugins/base/src/test/kotlin/utils/TestUtils.kt
+++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt
@@ -3,6 +3,7 @@ package utils
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.doc.*
import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
+import org.junit.jupiter.api.Assertions.assertTrue
import kotlin.collections.orEmpty
@DslMarker
@@ -22,6 +23,10 @@ interface AssertDSL {
infix fun Any?.equals(other: Any?) = this.assertEqual(other)
infix fun Collection<Any>?.allEquals(other: Any?) =
this?.also { c -> c.forEach { it equals other } } ?: run { assert(false) { "Collection is empty" } }
+ infix fun <T> Collection<T>?.exists(e: T) {
+ assertTrue(this.orEmpty().isNotEmpty(), "Collection cannot be null or empty")
+ assertTrue(this!!.any{it == e}, "Collection doesn't contain $e")
+ }
infix fun <T> Collection<T>?.counts(n: Int) = this.orEmpty().assertCount(n)