use of com.google.zxing.common.BitArray in project zxing by zxing.
the class BitVectorTestCase method testNumBytes.
@Test
public void testNumBytes() {
BitArray v = new BitArray();
assertEquals(0, v.getSizeInBytes());
v.appendBit(false);
// 1 bit was added in the vector, so 1 byte should be consumed.
assertEquals(1, v.getSizeInBytes());
v.appendBits(0, 7);
assertEquals(1, v.getSizeInBytes());
v.appendBits(0, 8);
assertEquals(2, v.getSizeInBytes());
v.appendBits(0, 1);
// We now have 17 bits, so 3 bytes should be consumed.
assertEquals(3, v.getSizeInBytes());
}
use of com.google.zxing.common.BitArray in project zxing by zxing.
the class BitVectorTestCase method testXOR2.
@Test
public void testXOR2() {
BitArray v1 = new BitArray();
// 010 1010
v1.appendBits(0x2a, 7);
BitArray v2 = new BitArray();
// 101 0101
v2.appendBits(0x55, 7);
v1.xor(v2);
// 1111 1110
assertEquals(0xfe000000L, getUnsignedInt(v1, 0));
}
use of com.google.zxing.common.BitArray in project zxing by zxing.
the class BitVectorTestCase method testAppendBitVector.
@Test
public void testAppendBitVector() {
BitArray v1 = new BitArray();
v1.appendBits(0xbe, 8);
BitArray v2 = new BitArray();
v2.appendBits(0xef, 8);
v1.appendBitArray(v2);
// beef = 1011 1110 1110 1111
assertEquals(" X.XXXXX. XXX.XXXX", v1.toString());
}
use of com.google.zxing.common.BitArray in project zxing by zxing.
the class EncoderTestCase method testAppendNumericBytes.
@Test
public void testAppendNumericBytes() {
// 1 = 01 = 0001 in 4 bits.
BitArray bits = new BitArray();
Encoder.appendNumericBytes("1", bits);
assertEquals(" ...X", bits.toString());
// 12 = 0xc = 0001100 in 7 bits.
bits = new BitArray();
Encoder.appendNumericBytes("12", bits);
assertEquals(" ...XX..", bits.toString());
// 123 = 0x7b = 0001111011 in 10 bits.
bits = new BitArray();
Encoder.appendNumericBytes("123", bits);
assertEquals(" ...XXXX. XX", bits.toString());
// 1234 = "123" + "4" = 0001111011 + 0100
bits = new BitArray();
Encoder.appendNumericBytes("1234", bits);
assertEquals(" ...XXXX. XX.X..", bits.toString());
// Empty.
bits = new BitArray();
Encoder.appendNumericBytes("", bits);
assertEquals("", bits.toString());
}
use of com.google.zxing.common.BitArray in project zxing by zxing.
the class EncoderTestCase method testAppendModeInfo.
@Test
public void testAppendModeInfo() {
BitArray bits = new BitArray();
Encoder.appendModeInfo(Mode.NUMERIC, bits);
assertEquals(" ...X", bits.toString());
}
Aggregations