"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "core/src/test/java/com/google/zxing/qrcode/encoder/MaskUtilTestCase.java" between
zxing-zxing-3.4.1.tar.gz and zxing-zxing-3.5.0.tar.gz

About: ZXing ("zebra crossing") is a multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages. Info: Project is in maintenance mode (no active development).

MaskUtilTestCase.java  (zxing-zxing-3.4.1):MaskUtilTestCase.java  (zxing-zxing-3.5.0)
skipping to change at line 121 skipping to change at line 121
matrix.set(2, 0, 1); matrix.set(2, 0, 1);
matrix.set(3, 0, 1); matrix.set(3, 0, 1);
matrix.set(4, 0, 1); matrix.set(4, 0, 1);
matrix.set(5, 0, 0); matrix.set(5, 0, 0);
matrix.set(6, 0, 1); matrix.set(6, 0, 1);
matrix.set(7, 0, 0); matrix.set(7, 0, 0);
matrix.set(8, 0, 0); matrix.set(8, 0, 0);
matrix.set(9, 0, 0); matrix.set(9, 0, 0);
matrix.set(10, 0, 0); matrix.set(10, 0, 0);
assertEquals(40, MaskUtil.applyMaskPenaltyRule3(matrix)); assertEquals(40, MaskUtil.applyMaskPenaltyRule3(matrix));
// Horizontal 1011101.
matrix = new ByteMatrix(7, 1);
matrix.set(0, 0, 1);
matrix.set(1, 0, 0);
matrix.set(2, 0, 1);
matrix.set(3, 0, 1);
matrix.set(4, 0, 1);
matrix.set(5, 0, 0);
matrix.set(6, 0, 1);
assertEquals(0, MaskUtil.applyMaskPenaltyRule3(matrix));
// Vertical 00001011101. // Vertical 00001011101.
matrix = new ByteMatrix(1, 11); matrix = new ByteMatrix(1, 11);
matrix.set(0, 0, 0); matrix.set(0, 0, 0);
matrix.set(0, 1, 0); matrix.set(0, 1, 0);
matrix.set(0, 2, 0); matrix.set(0, 2, 0);
matrix.set(0, 3, 0); matrix.set(0, 3, 0);
matrix.set(0, 4, 1); matrix.set(0, 4, 1);
matrix.set(0, 5, 0); matrix.set(0, 5, 0);
matrix.set(0, 6, 1); matrix.set(0, 6, 1);
matrix.set(0, 7, 1); matrix.set(0, 7, 1);
skipping to change at line 148 skipping to change at line 158
matrix.set(0, 1, 0); matrix.set(0, 1, 0);
matrix.set(0, 2, 1); matrix.set(0, 2, 1);
matrix.set(0, 3, 1); matrix.set(0, 3, 1);
matrix.set(0, 4, 1); matrix.set(0, 4, 1);
matrix.set(0, 5, 0); matrix.set(0, 5, 0);
matrix.set(0, 6, 1); matrix.set(0, 6, 1);
matrix.set(0, 7, 0); matrix.set(0, 7, 0);
matrix.set(0, 8, 0); matrix.set(0, 8, 0);
matrix.set(0, 9, 0); matrix.set(0, 9, 0);
matrix.set(0, 10, 0); matrix.set(0, 10, 0);
assertEquals(40, MaskUtil.applyMaskPenaltyRule3(matrix)); // Vertical 1011101.
matrix = new ByteMatrix(1, 7);
matrix.set(0, 0, 1);
matrix.set(0, 1, 0);
matrix.set(0, 2, 1);
matrix.set(0, 3, 1);
matrix.set(0, 4, 1);
matrix.set(0, 5, 0);
matrix.set(0, 6, 1);
assertEquals(0, MaskUtil.applyMaskPenaltyRule3(matrix));
} }
@Test @Test
public void testApplyMaskPenaltyRule4() { public void testApplyMaskPenaltyRule4() {
// Dark cell ratio = 0% // Dark cell ratio = 0%
ByteMatrix matrix = new ByteMatrix(1, 1); ByteMatrix matrix = new ByteMatrix(1, 1);
matrix.set(0, 0, 0); matrix.set(0, 0, 0);
assertEquals(100, MaskUtil.applyMaskPenaltyRule4(matrix)); assertEquals(100, MaskUtil.applyMaskPenaltyRule4(matrix));
// Dark cell ratio = 5% // Dark cell ratio = 5%
matrix = new ByteMatrix(2, 1); matrix = new ByteMatrix(2, 1);
skipping to change at line 188 skipping to change at line 207
} }
} }
} }
return true; return true;
} }
// See mask patterns on the page 43 of JISX0510:2004. // See mask patterns on the page 43 of JISX0510:2004.
@Test @Test
public void testGetDataMaskBit() { public void testGetDataMaskBit() {
int[][] mask0 = { int[][] mask0 = {
{1, 0, 1, 0, 1, 0}, {1, 0, 1, 0, 1, 0},
{0, 1, 0, 1, 0, 1}, {0, 1, 0, 1, 0, 1},
{1, 0, 1, 0, 1, 0}, {1, 0, 1, 0, 1, 0},
{0, 1, 0, 1, 0, 1}, {0, 1, 0, 1, 0, 1},
{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},
{1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1},
{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0},
{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},
{1, 0, 0, 1, 0, 0}, {1, 0, 0, 1, 0, 0},
{1, 0, 0, 1, 0, 0}, {1, 0, 0, 1, 0, 0},
{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},
{0, 1, 0, 0, 1, 0}, {0, 1, 0, 0, 1, 0},
{1, 0, 0, 1, 0, 0}, {1, 0, 0, 1, 0, 0},
{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},
{0, 0, 0, 1, 1, 1}, {0, 0, 0, 1, 1, 1},
{0, 0, 0, 1, 1, 1}, {0, 0, 0, 1, 1, 1},
{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},
{1, 0, 0, 1, 0, 0}, {1, 0, 0, 1, 0, 0},
{1, 0, 1, 0, 1, 0}, {1, 0, 1, 0, 1, 0},
{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},
{1, 1, 0, 1, 1, 0}, {1, 1, 0, 1, 1, 0},
{1, 0, 1, 0, 1, 0}, {1, 0, 1, 0, 1, 0},
{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},
{1, 0, 0, 0, 1, 1}, {1, 0, 0, 0, 1, 1},
{0, 1, 0, 1, 0, 1}, {0, 1, 0, 1, 0, 1},
{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));
} }
} }
 End of changes. 10 change blocks. 
49 lines changed or deleted 68 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)