Skip to content

Commit

Permalink
tests/extmod/deflate_compress.py: Add a test for optimal compression.
Browse files Browse the repository at this point in the history
Signed-off-by: Damien George <damien@micropython.org>
  • Loading branch information
dpgeorge committed Nov 30, 2023
1 parent 6ba57f7 commit c554df5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/extmod/deflate_compress.py
Expand Up @@ -146,3 +146,9 @@ def check_header(n, a, b):
next_len = len(result)
print(next_len < prev_len and decompress(result, deflate.RAW, wbits) == buf)
prev_len = next_len

# Verify that compression is optimal: in the bytes below, the final "123" should be
# compressed by referencing the "123" just before it, and not the one all the way back
# at the start of the bytes.
compressed = compress(b"1234567890abcdefghijklmnopqrstuvwxyz123123", deflate.RAW)
print(len(compressed), compressed)
1 change: 1 addition & 0 deletions tests/extmod/deflate_compress.py.exp
Expand Up @@ -39,3 +39,4 @@ True
True
True
True
41 b'3426153\xb7\xb04HLJNIMK\xcf\xc8\xcc\xca\xce\xc9\xcd\xcb/(,*.)-+\xaf\xa8\xac\x02\xaa\x01"\x00'

0 comments on commit c554df5

Please sign in to comment.