tests: start a set of unit tests for mdiff.py, starting with splitnewlines
authorAugie Fackler <augie@google.com>
Thu, 25 Jan 2018 23:01:20 -0500
changeset 35862 1ab7b16c9437
parent 35861 ed939545edd0
child 35863 49426bb4476c
tests: start a set of unit tests for mdiff.py, starting with splitnewlines I want to optimize splitnewlines, so writing tests seems prudent. Differential Revision: https://phab.mercurial-scm.org/D1972 # no-check-commit because of test_ funciton
tests/test-mdiff.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-mdiff.py	Thu Jan 25 23:01:20 2018 -0500
@@ -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__)