Sha256: 4fba8d20eb9ebab232da8314d16ccb00fa97faeca6fc53c5d8073df548fc39db

Contents?: true

Size: 1.49 KB

Versions: 126

Compression:

Stored size: 1.49 KB

Contents

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

class FlattenerTest {

    @Test
    fun flatListIsUnchanged() {
        val flatList = listOf(0, 1, 2)
        assertEquals(listOf(0, 1, 2), Flattener.flatten(flatList))
    }

    @Ignore
    @Test
    fun flattens2LevelNestedList() {
        val nestedList = listOf(1, listOf(2, 3, 4, 5, 6, 7), 8)
        assertEquals(listOf(1, 2, 3, 4, 5, 6, 7, 8), Flattener.flatten(nestedList))
    }

    @Ignore
    @Test
    fun flattens5LevelNestedList() {
        val nestedList = listOf(0, 2, listOf(listOf(2, 3), 8, 100, 4, listOf(listOf(listOf(50))), -2))
        assertEquals(listOf(0, 2, 2, 3, 8, 100, 4, 50, -2), Flattener.flatten(nestedList))
    }

    @Ignore
    @Test
    fun flattens6LevelNestedList() {
        val nestedList = listOf(1, listOf(2, listOf(listOf(3)), listOf(4, listOf(listOf(5))), 6, 7), 8)
        assertEquals(listOf(1, 2, 3, 4, 5, 6, 7, 8), Flattener.flatten(nestedList))
    }

    @Ignore
    @Test
    fun flattens6LevelNestedListWithNulls() {
        val nestedList = listOf(0, 2, listOf(listOf(2, 3), 8, listOf(listOf(100)), null, listOf(listOf(null))), -2)
        assertEquals(listOf(0, 2, 2, 3, 8, 100, -2), Flattener.flatten(nestedList))
    }

    @Ignore
    @Test
    fun allNullNestedListReturnsEmptyList() {
        val nestedList = listOf(null, listOf(listOf(listOf(null))), null, null, listOf(listOf(null, null), null), null)
        assertEquals(emptyList<Any>(), Flattener.flatten(nestedList))
    }

}

Version data entries

126 entries across 126 versions & 1 rubygems

Version Path
trackler-2.2.1.78 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.77 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.76 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.75 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.74 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.73 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.72 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.71 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.70 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.69 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.68 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.67 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.66 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.65 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.64 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.63 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.62 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.61 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.60 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.59 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt