summaryrefslogtreecommitdiff
path: root/core/src/test/java
diff options
context:
space:
mode:
authorTaneli Huuskonen <taneli@poczta.onet.pl>2016-05-05 15:10:44 +0300
committerTaneli Huuskonen <taneli@poczta.onet.pl>2016-05-05 15:10:44 +0300
commite9896d03a65b96c9f7db3ba9f294e62d2f7aa168 (patch)
tree17a5f5c4b12caca3a34d7bbe22dca24ed94af2a7 /core/src/test/java
parent05a415f1a0a66a0332e8dc6148b7bbb7c13fe8f0 (diff)
downloadzxing-e9896d03a65b96c9f7db3ba9f294e62d2f7aa168.tar.xz
Aztec decoder returns raw bytes
The Aztec decoder now packs the code bits into bytes and returns them as "raw bytes", even though the error correction codes and stuffing have been already removed. Also added a couple of tests for the byte-packing function.
Diffstat (limited to 'core/src/test/java')
-rw-r--r--core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java34
1 files changed, 33 insertions, 1 deletions
diff --git a/core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java b/core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java
index ce5b8a441..95f7e69a1 100644
--- a/core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java
+++ b/core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java
@@ -20,8 +20,9 @@ import com.google.zxing.ResultPoint;
import com.google.zxing.aztec.AztecDetectorResult;
import com.google.zxing.common.BitMatrix;
import org.junit.Test;
+import org.junit.Assert;
-public final class DecoderTest {
+public final class DecoderTest extends Assert {
private static final ResultPoint[] NO_POINTS = new ResultPoint[0];
@@ -105,4 +106,35 @@ public final class DecoderTest {
new Decoder().decode(r);
}
+ private static void assertEqualByteArrays(byte[] b1, byte[] b2) {
+ assertEquals(b1.length, b2.length);
+ for (int i = 0; i < b1.length; i++) {
+ assertEquals(b1[i], b2[i]);
+ }
+ }
+
+ @Test
+ public void testRawBytes() {
+ boolean bool0[] = {};
+ boolean bool1[] = { true };
+ boolean bool7[] = { true, false, true, false, true, false, true };
+ boolean bool8[] = { true, false, true, false, true, false, true, false };
+ boolean bool9[] = { true, false, true, false, true, false, true, false,
+ true };
+ boolean bool16[] = { false, true, true, false, false, false, true, true,
+ true, true, false, false, false, false, false, true };
+ byte byte0[] = {};
+ byte byte1[] = { -128 };
+ byte byte7[] = { -86 };
+ byte byte8[] = { -86 };
+ byte byte9[] = { -86, -128 };
+ byte byte16[] = { 99, -63 };
+
+ assertEqualByteArrays(byte0, Decoder.convertBoolArrayToByteArray(bool0));
+ assertEqualByteArrays(byte1, Decoder.convertBoolArrayToByteArray(bool1));
+ assertEqualByteArrays(byte7, Decoder.convertBoolArrayToByteArray(bool7));
+ assertEqualByteArrays(byte8, Decoder.convertBoolArrayToByteArray(bool8));
+ assertEqualByteArrays(byte9, Decoder.convertBoolArrayToByteArray(bool9));
+ assertEqualByteArrays(byte16, Decoder.convertBoolArrayToByteArray(bool16));
+ }
}