Sha256: c44920a79b3481c787971d5899e336d251c1dab20ab49c75fad9544241c15622

Contents?: true

Size: 1.36 KB

Versions: 129

Compression:

Stored size: 1.36 KB

Contents

import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
import kotlin.test.assertEquals

class CollatzCalculatorTest {

    @Rule
    @JvmField
    var expectedException: ExpectedException = ExpectedException.none()

    @Test
    fun testZeroStepsRequiredWhenStartingFrom1() {
        assertEquals(0, CollatzCalculator.computeStepCount(1))
    }

    @Ignore
    @Test
    fun testCorrectNumberOfStepsWhenAllStepsAreDivisions() {
        assertEquals(4, CollatzCalculator.computeStepCount(16))
    }

    @Ignore
    @Test
    fun testCorrectNumberOfStepsWhenBothStepTypesAreNeeded() {
        assertEquals(9, CollatzCalculator.computeStepCount(12))
    }

    @Ignore
    @Test
    fun testAVeryLargeInput() {
        assertEquals(152, CollatzCalculator.computeStepCount(1000000))
    }

    @Ignore
    @Test
    fun testZeroIsConsideredInvalidInput() {
        expectedException.expect(IllegalArgumentException::class.java)
        expectedException.expectMessage("Only natural numbers are allowed")

        CollatzCalculator.computeStepCount(0)
    }

    @Ignore
    @Test
    fun testNegativeIntegerIsConsideredInvalidInput() {
        expectedException.expect(IllegalArgumentException::class.java)
        expectedException.expectMessage("Only natural numbers are allowed")

        CollatzCalculator.computeStepCount(-15)
    }

}

Version data entries

129 entries across 129 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.138 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.137 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.136 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.135 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.134 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.133 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.132 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.131 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.130 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.129 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.128 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.127 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.126 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.125 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.124 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.123 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.122 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.121 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt
trackler-2.2.1.120 tracks/kotlin/exercises/collatz-conjecture/src/test/kotlin/CollatzCalculatorTest.kt