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.139 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.138 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.137 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.136 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.135 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.134 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.133 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.132 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.131 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.130 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.129 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.128 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.127 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.126 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.125 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.124 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.123 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.122 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.121 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt
trackler-2.2.1.120 tracks/kotlin/exercises/flatten-array/src/test/kotlin/FlattenerTest.kt