예제 #1
0
    def test_single_deletion_reversed(self):
        a = "a b".split()
        b = "b".split()

        expected = [
            (['a', 'b'], ['b']),
        ]

        self.assertEqual(align(a, b), expected)
예제 #2
0
    def test_single_insertion(self):
        a = "a".split()
        b = "a b".split()

        expected = [
            (['a'], ['a', 'b']),
        ]

        self.assertEqual(align(a, b), expected)
예제 #3
0
    def test_double_deletion(self):
        a = "a b c".split()
        b = "a".split()

        expected = [
            (['a', 'b', 'c'], ['a']),
        ]

        self.assertEqual(align(a, b), expected)
예제 #4
0
    def test_double_insertion_reversed(self):
        a = "b".split()
        b = "c a b".split()

        expected = [
            (['b'], ['c', 'a', 'b']),
        ]

        self.assertEqual(align(a, b), expected)
예제 #5
0
    def test_substitution_only(self):
        a = "a".split()
        b = "b".split()

        expected = [
            (['a'], ['b']),
        ]

        self.assertEqual(align(a, b), expected)
예제 #6
0
    def test_single_element(self):
        a = "a".split()
        b = "a".split()

        expected = [
            (['a'], ['a']),
        ]

        self.assertEqual(align(a, b), expected)
예제 #7
0
    def test_trivial(self):
        a = "a b".split()
        b = "a b".split()

        expected = [
            (['a'], ['a']),
            (['b'], ['b']),
        ]

        self.assertEqual(align(a, b), expected)
예제 #8
0
    def test_inversion_at_end(self):
        a = "a b c d".split()
        b = "a b d c".split()

        expected = [
            (['a'], ['a']),
            (['b'], ['b']),
            (['c'], ['d']),
            (['d'], ['c']),
        ]

        self.assertEqual(align(a, b), expected)
예제 #9
0
    def test_double_substituion(self):
        a = "a b c d".split()
        b = "a x y d".split()

        expected = [
            (['a'], ['a']),
            (['b'], ['x']),
            (['c'], ['y']),
            (['d'], ['d']),
        ]

        self.assertEqual(align(a, b), expected)
예제 #10
0
    def test_inner_insertion(self):
        a = "a d".split()
        b = "a b c d".split()

        expected_1 = [
            (['a'], ['a', 'b', 'c']),
            (['d'], ['d']),
        ]
        expected_2 = [
            (['a'], ['a']),
            (['d'], ['b', 'c', 'd']),
        ]

        self.assertIn(align(a, b), [expected_1, expected_2])