
commonMain.io.kotest.matchers.collections.contain.kt Maven / Gradle / Ivy
package io.kotest.matchers.collections
import io.kotest.assertions.show.show
import io.kotest.matchers.Matcher
import io.kotest.matchers.MatcherResult
import io.kotest.matchers.should
import io.kotest.matchers.shouldNot
infix fun Iterable.shouldNotContain(t: T) = toList().shouldNotContain(t)
infix fun Array.shouldNotContain(t: T) = asList().shouldNotContain(t)
infix fun > C.shouldNotContain(t: T) = this shouldNot contain(t)
infix fun Iterable.shouldContain(t: T) = toList().shouldContain(t)
infix fun Array.shouldContain(t: T) = asList().shouldContain(t)
infix fun > C.shouldContain(t: T) = this should contain(t)
fun > contain(t: T) = object : Matcher {
override fun test(value: C) = MatcherResult(
value.contains(t),
{ "Collection should contain element ${t.show().value}; listing some elements ${value.take(5)}" },
{ "Collection should not contain element ${t.show().value}" }
)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy