Introduce filterIndexed

#KT-9502 Fixed
This commit is contained in:
Ilya Gorbunov
2015-11-07 17:55:33 +03:00
parent ee759c10c8
commit 008a8059cf
9 changed files with 310 additions and 27 deletions
+9
View File
@@ -746,6 +746,15 @@ class StringTest {
assertContentEquals("abcd", arg1("a1b2c3d4").filterNot { it.isAsciiDigit() })
}
@test fun filterIndexed() {
val data = "abedcf"
assertEquals("abdf", data.filterIndexed { index, c -> c == 'a' + index })
}
@test fun filterIndexedCharSequence() = withOneCharSequenceArg("abedcf") { data ->
assertContentEquals("abdf", data.filterIndexed { index, c -> c == 'a' + index })
}
@test fun all() = withOneCharSequenceArg("AbCd") { data ->
assertTrue {
data.all { it.isAsciiLetter() }