Sha256: 1afd5c1898f89995048270ac8aa614282dd94cb366b88ebc5b9849a43c529549

Contents?: true

Size: 1.52 KB

Versions: 89

Compression:

Stored size: 1.52 KB

Contents

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

class WordCountTest {

    @Test
    fun countOneWord() {
        val expectedWordCount = mapOf("word" to 1)

        assertEquals(expectedWordCount, WordCount.phrase("word"))
    }

    @Test
    fun countOneOfEach() {
        val expectedWordCount = mapOf("one" to 1, "of" to 1, "each" to 1)

        assertEquals(expectedWordCount, WordCount.phrase("one of each"))
    }

    @Test
    fun countMultipleOccurences() {
        val expectedWordCount = mapOf("one" to 1, "fish" to 4, "two" to 1, "red" to 1, "blue" to 1)

        assertEquals(expectedWordCount, WordCount.phrase("one fish two fish red fish blue fish"))
    }

    @Test
    fun ignorePunctuation() {
        val expectedWordCount = mapOf("car" to 1, "carpet" to 1, "as" to 1, "java" to 1, "javascript" to 1)

        assertEquals(expectedWordCount, WordCount.phrase("car : carpet as java : javascript!!&@$%^&"))

    }

    @Test
    fun includeNumbers() {
        val expectedWordCount = mapOf("testing" to 2, "1" to 1, "2" to 1)

        assertEquals(expectedWordCount, WordCount.phrase("testing, 1, 2 testing"))
    }

    @Test
    fun normalizeCase() {
        val expectedWordCount = mapOf("go" to 3)

        assertEquals(expectedWordCount, WordCount.phrase("go Go GO"))
    }

    @Test
    fun allowApostrophes() {
        val expectedWordCount = mapOf("first" to 1, "don't" to 2, "laugh" to 1, "then" to 1, "cry" to 1)

        assertEquals(expectedWordCount, WordCount.phrase("First: don't laugh. Then: don't cry."))
    }

}

Version data entries

89 entries across 89 versions & 1 rubygems

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