Introduce toMap with key-value pair selector.

#KT-6657
This commit is contained in:
Ilya Gorbunov
2015-11-30 04:19:52 +03:00
parent 2966420d24
commit 544bc9a70c
6 changed files with 232 additions and 3 deletions
+11 -3
View File
@@ -184,9 +184,17 @@ class MapTest {
@test fun createWithSelectorForKeyAndValue() {
val map = listOf("a", "bb", "ccc").toMap({ it.length }, { it.toUpperCase() })
assertEquals(3, map.size)
assertEquals("A", map.get(1))
assertEquals("BB", map.get(2))
assertEquals("CCC", map.get(3))
assertEquals("A", map[1])
assertEquals("BB", map[2])
assertEquals("CCC", map[3])
}
@test fun createWithPairSelector() {
val map = listOf("a", "bb", "ccc").toMap { it.length to it.toUpperCase() }
assertEquals(3, map.size)
assertEquals("A", map[1])
assertEquals("BB", map[2])
assertEquals("CCC", map[3])
}
@test fun createUsingTo() {