tests/test-mdiff.py
author Arseniy Alekseyev <aalekseyev@janestreet.com>
Tue, 09 Apr 2024 11:12:24 +0100
changeset 51602 68929cf3c0c6
parent 48875 6000f5b25c9b
permissions -rw-r--r--
match: avoid rust fast path if the matcher was tampered with Otherwise the fast path does not respect the modifications made by the extension (concretely largefiles, but other extensions can start using that too)

import unittest

from mercurial import mdiff


class splitnewlinesTests(unittest.TestCase):
    def test_splitnewlines(self):
        cases = {
            b'a\nb\nc\n': [b'a\n', b'b\n', b'c\n'],
            b'a\nb\nc': [b'a\n', b'b\n', b'c'],
            b'a\nb\nc\n\n': [b'a\n', b'b\n', b'c\n', b'\n'],
            b'': [],
            b'abcabc': [b'abcabc'],
        }
        for inp, want in cases.items():
            self.assertEqual(mdiff.splitnewlines(inp), want)


if __name__ == '__main__':
    import silenttestrunner

    silenttestrunner.main(__name__)