Package rekall :: Package ui :: Module text_test
[frames] | no frames]

Source Code for Module rekall.ui.text_test

 1  from rekall import testlib 
 2   
 3  from rekall.ui import text 
 4   
 5   
6 -class CellTest(testlib.RekallBaseUnitTestCase):
7
8 - def testNesting(self):
9 c1 = text.Cell(value="Hello, world!", width=6, align="r") 10 self.assertEqual(c1.lines, ["Hello,", "world!"]) 11 c1.rewrap(width=7) 12 self.assertEqual(c1.lines, [" Hello,", " world!"]) 13 c1.rewrap(align="l") 14 self.assertEqual(c1.lines, ["Hello, ", "world! "]) 15 16 c2 = text.Cell(value="I am a line of text.", width=13, align="l") 17 self.assertEqual(c2.lines, ["I am a line ", "of text. "]) 18 c2.rewrap(width=8) 19 self.assertEqual(c2.lines, ["I am a ", "line of ", "text. "]) 20 self.assertEqual(c2.width, 8) 21 self.assertEqual(c2.height, 3) 22 23 c3 = text.JoinedCell(c1, c2, tablesep="|") 24 self.assertEqual(c3.lines, ["Hello, |I am a ", 25 "world! |line of ", 26 " |text. "]) 27 self.assertEqual(c3.height, 3) 28 self.assertEqual(c3.width, 7 + 1 + 8) 29 30 c4 = text.JoinedCell(c3, c1) 31 self.assertEqual(len(c4.cells), 3) 32 self.assertEqual(c4.width, 7 + 1 + 8 + 1 + 7)
33
34 - def testColors(self):
35 # Invisible characters shouldn't affect reported width. 36 c1 = text.Cell(value="Hello, world!", highlights=[(0, 6, "RED", None)]) 37 self.assertEqual(c1.width, 13)
38
39 - def testPreserveNewLines(self):
40 c1 = text.Cell(value="Hello,\n world!") 41 self.assertEqual(c1.lines[0], "Hello, ")
42