mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Apply checkstyle to test code too, and fix violations; minor updates from code inspections
This commit is contained in:
parent
2c2c395afa
commit
a372dfe175
|
@ -197,7 +197,7 @@ public final class HttpHelper {
|
||||||
throw new IOException(npe);
|
throw new IOException(npe);
|
||||||
}
|
}
|
||||||
if (!(conn instanceof HttpURLConnection)) {
|
if (!(conn instanceof HttpURLConnection)) {
|
||||||
throw new IOException();
|
throw new IOException("Expected HttpURLConnection but got " + conn.getClass());
|
||||||
}
|
}
|
||||||
return (HttpURLConnection) conn;
|
return (HttpURLConnection) conn;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public final class BitMatrix implements Cloneable {
|
||||||
private final int[] bits;
|
private final int[] bits;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty square {@link BitMatrix}.
|
* Creates an empty square {@code BitMatrix}.
|
||||||
*
|
*
|
||||||
* @param dimension height and width
|
* @param dimension height and width
|
||||||
*/
|
*/
|
||||||
|
@ -50,7 +50,7 @@ public final class BitMatrix implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty {@link BitMatrix}.
|
* Creates an empty {@code BitMatrix}.
|
||||||
*
|
*
|
||||||
* @param width bit matrix width
|
* @param width bit matrix width
|
||||||
* @param height bit matrix height
|
* @param height bit matrix height
|
||||||
|
@ -73,10 +73,10 @@ public final class BitMatrix implements Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interprets a 2D array of booleans as a {@link BitMatrix}, where "true" means an "on" bit.
|
* Interprets a 2D array of booleans as a {@code BitMatrix}, where "true" means an "on" bit.
|
||||||
*
|
*
|
||||||
* @param image bits of the image, as a row-major 2D array. Elements are arrays representing rows
|
* @param image bits of the image, as a row-major 2D array. Elements are arrays representing rows
|
||||||
* @return {@link BitMatrix} representation of image
|
* @return {@code BitMatrix} representation of image
|
||||||
*/
|
*/
|
||||||
public static BitMatrix parse(boolean[][] image) {
|
public static BitMatrix parse(boolean[][] image) {
|
||||||
int height = image.length;
|
int height = image.length;
|
||||||
|
|
|
@ -185,7 +185,7 @@ final class DecodedBitStreamParser {
|
||||||
default:
|
default:
|
||||||
// Not to be used in ASCII encodation
|
// Not to be used in ASCII encodation
|
||||||
// but work around encoders that end with 254, latch back to ASCII
|
// but work around encoders that end with 254, latch back to ASCII
|
||||||
if (oneByte >= 242 && (oneByte != 254 || bits.available() != 0)) {
|
if (oneByte != 254 || bits.available() != 0) {
|
||||||
throw FormatException.getFormatInstance();
|
throw FormatException.getFormatInstance();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -129,40 +129,44 @@ class C40Encoder implements Encoder {
|
||||||
if (c == ' ') {
|
if (c == ' ') {
|
||||||
sb.append('\3');
|
sb.append('\3');
|
||||||
return 1;
|
return 1;
|
||||||
} else if (c >= '0' && c <= '9') {
|
}
|
||||||
|
if (c >= '0' && c <= '9') {
|
||||||
sb.append((char) (c - 48 + 4));
|
sb.append((char) (c - 48 + 4));
|
||||||
return 1;
|
return 1;
|
||||||
} else if (c >= 'A' && c <= 'Z') {
|
}
|
||||||
|
if (c >= 'A' && c <= 'Z') {
|
||||||
sb.append((char) (c - 65 + 14));
|
sb.append((char) (c - 65 + 14));
|
||||||
return 1;
|
return 1;
|
||||||
} else if (c >= '\0' && c <= '\u001f') {
|
}
|
||||||
|
if (c < ' ') {
|
||||||
sb.append('\0'); //Shift 1 Set
|
sb.append('\0'); //Shift 1 Set
|
||||||
sb.append(c);
|
sb.append(c);
|
||||||
return 2;
|
return 2;
|
||||||
} else if (c >= '!' && c <= '/') {
|
}
|
||||||
|
if (c >= '!' && c <= '/') {
|
||||||
sb.append('\1'); //Shift 2 Set
|
sb.append('\1'); //Shift 2 Set
|
||||||
sb.append((char) (c - 33));
|
sb.append((char) (c - 33));
|
||||||
return 2;
|
return 2;
|
||||||
} else if (c >= ':' && c <= '@') {
|
}
|
||||||
|
if (c >= ':' && c <= '@') {
|
||||||
sb.append('\1'); //Shift 2 Set
|
sb.append('\1'); //Shift 2 Set
|
||||||
sb.append((char) (c - 58 + 15));
|
sb.append((char) (c - 58 + 15));
|
||||||
return 2;
|
return 2;
|
||||||
} else if (c >= '[' && c <= '_') {
|
}
|
||||||
|
if (c >= '[' && c <= '_') {
|
||||||
sb.append('\1'); //Shift 2 Set
|
sb.append('\1'); //Shift 2 Set
|
||||||
sb.append((char) (c - 91 + 22));
|
sb.append((char) (c - 91 + 22));
|
||||||
return 2;
|
return 2;
|
||||||
} else if (c >= '\u0060' && c <= '\u007f') {
|
}
|
||||||
|
if (c >= '`' && c <= 127) {
|
||||||
sb.append('\2'); //Shift 3 Set
|
sb.append('\2'); //Shift 3 Set
|
||||||
sb.append((char) (c - 96));
|
sb.append((char) (c - 96));
|
||||||
return 2;
|
return 2;
|
||||||
} else if (c >= '\u0080') {
|
}
|
||||||
sb.append("\1\u001e"); //Shift 2, Upper Shift
|
sb.append("\1\u001e"); //Shift 2, Upper Shift
|
||||||
int len = 2;
|
int len = 2;
|
||||||
len += encodeChar((char) (c - 128), sb);
|
len += encodeChar((char) (c - 128), sb);
|
||||||
return len;
|
return len;
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("Illegal character: " + c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String encodeToCodewords(CharSequence sb, int startPos) {
|
private static String encodeToCodewords(CharSequence sb, int startPos) {
|
||||||
|
|
|
@ -37,7 +37,7 @@ final class TextEncoder extends C40Encoder {
|
||||||
sb.append((char) (c - 97 + 14));
|
sb.append((char) (c - 97 + 14));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (c >= '\0' && c <= '\u001f') {
|
if (c < ' ') {
|
||||||
sb.append('\0'); //Shift 1 Set
|
sb.append('\0'); //Shift 1 Set
|
||||||
sb.append(c);
|
sb.append(c);
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -57,7 +57,7 @@ final class TextEncoder extends C40Encoder {
|
||||||
sb.append((char) (c - 91 + 22));
|
sb.append((char) (c - 91 + 22));
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
if (c == '\u0060') {
|
if (c == '`') {
|
||||||
sb.append('\2'); //Shift 3 Set
|
sb.append('\2'); //Shift 3 Set
|
||||||
sb.append((char) (c - 96));
|
sb.append((char) (c - 96));
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -67,19 +67,15 @@ final class TextEncoder extends C40Encoder {
|
||||||
sb.append((char) (c - 65 + 1));
|
sb.append((char) (c - 65 + 1));
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
if (c >= '{' && c <= '\u007f') {
|
if (c >= '{' && c <= 127) {
|
||||||
sb.append('\2'); //Shift 3 Set
|
sb.append('\2'); //Shift 3 Set
|
||||||
sb.append((char) (c - 123 + 27));
|
sb.append((char) (c - 123 + 27));
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
if (c >= '\u0080') {
|
|
||||||
sb.append("\1\u001e"); //Shift 2, Upper Shift
|
sb.append("\1\u001e"); //Shift 2, Upper Shift
|
||||||
int len = 2;
|
int len = 2;
|
||||||
len += encodeChar((char) (c - 128), sb);
|
len += encodeChar((char) (c - 128), sb);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
HighLevelEncoder.illegalCharacter(c);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,12 +43,6 @@ public final class MaxiCodeReader implements Reader {
|
||||||
|
|
||||||
private final Decoder decoder = new Decoder();
|
private final Decoder decoder = new Decoder();
|
||||||
|
|
||||||
/*
|
|
||||||
Decoder getDecoder() {
|
|
||||||
return decoder;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locates and decodes a MaxiCode in an image.
|
* Locates and decodes a MaxiCode in an image.
|
||||||
*
|
*
|
||||||
|
|
|
@ -117,29 +117,29 @@ public final class Code39Writer extends OneDimensionalCodeWriter {
|
||||||
extendedContent.append("%W");
|
extendedContent.append("%W");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (character > 0 && character < 27) {
|
if (character <= 26) {
|
||||||
extendedContent.append('$');
|
extendedContent.append('$');
|
||||||
extendedContent.append((char) ('A' + (character - 1)));
|
extendedContent.append((char) ('A' + (character - 1)));
|
||||||
} else if (character > 26 && character < ' ') {
|
} else if (character < ' ') {
|
||||||
extendedContent.append('%');
|
extendedContent.append('%');
|
||||||
extendedContent.append((char) ('A' + (character - 27)));
|
extendedContent.append((char) ('A' + (character - 27)));
|
||||||
} else if ((character > ' ' && character < '-') || character == '/' || character == ':') {
|
} else if (character <= ',' || character == '/' || character == ':') {
|
||||||
extendedContent.append('/');
|
extendedContent.append('/');
|
||||||
extendedContent.append((char) ('A' + (character - 33)));
|
extendedContent.append((char) ('A' + (character - 33)));
|
||||||
} else if (character > '/' && character < ':') {
|
} else if (character <= '9') {
|
||||||
extendedContent.append((char) ('0' + (character - 48)));
|
extendedContent.append((char) ('0' + (character - 48)));
|
||||||
} else if (character > ':' && character < '@') {
|
} else if (character <= '?') {
|
||||||
extendedContent.append('%');
|
extendedContent.append('%');
|
||||||
extendedContent.append((char) ('F' + (character - 59)));
|
extendedContent.append((char) ('F' + (character - 59)));
|
||||||
} else if (character > '@' && character < '[') {
|
} else if (character <= 'Z') {
|
||||||
extendedContent.append((char) ('A' + (character - 65)));
|
extendedContent.append((char) ('A' + (character - 65)));
|
||||||
} else if (character > 'Z' && character < '`') {
|
} else if (character <= '_') {
|
||||||
extendedContent.append('%');
|
extendedContent.append('%');
|
||||||
extendedContent.append((char) ('K' + (character - 91)));
|
extendedContent.append((char) ('K' + (character - 91)));
|
||||||
} else if (character > '`' && character < '{') {
|
} else if (character <= 'z') {
|
||||||
extendedContent.append('+');
|
extendedContent.append('+');
|
||||||
extendedContent.append((char) ('A' + (character - 97)));
|
extendedContent.append((char) ('A' + (character - 97)));
|
||||||
} else if (character > 'z' && character < 128) {
|
} else if (character <= 127) {
|
||||||
extendedContent.append('%');
|
extendedContent.append('%');
|
||||||
extendedContent.append((char) ('P' + (character - 123)));
|
extendedContent.append((char) ('P' + (character - 123)));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -145,16 +145,17 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
||||||
|
|
||||||
// Not private for testing
|
// Not private for testing
|
||||||
List<ExpandedPair> decodeRow2pairs(int rowNumber, BitArray row) throws NotFoundException {
|
List<ExpandedPair> decodeRow2pairs(int rowNumber, BitArray row) throws NotFoundException {
|
||||||
|
boolean done = false;
|
||||||
|
while (!done) {
|
||||||
try {
|
try {
|
||||||
while (true) {
|
this.pairs.add(retrieveNextPair(row, this.pairs, rowNumber));
|
||||||
ExpandedPair nextPair = retrieveNextPair(row, this.pairs, rowNumber);
|
|
||||||
this.pairs.add(nextPair);
|
|
||||||
// exit this loop when retrieveNextPair() fails and throws
|
|
||||||
}
|
|
||||||
} catch (NotFoundException nfe) {
|
} catch (NotFoundException nfe) {
|
||||||
if (this.pairs.isEmpty()) {
|
if (this.pairs.isEmpty()) {
|
||||||
throw nfe;
|
throw nfe;
|
||||||
}
|
}
|
||||||
|
// exit this loop when retrieveNextPair() fails and throws
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: verify sequence of finder patterns as in checkPairSequence()
|
// TODO: verify sequence of finder patterns as in checkPairSequence()
|
||||||
|
@ -227,8 +228,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
||||||
return this.pairs;
|
return this.pairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ExpandedRow> rs = new ArrayList<>();
|
List<ExpandedRow> rs = new ArrayList<>(collectedRows);
|
||||||
rs.addAll(collectedRows);
|
|
||||||
rs.add(row);
|
rs.add(row);
|
||||||
try {
|
try {
|
||||||
// Recursion: try to add more rows
|
// Recursion: try to add more rows
|
||||||
|
|
|
@ -25,15 +25,15 @@ import com.google.zxing.common.BitMatrix;
|
||||||
*/
|
*/
|
||||||
final class BoundingBox {
|
final class BoundingBox {
|
||||||
|
|
||||||
private BitMatrix image;
|
private final BitMatrix image;
|
||||||
private ResultPoint topLeft;
|
private final ResultPoint topLeft;
|
||||||
private ResultPoint bottomLeft;
|
private final ResultPoint bottomLeft;
|
||||||
private ResultPoint topRight;
|
private final ResultPoint topRight;
|
||||||
private ResultPoint bottomRight;
|
private final ResultPoint bottomRight;
|
||||||
private int minX;
|
private final int minX;
|
||||||
private int maxX;
|
private final int maxX;
|
||||||
private int minY;
|
private final int minY;
|
||||||
private int maxY;
|
private final int maxY;
|
||||||
|
|
||||||
BoundingBox(BitMatrix image,
|
BoundingBox(BitMatrix image,
|
||||||
ResultPoint topLeft,
|
ResultPoint topLeft,
|
||||||
|
@ -46,24 +46,34 @@ final class BoundingBox {
|
||||||
(topRight != null && bottomRight == null)) {
|
(topRight != null && bottomRight == null)) {
|
||||||
throw NotFoundException.getNotFoundInstance();
|
throw NotFoundException.getNotFoundInstance();
|
||||||
}
|
}
|
||||||
init(image, topLeft, bottomLeft, topRight, bottomRight);
|
if (topLeft == null) {
|
||||||
|
topLeft = new ResultPoint(0, topRight.getY());
|
||||||
|
bottomLeft = new ResultPoint(0, bottomRight.getY());
|
||||||
|
} else if (topRight == null) {
|
||||||
|
topRight = new ResultPoint(image.getWidth() - 1, topLeft.getY());
|
||||||
|
bottomRight = new ResultPoint(image.getWidth() - 1, bottomLeft.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
BoundingBox(BoundingBox boundingBox) {
|
|
||||||
init(boundingBox.image, boundingBox.topLeft, boundingBox.bottomLeft, boundingBox.topRight, boundingBox.bottomRight);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(BitMatrix image,
|
|
||||||
ResultPoint topLeft,
|
|
||||||
ResultPoint bottomLeft,
|
|
||||||
ResultPoint topRight,
|
|
||||||
ResultPoint bottomRight) {
|
|
||||||
this.image = image;
|
this.image = image;
|
||||||
this.topLeft = topLeft;
|
this.topLeft = topLeft;
|
||||||
this.bottomLeft = bottomLeft;
|
this.bottomLeft = bottomLeft;
|
||||||
this.topRight = topRight;
|
this.topRight = topRight;
|
||||||
this.bottomRight = bottomRight;
|
this.bottomRight = bottomRight;
|
||||||
calculateMinMaxValues();
|
this.minX = (int) Math.min(topLeft.getX(), bottomLeft.getX());
|
||||||
|
this.maxX = (int) Math.max(topRight.getX(), bottomRight.getX());
|
||||||
|
this.minY = (int) Math.min(topLeft.getY(), topRight.getY());
|
||||||
|
this.maxY = (int) Math.max(bottomLeft.getY(), bottomRight.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
BoundingBox(BoundingBox boundingBox) {
|
||||||
|
this.image = boundingBox.image;
|
||||||
|
this.topLeft = boundingBox.getTopLeft();
|
||||||
|
this.bottomLeft = boundingBox.getBottomLeft();
|
||||||
|
this.topRight = boundingBox.getTopRight();
|
||||||
|
this.bottomRight = boundingBox.getBottomRight();
|
||||||
|
this.minX = boundingBox.getMinX();
|
||||||
|
this.maxX = boundingBox.getMaxX();
|
||||||
|
this.minY = boundingBox.getMinY();
|
||||||
|
this.maxY = boundingBox.getMaxY();
|
||||||
}
|
}
|
||||||
|
|
||||||
static BoundingBox merge(BoundingBox leftBox, BoundingBox rightBox) throws NotFoundException {
|
static BoundingBox merge(BoundingBox leftBox, BoundingBox rightBox) throws NotFoundException {
|
||||||
|
@ -110,37 +120,9 @@ final class BoundingBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateMinMaxValues();
|
|
||||||
return new BoundingBox(image, newTopLeft, newBottomLeft, newTopRight, newBottomRight);
|
return new BoundingBox(image, newTopLeft, newBottomLeft, newTopRight, newBottomRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateMinMaxValues() {
|
|
||||||
if (topLeft == null) {
|
|
||||||
topLeft = new ResultPoint(0, topRight.getY());
|
|
||||||
bottomLeft = new ResultPoint(0, bottomRight.getY());
|
|
||||||
} else if (topRight == null) {
|
|
||||||
topRight = new ResultPoint(image.getWidth() - 1, topLeft.getY());
|
|
||||||
bottomRight = new ResultPoint(image.getWidth() - 1, bottomLeft.getY());
|
|
||||||
}
|
|
||||||
|
|
||||||
minX = (int) Math.min(topLeft.getX(), bottomLeft.getX());
|
|
||||||
maxX = (int) Math.max(topRight.getX(), bottomRight.getX());
|
|
||||||
minY = (int) Math.min(topLeft.getY(), topRight.getY());
|
|
||||||
maxY = (int) Math.max(bottomLeft.getY(), bottomRight.getY());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
void setTopRight(ResultPoint topRight) {
|
|
||||||
this.topRight = topRight;
|
|
||||||
calculateMinMaxValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBottomRight(ResultPoint bottomRight) {
|
|
||||||
this.bottomRight = bottomRight;
|
|
||||||
calculateMinMaxValues();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
int getMinX() {
|
int getMinX() {
|
||||||
return minX;
|
return minX;
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,11 +123,7 @@ public final class Decoder {
|
||||||
if (fe != null) {
|
if (fe != null) {
|
||||||
throw fe;
|
throw fe;
|
||||||
}
|
}
|
||||||
if (ce != null) {
|
throw ce; // If fe is null, this can't be
|
||||||
throw ce;
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -256,9 +256,6 @@ public class FinderPatternFinder {
|
||||||
*
|
*
|
||||||
* @param centerI row where a finder pattern was detected
|
* @param centerI row where a finder pattern was detected
|
||||||
* @param centerJ center of the section that appears to cross a finder pattern
|
* @param centerJ center of the section that appears to cross a finder pattern
|
||||||
* @param maxCount maximum reasonable number of modules that should be
|
|
||||||
* observed in any reading state, based on the results of the horizontal scan
|
|
||||||
* @param originalStateCountTotal The original state count total.
|
|
||||||
* @return true if proportions are withing expected limits
|
* @return true if proportions are withing expected limits
|
||||||
*/
|
*/
|
||||||
private boolean crossCheckDiagonal(int centerI, int centerJ) {
|
private boolean crossCheckDiagonal(int centerI, int centerJ) {
|
||||||
|
|
|
@ -92,7 +92,7 @@ public final class Encoder {
|
||||||
BitArray headerBits = new BitArray();
|
BitArray headerBits = new BitArray();
|
||||||
|
|
||||||
// Append ECI segment if applicable
|
// Append ECI segment if applicable
|
||||||
if (mode == Mode.BYTE && (hasEncodingHint || !DEFAULT_BYTE_MODE_ENCODING.equals(encoding))) {
|
if (mode == Mode.BYTE && hasEncodingHint) {
|
||||||
CharacterSetECI eci = CharacterSetECI.getCharacterSetECIByName(encoding);
|
CharacterSetECI eci = CharacterSetECI.getCharacterSetECIByName(encoding);
|
||||||
if (eci != null) {
|
if (eci != null) {
|
||||||
appendECI(eci, headerBits);
|
appendECI(eci, headerBits);
|
||||||
|
|
|
@ -19,6 +19,9 @@ package com.google.zxing;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link PlanarYUVLuminanceSource}.
|
||||||
|
*/
|
||||||
public final class PlanarYUVLuminanceSourceTestCase extends Assert {
|
public final class PlanarYUVLuminanceSourceTestCase extends Assert {
|
||||||
|
|
||||||
private static final byte[] YUV = {
|
private static final byte[] YUV = {
|
||||||
|
|
|
@ -19,6 +19,9 @@ package com.google.zxing;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link RGBLuminanceSource}.
|
||||||
|
*/
|
||||||
public final class RGBLuminanceSourceTestCase extends Assert {
|
public final class RGBLuminanceSourceTestCase extends Assert {
|
||||||
|
|
||||||
private static final RGBLuminanceSource SOURCE = new RGBLuminanceSource(3, 3, new int[] {
|
private static final RGBLuminanceSource SOURCE = new RGBLuminanceSource(3, 3, new int[] {
|
||||||
|
|
|
@ -23,6 +23,9 @@ import com.google.zxing.common.DecoderResult;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link Decoder}.
|
||||||
|
*/
|
||||||
public final class DecoderTest extends Assert {
|
public final class DecoderTest extends Assert {
|
||||||
|
|
||||||
private static final ResultPoint[] NO_POINTS = new ResultPoint[0];
|
private static final ResultPoint[] NO_POINTS = new ResultPoint[0];
|
||||||
|
|
|
@ -51,7 +51,7 @@ public final class EncoderTest extends Assert {
|
||||||
// real life tests
|
// real life tests
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncode1() throws Exception {
|
public void testEncode1() {
|
||||||
testEncode("This is an example Aztec symbol for Wikipedia.", true, 3,
|
testEncode("This is an example Aztec symbol for Wikipedia.", true, 3,
|
||||||
"X X X X X X X X \n" +
|
"X X X X X X X X \n" +
|
||||||
"X X X X X X X X X X \n" +
|
"X X X X X X X X X X \n" +
|
||||||
|
@ -79,7 +79,7 @@ public final class EncoderTest extends Assert {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncode2() throws Exception {
|
public void testEncode2() {
|
||||||
testEncode("Aztec Code is a public domain 2D matrix barcode symbology" +
|
testEncode("Aztec Code is a public domain 2D matrix barcode symbology" +
|
||||||
" of nominally square symbols built on a square grid with a " +
|
" of nominally square symbols built on a square grid with a " +
|
||||||
"distinctive square bullseye pattern at their center.", false, 6,
|
"distinctive square bullseye pattern at their center.", false, 6,
|
||||||
|
@ -279,7 +279,7 @@ public final class EncoderTest extends Assert {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHighLevelEncode() throws Exception {
|
public void testHighLevelEncode() {
|
||||||
testHighLevelEncodeString("A. b.",
|
testHighLevelEncodeString("A. b.",
|
||||||
// 'A' P/S '. ' L/L b D/L '.'
|
// 'A' P/S '. ' L/L b D/L '.'
|
||||||
"...X. ..... ...XX XXX.. ...XX XXXX. XX.X");
|
"...X. ..... ...XX XXX.. ...XX XXXX. XX.X");
|
||||||
|
@ -309,7 +309,7 @@ public final class EncoderTest extends Assert {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHighLevelEncodeBinary() throws Exception {
|
public void testHighLevelEncodeBinary() {
|
||||||
// binary short form single byte
|
// binary short form single byte
|
||||||
testHighLevelEncodeString("N\0N",
|
testHighLevelEncodeString("N\0N",
|
||||||
// 'N' B/S =1 '\0' N
|
// 'N' B/S =1 '\0' N
|
||||||
|
@ -338,7 +338,7 @@ public final class EncoderTest extends Assert {
|
||||||
// Create a string in which every character requires binary
|
// Create a string in which every character requires binary
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i <= 3000; i++) {
|
for (int i = 0; i <= 3000; i++) {
|
||||||
sb.append((char)(128 + (i % 30)));
|
sb.append((char) (128 + (i % 30)));
|
||||||
}
|
}
|
||||||
// Test the output generated by Binary/Switch, particularly near the
|
// Test the output generated by Binary/Switch, particularly near the
|
||||||
// places where the encoding changes: 31, 62, and 2047+31=2078
|
// places where the encoding changes: 31, 62, and 2047+31=2078
|
||||||
|
@ -346,7 +346,7 @@ public final class EncoderTest extends Assert {
|
||||||
60, 61, 62, 63, 64, 2076, 2077, 2078, 2079, 2080, 2100 }) {
|
60, 61, 62, 63, 64, 2076, 2077, 2078, 2079, 2080, 2100 }) {
|
||||||
// This is the expected length of a binary string of length "i"
|
// This is the expected length of a binary string of length "i"
|
||||||
int expectedLength = (8 * i) +
|
int expectedLength = (8 * i) +
|
||||||
( (i <= 31) ? 10 : (i <= 62) ? 20 : (i <= 2078) ? 21 : 31);
|
((i <= 31) ? 10 : (i <= 62) ? 20 : (i <= 2078) ? 21 : 31);
|
||||||
// Verify that we are correct about the length.
|
// Verify that we are correct about the length.
|
||||||
testHighLevelEncodeString(sb.substring(0, i), expectedLength);
|
testHighLevelEncodeString(sb.substring(0, i), expectedLength);
|
||||||
if (i != 1 && i != 32 && i != 2079) {
|
if (i != 1 && i != 32 && i != 2079) {
|
||||||
|
@ -364,7 +364,7 @@ public final class EncoderTest extends Assert {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHighLevelEncodePairs() throws Exception {
|
public void testHighLevelEncodePairs() {
|
||||||
// Typical usage
|
// Typical usage
|
||||||
testHighLevelEncodeString("ABC. DEF\r\n",
|
testHighLevelEncodeString("ABC. DEF\r\n",
|
||||||
// A B C P/S .<sp> D E F P/S \r\n
|
// A B C P/S .<sp> D E F P/S \r\n
|
||||||
|
@ -387,7 +387,7 @@ public final class EncoderTest extends Assert {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUserSpecifiedLayers() throws Exception {
|
public void testUserSpecifiedLayers() {
|
||||||
byte[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".getBytes(StandardCharsets.ISO_8859_1);
|
byte[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".getBytes(StandardCharsets.ISO_8859_1);
|
||||||
AztecCode aztec = Encoder.encode(alphabet, 25, -2);
|
AztecCode aztec = Encoder.encode(alphabet, 25, -2);
|
||||||
assertEquals(2, aztec.getLayers());
|
assertEquals(2, aztec.getLayers());
|
||||||
|
@ -413,7 +413,7 @@ public final class EncoderTest extends Assert {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBorderCompact4Case() throws Exception {
|
public void testBorderCompact4Case() {
|
||||||
// Compact(4) con hold 608 bits of information, but at most 504 can be data. Rest must
|
// Compact(4) con hold 608 bits of information, but at most 504 can be data. Rest must
|
||||||
// be error correction
|
// be error correction
|
||||||
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
@ -441,7 +441,7 @@ public final class EncoderTest extends Assert {
|
||||||
|
|
||||||
// Helper routines
|
// Helper routines
|
||||||
|
|
||||||
private static void testEncode(String data, boolean compact, int layers, String expected) throws Exception {
|
private static void testEncode(String data, boolean compact, int layers, String expected) {
|
||||||
AztecCode aztec = Encoder.encode(data.getBytes(StandardCharsets.ISO_8859_1), 33, Encoder.DEFAULT_AZTEC_LAYERS);
|
AztecCode aztec = Encoder.encode(data.getBytes(StandardCharsets.ISO_8859_1), 33, Encoder.DEFAULT_AZTEC_LAYERS);
|
||||||
assertEquals("Unexpected symbol format (compact)", compact, aztec.isCompact());
|
assertEquals("Unexpected symbol format (compact)", compact, aztec.isCompact());
|
||||||
assertEquals("Unexpected nr. of layers", layers, aztec.getLayers());
|
assertEquals("Unexpected nr. of layers", layers, aztec.getLayers());
|
||||||
|
|
|
@ -41,7 +41,7 @@ import java.util.Map;
|
||||||
public final class ExpandedProductParsedResultTestCase extends Assert {
|
public final class ExpandedProductParsedResultTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test_RSSExpanded() {
|
public void testRSSExpanded() {
|
||||||
Map<String,String> uncommonAIs = new HashMap<>();
|
Map<String,String> uncommonAIs = new HashMap<>();
|
||||||
uncommonAIs.put("123", "544654");
|
uncommonAIs.put("123", "544654");
|
||||||
Result result =
|
Result result =
|
||||||
|
|
|
@ -22,6 +22,9 @@ import com.google.zxing.Result;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link VINParsedResult}.
|
||||||
|
*/
|
||||||
public final class VINParsedResultTestCase extends Assert {
|
public final class VINParsedResultTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -322,7 +322,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(original.getType()) {
|
switch (original.getType()) {
|
||||||
case BufferedImage.TYPE_BYTE_INDEXED:
|
case BufferedImage.TYPE_BYTE_INDEXED:
|
||||||
case BufferedImage.TYPE_BYTE_BINARY:
|
case BufferedImage.TYPE_BYTE_BINARY:
|
||||||
BufferedImage argb = new BufferedImage(original.getWidth(),
|
BufferedImage argb = new BufferedImage(original.getWidth(),
|
||||||
|
|
|
@ -21,22 +21,25 @@ import org.junit.Test;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link StringUtils}.
|
||||||
|
*/
|
||||||
public final class StringUtilsTestCase extends Assert {
|
public final class StringUtilsTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShortShiftJIS_1() {
|
public void testShortShiftJIS1() {
|
||||||
// 金魚
|
// 金魚
|
||||||
doTest(new byte[] { (byte) 0x8b, (byte) 0xe0, (byte) 0x8b, (byte) 0x9b, }, "SJIS");
|
doTest(new byte[] { (byte) 0x8b, (byte) 0xe0, (byte) 0x8b, (byte) 0x9b, }, "SJIS");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShortISO88591_1() {
|
public void testShortISO885911() {
|
||||||
// båd
|
// båd
|
||||||
doTest(new byte[] { (byte) 0x62, (byte) 0xe5, (byte) 0x64, }, "ISO-8859-1");
|
doTest(new byte[] { (byte) 0x62, (byte) 0xe5, (byte) 0x64, }, "ISO-8859-1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMixedShiftJIS_1() {
|
public void testMixedShiftJIS1() {
|
||||||
// Hello Èáë!
|
// Hello Èáë!
|
||||||
doTest(new byte[] { (byte) 0x48, (byte) 0x65, (byte) 0x6c, (byte) 0x6c, (byte) 0x6f,
|
doTest(new byte[] { (byte) 0x48, (byte) 0x65, (byte) 0x6c, (byte) 0x6c, (byte) 0x6f,
|
||||||
(byte) 0x20, (byte) 0x8b, (byte) 0xe0, (byte) 0x21, },
|
(byte) 0x20, (byte) 0x8b, (byte) 0xe0, (byte) 0x21, },
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
package com.google.zxing.common;
|
package com.google.zxing.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encapsulates the result of one test over a batch of black-box images.
|
||||||
|
*/
|
||||||
public final class TestResult {
|
public final class TestResult {
|
||||||
|
|
||||||
private final int mustPassCount;
|
private final int mustPassCount;
|
||||||
|
|
|
@ -19,6 +19,9 @@ package com.google.zxing.common.detector;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link MathUtils}.
|
||||||
|
*/
|
||||||
public final class MathUtilsTestCase extends Assert {
|
public final class MathUtilsTestCase extends Assert {
|
||||||
|
|
||||||
private static final float EPSILON = 1.0E-8f;
|
private static final float EPSILON = 1.0E-8f;
|
||||||
|
|
|
@ -493,7 +493,7 @@ public final class ReedSolomonTestCase extends Assert {
|
||||||
|
|
||||||
private static String arrayToString(int[] data) {
|
private static String arrayToString(int[] data) {
|
||||||
StringBuilder sb = new StringBuilder("{");
|
StringBuilder sb = new StringBuilder("{");
|
||||||
for (int i=0; i<data.length; i++) {
|
for (int i = 0; i < data.length; i++) {
|
||||||
sb.append(String.format(i > 0 ? ",%X" : "%X", data[i]));
|
sb.append(String.format(i > 0 ? ",%X" : "%X", data[i]));
|
||||||
}
|
}
|
||||||
return sb.append('}').toString();
|
return sb.append('}').toString();
|
||||||
|
|
|
@ -34,9 +34,9 @@ public final class DecodedBitStreamParserTestCase extends Assert {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAsciiDoubleDigitDecode() throws Exception{
|
public void testAsciiDoubleDigitDecode() throws Exception {
|
||||||
// ASCII double digit (00 - 99) Numeric Value + 130
|
// ASCII double digit (00 - 99) Numeric Value + 130
|
||||||
byte[] bytes = {(byte) 130 , (byte) ( 1 + 130),
|
byte[] bytes = {(byte) 130 , (byte) (1 + 130),
|
||||||
(byte) (98 + 130), (byte) (99 + 130)};
|
(byte) (98 + 130), (byte) (99 + 130)};
|
||||||
String decodedString = DecodedBitStreamParser.decode(bytes).getText();
|
String decodedString = DecodedBitStreamParser.decode(bytes).getText();
|
||||||
assertEquals("00019899", decodedString);
|
assertEquals("00019899", decodedString);
|
||||||
|
|
|
@ -20,6 +20,9 @@ import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.MultiFormatReader;
|
import com.google.zxing.MultiFormatReader;
|
||||||
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link MaxiCodeReader} against a fixed set of test images.
|
||||||
|
*/
|
||||||
public final class Maxicode1TestCase extends AbstractBlackBoxTestCase {
|
public final class Maxicode1TestCase extends AbstractBlackBoxTestCase {
|
||||||
|
|
||||||
public Maxicode1TestCase() {
|
public Maxicode1TestCase() {
|
||||||
|
|
|
@ -31,6 +31,9 @@ import com.google.zxing.common.HybridBinarizer;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link MultipleBarcodeReader}.
|
||||||
|
*/
|
||||||
public final class MultiTestCase extends Assert {
|
public final class MultiTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -35,6 +35,9 @@ import com.google.zxing.multi.MultipleBarcodeReader;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link QRCodeMultiReader}.
|
||||||
|
*/
|
||||||
public final class MultiQRCodeTestCase extends Assert {
|
public final class MultiQRCodeTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -28,6 +28,9 @@ import com.google.zxing.WriterException;
|
||||||
import com.google.zxing.common.BitArray;
|
import com.google.zxing.common.BitArray;
|
||||||
import com.google.zxing.common.BitMatrix;
|
import com.google.zxing.common.BitMatrix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link Code128Writer}.
|
||||||
|
*/
|
||||||
public class Code128WriterTestCase extends Assert {
|
public class Code128WriterTestCase extends Assert {
|
||||||
|
|
||||||
private static final String FNC1 = "11110101110";
|
private static final String FNC1 = "11110101110";
|
||||||
|
|
|
@ -32,7 +32,7 @@ import com.google.zxing.Result;
|
||||||
public final class Code39ExtendedModeTestCase extends Assert {
|
public final class Code39ExtendedModeTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeExtendedMode() throws FormatException, ChecksumException, NotFoundException {
|
public void testDecodeExtendedMode() throws Exception {
|
||||||
doTest("\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f",
|
doTest("\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f",
|
||||||
"000001001011011010101001001001011001010101101001001001010110101001011010010010010101011010010110100100100101011011010010101001001001010101011001011010010010010101101011001010100100100101010110110010101001001001010101010011011010010010010101101010011010100100100101010110100110101001001001010101011001101010010010010101101010100110100100100101010110101001101001001001010110110101001010010010010101010110100110100100100101011010110100101001001001010101101101001010010010010101010101100110100100100101011010101100101001001001010101101011001010010010010101010110110010100100100101011001010101101001001001010100110101011010010010010101100110101010100100100101010010110101101001001001010110010110101010010010010101001101101010101001001001011010100101101010010010010101101001011010100100100101101101001010101001001001010101100101101010010010010110101100101010010110110100000");
|
"000001001011011010101001001001011001010101101001001001010110101001011010010010010101011010010110100100100101011011010010101001001001010101011001011010010010010101101011001010100100100101010110110010101001001001010101010011011010010010010101101010011010100100100101010110100110101001001001010101011001101010010010010101101010100110100100100101010110101001101001001001010110110101001010010010010101010110100110100100100101011010110100101001001001010101101101001010010010010101010101100110100100100101011010101100101001001001010101101011001010010010010101010110110010100100100101011001010101101001001001010100110101011010010010010101100110101010100100100101010010110101101001001001010110010110101010010010010101001101101010101001001001011010100101101010010010010101101001011010100100100101101101001010101001001001010101100101101010010010010110101100101010010110110100000");
|
||||||
doTest(" !\"#$%&'()*+,-./0123456789:;<=>?",
|
doTest(" !\"#$%&'()*+,-./0123456789:;<=>?",
|
||||||
|
|
|
@ -23,6 +23,9 @@ import com.google.zxing.common.BitMatrixTestCase;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link Code39Writer}.
|
||||||
|
*/
|
||||||
public final class Code39WriterTestCase extends Assert {
|
public final class Code39WriterTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -23,6 +23,9 @@ import com.google.zxing.common.BitMatrixTestCase;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link Code93Writer}.
|
||||||
|
*/
|
||||||
public final class Code93WriterTestCase extends Assert {
|
public final class Code93WriterTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -23,6 +23,9 @@ import com.google.zxing.common.BitMatrixTestCase;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link ITFWriter}.
|
||||||
|
*/
|
||||||
public final class ITFWriterTestCase extends Assert {
|
public final class ITFWriterTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -23,6 +23,9 @@ import com.google.zxing.common.BitMatrixTestCase;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link UPCEWriter}.
|
||||||
|
*/
|
||||||
public final class UPCEWriterTestCase extends Assert {
|
public final class UPCEWriterTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -30,6 +30,9 @@ import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.MultiFormatReader;
|
import com.google.zxing.MultiFormatReader;
|
||||||
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A test of {@link RSSExpandedReader} against a fixed test set of images.
|
||||||
|
*/
|
||||||
public final class RSSExpandedBlackBox1TestCase extends AbstractBlackBoxTestCase {
|
public final class RSSExpandedBlackBox1TestCase extends AbstractBlackBoxTestCase {
|
||||||
|
|
||||||
public RSSExpandedBlackBox1TestCase() {
|
public RSSExpandedBlackBox1TestCase() {
|
||||||
|
|
|
@ -30,6 +30,9 @@ import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.MultiFormatReader;
|
import com.google.zxing.MultiFormatReader;
|
||||||
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A test of {@link RSSExpandedReader} against a fixed test set of images.
|
||||||
|
*/
|
||||||
public final class RSSExpandedBlackBox2TestCase extends AbstractBlackBoxTestCase {
|
public final class RSSExpandedBlackBox2TestCase extends AbstractBlackBoxTestCase {
|
||||||
|
|
||||||
public RSSExpandedBlackBox2TestCase() {
|
public RSSExpandedBlackBox2TestCase() {
|
||||||
|
|
|
@ -30,6 +30,9 @@ import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.MultiFormatReader;
|
import com.google.zxing.MultiFormatReader;
|
||||||
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A test of {@link RSSExpandedReader} against a fixed test set of images.
|
||||||
|
*/
|
||||||
public final class RSSExpandedBlackBox3TestCase extends AbstractBlackBoxTestCase {
|
public final class RSSExpandedBlackBox3TestCase extends AbstractBlackBoxTestCase {
|
||||||
|
|
||||||
public RSSExpandedBlackBox3TestCase() {
|
public RSSExpandedBlackBox3TestCase() {
|
||||||
|
|
|
@ -50,124 +50,124 @@ import org.junit.Test;
|
||||||
public final class RSSExpandedImage2binaryTestCase extends Assert {
|
public final class RSSExpandedImage2binaryTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_1() throws Exception {
|
public void testDecodeRow2binary1() throws Exception {
|
||||||
// (11)100224(17)110224(3102)000100
|
// (11)100224(17)110224(3102)000100
|
||||||
assertCorrectImage2binary(
|
assertCorrectImage2binary(
|
||||||
"1.png", " ...X...X .X....X. .XX...X. X..X...X ...XX.X. ..X.X... ..X.X..X ...X..X. X.X....X .X....X. .....X.. X...X...");
|
"1.png", " ...X...X .X....X. .XX...X. X..X...X ...XX.X. ..X.X... ..X.X..X ...X..X. X.X....X .X....X. .....X.. X...X...");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_2() throws Exception {
|
public void testDecodeRow2binary2() throws Exception {
|
||||||
// (01)90012345678908(3103)001750
|
// (01)90012345678908(3103)001750
|
||||||
assertCorrectImage2binary("2.png", " ..X..... ......X. .XXX.X.X .X...XX. XXXXX.XX XX.X.... .XX.XX.X .XX.");
|
assertCorrectImage2binary("2.png", " ..X..... ......X. .XXX.X.X .X...XX. XXXXX.XX XX.X.... .XX.XX.X .XX.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_3() throws Exception {
|
public void testDecodeRow2binary3() throws Exception {
|
||||||
// (10)12A
|
// (10)12A
|
||||||
assertCorrectImage2binary("3.png", " .......X ..XX..X. X.X....X .......X ....");
|
assertCorrectImage2binary("3.png", " .......X ..XX..X. X.X....X .......X ....");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_4() throws Exception {
|
public void testDecodeRow2binary4() throws Exception {
|
||||||
// (01)98898765432106(3202)012345(15)991231
|
// (01)98898765432106(3202)012345(15)991231
|
||||||
assertCorrectImage2binary(
|
assertCorrectImage2binary(
|
||||||
"4.png", " ..XXXX.X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX..XX XX.X.XXX X..XX..X .X.XXXXX XXXX");
|
"4.png", " ..XXXX.X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX..XX XX.X.XXX X..XX..X .X.XXXXX XXXX");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_5() throws Exception {
|
public void testDecodeRow2binary5() throws Exception {
|
||||||
// (01)90614141000015(3202)000150
|
// (01)90614141000015(3202)000150
|
||||||
assertCorrectImage2binary(
|
assertCorrectImage2binary(
|
||||||
"5.png", " ..X.X... .XXXX.X. XX..XXXX ....XX.. X....... ....X... ....X..X .XX.");
|
"5.png", " ..X.X... .XXXX.X. XX..XXXX ....XX.. X....... ....X... ....X..X .XX.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_10() throws Exception {
|
public void testDecodeRow2binary10() throws Exception {
|
||||||
// (01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456(423)0123456789012
|
// (01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456(423)0123456789012
|
||||||
assertCorrectImage2binary(
|
assertCorrectImage2binary(
|
||||||
"10.png", " .X.XX..X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX...X XX.X.... X.X.X.X. X.X..X.X .X....X. XX...X.. ...XX.X. .XXXXXX. .X..XX.. X.X.X... .X...... XXXX.... XX.XX... XXXXX.X. ...XXXXX .....X.X ...X.... X.XXX..X X.X.X... XX.XX..X .X..X..X .X.X.X.X X.XX...X .XX.XXX. XXX.X.XX ..X.");
|
"10.png", " .X.XX..X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX...X XX.X.... X.X.X.X. X.X..X.X .X....X. XX...X.. ...XX.X. .XXXXXX. .X..XX.. X.X.X... .X...... XXXX.... XX.XX... XXXXX.X. ...XXXXX .....X.X ...X.... X.XXX..X X.X.X... XX.XX..X .X..X..X .X.X.X.X X.XX...X .XX.XXX. XXX.X.XX ..X.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_11() throws Exception {
|
public void testDecodeRow2binary11() throws Exception {
|
||||||
// (01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456
|
// (01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456
|
||||||
assertCorrectImage2binary(
|
assertCorrectImage2binary(
|
||||||
"11.png", " .X.XX..X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX...X XX.X.... X.X.X.X. X.X..X.X .X....X. XX...X.. ...XX.X. .XXXXXX. .X..XX.. X.X.X... .X...... XXXX.... XX.XX... XXXXX.X. ...XXXXX .....X.X ...X.... X.XXX..X X.X.X... ....");
|
"11.png", " .X.XX..X XX.XXXX. .XXX.XX. XX..X... .XXXXX.. XX.X..X. ..XX...X XX.X.... X.X.X.X. X.X..X.X .X....X. XX...X.. ...XX.X. .XXXXXX. .X..XX.. X.X.X... .X...... XXXX.... XX.XX... XXXXX.X. ...XXXXX .....X.X ...X.... X.XXX..X X.X.X... ....");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_12() throws Exception {
|
public void testDecodeRow2binary12() throws Exception {
|
||||||
// (01)98898765432106(3103)001750
|
// (01)98898765432106(3103)001750
|
||||||
assertCorrectImage2binary(
|
assertCorrectImage2binary(
|
||||||
"12.png", " ..X..XX. XXXX..XX X.XX.XX. .X....XX XXX..XX. X..X.... .XX.XX.X .XX.");
|
"12.png", " ..X..XX. XXXX..XX X.XX.XX. .X....XX XXX..XX. X..X.... .XX.XX.X .XX.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_13() throws Exception {
|
public void testDecodeRow2binary13() throws Exception {
|
||||||
// (01)90012345678908(3922)795
|
// (01)90012345678908(3922)795
|
||||||
assertCorrectImage2binary(
|
assertCorrectImage2binary(
|
||||||
"13.png", " ..XX..X. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. X.X.XXXX .X..X..X ......X.");
|
"13.png", " ..XX..X. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. X.X.XXXX .X..X..X ......X.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_14() throws Exception {
|
public void testDecodeRow2binary14() throws Exception {
|
||||||
// (01)90012345678908(3932)0401234
|
// (01)90012345678908(3932)0401234
|
||||||
assertCorrectImage2binary(
|
assertCorrectImage2binary(
|
||||||
"14.png", " ..XX.X.. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. X.....X. X.....X. X.X.X.XX .X...... X...");
|
"14.png", " ..XX.X.. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. X.....X. X.....X. X.X.X.XX .X...... X...");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_15() throws Exception {
|
public void testDecodeRow2binary15() throws Exception {
|
||||||
// (01)90012345678908(3102)001750(11)100312
|
// (01)90012345678908(3102)001750(11)100312
|
||||||
assertCorrectImage2binary(
|
assertCorrectImage2binary(
|
||||||
"15.png", " ..XXX... ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
|
"15.png", " ..XXX... ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_16() throws Exception {
|
public void testDecodeRow2binary16() throws Exception {
|
||||||
// (01)90012345678908(3202)001750(11)100312
|
// (01)90012345678908(3202)001750(11)100312
|
||||||
assertCorrectImage2binary(
|
assertCorrectImage2binary(
|
||||||
"16.png", " ..XXX..X ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
|
"16.png", " ..XXX..X ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_17() throws Exception {
|
public void testDecodeRow2binary17() throws Exception {
|
||||||
// (01)90012345678908(3102)001750(13)100312
|
// (01)90012345678908(3102)001750(13)100312
|
||||||
assertCorrectImage2binary(
|
assertCorrectImage2binary(
|
||||||
"17.png", " ..XXX.X. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
|
"17.png", " ..XXX.X. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_18() throws Exception {
|
public void testDecodeRow2binary18() throws Exception {
|
||||||
// (01)90012345678908(3202)001750(13)100312
|
// (01)90012345678908(3202)001750(13)100312
|
||||||
assertCorrectImage2binary(
|
assertCorrectImage2binary(
|
||||||
"18.png", " ..XXX.XX ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
|
"18.png", " ..XXX.XX ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_19() throws Exception {
|
public void testDecodeRow2binary19() throws Exception {
|
||||||
// (01)90012345678908(3102)001750(15)100312
|
// (01)90012345678908(3102)001750(15)100312
|
||||||
assertCorrectImage2binary(
|
assertCorrectImage2binary(
|
||||||
"19.png", " ..XXXX.. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
|
"19.png", " ..XXXX.. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_20() throws Exception {
|
public void testDecodeRow2binary20() throws Exception {
|
||||||
// (01)90012345678908(3202)001750(15)100312
|
// (01)90012345678908(3202)001750(15)100312
|
||||||
assertCorrectImage2binary(
|
assertCorrectImage2binary(
|
||||||
"20.png", " ..XXXX.X ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
|
"20.png", " ..XXXX.X ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_21() throws Exception {
|
public void testDecodeRow2binary21() throws Exception {
|
||||||
// (01)90012345678908(3102)001750(17)100312
|
// (01)90012345678908(3102)001750(17)100312
|
||||||
assertCorrectImage2binary(
|
assertCorrectImage2binary(
|
||||||
"21.png", " ..XXXXX. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
|
"21.png", " ..XXXXX. ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2binary_22() throws Exception {
|
public void testDecodeRow2binary22() throws Exception {
|
||||||
// (01)90012345678908(3202)001750(17)100312
|
// (01)90012345678908(3202)001750(17)100312
|
||||||
assertCorrectImage2binary(
|
assertCorrectImage2binary(
|
||||||
"22.png", " ..XXXXXX ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
|
"22.png", " ..XXXXXX ........ .X..XXX. X.X.X... XX.XXXXX .XXXX.X. ..XX...X .X.....X .XX..... XXXX.X.. XX..");
|
||||||
|
|
|
@ -61,7 +61,7 @@ import org.junit.Test;
|
||||||
public final class RSSExpandedImage2resultTestCase extends Assert {
|
public final class RSSExpandedImage2resultTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2result_2() throws Exception {
|
public void testDecodeRow2result2() throws Exception {
|
||||||
// (01)90012345678908(3103)001750
|
// (01)90012345678908(3103)001750
|
||||||
ExpandedProductParsedResult expected =
|
ExpandedProductParsedResult expected =
|
||||||
new ExpandedProductParsedResult("(01)90012345678908(3103)001750",
|
new ExpandedProductParsedResult("(01)90012345678908(3103)001750",
|
||||||
|
|
|
@ -51,138 +51,138 @@ import org.junit.Test;
|
||||||
public final class RSSExpandedImage2stringTestCase extends Assert {
|
public final class RSSExpandedImage2stringTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_1() throws Exception {
|
public void testDecodeRow2string1() throws Exception {
|
||||||
assertCorrectImage2string("1.png", "(11)100224(17)110224(3102)000100");
|
assertCorrectImage2string("1.png", "(11)100224(17)110224(3102)000100");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_2() throws Exception {
|
public void testDecodeRow2string2() throws Exception {
|
||||||
assertCorrectImage2string("2.png", "(01)90012345678908(3103)001750");
|
assertCorrectImage2string("2.png", "(01)90012345678908(3103)001750");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_3() throws Exception {
|
public void testDecodeRow2string3() throws Exception {
|
||||||
assertCorrectImage2string("3.png", "(10)12A");
|
assertCorrectImage2string("3.png", "(10)12A");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_4() throws Exception {
|
public void testDecodeRow2string4() throws Exception {
|
||||||
assertCorrectImage2string("4.png", "(01)98898765432106(3202)012345(15)991231");
|
assertCorrectImage2string("4.png", "(01)98898765432106(3202)012345(15)991231");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_5() throws Exception {
|
public void testDecodeRow2string5() throws Exception {
|
||||||
assertCorrectImage2string("5.png", "(01)90614141000015(3202)000150");
|
assertCorrectImage2string("5.png", "(01)90614141000015(3202)000150");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_7() throws Exception {
|
public void testDecodeRow2string7() throws Exception {
|
||||||
assertCorrectImage2string("7.png", "(10)567(11)010101");
|
assertCorrectImage2string("7.png", "(10)567(11)010101");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_10() throws Exception {
|
public void testDecodeRow2string10() throws Exception {
|
||||||
String expected = "(01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456(423)012345678901";
|
String expected = "(01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456(423)012345678901";
|
||||||
assertCorrectImage2string("10.png", expected);
|
assertCorrectImage2string("10.png", expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_11() throws Exception {
|
public void testDecodeRow2string11() throws Exception {
|
||||||
assertCorrectImage2string("11.png", "(01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456");
|
assertCorrectImage2string("11.png", "(01)98898765432106(15)991231(3103)001750(10)12A(422)123(21)123456");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_12() throws Exception {
|
public void testDecodeRow2string12() throws Exception {
|
||||||
assertCorrectImage2string("12.png", "(01)98898765432106(3103)001750");
|
assertCorrectImage2string("12.png", "(01)98898765432106(3103)001750");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_13() throws Exception {
|
public void testDecodeRow2string13() throws Exception {
|
||||||
assertCorrectImage2string("13.png", "(01)90012345678908(3922)795");
|
assertCorrectImage2string("13.png", "(01)90012345678908(3922)795");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_14() throws Exception {
|
public void testDecodeRow2string14() throws Exception {
|
||||||
assertCorrectImage2string("14.png", "(01)90012345678908(3932)0401234");
|
assertCorrectImage2string("14.png", "(01)90012345678908(3932)0401234");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_15() throws Exception {
|
public void testDecodeRow2string15() throws Exception {
|
||||||
assertCorrectImage2string("15.png", "(01)90012345678908(3102)001750(11)100312");
|
assertCorrectImage2string("15.png", "(01)90012345678908(3102)001750(11)100312");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_16() throws Exception {
|
public void testDecodeRow2string16() throws Exception {
|
||||||
assertCorrectImage2string("16.png", "(01)90012345678908(3202)001750(11)100312");
|
assertCorrectImage2string("16.png", "(01)90012345678908(3202)001750(11)100312");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_17() throws Exception {
|
public void testDecodeRow2string17() throws Exception {
|
||||||
assertCorrectImage2string("17.png", "(01)90012345678908(3102)001750(13)100312");
|
assertCorrectImage2string("17.png", "(01)90012345678908(3102)001750(13)100312");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_18() throws Exception {
|
public void testDecodeRow2string18() throws Exception {
|
||||||
assertCorrectImage2string("18.png", "(01)90012345678908(3202)001750(13)100312");
|
assertCorrectImage2string("18.png", "(01)90012345678908(3202)001750(13)100312");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_19() throws Exception {
|
public void testDecodeRow2string19() throws Exception {
|
||||||
assertCorrectImage2string("19.png", "(01)90012345678908(3102)001750(15)100312");
|
assertCorrectImage2string("19.png", "(01)90012345678908(3102)001750(15)100312");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_20() throws Exception {
|
public void testDecodeRow2string20() throws Exception {
|
||||||
assertCorrectImage2string("20.png", "(01)90012345678908(3202)001750(15)100312");
|
assertCorrectImage2string("20.png", "(01)90012345678908(3202)001750(15)100312");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_21() throws Exception {
|
public void testDecodeRow2string21() throws Exception {
|
||||||
assertCorrectImage2string("21.png", "(01)90012345678908(3102)001750(17)100312");
|
assertCorrectImage2string("21.png", "(01)90012345678908(3102)001750(17)100312");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_22() throws Exception {
|
public void testDecodeRow2string22() throws Exception {
|
||||||
assertCorrectImage2string("22.png", "(01)90012345678908(3202)001750(17)100312");
|
assertCorrectImage2string("22.png", "(01)90012345678908(3202)001750(17)100312");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_25() throws Exception {
|
public void testDecodeRow2string25() throws Exception {
|
||||||
assertCorrectImage2string("25.png", "(10)123");
|
assertCorrectImage2string("25.png", "(10)123");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_26() throws Exception {
|
public void testDecodeRow2string26() throws Exception {
|
||||||
assertCorrectImage2string("26.png", "(10)5678(11)010101");
|
assertCorrectImage2string("26.png", "(10)5678(11)010101");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_27() throws Exception {
|
public void testDecodeRow2string27() throws Exception {
|
||||||
assertCorrectImage2string("27.png", "(10)1098-1234");
|
assertCorrectImage2string("27.png", "(10)1098-1234");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_28() throws Exception {
|
public void testDecodeRow2string28() throws Exception {
|
||||||
assertCorrectImage2string("28.png", "(10)1098/1234");
|
assertCorrectImage2string("28.png", "(10)1098/1234");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_29() throws Exception {
|
public void testDecodeRow2string29() throws Exception {
|
||||||
assertCorrectImage2string("29.png", "(10)1098.1234");
|
assertCorrectImage2string("29.png", "(10)1098.1234");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_30() throws Exception {
|
public void testDecodeRow2string30() throws Exception {
|
||||||
assertCorrectImage2string("30.png", "(10)1098*1234");
|
assertCorrectImage2string("30.png", "(10)1098*1234");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_31() throws Exception {
|
public void testDecodeRow2string31() throws Exception {
|
||||||
assertCorrectImage2string("31.png", "(10)1098,1234");
|
assertCorrectImage2string("31.png", "(10)1098,1234");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDecodeRow2string_32() throws Exception {
|
public void testDecodeRow2string32() throws Exception {
|
||||||
assertCorrectImage2string("32.png", "(15)991231(3103)001750(10)12A(422)123(21)123456(423)0123456789012");
|
assertCorrectImage2string("32.png", "(15)991231(3103)001750(10)12A(422)123(21)123456(423)0123456789012");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ public final class RSSExpandedInternalTestCase extends Assert {
|
||||||
assertNotNull(finderPattern);
|
assertNotNull(finderPattern);
|
||||||
assertEquals(1, finderPattern.getValue());
|
assertEquals(1, finderPattern.getValue());
|
||||||
|
|
||||||
try{
|
try {
|
||||||
rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber);
|
rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber);
|
||||||
// the previous was the last pair
|
// the previous was the last pair
|
||||||
fail(NotFoundException.class.getName() + " expected");
|
fail(NotFoundException.class.getName() + " expected");
|
||||||
|
@ -116,8 +116,8 @@ public final class RSSExpandedInternalTestCase extends Assert {
|
||||||
BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
|
BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
|
||||||
BitArray row = binaryMap.getBlackRow(binaryMap.getHeight() / 2, null);
|
BitArray row = binaryMap.getBlackRow(binaryMap.getHeight() / 2, null);
|
||||||
|
|
||||||
int[] startEnd = {145, 243};//image pixels where the A1 pattern starts (at 124) and ends (at 214)
|
int[] startEnd = {145, 243}; //image pixels where the A1 pattern starts (at 124) and ends (at 214)
|
||||||
int value = 0;// A
|
int value = 0; // A
|
||||||
FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.getHeight() / 2);
|
FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.getHeight() / 2);
|
||||||
//{1, 8, 4, 1, 1};
|
//{1, 8, 4, 1, 1};
|
||||||
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
|
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
|
||||||
|
@ -132,7 +132,7 @@ public final class RSSExpandedInternalTestCase extends Assert {
|
||||||
BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
|
BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
|
||||||
BitArray row = binaryMap.getBlackRow(binaryMap.getHeight() / 2, null);
|
BitArray row = binaryMap.getBlackRow(binaryMap.getHeight() / 2, null);
|
||||||
|
|
||||||
int[] startEnd = {145, 243};//image pixels where the A1 pattern starts (at 124) and ends (at 214)
|
int[] startEnd = {145, 243}; //image pixels where the A1 pattern starts (at 124) and ends (at 214)
|
||||||
int value = 0; // A
|
int value = 0; // A
|
||||||
FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.getHeight() / 2);
|
FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.getHeight() / 2);
|
||||||
//{1, 8, 4, 1, 1};
|
//{1, 8, 4, 1, 1};
|
||||||
|
|
|
@ -30,6 +30,10 @@ import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.MultiFormatReader;
|
import com.google.zxing.MultiFormatReader;
|
||||||
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A test of {@link RSSExpandedReader} against a fixed test set of images including
|
||||||
|
* stacked RSS barcodes.
|
||||||
|
*/
|
||||||
public final class RSSExpandedStackedBlackBox1TestCase extends AbstractBlackBoxTestCase {
|
public final class RSSExpandedStackedBlackBox1TestCase extends AbstractBlackBoxTestCase {
|
||||||
|
|
||||||
public RSSExpandedStackedBlackBox1TestCase() {
|
public RSSExpandedStackedBlackBox1TestCase() {
|
||||||
|
|
|
@ -30,6 +30,10 @@ import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.MultiFormatReader;
|
import com.google.zxing.MultiFormatReader;
|
||||||
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A test of {@link RSSExpandedReader} against a fixed test set of images including
|
||||||
|
* stacked RSS barcodes.
|
||||||
|
*/
|
||||||
public final class RSSExpandedStackedBlackBox2TestCase extends AbstractBlackBoxTestCase {
|
public final class RSSExpandedStackedBlackBox2TestCase extends AbstractBlackBoxTestCase {
|
||||||
|
|
||||||
public RSSExpandedStackedBlackBox2TestCase() {
|
public RSSExpandedStackedBlackBox2TestCase() {
|
||||||
|
|
|
@ -37,6 +37,9 @@ import com.google.zxing.NotFoundException;
|
||||||
import com.google.zxing.Result;
|
import com.google.zxing.Result;
|
||||||
import com.google.zxing.common.BitArray;
|
import com.google.zxing.common.BitArray;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link RSSExpandedReader} handling of stacked RSS barcodes.
|
||||||
|
*/
|
||||||
public final class RSSExpandedStackedInternalTestCase extends Assert {
|
public final class RSSExpandedStackedInternalTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -32,27 +32,27 @@ import org.junit.Test;
|
||||||
/**
|
/**
|
||||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||||
*/
|
*/
|
||||||
public final class AI01_3103_DecoderTest extends AbstractDecoderTest {
|
public final class AI013103DecoderTest extends AbstractDecoderTest {
|
||||||
|
|
||||||
private static final String header = "..X..";
|
private static final String header = "..X..";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test01_3103_1() throws Exception {
|
public void test0131031() throws Exception {
|
||||||
CharSequence data = header + compressedGtin_900123456798908 + compressed15bitWeight_1750;
|
CharSequence data = header + compressedGtin900123456798908 + compressed15bitWeight1750;
|
||||||
String expected = "(01)90012345678908(3103)001750";
|
String expected = "(01)90012345678908(3103)001750";
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test01_3103_2() throws Exception {
|
public void test0131032() throws Exception {
|
||||||
CharSequence data = header + compressedGtin_900000000000008 + compressed15bitWeight_0;
|
CharSequence data = header + compressedGtin900000000000008 + compressed15bitWeight0;
|
||||||
String expected = "(01)90000000000003(3103)000000";
|
String expected = "(01)90000000000003(3103)000000";
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NotFoundException.class)
|
@Test(expected = NotFoundException.class)
|
||||||
public void test01_3103_invalid() throws Exception {
|
public void test013103invalid() throws Exception {
|
||||||
CharSequence data = header + compressedGtin_900123456798908 + compressed15bitWeight_1750 + "..";
|
CharSequence data = header + compressedGtin900123456798908 + compressed15bitWeight1750 + "..";
|
||||||
assertCorrectBinaryString(data, "");
|
assertCorrectBinaryString(data, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -31,21 +31,21 @@ import org.junit.Test;
|
||||||
/**
|
/**
|
||||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||||
*/
|
*/
|
||||||
public final class AI01_3202_3203_DecoderTest extends AbstractDecoderTest {
|
public final class AI0132023203DecoderTest extends AbstractDecoderTest {
|
||||||
|
|
||||||
private static final String header = "..X.X";
|
private static final String header = "..X.X";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test01_3202_1() throws Exception {
|
public void test0132021() throws Exception {
|
||||||
CharSequence data = header + compressedGtin_900123456798908 + compressed15bitWeight_1750;
|
CharSequence data = header + compressedGtin900123456798908 + compressed15bitWeight1750;
|
||||||
String expected = "(01)90012345678908(3202)001750";
|
String expected = "(01)90012345678908(3202)001750";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test01_3203_1() throws Exception {
|
public void test0132031() throws Exception {
|
||||||
CharSequence data = header + compressedGtin_900123456798908 + compressed15bitWeight_11750;
|
CharSequence data = header + compressedGtin900123456798908 + compressed15bitWeight11750;
|
||||||
String expected = "(01)90012345678908(3203)001750";
|
String expected = "(01)90012345678908(3203)001750";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
|
@ -31,84 +31,84 @@ import org.junit.Test;
|
||||||
/**
|
/**
|
||||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||||
*/
|
*/
|
||||||
public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
|
public final class AI013X0X1XDecoderTest extends AbstractDecoderTest {
|
||||||
|
|
||||||
private static final String header_310x_11 = "..XXX...";
|
private static final String header310x11 = "..XXX...";
|
||||||
private static final String header_320x_11 = "..XXX..X";
|
private static final String header320x11 = "..XXX..X";
|
||||||
private static final String header_310x_13 = "..XXX.X.";
|
private static final String header310x13 = "..XXX.X.";
|
||||||
private static final String header_320x_13 = "..XXX.XX";
|
private static final String header320x13 = "..XXX.XX";
|
||||||
private static final String header_310x_15 = "..XXXX..";
|
private static final String header310x15 = "..XXXX..";
|
||||||
private static final String header_320x_15 = "..XXXX.X";
|
private static final String header320x15 = "..XXXX.X";
|
||||||
private static final String header_310x_17 = "..XXXXX.";
|
private static final String header310x17 = "..XXXXX.";
|
||||||
private static final String header_320x_17 = "..XXXXXX";
|
private static final String header320x17 = "..XXXXXX";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test01_310X_1X_endDate() throws Exception {
|
public void test01310X1XendDate() throws Exception {
|
||||||
CharSequence data = header_310x_11 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_End;
|
CharSequence data = header310x11 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateEnd;
|
||||||
String expected = "(01)90012345678908(3100)001750";
|
String expected = "(01)90012345678908(3100)001750";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test01_310X_11_1() throws Exception {
|
public void test01310X111() throws Exception {
|
||||||
CharSequence data = header_310x_11 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
|
CharSequence data = header310x11 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateMarch12th2010;
|
||||||
String expected = "(01)90012345678908(3100)001750(11)100312";
|
String expected = "(01)90012345678908(3100)001750(11)100312";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test01_320X_11_1() throws Exception {
|
public void test01320X111() throws Exception {
|
||||||
CharSequence data = header_320x_11 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
|
CharSequence data = header320x11 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateMarch12th2010;
|
||||||
String expected = "(01)90012345678908(3200)001750(11)100312";
|
String expected = "(01)90012345678908(3200)001750(11)100312";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test01_310X_13_1() throws Exception {
|
public void test01310X131() throws Exception {
|
||||||
CharSequence data = header_310x_13 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
|
CharSequence data = header310x13 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateMarch12th2010;
|
||||||
String expected = "(01)90012345678908(3100)001750(13)100312";
|
String expected = "(01)90012345678908(3100)001750(13)100312";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test01_320X_13_1() throws Exception {
|
public void test01320X131() throws Exception {
|
||||||
CharSequence data = header_320x_13 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
|
CharSequence data = header320x13 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateMarch12th2010;
|
||||||
String expected = "(01)90012345678908(3200)001750(13)100312";
|
String expected = "(01)90012345678908(3200)001750(13)100312";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test01_310X_15_1() throws Exception {
|
public void test01310X151() throws Exception {
|
||||||
CharSequence data = header_310x_15 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
|
CharSequence data = header310x15 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateMarch12th2010;
|
||||||
String expected = "(01)90012345678908(3100)001750(15)100312";
|
String expected = "(01)90012345678908(3100)001750(15)100312";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test01_320X_15_1() throws Exception {
|
public void test01320X151() throws Exception {
|
||||||
CharSequence data = header_320x_15 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
|
CharSequence data = header320x15 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateMarch12th2010;
|
||||||
String expected = "(01)90012345678908(3200)001750(15)100312";
|
String expected = "(01)90012345678908(3200)001750(15)100312";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test01_310X_17_1() throws Exception {
|
public void test01310X171() throws Exception {
|
||||||
CharSequence data = header_310x_17 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
|
CharSequence data = header310x17 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateMarch12th2010;
|
||||||
String expected = "(01)90012345678908(3100)001750(17)100312";
|
String expected = "(01)90012345678908(3100)001750(17)100312";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test01_320X_17_1() throws Exception {
|
public void test01320X171() throws Exception {
|
||||||
CharSequence data = header_320x_17 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
|
CharSequence data = header320x17 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateMarch12th2010;
|
||||||
String expected = "(01)90012345678908(3200)001750(17)100312";
|
String expected = "(01)90012345678908(3200)001750(17)100312";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
|
@ -38,34 +38,34 @@ import org.junit.Assert;
|
||||||
*/
|
*/
|
||||||
abstract class AbstractDecoderTest extends Assert {
|
abstract class AbstractDecoderTest extends Assert {
|
||||||
|
|
||||||
static final String numeric_10 = "..X..XX";
|
static final String numeric10 = "..X..XX";
|
||||||
static final String numeric_12 = "..X.X.X";
|
static final String numeric12 = "..X.X.X";
|
||||||
static final String numeric_1FNC1 = "..XXX.X";
|
static final String numeric1FNC1 = "..XXX.X";
|
||||||
// static final String numeric_FNC11 = "XXX.XXX";
|
// static final String numericFNC11 = "XXX.XXX";
|
||||||
|
|
||||||
static final String numeric2alpha = "....";
|
static final String numeric2alpha = "....";
|
||||||
|
|
||||||
static final String alpha_A = "X.....";
|
static final String alphaA = "X.....";
|
||||||
static final String alpha_FNC1 = ".XXXX";
|
static final String alphaFNC1 = ".XXXX";
|
||||||
static final String alpha2numeric = "...";
|
static final String alpha2numeric = "...";
|
||||||
static final String alpha2isoiec646 = "..X..";
|
static final String alpha2isoiec646 = "..X..";
|
||||||
|
|
||||||
static final String i646_B = "X.....X";
|
static final String i646B = "X.....X";
|
||||||
static final String i646_C = "X....X.";
|
static final String i646C = "X....X.";
|
||||||
static final String i646_FNC1 = ".XXXX";
|
static final String i646FNC1 = ".XXXX";
|
||||||
static final String isoiec646_2alpha = "..X..";
|
static final String isoiec6462alpha = "..X..";
|
||||||
|
|
||||||
static final String compressedGtin_900123456798908 = ".........X..XXX.X.X.X...XX.XXXXX.XXXX.X.";
|
static final String compressedGtin900123456798908 = ".........X..XXX.X.X.X...XX.XXXXX.XXXX.X.";
|
||||||
static final String compressedGtin_900000000000008 = "........................................";
|
static final String compressedGtin900000000000008 = "........................................";
|
||||||
|
|
||||||
static final String compressed15bitWeight_1750 = "....XX.XX.X.XX.";
|
static final String compressed15bitWeight1750 = "....XX.XX.X.XX.";
|
||||||
static final String compressed15bitWeight_11750 = ".X.XX.XXXX..XX.";
|
static final String compressed15bitWeight11750 = ".X.XX.XXXX..XX.";
|
||||||
static final String compressed15bitWeight_0 = "...............";
|
static final String compressed15bitWeight0 = "...............";
|
||||||
|
|
||||||
static final String compressed20bitWeight_1750 = ".........XX.XX.X.XX.";
|
static final String compressed20bitWeight1750 = ".........XX.XX.X.XX.";
|
||||||
|
|
||||||
static final String compressedDate_March_12th_2010 = "....XXXX.X..XX..";
|
static final String compressedDateMarch12th2010 = "....XXXX.X..XX..";
|
||||||
static final String compressedDate_End = "X..X.XX.........";
|
static final String compressedDateEnd = "X..X.XX.........";
|
||||||
|
|
||||||
static void assertCorrectBinaryString(CharSequence binaryString,
|
static void assertCorrectBinaryString(CharSequence binaryString,
|
||||||
String expectedNumber) throws NotFoundException, FormatException {
|
String expectedNumber) throws NotFoundException, FormatException {
|
||||||
|
|
|
@ -36,48 +36,48 @@ public final class AnyAIDecoderTest extends AbstractDecoderTest {
|
||||||
private static final String header = ".....";
|
private static final String header = ".....";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAnyAIDecoder_1() throws Exception {
|
public void testAnyAIDecoder1() throws Exception {
|
||||||
CharSequence data = header + numeric_10 + numeric_12 + numeric2alpha + alpha_A + alpha2numeric + numeric_12;
|
CharSequence data = header + numeric10 + numeric12 + numeric2alpha + alphaA + alpha2numeric + numeric12;
|
||||||
String expected = "(10)12A12";
|
String expected = "(10)12A12";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAnyAIDecoder_2() throws Exception {
|
public void testAnyAIDecoder2() throws Exception {
|
||||||
CharSequence data = header + numeric_10 + numeric_12 + numeric2alpha + alpha_A + alpha2isoiec646 + i646_B;
|
CharSequence data = header + numeric10 + numeric12 + numeric2alpha + alphaA + alpha2isoiec646 + i646B;
|
||||||
String expected = "(10)12AB";
|
String expected = "(10)12AB";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAnyAIDecoder_3() throws Exception {
|
public void testAnyAIDecoder3() throws Exception {
|
||||||
CharSequence data = header + numeric_10 + numeric2alpha + alpha2isoiec646 + i646_B + i646_C + isoiec646_2alpha + alpha_A + alpha2numeric + numeric_10;
|
CharSequence data = header + numeric10 + numeric2alpha + alpha2isoiec646 + i646B + i646C + isoiec6462alpha + alphaA + alpha2numeric + numeric10;
|
||||||
String expected = "(10)BCA10";
|
String expected = "(10)BCA10";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAnyAIDecoder_numericFNC1_secondDigit() throws Exception {
|
public void testAnyAIDecodernumericFNC1secondDigit() throws Exception {
|
||||||
CharSequence data = header + numeric_10 + numeric_1FNC1;
|
CharSequence data = header + numeric10 + numeric1FNC1;
|
||||||
String expected = "(10)1";
|
String expected = "(10)1";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAnyAIDecoder_alphaFNC1() throws Exception {
|
public void testAnyAIDecoderalphaFNC1() throws Exception {
|
||||||
CharSequence data = header + numeric_10 + numeric2alpha + alpha_A + alpha_FNC1;
|
CharSequence data = header + numeric10 + numeric2alpha + alphaA + alphaFNC1;
|
||||||
String expected = "(10)A";
|
String expected = "(10)A";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAnyAIDecoder_646FNC1() throws Exception {
|
public void testAnyAIDecoder646FNC1() throws Exception {
|
||||||
CharSequence data = header + numeric_10 + numeric2alpha + alpha_A + isoiec646_2alpha + i646_B + i646_FNC1;
|
CharSequence data = header + numeric10 + numeric2alpha + alphaA + isoiec6462alpha + i646B + i646FNC1;
|
||||||
String expected = "(10)AB";
|
String expected = "(10)AB";
|
||||||
|
|
||||||
assertCorrectBinaryString(data, expected);
|
assertCorrectBinaryString(data, expected);
|
||||||
|
|
|
@ -43,12 +43,12 @@ public final class FieldParserTest extends Assert {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseField() throws Exception{
|
public void testParseField() throws Exception {
|
||||||
checkFields("(15)991231(3103)001750(10)12A");
|
checkFields("(15)991231(3103)001750(10)12A");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseField2() throws Exception{
|
public void testParseField2() throws Exception {
|
||||||
checkFields("(15)991231(15)991231(3103)001750(10)12A");
|
checkFields("(15)991231(15)991231(3103)001750(10)12A");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,9 @@ import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.MultiFormatReader;
|
import com.google.zxing.MultiFormatReader;
|
||||||
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link PDF417Reader} against more sample images.
|
||||||
|
*/
|
||||||
public final class PDF417BlackBox3TestCase extends AbstractBlackBoxTestCase {
|
public final class PDF417BlackBox3TestCase extends AbstractBlackBoxTestCase {
|
||||||
|
|
||||||
public PDF417BlackBox3TestCase() {
|
public PDF417BlackBox3TestCase() {
|
||||||
|
|
|
@ -26,6 +26,9 @@ import com.google.zxing.common.BitMatrix;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link PDF417Writer}.
|
||||||
|
*/
|
||||||
public final class PDF417WriterTestCase extends Assert {
|
public final class PDF417WriterTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -21,6 +21,9 @@ import com.google.zxing.pdf417.PDF417ResultMetadata;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link DecodedBitStreamParser}.
|
||||||
|
*/
|
||||||
public class PDF417DecoderTestCase extends Assert {
|
public class PDF417DecoderTestCase extends Assert {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,6 +21,9 @@ import java.nio.charset.StandardCharsets;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link PDF417HighLevelEncoder}.
|
||||||
|
*/
|
||||||
public final class PDF417EncoderTestCase extends Assert {
|
public final class PDF417EncoderTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -32,7 +35,7 @@ public final class PDF417EncoderTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEncodeAutoWithSpecialChars() throws Exception {
|
public void testEncodeAutoWithSpecialChars() throws Exception {
|
||||||
//Just check if this does not throw an exception
|
// Just check if this does not throw an exception
|
||||||
PDF417HighLevelEncoder.encodeHighLevel(
|
PDF417HighLevelEncoder.encodeHighLevel(
|
||||||
"1%§s ?aG$", Compaction.AUTO, StandardCharsets.UTF_8);
|
"1%§s ?aG$", Compaction.AUTO, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public final class VersionTestCase extends Assert {
|
||||||
// good
|
// good
|
||||||
}
|
}
|
||||||
for (int i = 1; i <= 40; i++) {
|
for (int i = 1; i <= 40; i++) {
|
||||||
checkVersion(Version.getVersionForNumber(i), i, 4*i + 17);
|
checkVersion(Version.getVersionForNumber(i), i, 4 * i + 17);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public final class VersionTestCase extends Assert {
|
||||||
@Test
|
@Test
|
||||||
public void testGetProvisionalVersionForDimension() throws Exception {
|
public void testGetProvisionalVersionForDimension() throws Exception {
|
||||||
for (int i = 1; i <= 40; i++) {
|
for (int i = 1; i <= 40; i++) {
|
||||||
assertEquals(i, Version.getProvisionalVersionForDimension(4*i + 17).getVersionNumber());
|
assertEquals(i, Version.getProvisionalVersionForDimension(4 * i + 17).getVersionNumber());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,13 +84,13 @@ public final class EncoderTestCase extends Assert {
|
||||||
|
|
||||||
// AIUE in Hiragana in Shift_JIS
|
// AIUE in Hiragana in Shift_JIS
|
||||||
assertSame(Mode.BYTE,
|
assertSame(Mode.BYTE,
|
||||||
Encoder.chooseMode(shiftJISString(new byte[]{0x8, 0xa, 0x8, 0xa, 0x8, 0xa, 0x8, (byte) 0xa6})));
|
Encoder.chooseMode(shiftJISString(bytes(0x8, 0xa, 0x8, 0xa, 0x8, 0xa, 0x8, 0xa6))));
|
||||||
|
|
||||||
// Nihon in Kanji in Shift_JIS.
|
// Nihon in Kanji in Shift_JIS.
|
||||||
assertSame(Mode.BYTE, Encoder.chooseMode(shiftJISString(new byte[]{0x9, 0xf, 0x9, 0x7b})));
|
assertSame(Mode.BYTE, Encoder.chooseMode(shiftJISString(bytes(0x9, 0xf, 0x9, 0x7b))));
|
||||||
|
|
||||||
// Sou-Utsu-Byou in Kanji in Shift_JIS.
|
// Sou-Utsu-Byou in Kanji in Shift_JIS.
|
||||||
assertSame(Mode.BYTE, Encoder.chooseMode(shiftJISString(new byte[]{0xe, 0x4, 0x9, 0x5, 0x9, 0x61})));
|
assertSame(Mode.BYTE, Encoder.chooseMode(shiftJISString(bytes(0xe, 0x4, 0x9, 0x5, 0x9, 0x61))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -388,7 +388,8 @@ public final class EncoderTestCase extends Assert {
|
||||||
// Should use appendKanjiBytes.
|
// Should use appendKanjiBytes.
|
||||||
// 0x93, 0x5f
|
// 0x93, 0x5f
|
||||||
bits = new BitArray();
|
bits = new BitArray();
|
||||||
Encoder.appendBytes(shiftJISString(new byte[] {(byte)0x93,0x5f}), Mode.KANJI, bits, Encoder.DEFAULT_BYTE_MODE_ENCODING);
|
Encoder.appendBytes(shiftJISString(bytes(0x93, 0x5f)), Mode.KANJI, bits,
|
||||||
|
Encoder.DEFAULT_BYTE_MODE_ENCODING);
|
||||||
assertEquals(" .XX.XX.. XXXXX", bits.toString());
|
assertEquals(" .XX.XX.. XXXXX", bits.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,19 +461,19 @@ public final class EncoderTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInterleaveWithECBytes() throws WriterException {
|
public void testInterleaveWithECBytes() throws WriterException {
|
||||||
byte[] dataBytes = {32, 65, (byte)205, 69, 41, (byte)220, 46, (byte)128, (byte)236};
|
byte[] dataBytes = bytes(32, 65, 205, 69, 41, 220, 46, 128, 236);
|
||||||
BitArray in = new BitArray();
|
BitArray in = new BitArray();
|
||||||
for (byte dataByte: dataBytes) {
|
for (byte dataByte: dataBytes) {
|
||||||
in.appendBits(dataByte, 8);
|
in.appendBits(dataByte, 8);
|
||||||
}
|
}
|
||||||
BitArray out = Encoder.interleaveWithECBytes(in, 26, 9, 1);
|
BitArray out = Encoder.interleaveWithECBytes(in, 26, 9, 1);
|
||||||
byte[] expected = {
|
byte[] expected = bytes(
|
||||||
// Data bytes.
|
// Data bytes.
|
||||||
32, 65, (byte)205, 69, 41, (byte)220, 46, (byte)128, (byte)236,
|
32, 65, 205, 69, 41, 220, 46, 128, 236,
|
||||||
// Error correction bytes.
|
// Error correction bytes.
|
||||||
42, (byte)159, 74, (byte)221, (byte)244, (byte)169, (byte)239, (byte)150, (byte)138, 70,
|
42, 159, 74, 221, 244, 169, 239, 150, 138, 70,
|
||||||
(byte)237, 85, (byte)224, 96, 74, (byte)219, 61,
|
237, 85, 224, 96, 74, 219, 61
|
||||||
};
|
);
|
||||||
assertEquals(expected.length, out.getSizeInBytes());
|
assertEquals(expected.length, out.getSizeInBytes());
|
||||||
byte[] outArray = new byte[expected.length];
|
byte[] outArray = new byte[expected.length];
|
||||||
out.toBytes(0, outArray, 0, expected.length);
|
out.toBytes(0, outArray, 0, expected.length);
|
||||||
|
@ -481,37 +482,37 @@ public final class EncoderTestCase extends Assert {
|
||||||
assertEquals(expected[x], outArray[x]);
|
assertEquals(expected[x], outArray[x]);
|
||||||
}
|
}
|
||||||
// Numbers are from http://www.swetake.com/qr/qr8.html
|
// Numbers are from http://www.swetake.com/qr/qr8.html
|
||||||
dataBytes = new byte[] {
|
dataBytes = bytes(
|
||||||
67, 70, 22, 38, 54, 70, 86, 102, 118, (byte)134, (byte)150, (byte)166, (byte)182,
|
67, 70, 22, 38, 54, 70, 86, 102, 118, 134, 150, 166, 182,
|
||||||
(byte)198, (byte)214, (byte)230, (byte)247, 7, 23, 39, 55, 71, 87, 103, 119, (byte)135,
|
198, 214, 230, 247, 7, 23, 39, 55, 71, 87, 103, 119, 135,
|
||||||
(byte)151, (byte)166, 22, 38, 54, 70, 86, 102, 118, (byte)134, (byte)150, (byte)166,
|
151, 166, 22, 38, 54, 70, 86, 102, 118, 134, 150, 166,
|
||||||
(byte)182, (byte)198, (byte)214, (byte)230, (byte)247, 7, 23, 39, 55, 71, 87, 103, 119,
|
182, 198, 214, 230, 247, 7, 23, 39, 55, 71, 87, 103, 119,
|
||||||
(byte)135, (byte)151, (byte)160, (byte)236, 17, (byte)236, 17, (byte)236, 17, (byte)236,
|
135, 151, 160, 236, 17, 236, 17, 236, 17, 236,
|
||||||
17
|
17
|
||||||
};
|
);
|
||||||
in = new BitArray();
|
in = new BitArray();
|
||||||
for (byte dataByte: dataBytes) {
|
for (byte dataByte: dataBytes) {
|
||||||
in.appendBits(dataByte, 8);
|
in.appendBits(dataByte, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
out = Encoder.interleaveWithECBytes(in, 134, 62, 4);
|
out = Encoder.interleaveWithECBytes(in, 134, 62, 4);
|
||||||
expected = new byte[] {
|
expected = bytes(
|
||||||
// Data bytes.
|
// Data bytes.
|
||||||
67, (byte)230, 54, 55, 70, (byte)247, 70, 71, 22, 7, 86, 87, 38, 23, 102, 103, 54, 39,
|
67, 230, 54, 55, 70, 247, 70, 71, 22, 7, 86, 87, 38, 23, 102, 103, 54, 39,
|
||||||
118, 119, 70, 55, (byte)134, (byte)135, 86, 71, (byte)150, (byte)151, 102, 87, (byte)166,
|
118, 119, 70, 55, 134, 135, 86, 71, 150, 151, 102, 87, 166,
|
||||||
(byte)160, 118, 103, (byte)182, (byte)236, (byte)134, 119, (byte)198, 17, (byte)150,
|
160, 118, 103, 182, 236, 134, 119, 198, 17, 150,
|
||||||
(byte)135, (byte)214, (byte)236, (byte)166, (byte)151, (byte)230, 17, (byte)182,
|
135, 214, 236, 166, 151, 230, 17, 182,
|
||||||
(byte)166, (byte)247, (byte)236, (byte)198, 22, 7, 17, (byte)214, 38, 23, (byte)236, 39,
|
166, 247, 236, 198, 22, 7, 17, 214, 38, 23, 236, 39,
|
||||||
17,
|
17,
|
||||||
// Error correction bytes.
|
// Error correction bytes.
|
||||||
(byte)175, (byte)155, (byte)245, (byte)236, 80, (byte)146, 56, 74, (byte)155, (byte)165,
|
175, 155, 245, 236, 80, 146, 56, 74, 155, 165,
|
||||||
(byte)133, (byte)142, 64, (byte)183, (byte)132, 13, (byte)178, 54, (byte)132, 108, 45,
|
133, 142, 64, 183, 132, 13, 178, 54, 132, 108, 45,
|
||||||
113, 53, 50, (byte)214, 98, (byte)193, (byte)152, (byte)233, (byte)147, 50, 71, 65,
|
113, 53, 50, 214, 98, 193, 152, 233, 147, 50, 71, 65,
|
||||||
(byte)190, 82, 51, (byte)209, (byte)199, (byte)171, 54, 12, 112, 57, 113, (byte)155, 117,
|
190, 82, 51, 209, 199, 171, 54, 12, 112, 57, 113, 155, 117,
|
||||||
(byte)211, (byte)164, 117, 30, (byte)158, (byte)225, 31, (byte)190, (byte)242, 38,
|
211, 164, 117, 30, 158, 225, 31, 190, 242, 38,
|
||||||
(byte)140, 61, (byte)179, (byte)154, (byte)214, (byte)138, (byte)147, 87, 27, 96, 77, 47,
|
140, 61, 179, 154, 214, 138, 147, 87, 27, 96, 77, 47,
|
||||||
(byte)187, 49, (byte)156, (byte)214,
|
187, 49, 156, 214
|
||||||
};
|
);
|
||||||
assertEquals(expected.length, out.getSizeInBytes());
|
assertEquals(expected.length, out.getSizeInBytes());
|
||||||
outArray = new byte[expected.length];
|
outArray = new byte[expected.length];
|
||||||
out.toBytes(0, outArray, 0, expected.length);
|
out.toBytes(0, outArray, 0, expected.length);
|
||||||
|
@ -520,6 +521,14 @@ public final class EncoderTestCase extends Assert {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static byte[] bytes(int... ints) {
|
||||||
|
byte[] bytes = new byte[ints.length];
|
||||||
|
for (int i = 0; i < ints.length; i++) {
|
||||||
|
bytes[i] = (byte) ints[i];
|
||||||
|
}
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAppendNumericBytes() {
|
public void testAppendNumericBytes() {
|
||||||
// 1 = 01 = 0001 in 4 bits.
|
// 1 = 01 = 0001 in 4 bits.
|
||||||
|
@ -586,9 +595,9 @@ public final class EncoderTestCase extends Assert {
|
||||||
@Test
|
@Test
|
||||||
public void testAppendKanjiBytes() throws WriterException {
|
public void testAppendKanjiBytes() throws WriterException {
|
||||||
BitArray bits = new BitArray();
|
BitArray bits = new BitArray();
|
||||||
Encoder.appendKanjiBytes(shiftJISString(new byte[] {(byte)0x93,0x5f}), bits);
|
Encoder.appendKanjiBytes(shiftJISString(bytes(0x93, 0x5f)), bits);
|
||||||
assertEquals(" .XX.XX.. XXXXX", bits.toString());
|
assertEquals(" .XX.XX.. XXXXX", bits.toString());
|
||||||
Encoder.appendKanjiBytes(shiftJISString(new byte[] {(byte)0xe4,(byte)0xaa}), bits);
|
Encoder.appendKanjiBytes(shiftJISString(bytes(0xe4, 0xaa)), bits);
|
||||||
assertEquals(" .XX.XX.. XXXXXXX. X.X.X.X. X.", bits.toString());
|
assertEquals(" .XX.XX.. XXXXXXX. X.X.X.X. X.", bits.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,7 +605,7 @@ public final class EncoderTestCase extends Assert {
|
||||||
// http://www.swetake.com/qr/qr9.html
|
// http://www.swetake.com/qr/qr9.html
|
||||||
@Test
|
@Test
|
||||||
public void testGenerateECBytes() {
|
public void testGenerateECBytes() {
|
||||||
byte[] dataBytes = {32, 65, (byte)205, 69, 41, (byte)220, 46, (byte)128, (byte)236};
|
byte[] dataBytes = bytes(32, 65, 205, 69, 41, 220, 46, 128, 236);
|
||||||
byte[] ecBytes = Encoder.generateECBytes(dataBytes, 17);
|
byte[] ecBytes = Encoder.generateECBytes(dataBytes, 17);
|
||||||
int[] expected = {
|
int[] expected = {
|
||||||
42, 159, 74, 221, 244, 169, 239, 150, 138, 70, 237, 85, 224, 96, 74, 219, 61
|
42, 159, 74, 221, 244, 169, 239, 150, 138, 70, 237, 85, 224, 96, 74, 219, 61
|
||||||
|
@ -605,8 +614,7 @@ public final class EncoderTestCase extends Assert {
|
||||||
for (int x = 0; x < expected.length; x++) {
|
for (int x = 0; x < expected.length; x++) {
|
||||||
assertEquals(expected[x], ecBytes[x] & 0xFF);
|
assertEquals(expected[x], ecBytes[x] & 0xFF);
|
||||||
}
|
}
|
||||||
dataBytes = new byte[] {67, 70, 22, 38, 54, 70, 86, 102, 118,
|
dataBytes = bytes(67, 70, 22, 38, 54, 70, 86, 102, 118, 134, 150, 166, 182, 198, 214);
|
||||||
(byte)134, (byte)150, (byte)166, (byte)182, (byte)198, (byte)214};
|
|
||||||
ecBytes = Encoder.generateECBytes(dataBytes, 18);
|
ecBytes = Encoder.generateECBytes(dataBytes, 18);
|
||||||
expected = new int[] {
|
expected = new int[] {
|
||||||
175, 80, 155, 64, 178, 45, 214, 233, 65, 209, 12, 155, 117, 31, 140, 214, 27, 187
|
175, 80, 155, 64, 178, 45, 214, 233, 65, 209, 12, 155, 117, 31, 140, 214, 27, 187
|
||||||
|
@ -616,7 +624,7 @@ public final class EncoderTestCase extends Assert {
|
||||||
assertEquals(expected[x], ecBytes[x] & 0xFF);
|
assertEquals(expected[x], ecBytes[x] & 0xFF);
|
||||||
}
|
}
|
||||||
// High-order zero coefficient case.
|
// High-order zero coefficient case.
|
||||||
dataBytes = new byte[] {32, 49, (byte)205, 69, 42, 20, 0, (byte)236, 17};
|
dataBytes = bytes(32, 49, 205, 69, 42, 20, 0, 236, 17);
|
||||||
ecBytes = Encoder.generateECBytes(dataBytes, 17);
|
ecBytes = Encoder.generateECBytes(dataBytes, 17);
|
||||||
expected = new int[] {
|
expected = new int[] {
|
||||||
0, 3, 130, 179, 194, 0, 55, 211, 110, 79, 98, 72, 170, 96, 211, 137, 213
|
0, 3, 130, 179, 194, 0, 55, 211, 110, 79, 98, 72, 170, 96, 211, 137, 213
|
||||||
|
@ -664,7 +672,7 @@ public final class EncoderTestCase extends Assert {
|
||||||
Encoder.encode(builder.toString(), ErrorCorrectionLevel.L);
|
Encoder.encode(builder.toString(), ErrorCorrectionLevel.L);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyGS1EncodedData(QRCode qrCode) {
|
private static void verifyGS1EncodedData(QRCode qrCode) {
|
||||||
String expected =
|
String expected =
|
||||||
"<<\n" +
|
"<<\n" +
|
||||||
" mode: ALPHANUMERIC\n" +
|
" mode: ALPHANUMERIC\n" +
|
||||||
|
@ -701,7 +709,7 @@ public final class EncoderTestCase extends Assert {
|
||||||
assertEquals(expected, qrCode.toString());
|
assertEquals(expected, qrCode.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyNotGS1EncodedData(QRCode qrCode) {
|
private static void verifyNotGS1EncodedData(QRCode qrCode) {
|
||||||
String expected =
|
String expected =
|
||||||
"<<\n" +
|
"<<\n" +
|
||||||
" mode: ALPHANUMERIC\n" +
|
" mode: ALPHANUMERIC\n" +
|
||||||
|
|
|
@ -170,7 +170,7 @@ public final class MaskUtilTestCase extends Assert {
|
||||||
assertEquals(30, MaskUtil.applyMaskPenaltyRule4(matrix));
|
assertEquals(30, MaskUtil.applyMaskPenaltyRule4(matrix));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean TestGetDataMaskBitInternal(int maskPattern, int[][] expected) {
|
private static boolean testGetDataMaskBitInternal(int maskPattern, int[][] expected) {
|
||||||
for (int x = 0; x < 6; ++x) {
|
for (int x = 0; x < 6; ++x) {
|
||||||
for (int y = 0; y < 6; ++y) {
|
for (int y = 0; y < 6; ++y) {
|
||||||
if ((expected[y][x] == 1) != MaskUtil.getDataMaskBit(maskPattern, x, y)) {
|
if ((expected[y][x] == 1) != MaskUtil.getDataMaskBit(maskPattern, x, y)) {
|
||||||
|
@ -192,7 +192,7 @@ public final class MaskUtilTestCase extends Assert {
|
||||||
{1, 0, 1, 0, 1, 0},
|
{1, 0, 1, 0, 1, 0},
|
||||||
{0, 1, 0, 1, 0, 1},
|
{0, 1, 0, 1, 0, 1},
|
||||||
};
|
};
|
||||||
assertTrue(TestGetDataMaskBitInternal(0, mask0));
|
assertTrue(testGetDataMaskBitInternal(0, mask0));
|
||||||
int[][] mask1 = {
|
int[][] mask1 = {
|
||||||
{1, 1, 1, 1, 1, 1},
|
{1, 1, 1, 1, 1, 1},
|
||||||
{0, 0, 0, 0, 0, 0},
|
{0, 0, 0, 0, 0, 0},
|
||||||
|
@ -201,7 +201,7 @@ public final class MaskUtilTestCase extends Assert {
|
||||||
{1, 1, 1, 1, 1, 1},
|
{1, 1, 1, 1, 1, 1},
|
||||||
{0, 0, 0, 0, 0, 0},
|
{0, 0, 0, 0, 0, 0},
|
||||||
};
|
};
|
||||||
assertTrue(TestGetDataMaskBitInternal(1, mask1));
|
assertTrue(testGetDataMaskBitInternal(1, mask1));
|
||||||
int[][] mask2 = {
|
int[][] mask2 = {
|
||||||
{1, 0, 0, 1, 0, 0},
|
{1, 0, 0, 1, 0, 0},
|
||||||
{1, 0, 0, 1, 0, 0},
|
{1, 0, 0, 1, 0, 0},
|
||||||
|
@ -210,7 +210,7 @@ public final class MaskUtilTestCase extends Assert {
|
||||||
{1, 0, 0, 1, 0, 0},
|
{1, 0, 0, 1, 0, 0},
|
||||||
{1, 0, 0, 1, 0, 0},
|
{1, 0, 0, 1, 0, 0},
|
||||||
};
|
};
|
||||||
assertTrue(TestGetDataMaskBitInternal(2, mask2));
|
assertTrue(testGetDataMaskBitInternal(2, mask2));
|
||||||
int[][] mask3 = {
|
int[][] mask3 = {
|
||||||
{1, 0, 0, 1, 0, 0},
|
{1, 0, 0, 1, 0, 0},
|
||||||
{0, 0, 1, 0, 0, 1},
|
{0, 0, 1, 0, 0, 1},
|
||||||
|
@ -219,7 +219,7 @@ public final class MaskUtilTestCase extends Assert {
|
||||||
{0, 0, 1, 0, 0, 1},
|
{0, 0, 1, 0, 0, 1},
|
||||||
{0, 1, 0, 0, 1, 0},
|
{0, 1, 0, 0, 1, 0},
|
||||||
};
|
};
|
||||||
assertTrue(TestGetDataMaskBitInternal(3, mask3));
|
assertTrue(testGetDataMaskBitInternal(3, mask3));
|
||||||
int[][] mask4 = {
|
int[][] mask4 = {
|
||||||
{1, 1, 1, 0, 0, 0},
|
{1, 1, 1, 0, 0, 0},
|
||||||
{1, 1, 1, 0, 0, 0},
|
{1, 1, 1, 0, 0, 0},
|
||||||
|
@ -228,7 +228,7 @@ public final class MaskUtilTestCase extends Assert {
|
||||||
{1, 1, 1, 0, 0, 0},
|
{1, 1, 1, 0, 0, 0},
|
||||||
{1, 1, 1, 0, 0, 0},
|
{1, 1, 1, 0, 0, 0},
|
||||||
};
|
};
|
||||||
assertTrue(TestGetDataMaskBitInternal(4, mask4));
|
assertTrue(testGetDataMaskBitInternal(4, mask4));
|
||||||
int[][] mask5 = {
|
int[][] mask5 = {
|
||||||
{1, 1, 1, 1, 1, 1},
|
{1, 1, 1, 1, 1, 1},
|
||||||
{1, 0, 0, 0, 0, 0},
|
{1, 0, 0, 0, 0, 0},
|
||||||
|
@ -237,7 +237,7 @@ public final class MaskUtilTestCase extends Assert {
|
||||||
{1, 0, 0, 1, 0, 0},
|
{1, 0, 0, 1, 0, 0},
|
||||||
{1, 0, 0, 0, 0, 0},
|
{1, 0, 0, 0, 0, 0},
|
||||||
};
|
};
|
||||||
assertTrue(TestGetDataMaskBitInternal(5, mask5));
|
assertTrue(testGetDataMaskBitInternal(5, mask5));
|
||||||
int[][] mask6 = {
|
int[][] mask6 = {
|
||||||
{1, 1, 1, 1, 1, 1},
|
{1, 1, 1, 1, 1, 1},
|
||||||
{1, 1, 1, 0, 0, 0},
|
{1, 1, 1, 0, 0, 0},
|
||||||
|
@ -246,7 +246,7 @@ public final class MaskUtilTestCase extends Assert {
|
||||||
{1, 0, 1, 1, 0, 1},
|
{1, 0, 1, 1, 0, 1},
|
||||||
{1, 0, 0, 0, 1, 1},
|
{1, 0, 0, 0, 1, 1},
|
||||||
};
|
};
|
||||||
assertTrue(TestGetDataMaskBitInternal(6, mask6));
|
assertTrue(testGetDataMaskBitInternal(6, mask6));
|
||||||
int[][] mask7 = {
|
int[][] mask7 = {
|
||||||
{1, 0, 1, 0, 1, 0},
|
{1, 0, 1, 0, 1, 0},
|
||||||
{0, 0, 0, 1, 1, 1},
|
{0, 0, 0, 1, 1, 1},
|
||||||
|
@ -255,6 +255,6 @@ public final class MaskUtilTestCase extends Assert {
|
||||||
{1, 1, 1, 0, 0, 0},
|
{1, 1, 1, 0, 0, 0},
|
||||||
{0, 1, 1, 1, 0, 0},
|
{0, 1, 1, 1, 0, 0},
|
||||||
};
|
};
|
||||||
assertTrue(TestGetDataMaskBitInternal(7, mask7));
|
assertTrue(testGetDataMaskBitInternal(7, mask7));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,8 +84,7 @@ final class DecoderConfig {
|
||||||
Map<DecodeHintType,?> buildHints() {
|
Map<DecodeHintType,?> buildHints() {
|
||||||
List<BarcodeFormat> finalPossibleFormats = possibleFormats;
|
List<BarcodeFormat> finalPossibleFormats = possibleFormats;
|
||||||
if (finalPossibleFormats == null || finalPossibleFormats.isEmpty()) {
|
if (finalPossibleFormats == null || finalPossibleFormats.isEmpty()) {
|
||||||
finalPossibleFormats = new ArrayList<>();
|
finalPossibleFormats = new ArrayList<>(Arrays.asList(
|
||||||
finalPossibleFormats.addAll(Arrays.asList(
|
|
||||||
BarcodeFormat.UPC_A,
|
BarcodeFormat.UPC_A,
|
||||||
BarcodeFormat.UPC_E,
|
BarcodeFormat.UPC_E,
|
||||||
BarcodeFormat.EAN_13,
|
BarcodeFormat.EAN_13,
|
||||||
|
|
|
@ -21,6 +21,9 @@ import org.junit.Test;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link Base64Decoder}.
|
||||||
|
*/
|
||||||
public final class Base64DecoderTestCase extends Assert {
|
public final class Base64DecoderTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -22,6 +22,9 @@ import org.junit.Test;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link ImageReader}.
|
||||||
|
*/
|
||||||
public final class ImageReaderTestCase extends Assert {
|
public final class ImageReaderTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -26,6 +26,9 @@ import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link MatrixToImageWriter}.
|
||||||
|
*/
|
||||||
public final class MatrixToImageWriterTestCase extends Assert {
|
public final class MatrixToImageWriterTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
5
pom.xml
5
pom.xml
|
@ -82,7 +82,7 @@
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.7</java.version>
|
<java.version>1.7</java.version>
|
||||||
<proguard.version>6.0.2</proguard.version>
|
<proguard.version>6.0.3</proguard.version>
|
||||||
<proguard.plugin.version>2.0.14</proguard.plugin.version>
|
<proguard.plugin.version>2.0.14</proguard.plugin.version>
|
||||||
<slf4j.version>1.7.25</slf4j.version>
|
<slf4j.version>1.7.25</slf4j.version>
|
||||||
<!-- This can't reference project.version as some subprojects version differently -->
|
<!-- This can't reference project.version as some subprojects version differently -->
|
||||||
|
@ -451,6 +451,7 @@
|
||||||
<configLocation>src/checkstyle/checkstyle.xml</configLocation>
|
<configLocation>src/checkstyle/checkstyle.xml</configLocation>
|
||||||
<!-- Android generated files -->
|
<!-- Android generated files -->
|
||||||
<excludes>**/R.java,**/BuildConfig.java,**/Manifest.java</excludes>
|
<excludes>**/R.java,**/BuildConfig.java,**/Manifest.java</excludes>
|
||||||
|
<includeTestSourceDirectory>true</includeTestSourceDirectory>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
@ -465,7 +466,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.puppycrawl.tools</groupId>
|
<groupId>com.puppycrawl.tools</groupId>
|
||||||
<artifactId>checkstyle</artifactId>
|
<artifactId>checkstyle</artifactId>
|
||||||
<version>8.9</version>
|
<version>8.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -33,7 +33,7 @@ import java.io.IOException;
|
||||||
abstract class AbstractFilter implements Filter {
|
abstract class AbstractFilter implements Filter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(FilterConfig filterConfig) throws ServletException {
|
public final void init(FilterConfig filterConfig) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,8 +41,9 @@ abstract class AbstractFilter implements Filter {
|
||||||
public abstract void doFilter(ServletRequest request,
|
public abstract void doFilter(ServletRequest request,
|
||||||
ServletResponse response,
|
ServletResponse response,
|
||||||
FilterChain chain) throws IOException, ServletException;
|
FilterChain chain) throws IOException, ServletException;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public final void destroy() {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ public final class OutputUtils {
|
||||||
|
|
||||||
private static char hexChar(int value) {
|
private static char hexChar(int value) {
|
||||||
if (value < 0 || value > 15) {
|
if (value < 0 || value > 15) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException("Bad hex digit value " + value);
|
||||||
}
|
}
|
||||||
return (char) (value < 10 ? ('0' + value) : ('a' + (value - 10)));
|
return (char) (value < 10 ? ('0' + value) : ('a' + (value - 10)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,9 @@
|
||||||
package com.google.zxing.web;
|
package com.google.zxing.web;
|
||||||
|
|
||||||
import javax.servlet.FilterChain;
|
import javax.servlet.FilterChain;
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.ServletRequest;
|
import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletResponse;
|
import javax.servlet.ServletResponse;
|
||||||
import javax.servlet.annotation.WebFilter;
|
import javax.servlet.annotation.WebFilter;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles redirects to the app landing page.
|
* Handles redirects to the app landing page.
|
||||||
|
@ -32,7 +30,7 @@ public final class WelcomeFilter extends AbstractFilter {
|
||||||
@Override
|
@Override
|
||||||
public void doFilter(ServletRequest servletRequest,
|
public void doFilter(ServletRequest servletRequest,
|
||||||
ServletResponse servletResponse,
|
ServletResponse servletResponse,
|
||||||
FilterChain filterChain) throws IOException, ServletException {
|
FilterChain filterChain) {
|
||||||
redirect(servletResponse, "/w/decode.jspx");
|
redirect(servletResponse, "/w/decode.jspx");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,14 @@ package com.google.zxing.web;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests {@link OutputUtils}.
|
||||||
|
*/
|
||||||
public final class OutputUtilsTestCase extends Assert {
|
public final class OutputUtilsTestCase extends Assert {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOutput() {
|
public void testOutput() {
|
||||||
byte[] array = new byte[] { 0, 1, -1, 127, -128, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
|
byte[] array = { 0, 1, -1, 127, -128, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"00 01 ff 7f 80 02 03 04 05 06 07 08 09 0a 0b 0c\n",
|
"00 01 ff 7f 80 02 03 04 05 06 07 08 09 0a 0b 0c\n",
|
||||||
OutputUtils.arrayToString(array));
|
OutputUtils.arrayToString(array));
|
||||||
|
|
Loading…
Reference in a new issue