示例#1
0
    def test_width_awareness(self):
        s = Chunk('asdf')
        self.assertEqual(
            Chunk('ab\u0300c').splitter().request(3), (3, Chunk('ab\u0300c')))
        self.assertEqual(
            Chunk('ab\u0300c').splitter().request(2), (2, Chunk('ab\u0300')))

        s = Chunk('ab\u0300c').splitter()
        self.assertEqual(s.request(1), (1, Chunk('a')))
        self.assertEqual(s.request(2), (2, Chunk('b\u0300c')))

        c = Chunk('aEbc')
        self.assertEqual(c.splitter().request(4), (4, Chunk('aEb')))
        s = c.splitter()
        self.assertEqual(s.request(2), (2, Chunk('a ')))
        self.assertEqual(s.request(2), (2, Chunk('E')))
        self.assertEqual(s.request(2), (2, Chunk('bc')))
        self.assertEqual(s.request(2), None)
示例#2
0
    def test_width_awareness(self):
        s = Chunk("asdf")
        self.assertEqual(
            Chunk("ab\u0300c").splitter().request(3), (3, Chunk("ab\u0300c")))
        self.assertEqual(
            Chunk("ab\u0300c").splitter().request(2), (2, Chunk("ab\u0300")))

        s = Chunk("ab\u0300c").splitter()
        self.assertEqual(s.request(1), (1, Chunk("a")))
        self.assertEqual(s.request(2), (2, Chunk("b\u0300c")))

        c = Chunk("aEbc")
        self.assertEqual(c.splitter().request(4), (4, Chunk("aEb")))
        s = c.splitter()
        self.assertEqual(s.request(2), (2, Chunk("a ")))
        self.assertEqual(s.request(2), (2, Chunk("E")))
        self.assertEqual(s.request(2), (2, Chunk("bc")))
        self.assertEqual(s.request(2), None)
示例#3
0
 def test_chunk_splitter(self):
     splitter = Chunk('asdf', {'fg': 32}).splitter()
     self.assertEqual(splitter.request(1), (1, Chunk('a', {'fg': 32})))
     self.assertEqual(splitter.request(4), (3, Chunk('sdf', {'fg': 32})))
     self.assertEqual(splitter.request(4), None)
示例#4
0
 def test_chunk_splitter(self):
     splitter = Chunk("asdf", {"fg": 32}).splitter()
     self.assertEqual(splitter.request(1), (1, Chunk("a", {"fg": 32})))
     self.assertEqual(splitter.request(4), (3, Chunk("sdf", {"fg": 32})))
     self.assertEqual(splitter.request(4), None)