Search in sources :

Example 51 with BitArray

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

Example 52 with BitArray

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

Example 53 with BitArray

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

Example 54 with BitArray

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

Example 55 with BitArray

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);
}
Also used : AbstractExpandedDecoder(com.google.zxing.oned.rss.expanded.decoders.AbstractExpandedDecoder) 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