correctly highlight lines with tabs
This commit is contained in:
30
testline.py
Normal file
30
testline.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import unittest
|
||||
|
||||
from line import Line
|
||||
|
||||
|
||||
class MyTestCase(unittest.TestCase):
|
||||
def test_column_to_char(self):
|
||||
byte_offset = 123
|
||||
text = "\tabc" # will be rendered as: ........abc where . represents a whitespace column
|
||||
line = Line(byte_offset=byte_offset, byte_end=byte_offset + len(text.encode("utf8")), line=text)
|
||||
|
||||
self.assertEqual(0, line.column_to_char(0)) # the tab
|
||||
self.assertEqual(0, line.column_to_char(1)) # the tab
|
||||
self.assertEqual(0, line.column_to_char(3)) # last column of the tab
|
||||
self.assertEqual(1, line.column_to_char(4)) # a
|
||||
self.assertEqual(2, line.column_to_char(5)) # b
|
||||
self.assertEqual(3, line.column_to_char(6)) # c
|
||||
|
||||
def test_char_to_column(self):
|
||||
byte_offset = 123
|
||||
text = "\tabc" # will be rendered as: ........abc where . represents a whitespace column
|
||||
line = Line(byte_offset=byte_offset, byte_end=byte_offset + len(text.encode("utf8")), line=text)
|
||||
self.assertEqual(0, line.char_to_column(0))
|
||||
self.assertEqual(4, line.char_to_column(1))
|
||||
self.assertEqual(5, line.char_to_column(2))
|
||||
self.assertEqual(6, line.char_to_column(3))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user