Files
kotlin-fork/backend.native/tests/external/stdlib/collections/GroupingTest/countEach.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

15 lines
438 B
Kotlin

import kotlin.test.*
fun box() {
val elements = listOf("foo", "bar", "flea", "zoo", "biscuit")
val counts = elements.groupingBy { it.first() }.eachCount()
assertEquals(mapOf('f' to 2, 'b' to 2, 'z' to 1), counts)
val elements2 = arrayOf("zebra", "baz", "cab")
val counts2 = elements2.groupingBy { it.last() }.eachCountTo(HashMap(counts))
assertEquals(mapOf('f' to 2, 'b' to 3, 'a' to 1, 'z' to 2), counts2)
}