diff options
author | Zufu Liu <unknown> | 2023-01-10 09:13:46 +1100 |
---|---|---|
committer | Zufu Liu <unknown> | 2023-01-10 09:13:46 +1100 |
commit | 5d71ee3725bb8d91937208b1aeaf3c99afa9a054 (patch) | |
tree | d862f3ed17b7f2f889e81317a8dcc29600e489ad /test/simpleTests.py | |
parent | 3b5beda672c3f6aede945a273f4bb42b54e462cb (diff) | |
download | scintilla-mirror-5d71ee3725bb8d91937208b1aeaf3c99afa9a054.tar.gz |
Bug [#2372]. Fix SCI_LINESJOIN bug where carriage returns were incorrectly
retained.
Diffstat (limited to 'test/simpleTests.py')
-rw-r--r-- | test/simpleTests.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/simpleTests.py b/test/simpleTests.py index a16b940fd..5383911ee 100644 --- a/test/simpleTests.py +++ b/test/simpleTests.py @@ -2960,6 +2960,49 @@ class TestDirectAccess(unittest.TestCase): cpBuffer = ctypes.c_char_p(rangePointer) self.assertEquals(cpBuffer.value, text[1:]) +class TestJoin(unittest.TestCase): + def setUp(self): + self.xite = Xite.xiteFrame + self.ed = self.xite.ed + self.ed.ClearAll() + self.ed.EmptyUndoBuffer() + + def tearDown(self): + self.ed.ClearAll() + self.ed.EmptyUndoBuffer() + + def testJoin(self): + text = b"a\r\nb\r\nc" + self.ed.SetContents(text) + self.ed.TargetWholeDocument() + self.ed.LinesJoin() + self.assertEquals(self.ed.Contents(), b"a b c") + + def testJoinEndLine(self): + text = b"a\r\nb\r\nc" + self.ed.SetContents(text) + # Select a..b + self.ed.SetTargetRange(0, 4) + self.ed.LinesJoin() + self.assertEquals(self.ed.Contents(), b"a b\r\nc") + + def testJoinSpace(self): + # Demonstration of bug #2372 which produced b"a \r" + text = b"a \r\n\r\n" + self.ed.SetContents(text) + self.ed.TargetWholeDocument() + self.ed.LinesJoin() + self.assertEquals(self.ed.Contents(), b"a ") + + def testJoinOutOfBounds(self): + text = b"a\r\nb\r\nc" + self.ed.SetContents(text) + # Setting end of target after document end encourages non-termination. + self.ed.SetTargetRange(-10, 16) + self.ed.LinesJoin() + # Out-of-bounds leaves extra space as 'c' is processed + self.assertEquals(self.ed.Contents(), b"a b c ") + class TestWordChars(unittest.TestCase): def setUp(self): self.xite = Xite.xiteFrame |