diff --git a/core/src/com/google/zxing/common/GlobalHistogramBinarizer.java b/core/src/com/google/zxing/common/GlobalHistogramBinarizer.java index d322ab3f0..f9676468b 100644 --- a/core/src/com/google/zxing/common/GlobalHistogramBinarizer.java +++ b/core/src/com/google/zxing/common/GlobalHistogramBinarizer.java @@ -36,13 +36,14 @@ public class GlobalHistogramBinarizer extends Binarizer { private static final int LUMINANCE_BITS = 5; private static final int LUMINANCE_SHIFT = 8 - LUMINANCE_BITS; private static final int LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS; + private static final byte[] EMPTY = new byte[0]; private byte[] luminances; private final int[] buckets; public GlobalHistogramBinarizer(LuminanceSource source) { super(source); - luminances = new byte[0]; + luminances = EMPTY; buckets = new int[LUMINANCE_BUCKETS]; } diff --git a/core/src/com/google/zxing/common/reedsolomon/GenericGFPoly.java b/core/src/com/google/zxing/common/reedsolomon/GenericGFPoly.java index 64aaf7eac..1ccc0358d 100644 --- a/core/src/com/google/zxing/common/reedsolomon/GenericGFPoly.java +++ b/core/src/com/google/zxing/common/reedsolomon/GenericGFPoly.java @@ -103,8 +103,8 @@ final class GenericGFPoly { if (a == 1) { // Just the sum of the coefficients int result = 0; - for (int i = 0; i < size; i++) { - result = GenericGF.addOrSubtract(result, coefficients[i]); + for (int coefficient : coefficients) { + result = GenericGF.addOrSubtract(result, coefficient); } return result; } diff --git a/core/src/com/google/zxing/datamatrix/decoder/Decoder.java b/core/src/com/google/zxing/datamatrix/decoder/Decoder.java index d26a04c4d..7e22c4f7d 100644 --- a/core/src/com/google/zxing/datamatrix/decoder/Decoder.java +++ b/core/src/com/google/zxing/datamatrix/decoder/Decoder.java @@ -84,8 +84,8 @@ public final class Decoder { // Count total number of data bytes int totalBytes = 0; - for (int i = 0; i < dataBlocksCount; i++) { - totalBytes += dataBlocks[i].getNumDataCodewords(); + for (DataBlock db : dataBlocks) { + totalBytes += db.getNumDataCodewords(); } byte[] resultBytes = new byte[totalBytes]; diff --git a/core/src/com/google/zxing/datamatrix/decoder/Version.java b/core/src/com/google/zxing/datamatrix/decoder/Version.java index 509313cb5..04558025e 100644 --- a/core/src/com/google/zxing/datamatrix/decoder/Version.java +++ b/core/src/com/google/zxing/datamatrix/decoder/Version.java @@ -99,13 +99,8 @@ public final class Version { if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) { throw FormatException.getFormatInstance(); } - - // TODO(bbrown): This is doing a linear search through the array of versions. - // If we interleave the rectangular versions with the square versions we could - // do a binary search. - int numVersions = VERSIONS.length; - for (int i = 0; i < numVersions; ++i){ - Version version = VERSIONS[i]; + + for (Version version : VERSIONS) { if (version.symbolSizeRows == numRows && version.symbolSizeColumns == numColumns) { return version; } diff --git a/core/src/com/google/zxing/oned/Code39Reader.java b/core/src/com/google/zxing/oned/Code39Reader.java index f7021e3fe..c73643578 100644 --- a/core/src/com/google/zxing/oned/Code39Reader.java +++ b/core/src/com/google/zxing/oned/Code39Reader.java @@ -213,8 +213,7 @@ public final class Code39Reader extends OneDReader { int wideCounters; do { int minCounter = Integer.MAX_VALUE; - for (int i = 0; i < numCounters; i++) { - int counter = counters[i]; + for (int counter : counters) { if (counter < minCounter && counter > maxNarrowCounter) { minCounter = counter; } diff --git a/core/src/com/google/zxing/oned/Code93Reader.java b/core/src/com/google/zxing/oned/Code93Reader.java index 1106d5e87..a9529ea01 100644 --- a/core/src/com/google/zxing/oned/Code93Reader.java +++ b/core/src/com/google/zxing/oned/Code93Reader.java @@ -147,8 +147,8 @@ public final class Code93Reader extends OneDReader { private static int toPattern(int[] counters) { int max = counters.length; int sum = 0; - for (int i = 0; i < max; i++) { - sum += counters[i]; + for (int counter : counters) { + sum += counter; } int pattern = 0; for (int i = 0; i < max; i++) { diff --git a/core/src/com/google/zxing/oned/rss/RSSUtils.java b/core/src/com/google/zxing/oned/rss/RSSUtils.java index 20a3c87cf..8df655321 100644 --- a/core/src/com/google/zxing/oned/rss/RSSUtils.java +++ b/core/src/com/google/zxing/oned/rss/RSSUtils.java @@ -64,8 +64,8 @@ public final class RSSUtils { public static int getRSSvalue(int[] widths, int maxWidth, boolean noNarrow) { int elements = widths.length; int n = 0; - for (int i = 0; i < elements; i++) { - n += widths[i]; + for (int width : widths) { + n += width; } int val = 0; int narrowMask = 0; diff --git a/core/test/src/com/google/zxing/qrcode/encoder/MatrixUtilTestCase.java b/core/test/src/com/google/zxing/qrcode/encoder/MatrixUtilTestCase.java index 4f8cf1e76..ccb3d14bc 100644 --- a/core/test/src/com/google/zxing/qrcode/encoder/MatrixUtilTestCase.java +++ b/core/test/src/com/google/zxing/qrcode/encoder/MatrixUtilTestCase.java @@ -55,10 +55,12 @@ public final class MatrixUtilTestCase extends Assert { } @Test - public void testEmbedBasicPatterns() throws WriterException { - { - // Version 1. - String expected = + public void testEmbedBasicPatterns1() throws WriterException { + // Version 1. + ByteMatrix matrix = new ByteMatrix(21, 21); + MatrixUtil.clearMatrix(matrix); + MatrixUtil.embedBasicPatterns(1, matrix); + String expected = " 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" + " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" + " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" + @@ -80,15 +82,17 @@ public final class MatrixUtilTestCase extends Assert { " 1 0 1 1 1 0 1 0 \n" + " 1 0 0 0 0 0 1 0 \n" + " 1 1 1 1 1 1 1 0 \n"; - ByteMatrix matrix = new ByteMatrix(21, 21); - MatrixUtil.clearMatrix(matrix); - MatrixUtil.embedBasicPatterns(1, matrix); - assertEquals(expected, matrix.toString()); - } - { - // Version 2. Position adjustment pattern should apppear at right - // bottom corner. - String expected = + assertEquals(expected, matrix.toString()); + } + + @Test + public void testEmbedBasicPatterns2() throws WriterException { + // Version 2. Position adjustment pattern should apppear at right + // bottom corner. + ByteMatrix matrix = new ByteMatrix(25, 25); + MatrixUtil.clearMatrix(matrix); + MatrixUtil.embedBasicPatterns(2, matrix); + String expected = " 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" + " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" + " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" + @@ -114,135 +118,109 @@ public final class MatrixUtilTestCase extends Assert { " 1 0 1 1 1 0 1 0 \n" + " 1 0 0 0 0 0 1 0 \n" + " 1 1 1 1 1 1 1 0 \n"; - ByteMatrix matrix = new ByteMatrix(25, 25); - MatrixUtil.clearMatrix(matrix); - MatrixUtil.embedBasicPatterns(2, matrix); - assertEquals(expected, matrix.toString()); - } + assertEquals(expected, matrix.toString()); } @Test public void testEmbedTypeInfo() throws WriterException { // Type info bits = 100000011001110. - String expected = - " 0 \n" + - " 1 \n" + - " 1 \n" + - " 1 \n" + - " 0 \n" + - " 0 \n" + - " \n" + - " 1 \n" + - " 1 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 0 \n" + - " 0 \n" + - " 0 \n" + - " 0 \n" + - " 0 \n" + - " 0 \n" + - " 1 \n"; ByteMatrix matrix = new ByteMatrix(21, 21); MatrixUtil.clearMatrix(matrix); MatrixUtil.embedTypeInfo(ErrorCorrectionLevel.M, 5, matrix); + String expected = + " 0 \n" + + " 1 \n" + + " 1 \n" + + " 1 \n" + + " 0 \n" + + " 0 \n" + + " \n" + + " 1 \n" + + " 1 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 0 \n" + + " 0 \n" + + " 0 \n" + + " 0 \n" + + " 0 \n" + + " 0 \n" + + " 1 \n"; assertEquals(expected, matrix.toString()); } @Test public void testEmbedVersionInfo() throws WriterException { // Version info bits = 000111 110010 010100 - String expected = - " 0 0 1 \n" + - " 0 1 0 \n" + - " 0 1 0 \n" + - " 0 1 1 \n" + - " 1 1 1 \n" + - " 0 0 0 \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 0 0 0 0 1 0 \n" + - " 0 1 1 1 1 0 \n" + - " 1 0 0 1 1 0 \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n"; // Actually, version 7 QR Code has 45x45 matrix but we use 21x21 here // since 45x45 matrix is too big to depict. ByteMatrix matrix = new ByteMatrix(21, 21); MatrixUtil.clearMatrix(matrix); MatrixUtil.maybeEmbedVersionInfo(7, matrix); + String expected = + " 0 0 1 \n" + + " 0 1 0 \n" + + " 0 1 0 \n" + + " 0 1 1 \n" + + " 1 1 1 \n" + + " 0 0 0 \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 0 0 0 0 1 0 \n" + + " 0 1 1 1 1 0 \n" + + " 1 0 0 1 1 0 \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n"; assertEquals(expected, matrix.toString()); } @Test public void testEmbedDataBits() throws WriterException { // Cells other than basic patterns should be filled with zero. - String expected = - " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1\n" + - " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" + - " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" + - " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + - " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + - " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"; BitArray bits = new BitArray(); ByteMatrix matrix = new ByteMatrix(21, 21); MatrixUtil.clearMatrix(matrix); MatrixUtil.embedBasicPatterns(1, matrix); MatrixUtil.embedDataBits(bits, -1, matrix); + String expected = + " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1\n" + + " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" + + " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" + + " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" + + " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" + + " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" + + " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + + " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + + " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + + " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + + " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + + " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + + " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + + " 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0\n" + + " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + + " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + + " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + + " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + + " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + + " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + + " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"; assertEquals(expected, matrix.toString()); } @Test public void testBuildMatrix() throws WriterException { // From http://www.swetake.com/qr/qr7.html - String expected = - " 1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1 1 1 1\n" + - " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" + - " 1 0 1 1 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1\n" + - " 1 0 1 1 1 0 1 0 1 1 0 0 1 0 1 0 1 1 1 0 1\n" + - " 1 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 0 0 0 1\n" + - " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + - " 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0\n" + - " 0 0 1 1 0 0 1 1 1 0 0 1 1 1 1 0 1 0 0 0 0\n" + - " 1 0 1 0 1 0 0 0 0 0 1 1 1 0 0 1 0 1 1 1 0\n" + - " 1 1 1 1 0 1 1 0 1 0 1 1 1 0 0 1 1 1 0 1 0\n" + - " 1 0 1 0 1 1 0 1 1 1 0 0 1 1 1 0 0 1 0 1 0\n" + - " 0 0 1 0 0 1 1 1 0 0 0 0 0 0 1 0 1 1 1 1 1\n" + - " 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 1 1\n" + - " 1 1 1 1 1 1 1 0 1 1 1 1 0 0 0 0 1 0 1 1 0\n" + - " 1 0 0 0 0 0 1 0 0 0 0 1 0 1 1 1 0 0 0 0 0\n" + - " 1 0 1 1 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1\n" + - " 1 0 1 1 1 0 1 0 1 1 0 1 0 0 0 0 0 1 1 1 0\n" + - " 1 0 1 1 1 0 1 0 1 1 1 1 0 0 0 0 1 1 1 0 0\n" + - " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0\n" + - " 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 1 0 0 1 0\n"; char[] bytes = {32, 65, 205, 69, 41, 220, 46, 128, 236, 42, 159, 74, 221, 244, 169, 239, 150, 138, 70, 237, 85, 224, 96, 74, 219 , 61}; @@ -256,6 +234,28 @@ public final class MatrixUtilTestCase extends Assert { 1, // Version 1 3, // Mask pattern 3 matrix); + String expected = + " 1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1 1 1 1\n" + + " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" + + " 1 0 1 1 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 0 1\n" + + " 1 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1\n" + + " 1 0 1 1 1 0 1 0 1 1 0 0 1 0 1 0 1 1 1 0 1\n" + + " 1 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 0 0 0 1\n" + + " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + + " 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0\n" + + " 0 0 1 1 0 0 1 1 1 0 0 1 1 1 1 0 1 0 0 0 0\n" + + " 1 0 1 0 1 0 0 0 0 0 1 1 1 0 0 1 0 1 1 1 0\n" + + " 1 1 1 1 0 1 1 0 1 0 1 1 1 0 0 1 1 1 0 1 0\n" + + " 1 0 1 0 1 1 0 1 1 1 0 0 1 1 1 0 0 1 0 1 0\n" + + " 0 0 1 0 0 1 1 1 0 0 0 0 0 0 1 0 1 1 1 1 1\n" + + " 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 1 1\n" + + " 1 1 1 1 1 1 1 0 1 1 1 1 0 0 0 0 1 0 1 1 0\n" + + " 1 0 0 0 0 0 1 0 0 0 0 1 0 1 1 1 0 0 0 0 0\n" + + " 1 0 1 1 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1\n" + + " 1 0 1 1 1 0 1 0 1 1 0 1 0 0 0 0 0 1 1 1 0\n" + + " 1 0 1 1 1 0 1 0 1 1 1 1 0 0 0 0 1 1 1 0 0\n" + + " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0\n" + + " 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 1 0 0 1 0\n"; assertEquals(expected, matrix.toString()); } diff --git a/core/test/src/com/google/zxing/qrcode/encoder/QRCodeTestCase.java b/core/test/src/com/google/zxing/qrcode/encoder/QRCodeTestCase.java index d646f116d..c648ec861 100644 --- a/core/test/src/com/google/zxing/qrcode/encoder/QRCodeTestCase.java +++ b/core/test/src/com/google/zxing/qrcode/encoder/QRCodeTestCase.java @@ -83,27 +83,45 @@ public final class QRCodeTestCase extends Assert { } @Test - public void testToString() { - { - QRCode qrCode = new QRCode(); - String expected = - "<<\n" + - " mode: null\n" + - " ecLevel: null\n" + - " version: -1\n" + - " matrixWidth: -1\n" + - " maskPattern: -1\n" + - " numTotalBytes: -1\n" + - " numDataBytes: -1\n" + - " numECBytes: -1\n" + - " numRSBlocks: -1\n" + - " matrix: null\n" + - ">>\n"; - assertEquals(expected, qrCode.toString()); + public void testToString1() { + QRCode qrCode = new QRCode(); + String expected = + "<<\n" + + " mode: null\n" + + " ecLevel: null\n" + + " version: -1\n" + + " matrixWidth: -1\n" + + " maskPattern: -1\n" + + " numTotalBytes: -1\n" + + " numDataBytes: -1\n" + + " numECBytes: -1\n" + + " numRSBlocks: -1\n" + + " matrix: null\n" + + ">>\n"; + assertEquals(expected, qrCode.toString()); + } + + @Test + public void testToString2() { + QRCode qrCode = new QRCode(); + qrCode.setMode(Mode.BYTE); + qrCode.setECLevel(ErrorCorrectionLevel.H); + qrCode.setVersion(1); + qrCode.setMatrixWidth(21); + qrCode.setMaskPattern(3); + qrCode.setNumTotalBytes(26); + qrCode.setNumDataBytes(9); + qrCode.setNumECBytes(17); + qrCode.setNumRSBlocks(1); + ByteMatrix matrix = new ByteMatrix(21, 21); + for (int y = 0; y < 21; ++y) { + for (int x = 0; x < 21; ++x) { + matrix.set(x, y, (y + x) % 2); + } } - { - String expected = - "<<\n" + + qrCode.setMatrix(matrix); + assertTrue(qrCode.isValid()); + String expected = "<<\n" + " mode: BYTE\n" + " ecLevel: H\n" + " version: 1\n" + @@ -136,26 +154,7 @@ public final class QRCodeTestCase extends Assert { " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + ">>\n"; - QRCode qrCode = new QRCode(); - qrCode.setMode(Mode.BYTE); - qrCode.setECLevel(ErrorCorrectionLevel.H); - qrCode.setVersion(1); - qrCode.setMatrixWidth(21); - qrCode.setMaskPattern(3); - qrCode.setNumTotalBytes(26); - qrCode.setNumDataBytes(9); - qrCode.setNumECBytes(17); - qrCode.setNumRSBlocks(1); - ByteMatrix matrix = new ByteMatrix(21, 21); - for (int y = 0; y < 21; ++y) { - for (int x = 0; x < 21; ++x) { - matrix.set(x, y, (y + x) % 2); - } - } - qrCode.setMatrix(matrix); - assertTrue(qrCode.isValid()); - assertEquals(expected, qrCode.toString()); - } + assertEquals(expected, qrCode.toString()); } @Test