tests/test-mdiff.py
author Gregory Szorc <gregory.szorc@gmail.com>
Mon, 05 Mar 2018 14:09:23 -0500
changeset 37109 a532b2f54f95
parent 36328 8d0b0b533e09
child 43076 2372284d9457
permissions -rw-r--r--
merge: use constants for merge state record types merge.py is using multiple discrete sets of 1 and 2 letter constants to define types and behavior. To the uninitiated, the code is very difficult to reason about. I didn't even realize there were multiple sets of constants in play initially! We begin our sanity injection with merge state records. The record types (which are serialized to disk) are now defined in RECORD_* constants. Differential Revision: https://phab.mercurial-scm.org/D2698

from __future__ import absolute_import
from __future__ import print_function

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__)