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
810133d9
Commit
810133d9
authored
Apr 25, 2017
by
Damien George
Browse files
tests/basics: Add tests for int.from_bytes when src has trailing zeros.
The trailing zeros should be truncated from the converted value.
parent
c7aa86ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/basics/int_bytes.py
View file @
810133d9
...
...
@@ -4,3 +4,7 @@ print((100).to_bytes(10, "little"))
print
(
int
.
from_bytes
(
b
"
\x00\x01\0\0\0\0\0\0
"
,
"little"
))
print
(
int
.
from_bytes
(
b
"
\x01\0\0\0\0\0\0\0
"
,
"little"
))
print
(
int
.
from_bytes
(
b
"
\x00\x01\0\0\0\0\0\0
"
,
"little"
))
# check that extra zero bytes don't change the internal int value
print
(
int
.
from_bytes
(
bytes
(
20
),
"little"
)
==
0
)
print
(
int
.
from_bytes
(
b
"
\x01
"
+
bytes
(
20
),
"little"
)
==
1
)
tests/basics/int_bytes_intbig.py
View file @
810133d9
...
...
@@ -7,3 +7,6 @@ ib = int.from_bytes(b, "big")
print
(
il
)
print
(
ib
)
print
(
il
.
to_bytes
(
20
,
"little"
))
# check that extra zero bytes don't change the internal int value
print
(
int
.
from_bytes
(
b
+
bytes
(
10
),
"little"
)
==
int
.
from_bytes
(
b
,
"little"
))
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