Mercurial > hg
comparison tests/test-mdiff.py @ 35862:1ab7b16c9437
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
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 25 Jan 2018 23:01:20 -0500 |
parents | |
children | 58c1368ab629 |
comparison
equal
deleted
inserted
replaced
35861:ed939545edd0 | 35862:1ab7b16c9437 |
---|---|
1 from __future__ import absolute_import | |
2 from __future__ import print_function | |
3 | |
4 import unittest | |
5 | |
6 from mercurial import ( | |
7 mdiff, | |
8 ) | |
9 | |
10 class splitnewlinesTests(unittest.TestCase): | |
11 | |
12 def test_splitnewlines(self): | |
13 cases = {'a\nb\nc\n': ['a\n', 'b\n', 'c\n'], | |
14 'a\nb\nc': ['a\n', 'b\n', 'c'], | |
15 'a\nb\nc\n\n': ['a\n', 'b\n', 'c\n', '\n'], | |
16 '': [], | |
17 'abcabc': ['abcabc'], | |
18 } | |
19 for inp, want in cases.iteritems(): | |
20 self.assertEqual(mdiff.splitnewlines(inp), want) | |
21 | |
22 if __name__ == '__main__': | |
23 import silenttestrunner | |
24 silenttestrunner.main(__name__) |