Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
d46de801
Commit
d46de801
authored
Sep 24, 2016
by
Paul Sokolovsky
Browse files
tests/uzlib_decompio_gz: Test for DecompIO with gzip bitstream.
parent
7b901d6f
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/extmod/uzlib_decompio_gz.py
0 → 100644
View file @
d46de801
try
:
import
zlib
except
ImportError
:
import
uzlib
as
zlib
import
uio
as
io
# gzip bitstream
buf
=
io
.
BytesIO
(
b
'
\x1f\x8b\x08\x08\x99\x0c\xe5
W
\x00\x03
hello
\x00\xcb
H
\xcd\xc9\xc9\x07\x00\x86\xa6\x10
6
\x05\x00\x00\x00
'
)
inp
=
zlib
.
DecompIO
(
buf
,
16
+
8
)
print
(
buf
.
seek
(
0
,
1
))
print
(
inp
.
read
(
1
))
print
(
buf
.
seek
(
0
,
1
))
print
(
inp
.
read
(
2
))
print
(
inp
.
read
())
print
(
buf
.
seek
(
0
,
1
))
print
(
inp
.
read
(
1
))
print
(
inp
.
read
())
print
(
buf
.
seek
(
0
,
1
))
# broken header
buf
=
io
.
BytesIO
(
b
'
\x1f\x8c\x08\x08\x99\x0c\xe5
W
\x00\x03
hello
\x00\xcb
H
\xcd\xc9\xc9\x07\x00\x86\xa6\x10
6
\x05\x00\x00\x00
'
)
try
:
inp
=
zlib
.
DecompIO
(
buf
,
16
+
8
)
except
ValueError
:
print
(
"ValueError"
)
# broken crc32
buf
=
io
.
BytesIO
(
b
'
\x1f\x8b\x08\x08\x99\x0c\xe5
W
\x00\x03
hello
\x00\xcb
H
\xcd\xc9\xc9\x07\x00\x86\xa7\x10
6
\x05\x00\x00\x00
'
)
inp
=
zlib
.
DecompIO
(
buf
,
16
+
8
)
try
:
inp
.
read
(
6
)
except
OSError
as
e
:
print
(
repr
(
e
))
# broken uncompressed size - not checked so far
#buf = io.BytesIO(b'\x1f\x8b\x08\x08\x99\x0c\xe5W\x00\x03hello\x00\xcbH\xcd\xc9\xc9\x07\x00\x86\xa6\x106\x06\x00\x00\x00')
#inp = zlib.DecompIO(buf, 16 + 8)
#inp.read(6)
tests/extmod/uzlib_decompio_gz.py.exp
0 → 100644
View file @
d46de801
16
b'h'
18
b'el'
b'lo'
31
b''
b''
31
ValueError
OSError(22,)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment