aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/simpleTests.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/simpleTests.py')
-rw-r--r--test/simpleTests.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/simpleTests.py b/test/simpleTests.py
index ce67edfde..867c0ebbc 100644
--- a/test/simpleTests.py
+++ b/test/simpleTests.py
@@ -2242,6 +2242,39 @@ class TestMultiSelection(unittest.TestCase):
self.assertEqual(self.ed.Contents(), b'a 1')
self.assertEqual(self.textOfSelection(0), b' ')
+ def testSelectionSerialization(self):
+ self.ed.SetContents(b"a")
+ self.ed.SetSelection(0, 1)
+ self.assertEqual(self.ed.GetSelectionSerialized(), b'1-0')
+ self.ed.SetSelection(1, 1)
+ self.assertEqual(self.ed.GetSelectionSerialized(), b'1')
+ self.ed.SetSelectionNAnchorVirtualSpace(0, 2)
+ self.ed.SetSelectionNCaretVirtualSpace(0, 3)
+ self.assertEqual(selectionRepresentation(self.ed, 0), "1+2v-1+3v")
+ self.assertEqual(self.textOfSelection(0), b'')
+ self.assertEqual(self.ed.GetSelectionSerialized(), b'1v2-1v3')
+ self.ed.SetSelectionSerialized(0, b'1-0')
+ self.assertEqual(self.ed.MainSelection, 0)
+ self.assertEqual(self.ed.Anchor, 1)
+ self.assertEqual(self.ed.CurrentPos, 0)
+ self.assertEqual(self.ed.GetSelectionNAnchor(0), 1)
+ self.assertEqual(self.ed.GetSelectionNCaret(0), 0)
+
+ def testSelectionSerializationOutOfBounds(self):
+ # Try setting selections that extend past document end through serialized form
+ # and check that the selection is limited to the document.
+ self.ed.SetContents(b"a")
+ self.ed.SetSelectionSerialized(0, b'200-0')
+ self.assertEqual(self.ed.GetSelectionSerialized(), b'1-0')
+
+ # Retain virtual space
+ self.ed.SetSelectionSerialized(0, b'0v1-200')
+ self.assertEqual(self.ed.GetSelectionSerialized(), b'0v1-1')
+
+ # Drop identical ranges, but touching empty range survives
+ self.ed.SetSelectionSerialized(0, b'0-200,300-400,500-600')
+ self.assertEqual(self.ed.GetSelectionSerialized(), b'0-1,1')
+
class TestModalSelection(unittest.TestCase):