File: test_hex.py

package info (click to toggle)
construct 2.10.68%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,812 kB
  • sloc: python: 11,793; makefile: 135
file content (27 lines) | stat: -rw-r--r-- 620 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from tests.declarativeunittest import *
from construct.lib.hex import *


def test_hexdump():
    for i in range(100):
        assert hexundump(hexdump(b"?"*i,32),32) == b"?"*i

def test_hexundump_issue_882():
    data1 = (hexdump(hexundump(
"""
0000   30 31 32 33 34 35 36 5C 0123456\\
0008   38                      8

""", linesize=8), linesize=8))

    data2 = (hexdump(hexundump(
"""
0000   30 31 32 33 34 35 36 37 01234567
0008   38                      8

""", linesize=8), linesize=8))

    print(data1)
    print(data2)
    assert data1 == hexdump(b"0123456\\8", 8)
    assert data2 == hexdump(b"012345678", 8)