diff --git a/exercises/hamming/.meta/src/reference/kotlin/Hamming.kt b/exercises/hamming/.meta/src/reference/kotlin/Hamming.kt index 8fdcf903..1edeb9ac 100644 --- a/exercises/hamming/.meta/src/reference/kotlin/Hamming.kt +++ b/exercises/hamming/.meta/src/reference/kotlin/Hamming.kt @@ -1,7 +1,7 @@ object Hamming { fun compute(leftStrand: String, rightStrand: String): Int { - require(leftStrand.length == rightStrand.length, {"left and right strands must be of equal length."}) + require(leftStrand.length == rightStrand.length, {"left and right strands must be of equal length"}) val commonPairs = leftStrand.zip(rightStrand) return commonPairs.count { it.first != it.second } diff --git a/exercises/hamming/.meta/version b/exercises/hamming/.meta/version index 7ec1d6db..276cbf9e 100644 --- a/exercises/hamming/.meta/version +++ b/exercises/hamming/.meta/version @@ -1 +1 @@ -2.1.0 +2.3.0 diff --git a/exercises/hamming/src/test/kotlin/HammingTest.kt b/exercises/hamming/src/test/kotlin/HammingTest.kt index d12712df..70adce2e 100644 --- a/exercises/hamming/src/test/kotlin/HammingTest.kt +++ b/exercises/hamming/src/test/kotlin/HammingTest.kt @@ -11,98 +11,49 @@ class HammingTest { var expectedException: ExpectedException = ExpectedException.none() @Test - fun noDistanceBetweenEmptyStrands() { + fun `empty strands`() { assertEquals(0, Hamming.compute("", "")) } @Ignore @Test - fun noDistanceBetweenShortIdenticalStrands() { + fun `single letter identical strands`() { assertEquals(0, Hamming.compute("A", "A")) } @Ignore @Test - fun noDistanceBetweenLongIdenticalStrands() { - assertEquals(0, Hamming.compute("GGACTGA", "GGACTGA")) + fun `single letter different strands`() { + assertEquals(1, Hamming.compute("G", "T")) } @Ignore @Test - fun completeDistanceInSingleNucleotideStrand() { - assertEquals(1, Hamming.compute("A", "G")) + fun `long identical strands`() { + assertEquals(0, Hamming.compute("GGACTGAAATCTG", "GGACTGAAATCTG")) } @Ignore @Test - fun completeDistanceInSmallStrand() { - assertEquals(2, Hamming.compute("AG", "CT")) - } - - @Ignore - @Test - fun smallDistanceInSmallStrand() { - assertEquals(1, Hamming.compute("AT", "CT")) - } - - @Ignore - @Test - fun smallDistanceInMediumStrand() { - assertEquals(1, Hamming.compute("GGACG", "GGTCG")) - } - - @Ignore - @Test - fun smallDistanceInLongStrand() { - assertEquals(2, Hamming.compute("ACCAGGG", "ACTATGG")) - } - - @Ignore - @Test - fun nonUniqueCharacterInFirstStrand() { - assertEquals(1, Hamming.compute("AAG", "AAA")) - } - - @Ignore - @Test - fun nonUniqueCharacterInSecondStrand() { - assertEquals(1, Hamming.compute("AAA", "AAG")) - } - - @Ignore - @Test - fun sameNucleotidesInDifferentPositions() { - assertEquals(2, Hamming.compute("TAG", "GAT")) - } - - @Ignore - @Test - fun largeDistanceInPermutedStrand() { - assertEquals(4, Hamming.compute("GATACA", "GCATAA")) - } - - @Ignore - @Test - fun largeDistanceInOffByOneStrand() { + fun `long different strands`() { assertEquals(9, Hamming.compute("GGACGGATTCTG", "AGGACGGATTCT")) } @Ignore @Test - fun validatesFirstStrandNotLonger() { + fun `disallow first strand longer`() { expectedException.expect(IllegalArgumentException::class.java) - expectedException.expectMessage("left and right strands must be of equal length.") + expectedException.expectMessage("left and right strands must be of equal length") Hamming.compute("AATG", "AAA") } @Ignore @Test - fun validatesSecondStrandNotLonger() { + fun `disallow second strand longer`() { expectedException.expect(IllegalArgumentException::class.java) - expectedException.expectMessage("left and right strands must be of equal length.") + expectedException.expectMessage("left and right strands must be of equal length") Hamming.compute("ATA", "AGTG") } - }