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

login
register
mail settings
Submitter phabricator
Date Feb. 1, 2018, 9:58 p.m.
Message ID <differential-rev-PHID-DREV-y5lwhwfzzdfpccjcneiw-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27153/
State Superseded
Headers show

Comments

phabricator - Feb. 1, 2018, 9:58 p.m.
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




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

Patch

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