Skip to content

Commit f92c007

Browse files
committed
Add regression test for glog(0) with binary null bytes at capacity (#423)
Already fixed by the #330 glog(0) fix, adding test coverage for the specific scenario reported in #423.
1 parent d54ddb8 commit f92c007

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

qrcode/tests/test_qrcode.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ def test_glog_zero_data_with_leading_zeros():
3636
qr.make()
3737

3838

39+
def test_glog_zero_binary_data_at_capacity():
40+
"""Regression test for issue #423: glog(0) with binary null bytes at capacity limit."""
41+
from qrcode.util import QRData, MODE_8BIT_BYTE
42+
43+
# Version 5 + Q = 60 bytes capacity, data padded with trailing null bytes
44+
data = (
45+
b"\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x16"
46+
b"Hello from kakaworld!!"
47+
+ b"\x00" * 26
48+
)
49+
assert len(data) == 60
50+
qr = qrcode.QRCode(version=5, error_correction=qrcode.constants.ERROR_CORRECT_Q)
51+
qr.add_data(QRData(data, mode=MODE_8BIT_BYTE))
52+
qr.make(fit=False)
53+
54+
3955
def test_invalid_version():
4056
with pytest.raises(ValueError):
4157
qrcode.QRCode(version=42)

0 commit comments

Comments
 (0)