mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Miscellaneous tweaks from inspection
git-svn-id: https://zxing.googlecode.com/svn/trunk@2244 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
b1dfc23418
commit
cc204e1bde
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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++) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue