Sha256: 5fd25bc51e782712fb6f0550242cfdcee7b5094331232f6f74d7f5962dba449d

Contents?: true

Size: 1.97 KB

Versions: 89

Compression:

Stored size: 1.97 KB

Contents

import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import kotlin.test.assertEquals

@RunWith(Parameterized::class)
class PigLatinTest(val input: String, val expectedOutput: String) {

    companion object {
        @JvmStatic
        @Parameterized.Parameters(name = "{index}: translate({0})={1}")
        fun data() = arrayOf(
                // Ay is added to words that start with vowels
                arrayOf("apple", "appleay"),
                arrayOf("ear", "earay"),
                arrayOf("igloo", "iglooay"),
                arrayOf("object", "objectay"),
                arrayOf("under", "underay"),

                // First letter and ay are moved to the end of words that start with consonants
                arrayOf("pig", "igpay"),
                arrayOf("koala", "oalakay"),
                arrayOf("yellow", "ellowyay"),
                arrayOf("xenon", "enonxay"),

                // Ch is treated like a single consonant
                arrayOf("chair", "airchay"),

                // Qu is treated like a single consonant
                arrayOf("queen", "eenquay"),

                // Qu and a single preceding consonant are treated like a single consonant
                arrayOf("square", "aresquay"),

                // Th is treated like a single consonant
                arrayOf("therapy", "erapythay"),

                // Thr is treated like a single consonant
                arrayOf("thrush", "ushthray"),

                // Sch is treated like a single consonant
                arrayOf("school", "oolschay"),

                // Yt is treated like a single vowel
                arrayOf("yttria", "yttriaay"),

                // Xr is treated like a single vowel
                arrayOf("xray", "xrayay"),

                // Phrases are translated
                arrayOf("quick fast run", "ickquay astfay unray")
        )
    }

    @Test
    fun test() {
        assertEquals(expectedOutput, PigLatin.translate(input))
    }
}

Version data entries

89 entries across 89 versions & 1 rubygems

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