summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/int_bytes.py
Commit message (Collapse)AuthorAge
* py/objint: Fix int.to_bytes() buffer size checks.Angus Gratton2024-06-24
| | | | | | | | | | | | | | | | | | | | | | | | Fixes and improvements to `int.to_bytes()` are: - No longer overflows if byte size is 0 (closes #13041). - Raises OverflowError in any case where number won't fit into byte length (now matches CPython, previously MicroPython would return a truncated bytes object). - Document that `micropython int.to_bytes()` doesn't implement the optional signed kwarg, but will behave as if `signed=True` when the integer is negative (this is the current behaviour). Add tests for this also. Requires changes for small ints, MPZ large ints, and "long long" large ints. Adds a new set of unit tests for ints between 32 and 64 bits to increase coverage of "long long" large ints, which are otherwise untested. Tested on unix port (64 bit small ints, MPZ long ints) and Zephyr STM32WB board (32 bit small ints, long long large ints). This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
* py/objint: In to_bytes(), allow length arg to be any int and check sign.Damien George2017-06-15
|
* py/objint: Support "big" byte-order in int.to_bytes().Damien George2017-06-15
|
* tests/basics: Add tests for int.from_bytes when src has trailing zeros.Damien George2017-04-25
| | | | The trailing zeros should be truncated from the converted value.
* tests/basic: Split tests into working with small ints and not working.Paul Sokolovsky2017-03-04
| | | | | | Tests which don't work with small ints are suffixed with _intbig.py. Some of these may still work with long long ints and need to be reclassified later.
* py: Support conversion of bignum to bytes.Damien George2015-04-25
| | | | | | | This gets int.to_bytes working for bignum, and also struct.pack with 'q' and 'Q' args on 32-bit machines. Addresses issue #1155.
* tests: Rename test scripts, changing - to _ for consistency.Damien George2014-07-05
From now on, all new tests must use underscore. Addresses issue #727.