Search in sources :

Example 41 with BitArray

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());
}
Also used : BitArray(com.google.zxing.common.BitArray) Test(org.junit.Test)

Example 42 with BitArray

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));
}
Also used : BitArray(com.google.zxing.common.BitArray) Test(org.junit.Test)

Example 43 with BitArray

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());
}
Also used : BitArray(com.google.zxing.common.BitArray) Test(org.junit.Test)

Example 44 with BitArray

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());
}
Also used : BitArray(com.google.zxing.common.BitArray) Test(org.junit.Test)

Example 45 with BitArray

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());
}
Also used : BitArray(com.google.zxing.common.BitArray) Test(org.junit.Test)

Aggregations

BitArray (com.google.zxing.common.BitArray)68 Test (org.junit.Test)28 BinaryBitmap (com.google.zxing.BinaryBitmap)8 Result (com.google.zxing.Result)8 BufferedImageLuminanceSource (com.google.zxing.BufferedImageLuminanceSource)7 WriterException (com.google.zxing.WriterException)7 GlobalHistogramBinarizer (com.google.zxing.common.GlobalHistogramBinarizer)7 BufferedImage (java.awt.image.BufferedImage)7 ResultPoint (com.google.zxing.ResultPoint)6 NotFoundException (com.google.zxing.NotFoundException)5 ReaderException (com.google.zxing.ReaderException)5 BitMatrix (com.google.zxing.common.BitMatrix)4 FinderPattern (com.google.zxing.oned.rss.FinderPattern)4 ArrayList (java.util.ArrayList)4 AbstractExpandedDecoder (com.google.zxing.oned.rss.expanded.decoders.AbstractExpandedDecoder)3 Path (java.nio.file.Path)3 DecodeHintType (com.google.zxing.DecodeHintType)2 CharacterSetECI (com.google.zxing.common.CharacterSetECI)2 ReedSolomonEncoder (com.google.zxing.common.reedsolomon.ReedSolomonEncoder)2 DataCharacter (com.google.zxing.oned.rss.DataCharacter)2