Covering stdlib with tests.

This commit is contained in:
Ilya Ryzhenkov
2015-01-12 22:42:08 +03:00
parent c3eaf1b869
commit 4ee64d7283
5 changed files with 42 additions and 2 deletions
@@ -66,6 +66,13 @@ public class StreamTest {
}
}
test fun withIndex() {
val data = streamOf("foo", "bar")
val indexed = data.withIndex().map { it.value.substring(0..it.index) }.toList()
assertEquals(2, indexed.size())
assertEquals(listOf("f", "ba"), indexed)
}
test fun filterAndTakeWhileExtractTheElementsWithinRange() {
assertEquals(listOf(144, 233, 377, 610, 987), fibonacci().filter { it > 100 }.takeWhile { it < 1000 }.toList())
}
@@ -99,6 +106,7 @@ public class StreamTest {
test fun dropWhile() {
assertEquals("233, 377, 610", fibonacci().dropWhile { it < 200 }.take(3).joinToString(limit = 10))
assertEquals("", streamOf(1).dropWhile { it < 200 }.joinToString(limit = 10))
}
test fun merge() {