All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonTest.number.TestComputation.kt Maven / Gradle / Ivy

Go to download

InstantSearch Android is a library providing widgets and helpers to help you build the best instant-search experience on Android with Algolia. It is built on top of Algolia's Kotlin API Client to provide you a high-level solution to quickly build various search interfaces.

There is a newer version: 3.3.1
Show newest version
package number

import com.algolia.instantsearch.core.number.Computation
import com.algolia.instantsearch.core.number.increment
import shouldEqual
import kotlin.test.Test

class TestComputation {

    @Test
    fun incrementDefaultZero() {
        var value: Int? = null
        val computation: Computation = { value = it(value) }

        computation.increment()
        value shouldEqual 0
    }

    @Test
    fun incrementDefaultOne() {
        var value: Int? = null
        val computation: Computation = { value = it(value) }

        computation.increment(default = 1)
        value shouldEqual 1
    }

    @Test
    fun incrementStep() {
        var value: Int? = null
        val step = 2
        val computation: Computation = { value = it(value) }

        computation.increment(step = step)
        value shouldEqual 0
        computation.increment(step = step)
        value shouldEqual 2
        computation.increment(step = step)
        value shouldEqual 4
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy