Add samples for zip on arrays and collections
Write the sample references in the template and run the generator
This commit is contained in:
committed by
Ilya Gorbunov
parent
137698d967
commit
2d4e591b5d
@@ -18,7 +18,6 @@ package samples.collections
|
||||
|
||||
import samples.*
|
||||
import kotlin.coroutines.experimental.buildIterator
|
||||
import kotlin.test.*
|
||||
|
||||
@RunWith(Enclosed::class)
|
||||
class Iterables {
|
||||
@@ -59,5 +58,19 @@ class Iterables {
|
||||
assertPrints(list.unzip(), "([1, 2, 3], [a, b, c])")
|
||||
}
|
||||
|
||||
@Sample
|
||||
fun zipIterable() {
|
||||
val listA = listOf("a", "b", "c")
|
||||
val listB = listOf(1, 2, 3, 4)
|
||||
assertPrints(listA zip listB, "[(a, 1), (b, 2), (c, 3)]")
|
||||
}
|
||||
|
||||
@Sample
|
||||
fun zipIterableWithTransform() {
|
||||
val listA = listOf("a", "b", "c")
|
||||
val listB = listOf(1, 2, 3, 4)
|
||||
val result = listA.zip(listB) { a, b -> "$a$b" }
|
||||
assertPrints(result, "[a1, b2, c3]")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user