Skip to content

Commit

Permalink
Issue exercism#1621 Update hamming_tests to v2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CometS1 committed Dec 11, 2018
1 parent ff8a718 commit 433b892
Showing 1 changed file with 8 additions and 32 deletions.
40 changes: 8 additions & 32 deletions exercises/hamming/hamming_test.py
Expand Up @@ -3,47 +3,23 @@
import hamming


# Tests adapted from `problem-specifications//canonical-data.json` @ v2.1.1
# Tests adapted from `problem-specifications//canonical-data.json` @ v2.2.0

class HammingTest(unittest.TestCase):

def test_empty_strands(self):
self.assertEqual(hamming.distance("", ""), 0)

def test_identical_strands(self):
def test_single_letter_identical_strands(self):
self.assertEqual(hamming.distance("A", "A"), 0)

def test_long_identical_strands(self):
self.assertEqual(hamming.distance("GGACTGA", "GGACTGA"), 0)

def test_complete_distance_in_single_nucleotide_strands(self):
self.assertEqual(hamming.distance("A", "G"), 1)

def test_complete_distance_in_small_strands(self):
self.assertEqual(hamming.distance("AG", "CT"), 2)

def test_small_distance_in_small_strands(self):
self.assertEqual(hamming.distance("AT", "CT"), 1)

def test_small_distance(self):
self.assertEqual(hamming.distance("GGACG", "GGTCG"), 1)
def test_single_letter_different_strands(self):
self.assertEqual(hamming.distance("G", "T"), 1)

def test_small_distance_in_long_strands(self):
self.assertEqual(hamming.distance("ACCAGGG", "ACTATGG"), 2)

def test_non_unique_character_in_first_strand(self):
self.assertEqual(hamming.distance("AAG", "AAA"), 1)

def test_non_unique_character_in_second_strand(self):
self.assertEqual(hamming.distance("AAA", "AAG"), 1)

def test_same_nucleotides_in_different_positions(self):
self.assertEqual(hamming.distance("TAG", "GAT"), 2)

def test_large_distance(self):
self.assertEqual(hamming.distance("GATACA", "GCATAA"), 4)
def test_long_identical_strands(self):
self.assertEqual(hamming.distance("GGACTGAAATCTG", "GGACTGAAATCTG"), 0)

def test_large_distance_in_off_by_one_strand(self):
def test_long_different_strands(self):
self.assertEqual(hamming.distance("GGACGGATTCTG", "AGGACGGATTCT"), 9)

def test_disallow_first_strand_longer(self):
Expand All @@ -66,4 +42,4 @@ def assertRaisesWithMessage(self, exception):


if __name__ == '__main__':
unittest.main()
unittest.main()

0 comments on commit 433b892

Please sign in to comment.