
commonMain.io.kotest.matchers.collections.smaller.kt Maven / Gradle / Ivy
package io.kotest.matchers.collections
import io.kotest.matchers.Matcher
import io.kotest.matchers.MatcherResult
import io.kotest.matchers.should
infix fun Iterable.shouldBeSmallerThan(other: Collection): Iterable {
toList().shouldBeSmallerThan(other)
return this
}
infix fun Array.shouldBeSmallerThan(other: Collection): Array {
asList().shouldBeSmallerThan(other)
return this
}
infix fun Iterable.shouldBeSmallerThan(other: Iterable): Iterable {
toList().shouldBeSmallerThan(other.toList())
return this
}
infix fun Array.shouldBeSmallerThan(other: Array): Array {
asList().shouldBeSmallerThan(other.asList())
return this
}
infix fun Collection.shouldBeSmallerThan(other: Collection): Collection {
this should beSmallerThan(other)
return this
}
fun beSmallerThan(other: Collection) = object : Matcher> {
override fun test(value: Collection) = MatcherResult(
value.size < other.size,
{ "Collection of size ${value.size} should be smaller than collection of size ${other.size}" },
{ "Collection of size ${value.size} should not be smaller than collection of size ${other.size}" })
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy