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.119 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.118 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.117 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.116 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.115 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.114 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.113 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.111 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.110 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.109 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.108 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.107 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.106 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.105 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.104 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.103 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.102 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.101 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.100 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt
trackler-2.2.1.99 tracks/kotlin/exercises/accumulate/src/test/kotlin/AccumulateTest.kt