diff options
| author | jmestwa-coder <jmestwa@gmail.com> | 2026-07-12 03:40:42 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-12 03:40:42 +0300 |
| commit | 82333b3ed894ef097d41dd8c922689ede8880e01 (patch) | |
| tree | ebbed4e3edf52ed3e2318328f22a9099a437a547 /core/src/test/java | |
| parent | 0cf4f20da56c63007c1d7e14d193c797fc765dd3 (diff) | |
| download | zxing-82333b3ed894ef097d41dd8c922689ede8880e01.tar.xz | |
reject bit matrix not matching layer count in aztec extractBits (#2117)
Diffstat (limited to 'core/src/test/java')
| -rw-r--r-- | core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java b/core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java index 9098adfac..e4036157a 100644 --- a/core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java +++ b/core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java @@ -90,6 +90,23 @@ public final class DecoderTest extends Assert { } @Test + public void testDecodeLayerCountMatrixMismatch() { + // a detector result whose bit matrix is smaller than its layer count implies must fail as + // FormatException, not ArrayIndexOutOfBoundsException out of the bit-extraction step + BitMatrix matrix = new BitMatrix(15, 15); // the size of a compact one-layer symbol only + for (boolean compact : new boolean[] { true, false }) { + for (int nbLayers : new int[] { 2, 4, 10, 32 }) { + try { + new Decoder().decode(new AztecDetectorResult(matrix, NO_POINTS, compact, 10, nbLayers)); + fail("compact=" + compact + " nbLayers=" + nbLayers + " should be rejected"); + } catch (FormatException expected) { + // expected + } + } + } + } + + @Test public void testAztecResult() throws FormatException { BitMatrix matrix = BitMatrix.parse( "X X X X X X X X X X X X X X \n" + |
