Skip to content

Commit 64af6e5

Browse files
committed
Try all qr_types when automatically sizing
Add test coverage adafruit#27
1 parent 6a8a224 commit 64af6e5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

adafruit_miniqr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def add_data(self, data):
9595
self.data_list.append(data)
9696
datalen = sum(len(x) for x in self.data_list)
9797
if not self.type:
98-
for qr_type in range(1, 6):
98+
for qr_type in range(1, 10):
9999
rs_blocks = _get_rs_blocks(qr_type, self.ECC)
100100
total_data_count = 0
101101
for block in rs_blocks:

tests/test_unit.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ def test_qr_pattern_mask(self):
5959
def test_qr_auto(self):
6060
# Confirm that increasing message size increases the matrix size monotonically
6161
sizes = []
62-
for i in range(14): # size 41 crashes
63-
_m = enc(b"aBc!1234" * i)
62+
for i in range(29):
63+
msg = b"aBc!1234" * i
64+
_m = enc(msg)
6465
sizes.append(_m.width)
6566
self.assertTrue(len(set(sizes)) > 1)
6667
self.assertEqual(sizes, sorted(sizes))
@@ -89,7 +90,7 @@ def test_qr_all(self):
8990

9091
def test_qr_maximum(self):
9192
msg = bytes([random.randrange(32, 127) for i in range(230)])
92-
_a = enc(msg, qr_type=9)
93+
_a = enc(msg)
9394
self.assertTrue(_a is not None)
9495

9596

0 commit comments

Comments
 (0)