D1972: tests: start a set of unit tests for mdiff.py, starting with splitnewlines

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Thu Feb 1 21:58:29 UTC 2018


durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I want to optimize splitnewlines, so writing tests seems prudent.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1972

AFFECTED FILES
  tests/test-mdiff.py

CHANGE DETAILS

diff --git a/tests/test-mdiff.py b/tests/test-mdiff.py
new file mode 100644
--- /dev/null
+++ b/tests/test-mdiff.py
@@ -0,0 +1,24 @@
+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 = {'a\nb\nc\n': ['a\n', 'b\n', 'c\n'],
+                 'a\nb\nc': ['a\n', 'b\n', 'c'],
+                 'a\nb\nc\n\n': ['a\n', 'b\n', 'c\n', '\n'],
+                 '': [],
+                 'abcabc': ['abcabc'],
+                 }
+        for inp, want in cases.iteritems():
+            self.assertEqual(mdiff.splitnewlines(inp), want)
+
+if __name__ == '__main__':
+    import silenttestrunner
+    silenttestrunner.main(__name__)



To: durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list