use of com.google.zxing.common.BitArray in project zxing by zxing.
the class RSSExpandedStackedInternalTestCase method testDecodingRowByRow.
@Test
public void testDecodingRowByRow() throws Exception {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
BinaryBitmap binaryMap = TestCaseUtil.getBinaryBitmap("src/test/resources/blackbox/rssexpandedstacked-2/1000.png");
int firstRowNumber = binaryMap.getHeight() / 3;
BitArray firstRow = binaryMap.getBlackRow(firstRowNumber, null);
try {
rssExpandedReader.decodeRow2pairs(firstRowNumber, firstRow);
fail(NotFoundException.class.getName() + " expected");
} catch (NotFoundException nfe) {
// ok
}
assertEquals(1, rssExpandedReader.getRows().size());
ExpandedRow firstExpandedRow = rssExpandedReader.getRows().get(0);
assertEquals(firstRowNumber, firstExpandedRow.getRowNumber());
assertEquals(2, firstExpandedRow.getPairs().size());
firstExpandedRow.getPairs().get(1).getFinderPattern().getStartEnd()[1] = 0;
int secondRowNumber = 2 * binaryMap.getHeight() / 3;
BitArray secondRow = binaryMap.getBlackRow(secondRowNumber, null);
secondRow.reverse();
List<ExpandedPair> totalPairs = rssExpandedReader.decodeRow2pairs(secondRowNumber, secondRow);
Result result = RSSExpandedReader.constructResult(totalPairs);
assertEquals("(01)98898765432106(3202)012345(15)991231", result.getText());
}
use of com.google.zxing.common.BitArray in project zxing by zxing.
the class BitVectorTestCase method testToString.
@Test
public void testToString() {
BitArray v = new BitArray();
// 1101 1110 1010 1101
v.appendBits(0xdead, 16);
assertEquals(" XX.XXXX. X.X.XX.X", v.toString());
}
use of com.google.zxing.common.BitArray in project zxing by zxing.
the class BitVectorTestCase method testAppendBits.
@Test
public void testAppendBits() {
BitArray v = new BitArray();
v.appendBits(0x1, 1);
assertEquals(1, v.getSize());
assertEquals(0x80000000L, getUnsignedInt(v, 0));
v = new BitArray();
v.appendBits(0xff, 8);
assertEquals(8, v.getSize());
assertEquals(0xff000000L, getUnsignedInt(v, 0));
v = new BitArray();
v.appendBits(0xff7, 12);
assertEquals(12, v.getSize());
assertEquals(0xff700000L, getUnsignedInt(v, 0));
}
use of com.google.zxing.common.BitArray in project zxing by zxing.
the class BitVectorTestCase method testAt.
@Test
public void testAt() {
BitArray v = new BitArray();
// 1101 1110 1010 1101
v.appendBits(0xdead, 16);
assertTrue(v.get(0));
assertTrue(v.get(1));
assertFalse(v.get(2));
assertTrue(v.get(3));
assertTrue(v.get(4));
assertTrue(v.get(5));
assertTrue(v.get(6));
assertFalse(v.get(7));
assertTrue(v.get(8));
assertFalse(v.get(9));
assertTrue(v.get(10));
assertFalse(v.get(11));
assertTrue(v.get(12));
assertTrue(v.get(13));
assertFalse(v.get(14));
assertTrue(v.get(15));
}
use of com.google.zxing.common.BitArray in project zxing by zxing.
the class EncoderTestCase method testAppendKanjiBytes.
// Numbers are from page 21 of JISX0510:2004
@Test
public void testAppendKanjiBytes() throws WriterException {
BitArray bits = new BitArray();
Encoder.appendKanjiBytes(shiftJISString(new byte[] { (byte) 0x93, 0x5f }), bits);
assertEquals(" .XX.XX.. XXXXX", bits.toString());
Encoder.appendKanjiBytes(shiftJISString(new byte[] { (byte) 0xe4, (byte) 0xaa }), bits);
assertEquals(" .XX.XX.. XXXXXXX. X.X.X.X. X.", bits.toString());
}
Aggregations