diff --git a/src/commonMain/kotlin/ch/tutteli/kbox/WithIndex.kt b/src/commonMain/kotlin/ch/tutteli/kbox/WithIndex.kt deleted file mode 100644 index cb13efc..0000000 --- a/src/commonMain/kotlin/ch/tutteli/kbox/WithIndex.kt +++ /dev/null @@ -1,7 +0,0 @@ -package ch.tutteli.kbox - -/** - * A named pair with [index] and [value]. - */ -@Suppress("MemberVisibilityCanBePrivate") -data class WithIndex(val index: Int, val value: T) diff --git a/src/commonMain/kotlin/ch/tutteli/kbox/mapWithIndex.kt b/src/commonMain/kotlin/ch/tutteli/kbox/mapWithIndex.kt deleted file mode 100644 index 3699687..0000000 --- a/src/commonMain/kotlin/ch/tutteli/kbox/mapWithIndex.kt +++ /dev/null @@ -1,16 +0,0 @@ -package ch.tutteli.kbox - -/** - * Maps the values to [WithIndex], containing the index next to the value itself. - */ -fun Array.mapWithIndex(): List> = this.mapIndexed { index, t -> WithIndex(index, t) } - -/** - * Maps the values to [WithIndex], containing the index next to the value itself. - */ -fun Iterable.mapWithIndex(): List> = this.mapIndexed { index, t -> WithIndex(index, t) } - -/** - * Maps the values to [WithIndex], containing the index next to the value itself. - */ -fun Sequence.mapWithIndex(): Sequence> = this.mapIndexed { index, t -> WithIndex(index, t) } diff --git a/src/commonTest/kotlin/ch/tutteli/kbox/MapWithIndexTest.kt b/src/commonTest/kotlin/ch/tutteli/kbox/MapWithIndexTest.kt deleted file mode 100644 index aba7160..0000000 --- a/src/commonTest/kotlin/ch/tutteli/kbox/MapWithIndexTest.kt +++ /dev/null @@ -1,53 +0,0 @@ -package ch.tutteli.kbox - -import ch.tutteli.atrium.api.fluent.en_GB.group -import ch.tutteli.atrium.api.fluent.en_GB.toContainExactly -import ch.tutteli.atrium.api.fluent.en_GB.toBeEmpty -import ch.tutteli.atrium.api.verbs.expect -import ch.tutteli.atrium.api.verbs.expectGrouped -import kotlin.test.Test - -class MapWithIndexTest { - - @Test - fun data_driven(){ - expectGrouped { - mapOf( - "Array" to { ints: Array -> ints.mapWithIndex() }, - "Iterable" to { ints: Array -> listOf(*ints).asIterable().mapWithIndex() }, - "Sequence" to { ints: Array -> listOf(*ints).asSequence().mapWithIndex().toList() } - ).forEach { (type, function) -> - group("empty $type") { - group("returns an empty list") { - val result = function(arrayOf()) - expect(result).toBeEmpty() - } - } - - group("$type with one element") { - group("returns list WithIndex(0, element0)") { - val result = function(arrayOf(1)) - expect(result).toContainExactly(WithIndex(0, 1)) - } - } - - group("$type with two elements") { - group("returns list WithIndex(0, element0) and WithIndex(1, element1") { - val result = function(arrayOf(1, 2)) - expect(result).toContainExactly(WithIndex(0, 1), WithIndex(1, 2)) - } - } - group("$type with three elements") { - group("returns list with three WithIndex(0..2, element0..2)") { - val result = function(arrayOf(1, 2, 3)) - expect(result).toContainExactly( - WithIndex(0, 1), - WithIndex(1, 2), - WithIndex(2, 3) - ) - } - } - } - } - } -}