Add Collections.isNullOrEmpty #KT-23279

This commit is contained in:
Jeff Wright
2018-02-20 10:03:27 -06:00
committed by Ilya Gorbunov
parent 6a140fb9ed
commit 292f69936b
2 changed files with 26 additions and 0 deletions
@@ -51,6 +51,18 @@ class Collections {
assertPrints(collection.orEmpty(), "[a, b, c]")
}
@Sample
fun collectionIsNullOrEmpty() {
val nullCollection: Collection<Any>? = null
assertTrue(nullCollection.isNullOrEmpty())
val emptyCollection: Collection<Any>? = listOf()
assertTrue(emptyCollection.isNullOrEmpty())
val collection: Collection<Char>? = listOf('a', 'b', 'c')
assertFalse(collection.isNullOrEmpty())
}
@Sample
fun collectionContainsAll() {
val collection = mutableListOf('a', 'b')