Enforce line length and indent in checkstyle (#1448)

This commit is contained in:
Sean Owen 2021-10-05 15:49:47 -05:00 committed by GitHub
parent fc50fca12f
commit b51346c072
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
72 changed files with 1011 additions and 901 deletions

View file

@ -288,8 +288,8 @@ public class IntentIntegrator {
} }
/** /**
* Initiates a scan, using the specified camera, only for a certain set of barcode types, given as strings corresponding * Initiates a scan, using the specified camera, only for a certain set of barcode types, given as strings
* to their names in ZXing's {@code BarcodeFormat} class like "UPC_A". You can supply constants * corresponding to their names in ZXing's {@code BarcodeFormat} class like "UPC_A". You can supply constants
* like {@link #PRODUCT_CODE_TYPES} for example. * like {@link #PRODUCT_CODE_TYPES} for example.
* *
* @param desiredBarcodeFormats names of {@code BarcodeFormat}s to scan for * @param desiredBarcodeFormats names of {@code BarcodeFormat}s to scan for

View file

@ -174,7 +174,8 @@ public abstract class ResultHandler {
} }
final void addPhoneOnlyContact(String[] phoneNumbers,String[] phoneTypes) { final void addPhoneOnlyContact(String[] phoneNumbers,String[] phoneTypes) {
addContact(null, null, null, phoneNumbers, phoneTypes, null, null, null, null, null, null, null, null, null, null, null); addContact(null, null, null, phoneNumbers, phoneTypes,
null, null, null, null, null, null, null, null, null, null, null);
} }
final void addEmailOnlyContact(String[] emails, String[] emailTypes) { final void addEmailOnlyContact(String[] emails, String[] emailTypes) {

View file

@ -61,7 +61,8 @@ public final class WifiResultHandler extends ResultHandler {
public void handleButtonPress(int index) { public void handleButtonPress(int index) {
if (index == 0) { if (index == 0) {
WifiParsedResult wifiResult = (WifiParsedResult) getResult(); WifiParsedResult wifiResult = (WifiParsedResult) getResult();
WifiManager wifiManager = (WifiManager) getActivity().getApplicationContext().getSystemService(Context.WIFI_SERVICE); WifiManager wifiManager =
(WifiManager) getActivity().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (wifiManager == null) { if (wifiManager == null) {
Log.w(TAG, "No WifiManager available from device"); Log.w(TAG, "No WifiManager available from device");
return; return;

View file

@ -117,7 +117,8 @@ public enum EncodeHintType {
GS1_FORMAT, GS1_FORMAT,
/** /**
* Forces which encoding will be used. Currently only used for Code-128 code sets (Type {@link String}). Valid values are "A", "B", "C". * Forces which encoding will be used. Currently only used for Code-128 code sets (Type {@link String}).
* Valid values are "A", "B", "C".
*/ */
FORCE_CODE_SET, FORCE_CODE_SET,
} }

View file

@ -96,7 +96,8 @@ public enum ResultMetadataType {
/** /**
* Barcode Symbology Identifier. * Barcode Symbology Identifier.
* Note: According to the GS1 specification the identifier may have to replace a leading FNC1/GS character when prepending to the barcode content. * Note: According to the GS1 specification the identifier may have to replace a leading FNC1/GS character
* when prepending to the barcode content.
*/ */
SYMBOLOGY_IDENTIFIER, SYMBOLOGY_IDENTIFIER,
} }

View file

@ -84,7 +84,8 @@ public final class Decoder {
CorrectedBitsResult correctedBits = correctBits(rawbits); CorrectedBitsResult correctedBits = correctBits(rawbits);
byte[] rawBytes = convertBoolArrayToByteArray(correctedBits.correctBits); byte[] rawBytes = convertBoolArrayToByteArray(correctedBits.correctBits);
String result = getEncodedData(correctedBits.correctBits); String result = getEncodedData(correctedBits.correctBits);
DecoderResult decoderResult = new DecoderResult(rawBytes, result, null, String.format("%d%%", correctedBits.ecLevel)); DecoderResult decoderResult =
new DecoderResult(rawBytes, result, null, String.format("%d%%", correctedBits.ecLevel));
decoderResult.setNumBits(correctedBits.correctBits.length); decoderResult.setNumBits(correctedBits.correctBits.length);
return decoderResult; return decoderResult;
} }

View file

@ -40,7 +40,14 @@ public final class WifiParsedResult extends ParsedResult {
this(networkEncryption, ssid, password, hidden, null, null, null, null); this(networkEncryption, ssid, password, hidden, null, null, null, null);
} }
public WifiParsedResult(String networkEncryption, String ssid, String password, boolean hidden, String identity, String anonymousIdentity, String eapMethod, String phase2Method) { public WifiParsedResult(String networkEncryption,
String ssid,
String password,
boolean hidden,
String identity,
String anonymousIdentity,
String eapMethod,
String phase2Method) {
super(ParsedResultType.WIFI); super(ParsedResultType.WIFI);
this.ssid = ssid; this.ssid = ssid;
this.networkEncryption = networkEncryption; this.networkEncryption = networkEncryption;

View file

@ -18,6 +18,7 @@ package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.Result;
@SuppressWarnings("checkstyle:lineLength")
/** /**
* <p>Parses a WIFI configuration string. Strings will be of the form:</p> * <p>Parses a WIFI configuration string. Strings will be of the form:</p>
* *

View file

@ -89,7 +89,8 @@ public final class DataMatrixWriter implements Writer {
String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo); String codewords = ErrorCorrection.encodeECC200(encoded, symbolInfo);
//3. step: Module placement in Matrix //3. step: Module placement in Matrix
DefaultPlacement placement = new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight()); DefaultPlacement placement =
new DefaultPlacement(codewords, symbolInfo.getSymbolDataWidth(), symbolInfo.getSymbolDataHeight());
placement.place(); placement.place();
//4. step: low-level encoding //4. step: low-level encoding

View file

@ -91,7 +91,8 @@ final class DecodedBitStreamParser {
StringBuilder resultTrailer = new StringBuilder(0); StringBuilder resultTrailer = new StringBuilder(0);
List<byte[]> byteSegments = new ArrayList<>(1); List<byte[]> byteSegments = new ArrayList<>(1);
Mode mode = Mode.ASCII_ENCODE; Mode mode = Mode.ASCII_ENCODE;
Set<Integer> fnc1Positions = new HashSet<>(); // Would be replaceable by looking directly at 'bytes', if we're sure to not having to account for multi byte values. // Could look directly at 'bytes', if we're sure of not having to account for multi byte values
Set<Integer> fnc1Positions = new HashSet<>();
int symbologyModifier; int symbologyModifier;
boolean isECIencoded = false; boolean isECIencoded = false;
do { do {
@ -146,7 +147,11 @@ final class DecodedBitStreamParser {
} }
} }
return new DecoderResult(bytes, result.toString(), byteSegments.isEmpty() ? null : byteSegments, null, symbologyModifier); return new DecoderResult(bytes,
result.toString(),
byteSegments.isEmpty() ? null : byteSegments,
null,
symbologyModifier);
} }
/** /**
@ -226,7 +231,8 @@ final class DecodedBitStreamParser {
/** /**
* See ISO 16022:2006, 5.2.5 and Annex C, Table C.1 * See ISO 16022:2006, 5.2.5 and Annex C, Table C.1
*/ */
private static void decodeC40Segment(BitSource bits, StringBuilder result, Set<Integer> fnc1positions) throws FormatException { private static void decodeC40Segment(BitSource bits, StringBuilder result, Set<Integer> fnc1positions)
throws FormatException {
// Three C40 values are encoded in a 16-bit value as // Three C40 values are encoded in a 16-bit value as
// (1600 * C1) + (40 * C2) + C3 + 1 // (1600 * C1) + (40 * C2) + C3 + 1
// TODO(bbrown): The Upper Shift with C40 doesn't work in the 4 value scenario all the time // TODO(bbrown): The Upper Shift with C40 doesn't work in the 4 value scenario all the time
@ -317,7 +323,8 @@ final class DecodedBitStreamParser {
/** /**
* See ISO 16022:2006, 5.2.6 and Annex C, Table C.2 * See ISO 16022:2006, 5.2.6 and Annex C, Table C.2
*/ */
private static void decodeTextSegment(BitSource bits, StringBuilder result, Set<Integer> fnc1positions) throws FormatException { private static void decodeTextSegment(BitSource bits, StringBuilder result, Set<Integer> fnc1positions)
throws FormatException {
// Three Text values are encoded in a 16-bit value as // Three Text values are encoded in a 16-bit value as
// (1600 * C1) + (40 * C2) + C3 + 1 // (1600 * C1) + (40 * C2) + C3 + 1
// TODO(bbrown): The Upper Shift with Text doesn't work in the 4 value scenario all the time // TODO(bbrown): The Upper Shift with Text doesn't work in the 4 value scenario all the time

View file

@ -24,6 +24,7 @@ import com.google.zxing.common.BitMatrix;
*/ */
final class BitMatrixParser { final class BitMatrixParser {
@SuppressWarnings("checkstyle:lineLength")
private static final int[][] BITNR = { private static final int[][] BITNR = {
{121,120,127,126,133,132,139,138,145,144,151,150,157,156,163,162,169,168,175,174,181,180,187,186,193,192,199,198, -2, -2}, {121,120,127,126,133,132,139,138,145,144,151,150,157,156,163,162,169,168,175,174,181,180,187,186,193,192,199,198, -2, -2},
{123,122,129,128,135,134,141,140,147,146,153,152,159,158,165,164,171,170,177,176,183,182,189,188,195,194,201,200,816, -3}, {123,122,129,128,135,134,141,140,147,146,153,152,159,158,165,164,171,170,177,176,183,182,189,188,195,194,201,200,816, -3},

View file

@ -46,6 +46,7 @@ final class DecodedBitStreamParser {
private static final char GS = '\u001D'; private static final char GS = '\u001D';
private static final char RS = '\u001E'; private static final char RS = '\u001E';
@SuppressWarnings("checkstyle:lineLength")
private static final String[] SETS = { private static final String[] SETS = {
"\nABCDEFGHIJKLMNOPQRSTUVWXYZ" + ECI + FS + GS + RS + NS + ' ' + PAD + "\nABCDEFGHIJKLMNOPQRSTUVWXYZ" + ECI + FS + GS + RS + NS + ' ' + PAD +
"\"#$%&'()*+,-./0123456789:" + SHIFTB + SHIFTC + SHIFTD + SHIFTE + LATCHB, "\"#$%&'()*+,-./0123456789:" + SHIFTB + SHIFTC + SHIFTD + SHIFTE + LATCHB,

View file

@ -48,8 +48,8 @@ public final class Code39Writer extends OneDimensionalCodeWriter {
contents = tryToConvertToExtendedMode(contents); contents = tryToConvertToExtendedMode(contents);
length = contents.length(); length = contents.length();
if (length > 80) { if (length > 80) {
throw new IllegalArgumentException( throw new IllegalArgumentException("Requested contents should be less than 80 digits long, but got " +
"Requested contents should be less than 80 digits long, but got " + length + " (extended full ASCII mode)"); length + " (extended full ASCII mode)");
} }
break; break;
} }

View file

@ -39,8 +39,8 @@ public class Code93Writer extends OneDimensionalCodeWriter {
contents = convertToExtended(contents); contents = convertToExtended(contents);
int length = contents.length(); int length = contents.length();
if (length > 80) { if (length > 80) {
throw new IllegalArgumentException( throw new IllegalArgumentException("Requested contents should be less than 80 digits long after " +
"Requested contents should be less than 80 digits long after converting to extended encoding, but got " + length); "converting to extended encoding, but got " + length);
} }
//length of code + 2 start/stop characters + 2 checksums, each of 9 bits, plus a termination bar //length of code + 2 start/stop characters + 2 checksums, each of 9 bits, plus a termination bar

View file

@ -101,6 +101,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
private static final int FINDER_PAT_E = 4; private static final int FINDER_PAT_E = 4;
private static final int FINDER_PAT_F = 5; private static final int FINDER_PAT_F = 5;
@SuppressWarnings("checkstyle:lineLength")
private static final int[][] FINDER_PATTERN_SEQUENCES = { private static final int[][] FINDER_PATTERN_SEQUENCES = {
{ FINDER_PAT_A, FINDER_PAT_A }, { FINDER_PAT_A, FINDER_PAT_A },
{ FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B }, { FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B },

View file

@ -273,7 +273,8 @@ final class DecodedBitStreamParser {
// do not include terminator // do not include terminator
optionalFieldsLength--; optionalFieldsLength--;
} }
resultMetadata.setOptionalData(Arrays.copyOfRange(codewords, optionalFieldsStart, optionalFieldsStart + optionalFieldsLength)); resultMetadata.setOptionalData(
Arrays.copyOfRange(codewords, optionalFieldsStart, optionalFieldsStart + optionalFieldsLength));
} }
return codeIndex; return codeIndex;

View file

@ -130,7 +130,9 @@ final class DetectionResult {
} }
int rowIndicatorRowNumber = codewords[codewordsRow].getRowNumber(); int rowIndicatorRowNumber = codewords[codewordsRow].getRowNumber();
int invalidRowCounts = 0; int invalidRowCounts = 0;
for (int barcodeColumn = barcodeColumnCount + 1; barcodeColumn > 0 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP; barcodeColumn--) { for (int barcodeColumn = barcodeColumnCount + 1;
barcodeColumn > 0 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP;
barcodeColumn--) {
Codeword codeword = detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow]; Codeword codeword = detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow];
if (codeword != null) { if (codeword != null) {
invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword); invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword);
@ -155,7 +157,9 @@ final class DetectionResult {
} }
int rowIndicatorRowNumber = codewords[codewordsRow].getRowNumber(); int rowIndicatorRowNumber = codewords[codewordsRow].getRowNumber();
int invalidRowCounts = 0; int invalidRowCounts = 0;
for (int barcodeColumn = 1; barcodeColumn < barcodeColumnCount + 1 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP; barcodeColumn++) { for (int barcodeColumn = 1;
barcodeColumn < barcodeColumnCount + 1 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP;
barcodeColumn++) {
Codeword codeword = detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow]; Codeword codeword = detectionResultColumns[barcodeColumn].getCodewords()[codewordsRow];
if (codeword != null) { if (codeword != null) {
invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword); invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword);

View file

@ -199,8 +199,10 @@ final class DetectionResultRowIndicatorColumn extends DetectionResultColumn {
(barcodeRowCountLowerPart.getValue().length == 0) || (barcodeRowCountLowerPart.getValue().length == 0) ||
(barcodeECLevel.getValue().length == 0) || (barcodeECLevel.getValue().length == 0) ||
barcodeColumnCount.getValue()[0] < 1 || barcodeColumnCount.getValue()[0] < 1 ||
barcodeRowCountUpperPart.getValue()[0] + barcodeRowCountLowerPart.getValue()[0] < PDF417Common.MIN_ROWS_IN_BARCODE || barcodeRowCountUpperPart.getValue()[0] + barcodeRowCountLowerPart.getValue()[0] <
barcodeRowCountUpperPart.getValue()[0] + barcodeRowCountLowerPart.getValue()[0] > PDF417Common.MAX_ROWS_IN_BARCODE) { PDF417Common.MIN_ROWS_IN_BARCODE ||
barcodeRowCountUpperPart.getValue()[0] + barcodeRowCountLowerPart.getValue()[0] >
PDF417Common.MAX_ROWS_IN_BARCODE) {
return null; return null;
} }
BarcodeMetadata barcodeMetadata = new BarcodeMetadata(barcodeColumnCount.getValue()[0], BarcodeMetadata barcodeMetadata = new BarcodeMetadata(barcodeColumnCount.getValue()[0],

View file

@ -55,7 +55,8 @@ public final class PDF417ScanningDecoder {
ResultPoint imageTopRight, ResultPoint imageTopRight,
ResultPoint imageBottomRight, ResultPoint imageBottomRight,
int minCodewordWidth, int minCodewordWidth,
int maxCodewordWidth) throws NotFoundException, FormatException, ChecksumException { int maxCodewordWidth)
throws NotFoundException, FormatException, ChecksumException {
BoundingBox boundingBox = new BoundingBox(image, imageTopLeft, imageBottomLeft, imageTopRight, imageBottomRight); BoundingBox boundingBox = new BoundingBox(image, imageTopLeft, imageBottomLeft, imageTopRight, imageBottomRight);
DetectionResultRowIndicatorColumn leftRowIndicatorColumn = null; DetectionResultRowIndicatorColumn leftRowIndicatorColumn = null;
DetectionResultRowIndicatorColumn rightRowIndicatorColumn = null; DetectionResultRowIndicatorColumn rightRowIndicatorColumn = null;

View file

@ -52,8 +52,9 @@ public final class Detector {
// if we set the value too low, then we don't detect the correct height of the bar if the start patterns are damaged. // if we set the value too low, then we don't detect the correct height of the bar if the start patterns are damaged.
// if we set the value too high, then we might detect the start pattern from a neighbor barcode. // if we set the value too high, then we might detect the start pattern from a neighbor barcode.
private static final int SKIPPED_ROW_COUNT_MAX = 25; private static final int SKIPPED_ROW_COUNT_MAX = 25;
// A PDF471 barcode should have at least 3 rows, with each row being >= 3 times the module width. Therefore it should be at least // A PDF471 barcode should have at least 3 rows, with each row being >= 3 times the module width.
// 9 pixels tall. To be conservative, we use about half the size to ensure we don't miss it. // Therefore it should be at least 9 pixels tall. To be conservative, we use about half the size to
// ensure we don't miss it.
private static final int ROW_STEP = 5; private static final int ROW_STEP = 5;
private static final int BARCODE_MIN_HEIGHT = 10; private static final int BARCODE_MIN_HEIGHT = 10;

View file

@ -136,7 +136,7 @@ public final class EncoderTest extends Assert {
public void testAztecWriter() throws Exception { public void testAztecWriter() throws Exception {
testWriter("Espa\u00F1ol", null, 25, true, 1); // Without ECI (implicit ISO-8859-1) testWriter("Espa\u00F1ol", null, 25, true, 1); // Without ECI (implicit ISO-8859-1)
testWriter("Espa\u00F1ol", ISO_8859_1, 25, true, 1); // Explicit ISO-8859-1 testWriter("Espa\u00F1ol", ISO_8859_1, 25, true, 1); // Explicit ISO-8859-1
testWriter("\u20AC 1 sample data.", WINDOWS_1252, 25, true, 2); // Standard ISO-8859-1 cannot encode Euro symbol; Windows-1252 superset can testWriter("\u20AC 1 sample data.", WINDOWS_1252, 25, true, 2); // ISO-8859-1 can't encode Euro; Windows-1252 can
testWriter("\u20AC 1 sample data.", ISO_8859_15, 25, true, 2); testWriter("\u20AC 1 sample data.", ISO_8859_15, 25, true, 2);
testWriter("\u20AC 1 sample data.", UTF_8, 25, true, 2); testWriter("\u20AC 1 sample data.", UTF_8, 25, true, 2);
testWriter("\u20AC 1 sample data.", UTF_8, 100, true, 3); testWriter("\u20AC 1 sample data.", UTF_8, 100, true, 3);
@ -417,8 +417,7 @@ public final class EncoderTest extends Assert {
// Latch to DIGIT rather than shift to PUNCT // Latch to DIGIT rather than shift to PUNCT
testHighLevelEncodeString("A. 1234", testHighLevelEncodeString("A. 1234",
// 'A' D/L '.' ' ' '1' '2' '3' '4' // 'A' D/L '.' ' ' '1' '2' '3' '4'
"...X. XXXX. XX.X ...X ..XX .X.. .X.X .X X." "...X. XXXX. XX.X ...X ..XX .X.. .X.X .X X.");
);
// Don't bother leaving Binary Shift. // Don't bother leaving Binary Shift.
testHighLevelEncodeString("A\200. \200", testHighLevelEncodeString("A\200. \200",
// 'A' B/S =2 \200 "." " " \200 // 'A' B/S =2 \200 "." " " \200

View file

@ -30,7 +30,8 @@ public final class AddressBookParsedResultTestCase extends Assert {
@Test @Test
public void testAddressBookDocomo() { public void testAddressBookDocomo() {
doTest("MECARD:N:Sean Owen;;", null, new String[] {"Sean Owen"}, null, null, null, null, null, null, null, null, null); doTest("MECARD:N:Sean Owen;;", null, new String[] {"Sean Owen"},
null, null, null, null, null, null, null, null, null);
doTest("MECARD:NOTE:ZXing Team;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;;", doTest("MECARD:NOTE:ZXing Team;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;;",
null, new String[] {"Sean Owen"}, null, null, new String[] {"srowen@example.org"}, null, null, null, null, new String[] {"Sean Owen"}, null, null, new String[] {"srowen@example.org"}, null, null, null,
new String[] {"google.com"}, null, "ZXing Team"); new String[] {"google.com"}, null, "ZXing Team");
@ -45,7 +46,8 @@ public final class AddressBookParsedResultTestCase extends Assert {
@Test @Test
public void testVCard() { public void testVCard() {
doTest("BEGIN:VCARD\r\nADR;HOME:123 Main St\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD", doTest("BEGIN:VCARD\r\nADR;HOME:123 Main St\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD",
null, new String[] {"Sean Owen"}, null, new String[] {"123 Main St"}, null, null, null, null, null, null, null); null, new String[] {"Sean Owen"}, null, new String[] {"123 Main St"},
null, null, null, null, null, null, null);
} }
@Test @Test
@ -69,13 +71,15 @@ public final class AddressBookParsedResultTestCase extends Assert {
@Test @Test
public void testVCardCaseInsensitive() { public void testVCardCaseInsensitive() {
doTest("begin:vcard\r\nadr;HOME:123 Main St\r\nVersion:2.1\r\nn:Owen;Sean\r\nEND:VCARD", doTest("begin:vcard\r\nadr;HOME:123 Main St\r\nVersion:2.1\r\nn:Owen;Sean\r\nEND:VCARD",
null, new String[] {"Sean Owen"}, null, new String[] {"123 Main St"}, null, null, null, null, null, null, null); null, new String[] {"Sean Owen"}, null, new String[] {"123 Main St"},
null, null, null, null, null, null, null);
} }
@Test @Test
public void testEscapedVCard() { public void testEscapedVCard() {
doTest("BEGIN:VCARD\r\nADR;HOME:123\\;\\\\ Main\\, St\\nHome\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD", doTest("BEGIN:VCARD\r\nADR;HOME:123\\;\\\\ Main\\, St\\nHome\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD",
null, new String[] {"Sean Owen"}, null, new String[] {"123;\\ Main, St\nHome"}, null, null, null, null, null, null, null); null, new String[] {"Sean Owen"}, null, new String[] {"123;\\ Main, St\nHome"},
null, null, null, null, null, null, null);
} }
@Test @Test

View file

@ -35,6 +35,7 @@ public final class URIParsedResultTestCase extends Assert {
doTest("MEBKM:URL:google.com;TITLE:Google;", "http://google.com", "Google"); doTest("MEBKM:URL:google.com;TITLE:Google;", "http://google.com", "Google");
} }
@SuppressWarnings("checkstyle:lineLength")
@Test @Test
public void testURI() { public void testURI() {
doTest("google.com", "http://google.com", null); doTest("google.com", "http://google.com", null);

View file

@ -69,7 +69,8 @@ public final class StringUtilsTestCase extends Assert {
// 调压柜 // 调压柜
doTest(new byte[] { (byte) 0xFE, (byte) 0xFF, (byte) 0x8c, (byte) 0x03, (byte) 0x53, (byte) 0x8b, doTest(new byte[] { (byte) 0xFE, (byte) 0xFF, (byte) 0x8c, (byte) 0x03, (byte) 0x53, (byte) 0x8b,
(byte) 0x67, (byte) 0xdc, }, (byte) 0x67, (byte) 0xdc, },
StandardCharsets.UTF_16, StandardCharsets.UTF_16.name()); StandardCharsets.UTF_16,
StandardCharsets.UTF_16.name());
} }
@Test @Test
@ -77,7 +78,8 @@ public final class StringUtilsTestCase extends Assert {
// 调压柜 // 调压柜
doTest(new byte[] { (byte) 0xFF, (byte) 0xFE, (byte) 0x03, (byte) 0x8c, (byte) 0x8b, (byte) 0x53, doTest(new byte[] { (byte) 0xFF, (byte) 0xFE, (byte) 0x03, (byte) 0x8c, (byte) 0x8b, (byte) 0x53,
(byte) 0xdc, (byte) 0x67, }, (byte) 0xdc, (byte) 0x67, },
StandardCharsets.UTF_16, StandardCharsets.UTF_16.name()); StandardCharsets.UTF_16,
StandardCharsets.UTF_16.name());
} }
private static void doTest(byte[] bytes, Charset charset, String encoding) { private static void doTest(byte[] bytes, Charset charset, String encoding) {

View file

@ -36,16 +36,19 @@ public final class ReedSolomonTestCase extends Assert {
// real life test cases // real life test cases
testEncodeDecode(GenericGF.DATA_MATRIX_FIELD_256, testEncodeDecode(GenericGF.DATA_MATRIX_FIELD_256,
new int[] { 142, 164, 186 }, new int[] { 114, 25, 5, 88, 102 }); new int[] { 142, 164, 186 }, new int[] { 114, 25, 5, 88, 102 });
testEncodeDecode(GenericGF.DATA_MATRIX_FIELD_256, new int[] { testEncodeDecode(GenericGF.DATA_MATRIX_FIELD_256,
new int[] {
0x69, 0x75, 0x75, 0x71, 0x3B, 0x30, 0x30, 0x64, 0x69, 0x75, 0x75, 0x71, 0x3B, 0x30, 0x30, 0x64,
0x70, 0x65, 0x66, 0x2F, 0x68, 0x70, 0x70, 0x68, 0x70, 0x65, 0x66, 0x2F, 0x68, 0x70, 0x70, 0x68,
0x6D, 0x66, 0x2F, 0x64, 0x70, 0x6E, 0x30, 0x71, 0x6D, 0x66, 0x2F, 0x64, 0x70, 0x6E, 0x30, 0x71,
0x30, 0x7B, 0x79, 0x6A, 0x6F, 0x68, 0x30, 0x81, 0x30, 0x7B, 0x79, 0x6A, 0x6F, 0x68, 0x30, 0x81,
0xF0, 0x88, 0x1F, 0xB5 }, 0xF0, 0x88, 0x1F, 0xB5
},
new int[] { new int[] {
0x1C, 0x64, 0xEE, 0xEB, 0xD0, 0x1D, 0x00, 0x03, 0x1C, 0x64, 0xEE, 0xEB, 0xD0, 0x1D, 0x00, 0x03,
0xF0, 0x1C, 0xF1, 0xD0, 0x6D, 0x00, 0x98, 0xDA, 0xF0, 0x1C, 0xF1, 0xD0, 0x6D, 0x00, 0x98, 0xDA,
0x80, 0x88, 0xBE, 0xFF, 0xB7, 0xFA, 0xA9, 0x95 }); 0x80, 0x88, 0xBE, 0xFF, 0xB7, 0xFA, 0xA9, 0x95
});
// synthetic test cases // synthetic test cases
testEncodeDecodeRandom(GenericGF.DATA_MATRIX_FIELD_256, 10, 240); testEncodeDecodeRandom(GenericGF.DATA_MATRIX_FIELD_256, 10, 240);
testEncodeDecodeRandom(GenericGF.DATA_MATRIX_FIELD_256, 128, 127); testEncodeDecodeRandom(GenericGF.DATA_MATRIX_FIELD_256, 128, 127);
@ -55,21 +58,27 @@ public final class ReedSolomonTestCase extends Assert {
@Test @Test
public void testQRCode() { public void testQRCode() {
// Test case from example given in ISO 18004, Annex I // Test case from example given in ISO 18004, Annex I
testEncodeDecode(GenericGF.QR_CODE_FIELD_256, new int[] { testEncodeDecode(GenericGF.QR_CODE_FIELD_256,
new int[] {
0x10, 0x20, 0x0C, 0x56, 0x61, 0x80, 0xEC, 0x11, 0x10, 0x20, 0x0C, 0x56, 0x61, 0x80, 0xEC, 0x11,
0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11 }, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11
},
new int[] { new int[] {
0xA5, 0x24, 0xD4, 0xC1, 0xED, 0x36, 0xC7, 0x87, 0xA5, 0x24, 0xD4, 0xC1, 0xED, 0x36, 0xC7, 0x87,
0x2C, 0x55 }); 0x2C, 0x55
testEncodeDecode(GenericGF.QR_CODE_FIELD_256, new int[] { });
testEncodeDecode(GenericGF.QR_CODE_FIELD_256,
new int[] {
0x72, 0x67, 0x2F, 0x77, 0x69, 0x6B, 0x69, 0x2F, 0x72, 0x67, 0x2F, 0x77, 0x69, 0x6B, 0x69, 0x2F,
0x4D, 0x61, 0x69, 0x6E, 0x5F, 0x50, 0x61, 0x67, 0x4D, 0x61, 0x69, 0x6E, 0x5F, 0x50, 0x61, 0x67,
0x65, 0x3B, 0x3B, 0x00, 0xEC, 0x11, 0xEC, 0x11, 0x65, 0x3B, 0x3B, 0x00, 0xEC, 0x11, 0xEC, 0x11,
0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11 }, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11
},
new int[] { new int[] {
0xD8, 0xB8, 0xEF, 0x14, 0xEC, 0xD0, 0xCC, 0x85, 0xD8, 0xB8, 0xEF, 0x14, 0xEC, 0xD0, 0xCC, 0x85,
0x73, 0x40, 0x0B, 0xB5, 0x5A, 0xB8, 0x8B, 0x2E, 0x73, 0x40, 0x0B, 0xB5, 0x5A, 0xB8, 0x8B, 0x2E,
0x08, 0x62 }); 0x08, 0x62
});
// real life test cases // real life test cases
// synthetic test cases // synthetic test cases
testEncodeDecodeRandom(GenericGF.QR_CODE_FIELD_256, 10, 240); testEncodeDecodeRandom(GenericGF.QR_CODE_FIELD_256, 10, 240);
@ -89,8 +98,10 @@ public final class ReedSolomonTestCase extends Assert {
testEncodeDecode(GenericGF.AZTEC_DATA_6, new int[] { testEncodeDecode(GenericGF.AZTEC_DATA_6, new int[] {
0x9, 0x32, 0x1, 0x29, 0x2F, 0x2, 0x27, 0x25, 0x1, 0x1B }, 0x9, 0x32, 0x1, 0x29, 0x2F, 0x2, 0x27, 0x25, 0x1, 0x1B },
new int[] { new int[] {
0x2C, 0x2, 0xD, 0xD, 0xA, 0x16, 0x28, 0x9, 0x22, 0xA, 0x14 }); 0x2C, 0x2, 0xD, 0xD, 0xA, 0x16, 0x28, 0x9, 0x22, 0xA, 0x14
testEncodeDecode(GenericGF.AZTEC_DATA_8, new int[] { });
testEncodeDecode(GenericGF.AZTEC_DATA_8,
new int[] {
0xE0, 0x86, 0x42, 0x98, 0xE8, 0x4A, 0x96, 0xC6, 0xE0, 0x86, 0x42, 0x98, 0xE8, 0x4A, 0x96, 0xC6,
0xB9, 0xF0, 0x8C, 0xA7, 0x4A, 0xDA, 0xF8, 0xCE, 0xB9, 0xF0, 0x8C, 0xA7, 0x4A, 0xDA, 0xF8, 0xCE,
0xB7, 0xDE, 0x88, 0x64, 0x29, 0x8E, 0x84, 0xA9, 0xB7, 0xDE, 0x88, 0x64, 0x29, 0x8E, 0x84, 0xA9,
@ -99,7 +110,8 @@ public final class ReedSolomonTestCase extends Assert {
0x52, 0xD8, 0xD7, 0x3E, 0x11, 0x94, 0xE9, 0x5B, 0x52, 0xD8, 0xD7, 0x3E, 0x11, 0x94, 0xE9, 0x5B,
0x5F, 0x19, 0xD6, 0xFB, 0xD1, 0x0C, 0x85, 0x31, 0x5F, 0x19, 0xD6, 0xFB, 0xD1, 0x0C, 0x85, 0x31,
0xD0, 0x95, 0x2D, 0x8D, 0x73, 0xE1, 0x19, 0x4E, 0xD0, 0x95, 0x2D, 0x8D, 0x73, 0xE1, 0x19, 0x4E,
0x95, 0xB5, 0xF1, 0x9D, 0x6F }, 0x95, 0xB5, 0xF1, 0x9D, 0x6F
},
new int[] { new int[] {
0x31, 0xD7, 0x04, 0x46, 0xB2, 0xC1, 0x06, 0x94, 0x31, 0xD7, 0x04, 0x46, 0xB2, 0xC1, 0x06, 0x94,
0x17, 0xE5, 0x0C, 0x2B, 0xA3, 0x99, 0x15, 0x7F, 0x17, 0xE5, 0x0C, 0x2B, 0xA3, 0x99, 0x15, 0x7F,
@ -107,8 +119,10 @@ public final class ReedSolomonTestCase extends Assert {
0x86, 0xBB, 0x4B, 0x15, 0x4E, 0x4A, 0xDE, 0xD4, 0x86, 0xBB, 0x4B, 0x15, 0x4E, 0x4A, 0xDE, 0xD4,
0xED, 0xA1, 0xF8, 0x47, 0x2A, 0x50, 0xA6, 0xBC, 0xED, 0xA1, 0xF8, 0x47, 0x2A, 0x50, 0xA6, 0xBC,
0x53, 0x7D, 0x29, 0xFE, 0x06, 0x49, 0xF3, 0x73, 0x53, 0x7D, 0x29, 0xFE, 0x06, 0x49, 0xF3, 0x73,
0x9F, 0xC1, 0x75 }); 0x9F, 0xC1, 0x75
testEncodeDecode(GenericGF.AZTEC_DATA_10, new int[] { });
testEncodeDecode(GenericGF.AZTEC_DATA_10,
new int[] {
0x15C, 0x1E1, 0x2D5, 0x02E, 0x048, 0x1E2, 0x037, 0x0CD, 0x15C, 0x1E1, 0x2D5, 0x02E, 0x048, 0x1E2, 0x037, 0x0CD,
0x02E, 0x056, 0x26A, 0x281, 0x1C2, 0x1A6, 0x296, 0x045, 0x02E, 0x056, 0x26A, 0x281, 0x1C2, 0x1A6, 0x296, 0x045,
0x041, 0x0AA, 0x095, 0x2CE, 0x003, 0x38F, 0x2CD, 0x1A2, 0x041, 0x0AA, 0x095, 0x2CE, 0x003, 0x38F, 0x2CD, 0x1A2,
@ -150,7 +164,8 @@ public final class ReedSolomonTestCase extends Assert {
0x0C5, 0x026, 0x295, 0x003, 0x396, 0x2A1, 0x176, 0x295, 0x0C5, 0x026, 0x295, 0x003, 0x396, 0x2A1, 0x176, 0x295,
0x201, 0x0AA, 0x04E, 0x004, 0x1B0, 0x070, 0x275, 0x154, 0x201, 0x0AA, 0x04E, 0x004, 0x1B0, 0x070, 0x275, 0x154,
0x026, 0x2C1, 0x2B3, 0x154, 0x2AA, 0x256, 0x0C1, 0x044, 0x026, 0x2C1, 0x2B3, 0x154, 0x2AA, 0x256, 0x0C1, 0x044,
0x004, 0x23F }, 0x004, 0x23F
},
new int[] { new int[] {
0x379, 0x099, 0x348, 0x010, 0x090, 0x196, 0x09C, 0x1FF, 0x379, 0x099, 0x348, 0x010, 0x090, 0x196, 0x09C, 0x1FF,
0x1B0, 0x32D, 0x244, 0x0DE, 0x201, 0x386, 0x163, 0x11F, 0x1B0, 0x32D, 0x244, 0x0DE, 0x201, 0x386, 0x163, 0x11F,
@ -169,8 +184,10 @@ public final class ReedSolomonTestCase extends Assert {
0x332, 0x318, 0x2E3, 0x24E, 0x3E2, 0x1E1, 0x0BE, 0x239, 0x332, 0x318, 0x2E3, 0x24E, 0x3E2, 0x1E1, 0x0BE, 0x239,
0x306, 0x3A5, 0x352, 0x351, 0x275, 0x0ED, 0x045, 0x229, 0x306, 0x3A5, 0x352, 0x351, 0x275, 0x0ED, 0x045, 0x229,
0x0BF, 0x05D, 0x253, 0x1BE, 0x02E, 0x35A, 0x0E4, 0x2E9, 0x0BF, 0x05D, 0x253, 0x1BE, 0x02E, 0x35A, 0x0E4, 0x2E9,
0x17A, 0x166, 0x03C, 0x007 }); 0x17A, 0x166, 0x03C, 0x007
testEncodeDecode(GenericGF.AZTEC_DATA_12, new int[] { });
testEncodeDecode(GenericGF.AZTEC_DATA_12,
new int[] {
0x571, 0xE1B, 0x542, 0xE12, 0x1E2, 0x0DC, 0xCD0, 0xB85, 0x571, 0xE1B, 0x542, 0xE12, 0x1E2, 0x0DC, 0xCD0, 0xB85,
0x69A, 0xA81, 0x709, 0xA6A, 0x584, 0x510, 0x4AA, 0x256, 0x69A, 0xA81, 0x709, 0xA6A, 0x584, 0x510, 0x4AA, 0x256,
0xCE0, 0x0F8, 0xFB3, 0x5A2, 0x0D9, 0xAD1, 0x389, 0x09C, 0xCE0, 0x0F8, 0xFB3, 0x5A2, 0x0D9, 0xAD1, 0x389, 0x09C,
@ -324,7 +341,8 @@ public final class ReedSolomonTestCase extends Assert {
0xAC2, 0x602, 0x3D5, 0x450, 0x551, 0xA59, 0xC1B, 0xAAE, 0xAC2, 0x602, 0x3D5, 0x450, 0x551, 0xA59, 0xC1B, 0xAAE,
0x69C, 0xC41, 0x34C, 0x550, 0x10C, 0x835, 0x429, 0x33C, 0x69C, 0xC41, 0x34C, 0x550, 0x10C, 0x835, 0x429, 0x33C,
0xB33, 0x4D5, 0x509, 0xCCD, 0x550, 0x35B, 0x4E2, 0xAA0, 0xB33, 0x4D5, 0x509, 0xCCD, 0x550, 0x35B, 0x4E2, 0xAA0,
0x5E6, 0x205, 0xB09, 0x99C, 0x09F }, 0x5E6, 0x205, 0xB09, 0x99C, 0x09F
},
new int[] { new int[] {
0xD54, 0x221, 0x154, 0x7CD, 0xBF3, 0x112, 0x89B, 0xC5E, 0xD54, 0x221, 0x154, 0x7CD, 0xBF3, 0x112, 0x89B, 0xC5E,
0x9CD, 0x07E, 0xFB6, 0x78F, 0x7FA, 0x16F, 0x377, 0x4B4, 0x9CD, 0x07E, 0xFB6, 0x78F, 0x7FA, 0x16F, 0x377, 0x4B4,
@ -380,7 +398,8 @@ public final class ReedSolomonTestCase extends Assert {
0x949, 0xA4C, 0xE36, 0x126, 0xC85, 0xE05, 0xFEE, 0x962, 0x949, 0xA4C, 0xE36, 0x126, 0xC85, 0xE05, 0xFEE, 0x962,
0x36D, 0x08D, 0xC76, 0x1E1, 0x1EC, 0x8D7, 0x231, 0xB68, 0x36D, 0x08D, 0xC76, 0x1E1, 0x1EC, 0x8D7, 0x231, 0xB68,
0x03C, 0x1DE, 0x7DF, 0x2B1, 0x09D, 0xC81, 0xDA4, 0x8F7, 0x03C, 0x1DE, 0x7DF, 0x2B1, 0x09D, 0xC81, 0xDA4, 0x8F7,
0x6B9, 0x947, 0x9B0 }); 0x6B9, 0x947, 0x9B0
});
// synthetic test cases // synthetic test cases
testEncodeDecodeRandom(GenericGF.AZTEC_PARAM, 2, 5); // compact mode message testEncodeDecodeRandom(GenericGF.AZTEC_PARAM, 2, 5); // compact mode message
testEncodeDecodeRandom(GenericGF.AZTEC_PARAM, 4, 6); // full mode message testEncodeDecodeRandom(GenericGF.AZTEC_PARAM, 4, 6); // full mode message

View file

@ -66,7 +66,8 @@ public final class MultiQRCodeTestCase extends Assert {
Collection<String> expectedContents = new HashSet<>(); Collection<String> expectedContents = new HashSet<>();
expectedContents.add("You earned the class a 5 MINUTE DANCE PARTY!! Awesome! Way to go! Let's boogie!"); expectedContents.add("You earned the class a 5 MINUTE DANCE PARTY!! Awesome! Way to go! Let's boogie!");
expectedContents.add("You earned the class 5 EXTRA MINUTES OF RECESS!! Fabulous!! Way to go!!"); expectedContents.add("You earned the class 5 EXTRA MINUTES OF RECESS!! Fabulous!! Way to go!!");
expectedContents.add("You get to SIT AT MRS. SIGMON'S DESK FOR A DAY!! Awesome!! Way to go!! Guess I better clean up! :)"); expectedContents.add(
"You get to SIT AT MRS. SIGMON'S DESK FOR A DAY!! Awesome!! Way to go!! Guess I better clean up! :)");
expectedContents.add("You get to CREATE OUR JOURNAL PROMPT FOR THE DAY! Yay! Way to go! "); expectedContents.add("You get to CREATE OUR JOURNAL PROMPT FOR THE DAY! Yay! Way to go! ");
assertEquals(expectedContents, barcodeContents); assertEquals(expectedContents, barcodeContents);
} }

View file

@ -63,8 +63,9 @@ public class Code128WriterTestCase extends Assert {
@Test @Test
public void testEncodeWithFunc3() throws WriterException { public void testEncodeWithFunc3() throws WriterException {
String toEncode = "\u00f3" + "123"; String toEncode = "\u00f3" + "123";
String expected = QUIET_SPACE + START_CODE_B + FNC3 +
// "1" "2" "3" check digit 51 // "1" "2" "3" check digit 51
String expected = QUIET_SPACE + START_CODE_B + FNC3 + "10011100110" + "11001110010" + "11001011100" + "11101000110" + STOP + QUIET_SPACE; "10011100110" + "11001110010" + "11001011100" + "11101000110" + STOP + QUIET_SPACE;
BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0); BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0);
@ -75,8 +76,9 @@ public class Code128WriterTestCase extends Assert {
@Test @Test
public void testEncodeWithFunc2() throws WriterException { public void testEncodeWithFunc2() throws WriterException {
String toEncode = "\u00f2" + "123"; String toEncode = "\u00f2" + "123";
String expected = QUIET_SPACE + START_CODE_B + FNC2 +
// "1" "2" "3" check digit 56 // "1" "2" "3" check digit 56
String expected = QUIET_SPACE + START_CODE_B + FNC2 + "10011100110" + "11001110010" + "11001011100" + "11100010110" + STOP + QUIET_SPACE; "10011100110" + "11001110010" + "11001011100" + "11100010110" + STOP + QUIET_SPACE;
BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0); BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0);
@ -87,8 +89,9 @@ public class Code128WriterTestCase extends Assert {
@Test @Test
public void testEncodeWithFunc1() throws WriterException { public void testEncodeWithFunc1() throws WriterException {
String toEncode = "\u00f1" + "123"; String toEncode = "\u00f1" + "123";
String expected = QUIET_SPACE + START_CODE_C + FNC1 +
// "12" "3" check digit 92 // "12" "3" check digit 92
String expected = QUIET_SPACE + START_CODE_C + FNC1 + "10110011100" + SWITCH_CODE_B + "11001011100" + "10101111000" + STOP + QUIET_SPACE; "10110011100" + SWITCH_CODE_B + "11001011100" + "10101111000" + STOP + QUIET_SPACE;
BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0); BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0);
@ -111,8 +114,9 @@ public class Code128WriterTestCase extends Assert {
@Test @Test
public void testEncodeWithFunc4() throws WriterException { public void testEncodeWithFunc4() throws WriterException {
String toEncode = "\u00f4" + "123"; String toEncode = "\u00f4" + "123";
String expected = QUIET_SPACE + START_CODE_B + FNC4B +
// "1" "2" "3" check digit 59 // "1" "2" "3" check digit 59
String expected = QUIET_SPACE + START_CODE_B + FNC4B + "10011100110" + "11001110010" + "11001011100" + "11100011010" + STOP + QUIET_SPACE; "10011100110" + "11001110010" + "11001011100" + "11100011010" + STOP + QUIET_SPACE;
BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0); BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0);
@ -124,7 +128,8 @@ public class Code128WriterTestCase extends Assert {
public void testEncodeWithFncsAndNumberInCodesetA() throws Exception { public void testEncodeWithFncsAndNumberInCodesetA() throws Exception {
String toEncode = "\n" + "\u00f1" + "\u00f4" + "1" + "\n"; String toEncode = "\n" + "\u00f1" + "\u00f4" + "1" + "\n";
String expected = QUIET_SPACE + START_CODE_A + LF + FNC1 + FNC4A + "10011100110" + LF + "10101111000" + STOP + QUIET_SPACE; String expected = QUIET_SPACE + START_CODE_A + LF + FNC1 + FNC4A +
"10011100110" + LF + "10101111000" + STOP + QUIET_SPACE;
BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0); BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0);
@ -136,12 +141,18 @@ public class Code128WriterTestCase extends Assert {
@Test @Test
public void testEncodeSwitchBetweenCodesetsAAndB() throws Exception { public void testEncodeSwitchBetweenCodesetsAAndB() throws Exception {
// start with A switch to B and back to A // start with A switch to B and back to A
// "\0" "A" "B" Switch to B "a" "b" Switch to A "\u0010" check digit testEncode("\0ABab\u0010", QUIET_SPACE + START_CODE_A +
testEncode("\0ABab\u0010", QUIET_SPACE + START_CODE_A + "10100001100" + "10100011000" + "10001011000" + SWITCH_CODE_B + "10010110000" + "10010000110" + SWITCH_CODE_A + "10100111100" + "11001110100" + STOP + QUIET_SPACE); // "\0" "A" "B" Switch to B "a" "b"
"10100001100" + "10100011000" + "10001011000" + SWITCH_CODE_B + "10010110000" + "10010000110" +
// Switch to A "\u0010" check digit
SWITCH_CODE_A + "10100111100" + "11001110100" + STOP + QUIET_SPACE);
// start with B switch to A and back to B // start with B switch to A and back to B
// "a" "b" Switch to A "\0 "Switch to B" "a" "b" check digit testEncode("ab\0ab", QUIET_SPACE + START_CODE_B +
testEncode("ab\0ab", QUIET_SPACE + START_CODE_B + "10010110000" + "10010000110" + SWITCH_CODE_A + "10100001100" + SWITCH_CODE_B + "10010110000" + "10010000110" + "11010001110" + STOP + QUIET_SPACE); // "a" "b" Switch to A "\0" Switch to B
"10010110000" + "10010000110" + SWITCH_CODE_A + "10100001100" + SWITCH_CODE_B +
// "a" "b" check digit
"10010110000" + "10010000110" + "11010001110" + STOP + QUIET_SPACE);
} }
private void testEncode(String toEncode, String expected) throws Exception { private void testEncode(String toEncode, String expected) throws Exception {
@ -209,8 +220,10 @@ public class Code128WriterTestCase extends Assert {
@Test @Test
public void testEncodeWithForcedCodeSetFailureCodeSetA() throws Exception { public void testEncodeWithForcedCodeSetFailureCodeSetA() throws Exception {
String toEncode = "AB123"; String toEncode = "AB123";
// would default to B "A" "B" "1" "2" "3" check digit 10 // would default to B "A" "B" "1"
String expected = QUIET_SPACE + START_CODE_A + "10100011000" + "10001011000" + "10011100110" + "11001110010" + "11001011100" + "11001000100" + STOP + QUIET_SPACE; String expected = QUIET_SPACE + START_CODE_A + "10100011000" + "10001011000" + "10011100110" +
// "2" "3" check digit 10
"11001110010" + "11001011100" + "11001000100" + STOP + QUIET_SPACE;
Map<EncodeHintType, Object> hints = new EnumMap<>(EncodeHintType.class); Map<EncodeHintType, Object> hints = new EnumMap<>(EncodeHintType.class);
hints.put(EncodeHintType.FORCE_CODE_SET, "A"); hints.put(EncodeHintType.FORCE_CODE_SET, "A");
@ -223,8 +236,10 @@ public class Code128WriterTestCase extends Assert {
@Test @Test
public void testEncodeWithForcedCodeSetFailureCodeSetB() throws Exception { public void testEncodeWithForcedCodeSetFailureCodeSetB() throws Exception {
String toEncode = "1234"; String toEncode = "1234";
// would default to C "1" "2" "3" "4" check digit 88 // would default to C "1" "2" "3"
String expected = QUIET_SPACE + START_CODE_B + "10011100110" + "11001110010" + "11001011100" + "11001001110" + "11110010010" + STOP + QUIET_SPACE; String expected = QUIET_SPACE + START_CODE_B + "10011100110" + "11001110010" + "11001011100" +
// "4" check digit 88
"11001001110" + "11110010010" + STOP + QUIET_SPACE;
Map<EncodeHintType, Object> hints = new EnumMap<>(EncodeHintType.class); Map<EncodeHintType, Object> hints = new EnumMap<>(EncodeHintType.class);
hints.put(EncodeHintType.FORCE_CODE_SET, "B"); hints.put(EncodeHintType.FORCE_CODE_SET, "B");

View file

@ -31,8 +31,9 @@ import com.google.zxing.Result;
*/ */
public final class Code39ExtendedModeTestCase extends Assert { public final class Code39ExtendedModeTestCase extends Assert {
@SuppressWarnings("checkstyle:lineLength")
@Test @Test
public void testDecodeExtendedMode() throws Exception { public void testDecodeExtendedMode() throws FormatException, ChecksumException, NotFoundException {
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:;<=>?",
@ -43,7 +44,8 @@ public final class Code39ExtendedModeTestCase extends Assert {
"000001001011011010101001001001011001101010101001010010010110101001011010010100100101011010010110100101001001011011010010101001010010010101011001011010010100100101101011001010100101001001010110110010101001010010010101010011011010010100100101101010011010100101001001010110100110101001010010010101011001101010010100100101101010100110100101001001010110101001101001010010010110110101001010010100100101010110100110100101001001011010110100101001010010010101101101001010010100100101010101100110100101001001011010101100101001010010010101101011001010010100100101010110110010100101001001011001010101101001010010010100110101011010010100100101100110101010100101001001010010110101101001010010010110010110101010010100100101001101101010101001001001010110110100101010010010010101010110011010100100100101101010110010101001001001010110101100101010010010010101011011001010010110110100000"); "000001001011011010101001001001011001101010101001010010010110101001011010010100100101011010010110100101001001011011010010101001010010010101011001011010010100100101101011001010100101001001010110110010101001010010010101010011011010010100100101101010011010100101001001010110100110101001010010010101011001101010010100100101101010100110100101001001010110101001101001010010010110110101001010010100100101010110100110100101001001011010110100101001010010010101101101001010010100100101010101100110100101001001011010101100101001010010010101101011001010010100100101010110110010100101001001011001010101101001010010010100110101011010010100100101100110101010100101001001010010110101101001010010010110010110101010010100100101001101101010101001001001010110110100101010010010010101010110011010100100100101101010110010101001001001010110101100101010010010010101011011001010010110110100000");
} }
private static void doTest(String expectedResult, String encodedResult) throws FormatException, ChecksumException, NotFoundException { private static void doTest(String expectedResult, String encodedResult)
throws FormatException, ChecksumException, NotFoundException {
Code39Reader sut = new Code39Reader(false, true); Code39Reader sut = new Code39Reader(false, true);
BitMatrix matrix = BitMatrix.parse(encodedResult, "1", "0"); BitMatrix matrix = BitMatrix.parse(encodedResult, "1", "0");
BitArray row = new BitArray(matrix.getWidth()); BitArray row = new BitArray(matrix.getWidth());

View file

@ -27,6 +27,7 @@ import org.junit.Test;
*/ */
public final class Code39WriterTestCase extends Assert { public final class Code39WriterTestCase extends Assert {
@SuppressWarnings("checkstyle:lineLength")
@Test @Test
public void testEncode() { public void testEncode() {
doTest("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", doTest("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",

View file

@ -31,13 +31,15 @@ import com.google.zxing.Result;
*/ */
public final class Code93ReaderTestCase extends Assert { public final class Code93ReaderTestCase extends Assert {
@SuppressWarnings("checkstyle:lineLength")
@Test @Test
public void testDecode() throws Exception { public void testDecode() throws FormatException, ChecksumException, NotFoundException {
doTest("Code93!\n$%/+ :\u001b;[{\u007f\u0000@`\u007f\u007f\u007f", doTest("Code93!\n$%/+ :\u001b;[{\u007f\u0000@`\u007f\u007f\u007f",
"0000001010111101101000101001100101001011001001100101100101001001100101100100101000010101010000101110101101101010001001001101001101001110010101101011101011011101011101101110100101110101101001110101110110101101010001110110101100010101110110101000110101110110101000101101110110101101001101110110101100101101110110101100110101110110101011011001110110101011001101110110101001101101110110101001110101001100101101010001010111101111"); "0000001010111101101000101001100101001011001001100101100101001001100101100100101000010101010000101110101101101010001001001101001101001110010101101011101011011101011101101110100101110101101001110101110110101101010001110110101100010101110110101000110101110110101000101101110110101101001101110110101100101101110110101100110101110110101011011001110110101011001101110110101001101101110110101001110101001100101101010001010111101111");
} }
private static void doTest(String expectedResult, String encodedResult) throws FormatException, ChecksumException, NotFoundException { private static void doTest(String expectedResult, String encodedResult)
throws FormatException, ChecksumException, NotFoundException {
Code93Reader sut = new Code93Reader(); Code93Reader sut = new Code93Reader();
BitMatrix matrix = BitMatrix.parse(encodedResult, "1", "0"); BitMatrix matrix = BitMatrix.parse(encodedResult, "1", "0");
BitArray row = new BitArray(matrix.getWidth()); BitArray row = new BitArray(matrix.getWidth());

View file

@ -29,14 +29,16 @@ public final class EAN13WriterTestCase extends Assert {
@Test @Test
public void testEncode() { public void testEncode() {
String testStr = "00001010001011010011101100110010011011110100111010101011001101101100100001010111001001110100010010100000"; String testStr =
"00001010001011010011101100110010011011110100111010101011001101101100100001010111001001110100010010100000";
BitMatrix result = new EAN13Writer().encode("5901234123457", BarcodeFormat.EAN_13, testStr.length(), 0); BitMatrix result = new EAN13Writer().encode("5901234123457", BarcodeFormat.EAN_13, testStr.length(), 0);
assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); assertEquals(testStr, BitMatrixTestCase.matrixToString(result));
} }
@Test @Test
public void testAddChecksumAndEncode() { public void testAddChecksumAndEncode() {
String testStr = "00001010001011010011101100110010011011110100111010101011001101101100100001010111001001110100010010100000"; String testStr =
"00001010001011010011101100110010011011110100111010101011001101101100100001010111001001110100010010100000";
BitMatrix result = new EAN13Writer().encode("590123412345", BarcodeFormat.EAN_13, testStr.length(), 0); BitMatrix result = new EAN13Writer().encode("590123412345", BarcodeFormat.EAN_13, testStr.length(), 0);
assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); assertEquals(testStr, BitMatrixTestCase.matrixToString(result));
} }

View file

@ -30,14 +30,16 @@ public final class UPCAWriterTestCase extends Assert {
@Test @Test
public void testEncode() { public void testEncode() {
String testStr = "00001010100011011011101100010001011010111101111010101011100101110100100111011001101101100101110010100000"; String testStr =
"00001010100011011011101100010001011010111101111010101011100101110100100111011001101101100101110010100000";
BitMatrix result = new UPCAWriter().encode("485963095124", BarcodeFormat.UPC_A, testStr.length(), 0); BitMatrix result = new UPCAWriter().encode("485963095124", BarcodeFormat.UPC_A, testStr.length(), 0);
assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); assertEquals(testStr, BitMatrixTestCase.matrixToString(result));
} }
@Test @Test
public void testAddChecksumAndEncode() { public void testAddChecksumAndEncode() {
String testStr = "00001010011001001001101111010100011011000101011110101010001001001000111010011100101100110110110010100000"; String testStr =
"00001010011001001001101111010100011011000101011110101010001001001000111010011100101100110110110010100000";
BitMatrix result = new UPCAWriter().encode("12345678901", BarcodeFormat.UPC_A, testStr.length(), 0); BitMatrix result = new UPCAWriter().encode("12345678901", BarcodeFormat.UPC_A, testStr.length(), 0);
assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); assertEquals(testStr, BitMatrixTestCase.matrixToString(result));
} }

View file

@ -52,8 +52,8 @@ public final class RSSExpandedImage2binaryTestCase extends Assert {
@Test @Test
public void testDecodeRow2binary1() throws Exception { public void testDecodeRow2binary1() throws Exception {
// (11)100224(17)110224(3102)000100 // (11)100224(17)110224(3102)000100
assertCorrectImage2binary( assertCorrectImage2binary("1.png",
"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..."); " ...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
@ -82,18 +82,20 @@ public final class RSSExpandedImage2binaryTestCase extends Assert {
"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.");
} }
@SuppressWarnings("checkstyle:lineLength")
@Test @Test
public void testDecodeRow2binary10() 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",
"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."); " .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.");
} }
@SuppressWarnings("checkstyle:lineLength")
@Test @Test
public void testDecodeRow2binary11() 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",
"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... ...."); " .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

View file

@ -52,7 +52,8 @@ public final class AI013X0X1XDecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01310X111() throws Exception { public void test01310X111() throws Exception {
CharSequence data = header310x11 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateMarch12th2010; 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);
@ -60,7 +61,8 @@ public final class AI013X0X1XDecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01320X111() throws Exception { public void test01320X111() throws Exception {
CharSequence data = header320x11 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateMarch12th2010; 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);
@ -68,7 +70,8 @@ public final class AI013X0X1XDecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01310X131() throws Exception { public void test01310X131() throws Exception {
CharSequence data = header310x13 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateMarch12th2010; 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);
@ -76,7 +79,8 @@ public final class AI013X0X1XDecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01320X131() throws Exception { public void test01320X131() throws Exception {
CharSequence data = header320x13 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateMarch12th2010; 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);
@ -84,7 +88,8 @@ public final class AI013X0X1XDecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01310X151() throws Exception { public void test01310X151() throws Exception {
CharSequence data = header310x15 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateMarch12th2010; 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);
@ -92,7 +97,8 @@ public final class AI013X0X1XDecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01320X151() throws Exception { public void test01320X151() throws Exception {
CharSequence data = header320x15 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateMarch12th2010; 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);
@ -100,7 +106,8 @@ public final class AI013X0X1XDecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01310X171() throws Exception { public void test01310X171() throws Exception {
CharSequence data = header310x17 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateMarch12th2010; 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);
@ -108,7 +115,8 @@ public final class AI013X0X1XDecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01320X171() throws Exception { public void test01320X171() throws Exception {
CharSequence data = header320x17 + compressedGtin900123456798908 + compressed20bitWeight1750 + compressedDateMarch12th2010; 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);

View file

@ -53,7 +53,8 @@ public final class AnyAIDecoderTest extends AbstractDecoderTest {
@Test @Test
public void testAnyAIDecoder3() throws Exception { public void testAnyAIDecoder3() throws Exception {
CharSequence data = header + numeric10 + numeric2alpha + alpha2isoiec646 + i646B + i646C + isoiec6462alpha + alphaA + alpha2numeric + numeric10; 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);

View file

@ -31,6 +31,7 @@ import org.junit.Test;
*/ */
public final class PDF417WriterTestCase extends Assert { public final class PDF417WriterTestCase extends Assert {
@SuppressWarnings("checkstyle:lineLength")
@Test @Test
public void testDataMatrixImageWriter() throws WriterException { public void testDataMatrixImageWriter() throws WriterException {
Map<EncodeHintType,Object> hints = new EnumMap<>(EncodeHintType.class); Map<EncodeHintType,Object> hints = new EnumMap<>(EncodeHintType.class);

View file

@ -96,8 +96,7 @@ public final class EncoderTestCase extends Assert {
@Test @Test
public void testEncode() throws WriterException { public void testEncode() throws WriterException {
QRCode qrCode = Encoder.encode("ABCDEF", ErrorCorrectionLevel.H); QRCode qrCode = Encoder.encode("ABCDEF", ErrorCorrectionLevel.H);
String expected = String expected = "<<\n" +
"<<\n" +
" mode: ALPHANUMERIC\n" + " mode: ALPHANUMERIC\n" +
" ecLevel: H\n" + " ecLevel: H\n" +
" version: 1\n" + " version: 1\n" +
@ -148,8 +147,7 @@ public final class EncoderTestCase extends Assert {
Map<EncodeHintType,Object> hints = new EnumMap<>(EncodeHintType.class); Map<EncodeHintType,Object> hints = new EnumMap<>(EncodeHintType.class);
hints.put(EncodeHintType.CHARACTER_SET, "UTF8"); hints.put(EncodeHintType.CHARACTER_SET, "UTF8");
QRCode qrCode = Encoder.encode("hello", ErrorCorrectionLevel.H, hints); QRCode qrCode = Encoder.encode("hello", ErrorCorrectionLevel.H, hints);
String expected = String expected = "<<\n" +
"<<\n" +
" mode: BYTE\n" + " mode: BYTE\n" +
" ecLevel: H\n" + " ecLevel: H\n" +
" version: 1\n" + " version: 1\n" +
@ -186,8 +184,7 @@ public final class EncoderTestCase extends Assert {
hints.put(EncodeHintType.CHARACTER_SET, "Shift_JIS"); hints.put(EncodeHintType.CHARACTER_SET, "Shift_JIS");
// Nihon in Kanji // Nihon in Kanji
QRCode qrCode = Encoder.encode("\u65e5\u672c", ErrorCorrectionLevel.M, hints); QRCode qrCode = Encoder.encode("\u65e5\u672c", ErrorCorrectionLevel.M, hints);
String expected = String expected = "<<\n" +
"<<\n" +
" mode: KANJI\n" + " mode: KANJI\n" +
" ecLevel: M\n" + " ecLevel: M\n" +
" version: 1\n" + " version: 1\n" +
@ -223,8 +220,7 @@ public final class EncoderTestCase extends Assert {
Map<EncodeHintType,Object> hints = new EnumMap<>(EncodeHintType.class); Map<EncodeHintType,Object> hints = new EnumMap<>(EncodeHintType.class);
hints.put(EncodeHintType.CHARACTER_SET, "Shift_JIS"); hints.put(EncodeHintType.CHARACTER_SET, "Shift_JIS");
QRCode qrCode = Encoder.encode("0123", ErrorCorrectionLevel.M, hints); QRCode qrCode = Encoder.encode("0123", ErrorCorrectionLevel.M, hints);
String expected = String expected = "<<\n" +
"<<\n" +
" mode: NUMERIC\n" + " mode: NUMERIC\n" +
" ecLevel: M\n" + " ecLevel: M\n" +
" version: 1\n" + " version: 1\n" +
@ -293,8 +289,7 @@ public final class EncoderTestCase extends Assert {
hints.put(EncodeHintType.CHARACTER_SET, "UTF8"); hints.put(EncodeHintType.CHARACTER_SET, "UTF8");
hints.put(EncodeHintType.GS1_FORMAT, true); hints.put(EncodeHintType.GS1_FORMAT, true);
QRCode qrCode = Encoder.encode("hello", ErrorCorrectionLevel.H, hints); QRCode qrCode = Encoder.encode("hello", ErrorCorrectionLevel.H, hints);
String expected = String expected = "<<\n" +
"<<\n" +
" mode: BYTE\n" + " mode: BYTE\n" +
" ecLevel: H\n" + " ecLevel: H\n" +
" version: 1\n" + " version: 1\n" +
@ -673,8 +668,7 @@ public final class EncoderTestCase extends Assert {
} }
private static void verifyGS1EncodedData(QRCode qrCode) { private static void verifyGS1EncodedData(QRCode qrCode) {
String expected = String expected = "<<\n" +
"<<\n" +
" mode: ALPHANUMERIC\n" + " mode: ALPHANUMERIC\n" +
" ecLevel: H\n" + " ecLevel: H\n" +
" version: 2\n" + " version: 2\n" +
@ -710,8 +704,7 @@ public final class EncoderTestCase extends Assert {
} }
private static void verifyNotGS1EncodedData(QRCode qrCode) { private static void verifyNotGS1EncodedData(QRCode qrCode) {
String expected = String expected = "<<\n" +
"<<\n" +
" mode: ALPHANUMERIC\n" + " mode: ALPHANUMERIC\n" +
" ecLevel: H\n" + " ecLevel: H\n" +
" version: 1\n" + " version: 1\n" +

View file

@ -206,7 +206,8 @@ public final class StringsResourceTranslator {
URLConnection connection = translateURI.toURL().openConnection(); URLConnection connection = translateURI.toURL().openConnection();
connection.connect(); connection.connect();
StringBuilder translateResult = new StringBuilder(200); StringBuilder translateResult = new StringBuilder(200);
try (BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) { try (BufferedReader in =
new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
char[] buffer = new char[8192]; char[] buffer = new char[8192];
int charsRead; int charsRead;
while ((charsRead = in.read(buffer)) > 0) { while ((charsRead = in.read(buffer)) > 0) {

23
pom.xml
View file

@ -166,7 +166,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.0</version> <version>3.3.1</version>
<configuration> <configuration>
<source>${java.version}</source> <source>${java.version}</source>
<quiet>true</quiet> <quiet>true</quiet>
@ -263,7 +263,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId> <artifactId>maven-scm-plugin</artifactId>
<version>1.11.3</version> <version>1.12.0</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
@ -311,7 +311,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version> <version>3.3.2</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>com.simpligility.maven.plugins</groupId> <groupId>com.simpligility.maven.plugins</groupId>
@ -442,7 +442,7 @@
<dependency> <dependency>
<groupId>com.puppycrawl.tools</groupId> <groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId> <artifactId>checkstyle</artifactId>
<version>8.45.1</version> <version>9.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
@ -690,6 +690,21 @@
</site> </site>
</distributionManagement> </distributionManagement>
<repositories>
<repository>
<id>google-maven-central</id>
<name>GCS Maven Central mirror</name>
<url>https://maven-central.storage-download.googleapis.com/maven2/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>google-maven-central</id>
<name>GCS Maven Central mirror</name>
<url>https://maven-central.storage-download.googleapis.com/maven2/</url>
</pluginRepository>
</pluginRepositories>
<profiles> <profiles>
<profile> <profile>
<id>build-android</id> <id>build-android</id>

View file

@ -104,11 +104,6 @@
<!-- Checks for Size Violations. --> <!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html --> <!-- See http://checkstyle.sf.net/config_sizes.html -->
<!--
<module name="LineLength">
<property name="max" value="120"/>
</module>
-->
<!-- <module name="MethodLength"/> --> <!-- <module name="MethodLength"/> -->
<!-- <module name="ParameterNumber"/> --> <!-- <module name="ParameterNumber"/> -->
@ -185,6 +180,13 @@
<!-- <module name="TodoComment"/> --> <!-- <module name="TodoComment"/> -->
<module name="UpperEll"/> <module name="UpperEll"/>
<module name="Indentation">
<property name="basicOffset" value="2" />
<property name="braceAdjustment" value="0" />
<property name="caseIndent" value="2" />
<property name="arrayInitIndent" value="2"/>
</module>
</module> </module>
<!-- Support @SuppressWarnings (added in Checkstyle 5.7) --> <!-- Support @SuppressWarnings (added in Checkstyle 5.7) -->
@ -195,4 +197,8 @@
<!-- See http://checkstyle.sourceforge.net/config_misc.html#UniqueProperties --> <!-- See http://checkstyle.sourceforge.net/config_misc.html#UniqueProperties -->
<module name="UniqueProperties"/> <module name="UniqueProperties"/>
<module name="LineLength">
<property name="max" value="120"/>
</module>
</module> </module>