Beispiel #1
0
 def test_no_lcs(self):
     seq1 = 'abc'
     seq2 = 'xyz'
     expected_lcs = []
     lcs_gen = diff._backtrack(diff._build_lcs_matrix(seq1, seq2))
     self.assertEqual(
         expected_lcs,
         [i for i in reversed([x for x in lcs_gen])])
Beispiel #2
0
 def test_lcs_is_not_aligned(self):
     seq1 = '---a-bc'
     seq2 = 'ab.c..'
     expected_lcs = [(3, 0), (5, 1), (6, 3)]
     lcs_gen = diff._backtrack(diff._build_lcs_matrix(seq1, seq2))
     self.assertEqual(
         expected_lcs,
         [i for i in reversed([x for x in lcs_gen])])
Beispiel #3
0
 def test_lcs_is_not_contiguous(self):
     seq1 = '-a-b-c-'
     seq2 = '.a.b.c.'
     expected_lcs = [(1, 1), (3, 3), (5, 5)]
     lcs_gen = diff._backtrack(diff._build_lcs_matrix(seq1, seq2))
     self.assertEqual(
         expected_lcs,
         [i for i in reversed([x for x in lcs_gen])])
Beispiel #4
0
 def test_more_than_one_possible_lcs(self):
     '''When there is a choice only one value should be returned'''
     # IMPORTANT if we swap in a different lcs function this test may have
     # to change because it may choose a different one.
     seq1 = 'aabb'
     seq2 = 'bbaa'
     expected_lcs = [(0, 2), (1, 3)]
     lcs_gen = diff._backtrack(diff._build_lcs_matrix(seq1, seq2))
     self.assertEqual(
         expected_lcs,
         [i for i in reversed([x for x in lcs_gen])])