use of com.google.zxing.common.BitArray in project zxing by zxing.
the class MatrixUtilTestCase method testMakeTypeInfoInfoBits.
// We don't test a lot of cases in this function since we've already
// tested them in TEST(calculateBCHCode).
@Test
public void testMakeTypeInfoInfoBits() throws WriterException {
// From Appendix C in JISX0510:2004 (p 65)
BitArray bits = new BitArray();
MatrixUtil.makeTypeInfoBits(ErrorCorrectionLevel.M, 5, bits);
assertEquals(" X......X X..XXX.", bits.toString());
}
use of com.google.zxing.common.BitArray in project zxing by zxing.
the class Code128WriterTestCase method testRoundtrip.
@Test
public void testRoundtrip() throws Exception {
String toEncode = "ñ" + "10958" + "ñ" + "17160526";
String expected = "1095817160526";
BitMatrix encResult = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0);
BitArray row = encResult.getRow(0, null);
Result rtResult = reader.decodeRow(0, row, null);
String actual = rtResult.getText();
assertEquals(expected, actual);
}
use of com.google.zxing.common.BitArray in project zxing by zxing.
the class BitVectorTestCase method testXOR.
@Test
public void testXOR() {
BitArray v1 = new BitArray();
v1.appendBits(0x5555aaaa, 32);
BitArray v2 = new BitArray();
v2.appendBits(0xaaaa5555, 32);
v1.xor(v2);
assertEquals(0xffffffffL, getUnsignedInt(v1, 0));
}
use of com.google.zxing.common.BitArray in project zxing by zxing.
the class BitVectorTestCase method testAppendBit.
@Test
public void testAppendBit() {
BitArray v = new BitArray();
assertEquals(0, v.getSizeInBytes());
// 1
v.appendBit(true);
assertEquals(1, v.getSize());
assertEquals(0x80000000L, getUnsignedInt(v, 0));
// 10
v.appendBit(false);
assertEquals(2, v.getSize());
assertEquals(0x80000000L, getUnsignedInt(v, 0));
// 101
v.appendBit(true);
assertEquals(3, v.getSize());
assertEquals(0xa0000000L, getUnsignedInt(v, 0));
// 1010
v.appendBit(false);
assertEquals(4, v.getSize());
assertEquals(0xa0000000L, getUnsignedInt(v, 0));
// 10101
v.appendBit(true);
assertEquals(5, v.getSize());
assertEquals(0xa8000000L, getUnsignedInt(v, 0));
// 101010
v.appendBit(false);
assertEquals(6, v.getSize());
assertEquals(0xa8000000L, getUnsignedInt(v, 0));
// 1010101
v.appendBit(true);
assertEquals(7, v.getSize());
assertEquals(0xaa000000L, getUnsignedInt(v, 0));
// 10101010
v.appendBit(false);
assertEquals(8, v.getSize());
assertEquals(0xaa000000L, getUnsignedInt(v, 0));
// 10101010 1
v.appendBit(true);
assertEquals(9, v.getSize());
assertEquals(0xaa800000L, getUnsignedInt(v, 0));
// 10101010 10
v.appendBit(false);
assertEquals(10, v.getSize());
assertEquals(0xaa800000L, getUnsignedInt(v, 0));
}
use of com.google.zxing.common.BitArray in project zxing by zxing.
the class ExpandedInformationDecoderTest method testNoAi.
@Test
public void testNoAi() throws Exception {
BitArray information = BinaryUtil.buildBitArrayFromString(" .......X ..XX..X. X.X....X .......X ....");
AbstractExpandedDecoder decoder = AbstractExpandedDecoder.createDecoder(information);
String decoded = decoder.parseInformation();
assertEquals("(10)12A", decoded);
}
Aggregations