Sha256: 1472f227d35b0e2739767fe9d68b6f8b239e831baa67692f5b2e8ee23d767ab4

Contents?: true

Size: 1.67 KB

Versions: 126

Compression:

Stored size: 1.67 KB

Contents

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

class BinarySearchTest {

    @Test
    fun findsTheItemInASingleElementList() {
        assertEquals(0, BinarySearch.search(listOf(6), 6))
    }

    @Ignore
    @Test
    fun findsTheItemInTheMiddleOfAList() {
        assertEquals(3, BinarySearch.search(listOf(1, 3, 4, 6, 8, 9, 11), 6))
    }

    @Ignore
    @Test
    fun findsTheItemAtTheBeginningOfAList() {
        assertEquals(0, BinarySearch.search(listOf(1, 3, 4, 6, 8, 9, 11), 1))
    }

    @Ignore
    @Test
    fun findsTheItemAtTheEndOfAList() {
        assertEquals(6, BinarySearch.search(listOf(1, 3, 4, 6, 8, 9, 11), 11))
    }

    @Ignore
    @Test
    fun findsValueInAListOfOddLength() {
        assertEquals(9, BinarySearch.search(listOf(1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634), 144))
    }

    @Ignore
    @Test
    fun findsValueInAListOfEvenLength() {
        assertEquals(5, BinarySearch.search(listOf(1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377), 21))
    }

    @Ignore
    @Test
    fun identifiesThatAValueIsNotInTheList() {
        assertEquals(-1, BinarySearch.search(listOf(1, 3, 4, 6, 8, 9, 11), 7))
    }

    @Ignore
    @Test
    fun identifiesThatAValueSmallerThanTheSmallestListElementIsNotInTheList() {
        assertEquals(-1, BinarySearch.search(listOf(1, 3, 4, 6, 8, 9, 11), 0))
    }

    @Ignore
    @Test
    fun identifiesThatAValueLargerThanTheLargestListElementIsNotInTheList() {
        assertEquals(-1, BinarySearch.search(listOf(1, 3, 4, 6, 8, 9, 11), 13))
    }

    @Ignore
    @Test
    fun identifiesThatNothingCanBeFoundInAnEmptyList() {
        assertEquals(-1, BinarySearch.search(emptyList(), 1))
    }

}

Version data entries

126 entries across 126 versions & 1 rubygems

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