summaryrefslogtreecommitdiff
path: root/tools/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tools/tests')
-rw-r--r--tools/tests/test_barcode_tools.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/tests/test_barcode_tools.py b/tools/tests/test_barcode_tools.py
index 7be1f18..0ee3cc4 100644
--- a/tools/tests/test_barcode_tools.py
+++ b/tools/tests/test_barcode_tools.py
@@ -8,6 +8,7 @@ from pathlib import Path
import barcode_ref as ref
import check_codes
import gen_code_vectors
+import gen_qr_tables
ROOT = Path(__file__).resolve().parents[2]
@@ -63,3 +64,24 @@ def test_check_codes_reads_dump_lines(tmp_path: Path) -> None:
empty = tmp_path / "empty.log"
empty.write_text("nothing\n", encoding="utf-8")
assert check_codes.main([str(empty)]) == 2
+
+
+def test_committed_qr_tables_match_segno() -> None:
+ committed = (ROOT / "source" / "codes" / "QrTables.mc").read_text(encoding="utf-8")
+ assert committed == gen_qr_tables.render(gen_qr_tables.table())
+ rows = gen_qr_tables.table()
+ assert rows[0] == [7, 1, 19, 0, 0] # version 1-L: 7 EC codewords, one block of 19
+ assert len(gen_qr_tables.alignment()) == 40 and gen_qr_tables.alignment()[0] == []
+
+
+def test_segno_padding_quirk_detection() -> None:
+ # Byte mode always ends on a codeword boundary after the terminator, so
+ # segno would add a zero byte unless the symbol is exactly full.
+ assert gen_code_vectors.segno_pads_extra_byte("hello", 0, 1)
+ assert not gen_code_vectors.segno_pads_extra_byte("01234567", 1, 1)
+
+
+def test_rendered_qr_matrix_decodes() -> None:
+ _, _, hexbits = gen_code_vectors.qr_reference("HELLO WORLD", 1, 1, 2)
+ image = ref.render_matrix(bytes.fromhex(hexbits), 21, 2, quiet=4)
+ assert ref.decode(image, ref.QR) == ["HELLO WORLD"]