diff options
| author | Sean Owen <srowen@gmail.com> | 2026-07-09 17:08:11 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-09 17:08:11 +0300 |
| commit | 0cf4f20da56c63007c1d7e14d193c797fc765dd3 (patch) | |
| tree | 1a3b1c2a7d1e78c842fc4677454e502afb2277e5 /core/src/test/java/com/google | |
| parent | 3fa6e8b889cc255451ef147724b3a7efd97e7c4d (diff) | |
| download | zxing-0cf4f20da56c63007c1d7e14d193c797fc765dd3.tar.xz | |
Address Issue #2115, Aztec grid (#2116)
Diffstat (limited to 'core/src/test/java/com/google')
| -rw-r--r-- | core/src/test/java/com/google/zxing/aztec/encoder/EncoderTest.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/core/src/test/java/com/google/zxing/aztec/encoder/EncoderTest.java b/core/src/test/java/com/google/zxing/aztec/encoder/EncoderTest.java index 280018d6d..61a74d745 100644 --- a/core/src/test/java/com/google/zxing/aztec/encoder/EncoderTest.java +++ b/core/src/test/java/com/google/zxing/aztec/encoder/EncoderTest.java @@ -477,6 +477,36 @@ public final class EncoderTest extends Assert { assertEquals(4, aztecCode.getLayers()); } + @Test + public void testEncodeReferenceGridComplete() { + // Regression test for https://github.com/zxing/zxing/issues/2115 + // A 12-layer full Aztec symbol is 67x67 modules and, per ISO/IEC 24778, must carry a + // complete reference grid with lines every 16 modules. Previously the outermost grid + // lines (one module in from each edge) were dropped because the drawing loop stopped one + // iteration short whenever (baseMatrixSize / 2 - 1) was an exact multiple of 15. + AztecCode aztec = Encoder.encode("Hello world", Encoder.DEFAULT_EC_PERCENT, 12); + assertFalse("Expected a full (non-compact) symbol", aztec.isCompact()); + assertEquals("Unexpected nr. of layers", 12, aztec.getLayers()); + BitMatrix matrix = aztec.getMatrix(); + int size = matrix.getWidth(); + assertEquals("Unexpected symbol size", 67, size); + + // The outermost reference grid lines lie at coordinate 1 and size - 2. Along a grid line + // the encoder draws dark modules on every other position (matching the parity of the + // symbol centre); the interleaving positions stay light. A grid line is an exclusive + // reference column/row, so no data modules land on it. + int parity = (size / 2) & 1; + for (int coord : new int[] {1, size - 2}) { + for (int k = 0; k < size; k++) { + boolean expectedDark = (k & 1) == parity; + assertEquals("reference grid column x=" + coord + ", y=" + k, + expectedDark, matrix.get(coord, k)); + assertEquals("reference grid row y=" + coord + ", x=" + k, + expectedDark, matrix.get(k, coord)); + } + } + } + // Helper routines private static void testEncode(String data, boolean compact, int layers, String expected) { |
