Add containsAll(Any?) check to CollectionBehaviors
This commit is contained in:
committed by
Ilya Gorbunov
parent
1b6b44c805
commit
60e83383ad
@@ -19,7 +19,7 @@ public fun <T> CompareContext<List<T>>.listBehavior() {
|
||||
for (index in expected.indices)
|
||||
propertyEquals { this[index] }
|
||||
|
||||
propertyFails { this[size] }
|
||||
propertyFailsWith<IndexOutOfBoundsException> { this[size] }
|
||||
|
||||
propertyEquals { indexOf(elementAtOrNull(0)) }
|
||||
propertyEquals { lastIndexOf(elementAtOrNull(0)) }
|
||||
@@ -103,6 +103,8 @@ public fun <T> CompareContext<Collection<T>>.collectionBehavior(objectName: Stri
|
||||
(object {}).let { propertyEquals { contains(it as Any?) } }
|
||||
propertyEquals { contains(firstOrNull()) }
|
||||
propertyEquals { containsAll(this) }
|
||||
(object {}).let { propertyEquals { containsAll(listOf<Any?>(it)) } }
|
||||
propertyEquals { containsAll(listOf<Any?>(null)) }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,6 +31,11 @@ public class CompareContext<out T>(public val expected: T, public val actual: T)
|
||||
assertFailEquals({ expected.getter() }, { actual.getter() })
|
||||
}
|
||||
|
||||
public inline fun <reified E : Throwable> propertyFailsWith(crossinline getter: T.() -> Unit) {
|
||||
assertFailsWith<E> { expected.getter() }
|
||||
assertFailsWith<E> { actual.getter() }
|
||||
}
|
||||
|
||||
public fun <P> compareProperty(getter: T.() -> P, block: CompareContext<P>.() -> Unit) {
|
||||
compare(expected.getter(), actual.getter(), block)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user