summaryrefslogtreecommitdiff
path: root/tests/extmod/deflate_compress.py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2023-11-29 11:43:43 +1100
committerDamien George <damien@micropython.org>2023-11-30 12:13:29 +1100
commitc554df57f618fb8c42fcd120ce227a425e44c4bc (patch)
tree1cebf965c1d2a291c11419a8faf9ee5b17e78b81 /tests/extmod/deflate_compress.py
parent6ba57f760cfcfed64157ef7dd030d76738cb0e24 (diff)
tests/extmod/deflate_compress.py: Add a test for optimal compression.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/extmod/deflate_compress.py')
-rw-r--r--tests/extmod/deflate_compress.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/extmod/deflate_compress.py b/tests/extmod/deflate_compress.py
index 612af663e..981a986cb 100644
--- a/tests/extmod/deflate_compress.py
+++ b/tests/extmod/deflate_compress.py
@@ -146,3 +146,9 @@ for wbits in range(5, 10):
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)