Ejemplo n.º 1
0
 def test__decode_two_bytes_asserts(self):
     from zope.index.text.widcode import _decode
     for wid in range(128, 2**14):
         hi, lo = divmod(wid, 128)
         code = chr(hi + 128) + chr(lo)
         with self.assertRaises(AssertionError):
             _decode(code)
Ejemplo n.º 2
0
 def test__decode_other_one_byte_asserts(self):
     from zope.index.text.widcode import _decode
     for wid in range(1, 128):
         try:
             _decode(chr(128 + wid))
         except AssertionError:
             pass
         else:
             self.fail("Didn't assert: %d" % wid)
Ejemplo n.º 3
0
 def test__decode_other_one_byte_asserts(self):
     from zope.index.text.widcode import _decode
     for wid in range(1, 128):
         try:
             _decode(chr(128 + wid))
         except AssertionError:
             pass
         else:
             self.fail("Didn't assert: %d" % wid)
Ejemplo n.º 4
0
 def test__decode_two_bytes_asserts(self):
     from zope.index.text.widcode import _decode
     for wid in range(128, 2**14):
         try:
             hi, lo = divmod(wid, 128)
             code = chr(hi + 128) + chr(lo)
             _decode(code)
         except AssertionError:
             pass
         else:
             self.fail("Didn't assert: %d" % wid)
Ejemplo n.º 5
0
 def test__decode_two_bytes_asserts(self):
     from zope.index.text.widcode import _decode
     for wid in range(128, 2**14):
         try:
             hi, lo = divmod(wid, 128)
             code = chr(hi + 128) + chr(lo)
             _decode(code)
         except AssertionError:
             pass
         else:
             self.fail("Didn't assert: %d" % wid)
Ejemplo n.º 6
0
 def test__decode_three_bytes(self):
     from zope.index.text.widcode import _decode
     for wid in range(2**14, 2**21, 247):
         mid, lo = divmod(wid, 128)
         hi, mid = divmod(mid, 128)
         code = chr(hi + 128) + chr(mid) + chr(lo)
         self.assertEqual(_decode(code), wid)
Ejemplo n.º 7
0
 def test__decode_three_bytes(self):
     from zope.index.text.widcode import _decode
     for wid in range(2**14, 2**21, 247):
         mid, lo = divmod(wid, 128)
         hi, mid = divmod(mid, 128)
         code = chr(hi + 128) + chr(mid) + chr(lo)
         self.assertEqual(_decode(code), wid)
Ejemplo n.º 8
0
 def test__decode_four_bytes(self):
     from zope.index.text.widcode import _decode
     STEP = (256 * 512) - 7
     for wid in range(2**21, 2**28, STEP):
         lmid, lo = divmod(wid, 128)
         hmid, lmid = divmod(lmid, 128)
         hi, hmid = divmod(hmid, 128)
         code = chr(hi + 128) + chr(hmid) + chr(lmid) + chr(lo)
         self.assertEqual(_decode(code), wid)
Ejemplo n.º 9
0
 def test__decode_four_bytes(self):
     from zope.index.text.widcode import _decode
     STEP = (256 * 512) - 7
     for wid in range(2**21, 2**28, STEP):
         lmid, lo = divmod(wid, 128)
         hmid, lmid = divmod(lmid, 128)
         hi, hmid = divmod(hmid, 128)
         code = chr(hi + 128) + chr(hmid) + chr(lmid) + chr(lo)
         self.assertEqual(_decode(code), wid)
Ejemplo n.º 10
0
 def test__decode_other_one_byte_asserts(self):
     from zope.index.text.widcode import _decode
     for wid in range(1, 128):
         with self.assertRaises(AssertionError):
             _decode(chr(128 + wid))