Exemple #1
0
    def remove_typos_beginning_negated_test(self):
        """
        Test the _remove_typos function with a large difference in the middle.
        """
        # GIVEN: A diffset with a large difference in the middle.
        diff = [('equal', 0, 10, 0, 10), ('replace', 10, 20, 10, 11), ('equal', 20, 30, 11, 21)]

        # WHEN: We remove the typos in there.
        result = _remove_typos(list(diff))

        # THEN: There diff should not have changed.
        assert result == diff
Exemple #2
0
    def remove_typos_beginning_negated_test(self):
        """
        Test the _remove_typos function with a large difference in the middle.
        """
        # GIVEN: A diffset with a large difference in the middle.
        diff = [('equal', 0, 10, 0, 10), ('replace', 10, 20, 10, 11), ('equal', 20, 30, 11, 21)]

        # WHEN: We remove the typos in there.
        result = _remove_typos(list(diff))

        # THEN: There diff should not have changed.
        assert result == diff
Exemple #3
0
    def test_remove_typos_end_negated(self):
        """
        Test the _remove_typos function with a large difference at the end.
        """
        # GIVEN: A diffset with a large difference at the end.
        diff = [('equal', 0, 10, 0, 10), ('replace', 10, 20, 10, 1)]

        # WHEN: We remove the typos in there.
        result = _remove_typos(list(diff))

        # THEN: There diff should not have changed.
        assert result == diff
Exemple #4
0
    def test_remove_typos_end_negated(self):
        """
        Test the _remove_typos function with a large difference at the end.
        """
        # GIVEN: A diffset with a large difference at the end.
        diff = [('equal', 0, 10, 0, 10), ('replace', 10, 20, 10, 1)]

        # WHEN: We remove the typos in there.
        result = _remove_typos(list(diff))

        # THEN: There diff should not have changed.
        assert result == diff
Exemple #5
0
    def remove_typos_end_test(self):
        """
        Test the _remove_typos function with a typo at the end.
        """
        # GIVEN: A diffset with a difference at the end.
        diff = [('equal', 0, 10, 0, 10), ('replace', 10, 12, 10, 11)]

        # WHEN: We remove the typos in there.
        result = _remove_typos(diff)

        # THEN: There should be no typos at the end anymore.
        assert len(result) == 1, 'The result should contain only one element.'
        assert result[0][0] == 'equal', 'The result should contain an equal element.'
Exemple #6
0
    def remove_typos_end_test(self):
        """
        Test the _remove_typos function with a typo at the end.
        """
        # GIVEN: A diffset with a difference at the end.
        diff = [('equal', 0, 10, 0, 10), ('replace', 10, 12, 10, 11)]

        # WHEN: We remove the typos in there.
        result = _remove_typos(diff)

        # THEN: There should be no typos at the end anymore.
        assert len(result) == 1, 'The result should contain only one element.'
        assert result[0][0] == 'equal', 'The result should contain an equal element.'
Exemple #7
0
    def remove_typos_middle_test(self):
        """
        Test the _remove_typos function with a typo in the middle.
        """
        # GIVEN: A diffset with a difference in the middle.
        diff = [('equal', 0, 10, 0, 10), ('replace', 10, 12, 10, 11), ('equal', 12, 22, 11, 21)]

        # WHEN: We remove the typos in there.
        result = _remove_typos(diff)

        # THEN: There should be no typos in the middle anymore. The remaining equals should have been merged.
        assert len(result) is 1, 'The result should contain only one element.'
        assert result[0][0] == 'equal', 'The result should contain an equal element.'
        assert result[0][1] == 0, 'The start indices should be kept.'
        assert result[0][2] == 22, 'The stop indices should be kept.'
        assert result[0][3] == 0, 'The start indices should be kept.'
        assert result[0][4] == 21, 'The stop indices should be kept.'
Exemple #8
0
    def remove_typos_middle_test(self):
        """
        Test the _remove_typos function with a typo in the middle.
        """
        # GIVEN: A diffset with a difference in the middle.
        diff = [('equal', 0, 10, 0, 10), ('replace', 10, 12, 10, 11), ('equal', 12, 22, 11, 21)]

        # WHEN: We remove the typos in there.
        result = _remove_typos(diff)

        # THEN: There should be no typos in the middle anymore. The remaining equals should have been merged.
        assert len(result) is 1, 'The result should contain only one element.'
        assert result[0][0] == 'equal', 'The result should contain an equal element.'
        assert result[0][1] == 0, 'The start indices should be kept.'
        assert result[0][2] == 22, 'The stop indices should be kept.'
        assert result[0][3] == 0, 'The start indices should be kept.'
        assert result[0][4] == 21, 'The stop indices should be kept.'