package com.google.zxing.common.reedsolomon;
+import org.junit.Test;
+
import java.util.Random;
/**
/**
* Tests example given in ISO 18004, Annex I
*/
+ @Test
public void testISO18004Example() {
- int[] dataBytes = new int[] {
+ int[] dataBytes = {
0x10, 0x20, 0x0C, 0x56, 0x61, 0x80, 0xEC, 0x11,
0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11 };
- int[] expectedECBytes = new int[] {
+ int[] expectedECBytes = {
0xA5, 0x24, 0xD4, 0xC1, 0xED, 0x36, 0xC7, 0x87,
0x2C, 0x55 };
doTestQRCodeEncoding(dataBytes, expectedECBytes);
}
+ @Test
public void testQRCodeVersusDecoder() throws Exception {
Random random = getRandom();
ReedSolomonEncoder encoder = new ReedSolomonEncoder(GF256.QR_CODE_FIELD);
for (int i = 0; i < 100; i++) {
int size = random.nextInt(1000);
int[] toEncode = new int[size];
- int ecBytes = random.nextInt(2 * (1 + size / 8));
+ int ecBytes = 1 + random.nextInt(2 * (1 + size / 8));
int dataBytes = size - ecBytes;
for (int j = 0; j < dataBytes; j++) {
toEncode[j] = random.nextInt(256);