Sha256: ec628ef53a4694040ae54d274d24d90d7bfe006cc186c113dcad4233b18f3696

Contents?: true

Size: 1.79 KB

Versions: 89

Compression:

Stored size: 1.79 KB

Contents

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

class NucleotideTest {

    @Test
    fun emptyDnaStringHasNoAdenosine() {
        val dna = DNA("");

        assertEquals(0, dna.count('A'))
    }

    @Test
    fun emptyDnaStringHasNoNucleotides() {
        val dna = DNA("");
        val expected = mapOf('A' to 0, 'C' to 0, 'G' to 0, 'T' to 0)

        assertEquals(expected, dna.nucleotideCounts)
    }

    @Test
    fun repetitiveCytidineGetsCounted() {
        val dna = DNA("CCCCC");
        assertEquals(5, dna.count('C'))
    }

    @Test
    fun repetitiveSequenceWithOnlyGuanosine() {
        val dna = DNA("GGGGGGGG");
        val expected = mapOf('A' to 0, 'C' to 0, 'G' to 8, 'T' to 0)

        assertEquals(expected, dna.nucleotideCounts)
    }

    @Test
    fun countsOnlyThymidine() {
        val dna = DNA("GGGGGTAACCCGG");

        assertEquals(1, dna.count('T'))
    }

    @Test
    fun countsANucleotideOnlyOnce() {
        val dna = DNA("CGATTGGG");

        dna.count('T')
        assertEquals(2, dna.count('T'))
    }

    @Test
    fun dnaCountsDoNotChangeAfterCountingAdenosine() {
        val dna = DNA("GATTACA");
        val expected = mapOf('A' to 3, 'C' to 1, 'G' to 1, 'T' to 2)

        dna.count('A');
        assertEquals(expected, dna.nucleotideCounts)
    }

    @Test(expected = IllegalArgumentException::class)
    fun validatesNucleotides() {
        DNA("GX")
    }

    @Test(expected = IllegalArgumentException::class)
    fun validatesNucleotidesCountInput() {
        DNA("GACT").count('X');
    }

    @Test
    fun countsAllNucleotides() {
        val dna = DNA("AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC")
        val expected = mapOf('A' to 20, 'C' to 12, 'G' to 17, 'T' to 21)

        assertEquals(expected, dna.nucleotideCounts)
    }
}

Version data entries

89 entries across 89 versions & 1 rubygems

Version Path
trackler-2.0.6.33 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.32 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.31 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.30 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.29 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.28 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.27 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.26 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.25 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.24 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.23 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.22 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.21 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.20 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.19 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.18 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.17 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.16 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.15 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt
trackler-2.0.6.14 tracks/kotlin/exercises/nucleotide-count/src/test/kotlin/NucleotideTest.kt