Files
kotlin-fork/backend.native/tests/external/stdlib/collections/CollectionTest/groupByKeysAndValues.kt
T
Ilya Matveev 85827b4880 tests: Copy stdlib tests from Kotlin/JVM
This patch copies Kotlin/JVM stdlib tests (libraries/stdlib/test)
excepting ones with explicit java dependencies. It also transforms
the tests to use them as box-tests.
2017-04-07 17:21:11 +07:00

18 lines
563 B
Kotlin

import kotlin.test.*
import kotlin.comparisons.*
fun box() {
val nameToTeam = listOf("Alice" to "Marketing", "Bob" to "Sales", "Carol" to "Marketing")
val namesByTeam = nameToTeam.groupBy({ it.second }, { it.first })
assertEquals(
listOf(
"Marketing" to listOf("Alice", "Carol"),
"Sales" to listOf("Bob")
),
namesByTeam.toList())
val mutableNamesByTeam = nameToTeam.groupByTo(HashMap(), { it.second }, { it.first })
assertEquals(namesByTeam, mutableNamesByTeam)
}