Skip to content

Commit

Permalink
hamming: updated tests to v2.2.0
Browse files Browse the repository at this point in the history
Updated hamming test cases to v2.2.0. Fixes exercism#1621
  • Loading branch information
parthsharma2 committed Jan 8, 2019
1 parent c98184d commit 2591965
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_single_letter_different_strands(self):
self.assertEqual(hamming.distance("G", "T"), 1)

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_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_large_distance_in_off_by_one_strand(self):
self.assertEqual(hamming.distance("GGACTGAAATCTG", "GGACTGAAATCTG"), 0)

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

def test_disallow_first_strand_longer(self):
Expand Down

0 comments on commit 2591965

Please sign in to comment.