mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Partial fix for #679: UPC/EAN min quiet zone is 9 modules for encoding
This commit is contained in:
parent
2d02cb05ea
commit
24681e8488
|
@ -28,7 +28,7 @@ public abstract class UPCEANWriter extends OneDimensionalCodeWriter {
|
|||
@Override
|
||||
public int getDefaultMargin() {
|
||||
// Use a different default more appropriate for UPC/EAN
|
||||
return UPCEANReader.START_END_PATTERN.length;
|
||||
return 9;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,14 +30,14 @@ public final class EAN13WriterTestCase extends Assert {
|
|||
|
||||
@Test
|
||||
public void testEncode() throws WriterException {
|
||||
String testStr = "00010100010110100111011001100100110111101001110101010110011011011001000010101110010011101000100101000";
|
||||
String testStr = "00001010001011010011101100110010011011110100111010101011001101101100100001010111001001110100010010100000";
|
||||
BitMatrix result = new EAN13Writer().encode("5901234123457", BarcodeFormat.EAN_13, testStr.length(), 0);
|
||||
assertEquals(testStr, BitMatrixTestCase.matrixToString(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddChecksumAndEncode() throws WriterException {
|
||||
String testStr = "00010100010110100111011001100100110111101001110101010110011011011001000010101110010011101000100101000";
|
||||
String testStr = "00001010001011010011101100110010011011110100111010101011001101101100100001010111001001110100010010100000";
|
||||
BitMatrix result = new EAN13Writer().encode("590123412345", BarcodeFormat.EAN_13, testStr.length(), 0);
|
||||
assertEquals(testStr, BitMatrixTestCase.matrixToString(result));
|
||||
}
|
||||
|
|
|
@ -30,14 +30,14 @@ public final class EAN8WriterTestCase extends Assert {
|
|||
|
||||
@Test
|
||||
public void testEncode() throws WriterException {
|
||||
String testStr = "0001010001011010111101111010110111010101001110111001010001001011100101000";
|
||||
String testStr = "0000001010001011010111101111010110111010101001110111001010001001011100101000000";
|
||||
BitMatrix result = new EAN8Writer().encode("96385074", BarcodeFormat.EAN_8, testStr.length(), 0);
|
||||
assertEquals(testStr, BitMatrixTestCase.matrixToString(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddChecksumAndEncode() throws WriterException {
|
||||
String testStr = "0001010001011010111101111010110111010101001110111001010001001011100101000";
|
||||
String testStr = "0000001010001011010111101111010110111010101001110111001010001001011100101000000";
|
||||
BitMatrix result = new EAN8Writer().encode("9638507", BarcodeFormat.EAN_8, testStr.length(), 0);
|
||||
assertEquals(testStr, BitMatrixTestCase.matrixToString(result));
|
||||
}
|
||||
|
|
|
@ -31,14 +31,14 @@ public final class UPCAWriterTestCase extends Assert {
|
|||
|
||||
@Test
|
||||
public void testEncode() throws WriterException {
|
||||
String testStr = "00010101000110110111011000100010110101111011110101010111001011101001001110110011011011001011100101000";
|
||||
String testStr = "00001010100011011011101100010001011010111101111010101011100101110100100111011001101101100101110010100000";
|
||||
BitMatrix result = new UPCAWriter().encode("485963095124", BarcodeFormat.UPC_A, testStr.length(), 0);
|
||||
assertEquals(testStr, BitMatrixTestCase.matrixToString(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddChecksumAndEncode() throws WriterException {
|
||||
String testStr = "00010100110010010011011110101000110110001010111101010100010010010001110100111001011001101101100101000";
|
||||
String testStr = "00001010011001001001101111010100011011000101011110101010001001001000111010011100101100110110110010100000";
|
||||
BitMatrix result = new UPCAWriter().encode("12345678901", BarcodeFormat.UPC_A, testStr.length(), 0);
|
||||
assertEquals(testStr, BitMatrixTestCase.matrixToString(result));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue