Add sample for orEmpty method

This commit is contained in:
Yuki Miida
2018-09-16 19:45:49 +09:00
committed by ilya-g
parent 64b23812c0
commit af1fc5b668
2 changed files with 11 additions and 0 deletions
@@ -119,6 +119,15 @@ class Maps {
assertFalse(map.isNullOrEmpty())
}
@Sample
fun mapOrEmpty() {
val nullMap: Map<String, Any>? = null
assertPrints(nullMap.orEmpty(), "{}")
val map: Map<Char, Int>? = mapOf('a' to 1, 'b' to 2, 'c' to 3)
assertPrints(map.orEmpty(), "{a=1, b=2, c=3}")
}
@Sample
fun mapIfEmpty() {
val emptyMap: Map<String, Int> = emptyMap()