Sha256: 45ed44d68a8fe58788f2df87b2464d6984a81b339255aa2465837f890b5d78ef

Contents?: true

Size: 1.68 KB

Versions: 307

Compression:

Stored size: 1.68 KB

Contents

import org.junit.Test
import org.junit.Ignore
import kotlin.test.assertEquals

class AccumulateTest {


    @Test
    fun emptyAccumulateProducesEmptyAccumulation() {
        val input = listOf<Int>()
        val expectedOutput = listOf<Int>()
        assertEquals(expectedOutput, Accumulate.accumulate(input, { x -> x * x }))
    }

    @Ignore
    @Test
    fun accumulateSquares() {
        val input = listOf(1, 2, 3)
        val expectedOutput = listOf(1, 4, 9)
        assertEquals(expectedOutput, Accumulate.accumulate(input, { x -> x * x }))
    }

    @Ignore
    @Test
    fun accumulateUpperCases() {
        val input = listOf("hello", "world")
        val expectedOutput = listOf("HELLO", "WORLD")
        assertEquals(expectedOutput, Accumulate.accumulate(input, { it.toUpperCase() }))
    }

    @Ignore
    @Test
    fun accumulateReversedStrings() {
        val input = "the quick brown fox etc".split(" ")
        val expectedOutput = "eht kciuq nworb xof cte".split(" ")
        assertEquals(expectedOutput, Accumulate.accumulate(input, { it.reversed() }))
    }

    @Ignore
    @Test
    fun accumulateWithinAccumulate() {
        val input1 = listOf("a", "b", "c")
        val input2 = listOf("1", "2", "3")
        val expectedOutput = listOf("a1 a2 a3", "b1 b2 b3", "c1 c2 c3")
        assertEquals(expectedOutput, Accumulate.accumulate(input1,
                { c -> Accumulate.accumulate(input2, { d -> c + d }).joinToString(" ") }
        ))
    }

    @Ignore
    @Test
    fun accumulateToDifferentType() {
        val input = listOf(1, 2, 3)
        val expectedOutput = listOf("1", "2", "3")
        assertEquals(expectedOutput, Accumulate.accumulate(input, { it.toString() }))
    }
}

Version data entries

307 entries across 307 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.179 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.178 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.177 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.176 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.175 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.174 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.173 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.172 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.171 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.170 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.169 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.167 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.166 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.165 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.164 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.163 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.162 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.161 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.160 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt