def test_hexdump_on_unicode_with_multibyte_chars(self): l = hexdump(u'ÉÈ€eêëẽ', file=self.output) self.assertEqual( self.output.getvalue(), '00000000 c3 89 c3 88 e2 82 ac 65 c3 aa c3 ab e1 ba bd ' '|.......e .......|\n' '0000000f\n') self.assertEqual(l, 15)
def test_hexdump_on_unicode_with_multibyte_chars(self): l = hexdump(u'ÉÈ€eêëẽ', file=self.output) self.assertEqual( self.output.getvalue(), '00000000 c3 89 c3 88 e2 82 ac 65 c3 aa c3 ab e1 ba bd ' '|.......e .......|\n' '0000000f\n') self.assertEqual(l, 15)
def test_hexdump_on_plain_ascii_bytes_16_bytes(self): l = hexdump(b'0123456789ABCDEF', file=self.output) self.assertEqual( self.output.getvalue(), '00000000 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 ' '|01234567 89ABCDEF|\n' '00000010\n') self.assertEqual(l, 16)
def test_hexdump_on_plain_ascii_bytes_16_bytes(self): l = hexdump(b'0123456789ABCDEF', file=self.output) self.assertEqual( self.output.getvalue(), '00000000 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 ' '|01234567 89ABCDEF|\n' '00000010\n') self.assertEqual(l, 16)
def test_hexdump_on_bytes_with_multibyte_chars(self): l = hexdump(b'\xC3\x89\xC3\x88\xE2\x82\xACe\xC3\xAA\xC3\xAB' b'\xE1\xBA\xBD', file=self.output) self.assertEqual( self.output.getvalue(), '00000000 c3 89 c3 88 e2 82 ac 65 c3 aa c3 ab e1 ba bd ' '|.......e .......|\n' '0000000f\n') self.assertEqual(l, 15)
def test_hexdump_on_plain_ascii_str(self): l = hexdump('0123456789ABCDEFGHIJKLMNOP', file=self.output) self.assertEqual( self.output.getvalue(), '00000000 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 ' '|01234567 89ABCDEF|\n' '00000010 47 48 49 4a 4b 4c 4d 4e 4f 50 ' '|GHIJKLMN OP|\n' '0000001a\n') self.assertEqual(l, 26)
def test_hexdump_on_plain_ascii_str(self): l = hexdump('0123456789ABCDEFGHIJKLMNOP', file=self.output) self.assertEqual( self.output.getvalue(), '00000000 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 ' '|01234567 89ABCDEF|\n' '00000010 47 48 49 4a 4b 4c 4d 4e 4f 50 ' '|GHIJKLMN OP|\n' '0000001a\n') self.assertEqual(l, 26)
def test_hexdump_on_bytes_with_multibyte_chars(self): l = hexdump( b'\xC3\x89\xC3\x88\xE2\x82\xACe\xC3\xAA\xC3\xAB' b'\xE1\xBA\xBD', file=self.output) self.assertEqual( self.output.getvalue(), '00000000 c3 89 c3 88 e2 82 ac 65 c3 aa c3 ab e1 ba bd ' '|.......e .......|\n' '0000000f\n') self.assertEqual(l, 15)
def test_hexdump_on_plain_ascii_unicode_16_bytes(self): """Makes sure no space is inserted in the section between pipes if exactly 8 bytes are printed. """ l = hexdump(u'0123456789ABCDEF', file=self.output) self.assertEqual( self.output.getvalue(), '00000000 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 ' '|01234567 89ABCDEF|\n' '00000010\n') self.assertEqual(l, 16)
def test_hexdump_on_plain_ascii_unicode_16_bytes(self): """Makes sure no space is inserted in the section between pipes if exactly 8 bytes are printed. """ l = hexdump(u'0123456789ABCDEF', file=self.output) self.assertEqual( self.output.getvalue(), '00000000 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 ' '|01234567 89ABCDEF|\n' '00000010\n') self.assertEqual(l, 16)
def test_hexdump_on_plain_ascii_bytes_8_bytes(self): """Makes sure that, when exactly 8 bytes are printed: - No space is inserted in the plain section; - there is the right amount of padding between the hex and the plain section; """ l = hexdump(b'01234567', file=self.output) self.assertEqual( self.output.getvalue(), '00000000 30 31 32 33 34 35 36 37 ' '|01234567|\n' '00000008\n') self.assertEqual(l, 8)
def test_hexdump_on_plain_ascii_bytes_8_bytes(self): """Makes sure that, when exactly 8 bytes are printed: - No space is inserted in the plain section; - there is the right amount of padding between the hex and the plain section; """ l = hexdump(b'01234567', file=self.output) self.assertEqual( self.output.getvalue(), '00000000 30 31 32 33 34 35 36 37 ' '|01234567|\n' '00000008\n') self.assertEqual(l, 8)
def test_hexdump_on_empty_unicode(self): l = hexdump(u'', file=self.output) self.assertEqual(self.output.getvalue(), '00000000\n') self.assertEqual(l, 0)
def test_hexdump_on_empty_unicode(self): l = hexdump(u'', file=self.output) self.assertEqual(self.output.getvalue(), '00000000\n') self.assertEqual(l, 0)