
commonMain.io.kotest.matchers.collections.duplicates.kt Maven / Gradle / Ivy
package io.kotest.matchers.collections
import io.kotest.matchers.Matcher
import io.kotest.matchers.MatcherResult
import io.kotest.matchers.should
import io.kotest.matchers.shouldNot
fun Iterable.shouldContainDuplicates(): Iterable {
toList().shouldContainDuplicates()
return this
}
fun Array.shouldContainDuplicates() {
asList().shouldContainDuplicates()
}
fun Collection.shouldContainDuplicates(): Collection {
this should containDuplicates()
return this
}
fun Iterable.shouldNotContainDuplicates(): Iterable {
toList().shouldNotContainDuplicates()
return this
}
fun Array.shouldNotContainDuplicates(): Array {
asList().shouldNotContainDuplicates()
return this
}
fun Collection.shouldNotContainDuplicates(): Collection {
this shouldNot containDuplicates()
return this
}
fun containDuplicates() = object : Matcher> {
override fun test(value: Collection) = MatcherResult(
value.toSet().size < value.size,
{ "Collection should contain duplicates" },
{
"Collection should not contain duplicates"
})
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy