diff options
| author | Sean Owen <srowen@gmail.com> | 2020-09-07 02:21:05 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-07 02:21:05 +0300 |
| commit | 40c2e2e9afa66148d0d70e978715f04106ead600 (patch) | |
| tree | 4ae3a1e6cc4bedb769e87e3ed7289cebd4f93fb8 /core/src/test/java/com | |
| parent | da049f21d9d6f7e4b0a0e94f3b8214847119bfe9 (diff) | |
| download | zxing-40c2e2e9afa66148d0d70e978715f04106ead600.tar.xz | |
Many small updates from code analysis; remove unused files; tune server params (#1311)
Diffstat (limited to 'core/src/test/java/com')
9 files changed, 43 insertions, 51 deletions
diff --git a/core/src/test/java/com/google/zxing/oned/CodaBarWriterTestCase.java b/core/src/test/java/com/google/zxing/oned/CodaBarWriterTestCase.java index ba22a1b6f..37e304976 100644 --- a/core/src/test/java/com/google/zxing/oned/CodaBarWriterTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/CodaBarWriterTestCase.java @@ -17,7 +17,6 @@ package com.google.zxing.oned; import com.google.zxing.BarcodeFormat; -import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrixTestCase; import org.junit.Assert; @@ -30,7 +29,7 @@ import org.junit.Test; public final class CodaBarWriterTestCase extends Assert { @Test - public void testEncode() throws WriterException { + public void testEncode() { doTest("B515-3/B", "00000" + "1001001011" + "0110101001" + "0101011001" + "0110101001" + "0101001101" + @@ -39,7 +38,7 @@ public final class CodaBarWriterTestCase extends Assert { } @Test - public void testEncode2() throws WriterException { + public void testEncode2() { doTest("T123T", "00000" + "1011001001" + "0101011001" + "0101001011" + "0110010101" + "01011001001" + @@ -47,16 +46,16 @@ public final class CodaBarWriterTestCase extends Assert { } @Test - public void testAltStartEnd() throws WriterException { + public void testAltStartEnd() { assertEquals(encode("T123456789-$T"), encode("A123456789-$A")); } - private static void doTest(String input, CharSequence expected) throws WriterException { + private static void doTest(String input, CharSequence expected) { BitMatrix result = encode(input); assertEquals(expected, BitMatrixTestCase.matrixToString(result)); } - private static BitMatrix encode(String input) throws WriterException { + private static BitMatrix encode(String input) { return new CodaBarWriter().encode(input, BarcodeFormat.CODABAR, 0, 0); } diff --git a/core/src/test/java/com/google/zxing/oned/Code39WriterTestCase.java b/core/src/test/java/com/google/zxing/oned/Code39WriterTestCase.java index 1872e9689..bcab73666 100644 --- a/core/src/test/java/com/google/zxing/oned/Code39WriterTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/Code39WriterTestCase.java @@ -17,7 +17,6 @@ package com.google.zxing.oned; import com.google.zxing.BarcodeFormat; -import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrixTestCase; import org.junit.Assert; @@ -29,7 +28,7 @@ import org.junit.Test; public final class Code39WriterTestCase extends Assert { @Test - public void testEncode() throws WriterException { + public void testEncode() { doTest("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", "000001001011011010110101001011010110100101101101101001010101011001011011010110010101" + "011011001010101010011011011010100110101011010011010101011001101011010101001101011010" + @@ -40,7 +39,7 @@ public final class Code39WriterTestCase extends Assert { // extended mode blocks doTest("\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f", - "000001001011011010101001001001011001010101101001001001010110101001011010010010010101" + + "000001001011011010101001001001011001010101101001001001010110101001011010010010010101" + "011010010110100100100101011011010010101001001001010101011001011010010010010101101011" + "001010100100100101010110110010101001001001010101010011011010010010010101101010011010" + "100100100101010110100110101001001001010101011001101010010010010101101010100110100100" + @@ -86,7 +85,7 @@ public final class Code39WriterTestCase extends Assert { "011011001010010110110100000"); } - private static void doTest(String input, CharSequence expected) throws WriterException { + private static void doTest(String input, CharSequence expected) { BitMatrix result = new Code39Writer().encode(input, BarcodeFormat.CODE_39, 0, 0); assertEquals(input, expected, BitMatrixTestCase.matrixToString(result)); } diff --git a/core/src/test/java/com/google/zxing/oned/Code93WriterTestCase.java b/core/src/test/java/com/google/zxing/oned/Code93WriterTestCase.java index c5aa4ff6f..dea0f1c53 100644 --- a/core/src/test/java/com/google/zxing/oned/Code93WriterTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/Code93WriterTestCase.java @@ -17,7 +17,6 @@ package com.google.zxing.oned; import com.google.zxing.BarcodeFormat; -import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrixTestCase; import org.junit.Assert; @@ -29,7 +28,7 @@ import org.junit.Test; public final class Code93WriterTestCase extends Assert { @Test - public void testEncode() throws WriterException { + public void testEncode() { doTest("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", "000001010111101101010001101001001101000101100101001100100101100010101011010001011001" + "001011000101001101001000110101010110001010011001010001101001011001000101101101101001" + @@ -54,7 +53,7 @@ public final class Code93WriterTestCase extends Assert { "101011110" + "100000"); } - private static void doTest(String input, CharSequence expected) throws WriterException { + private static void doTest(String input, CharSequence expected) { BitMatrix result = new Code93Writer().encode(input, BarcodeFormat.CODE_93, 0, 0); assertEquals(expected, BitMatrixTestCase.matrixToString(result)); } diff --git a/core/src/test/java/com/google/zxing/oned/EAN13WriterTestCase.java b/core/src/test/java/com/google/zxing/oned/EAN13WriterTestCase.java index 679b6f7ef..921784351 100644 --- a/core/src/test/java/com/google/zxing/oned/EAN13WriterTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/EAN13WriterTestCase.java @@ -17,7 +17,6 @@ package com.google.zxing.oned; import com.google.zxing.BarcodeFormat; -import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrixTestCase; import org.junit.Assert; @@ -29,21 +28,21 @@ import org.junit.Test; public final class EAN13WriterTestCase extends Assert { @Test - public void testEncode() throws WriterException { + public void testEncode() { String testStr = "00001010001011010011101100110010011011110100111010101011001101101100100001010111001001110100010010100000"; BitMatrix result = new EAN13Writer().encode("5901234123457", BarcodeFormat.EAN_13, testStr.length(), 0); assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); } @Test - public void testAddChecksumAndEncode() throws WriterException { + public void testAddChecksumAndEncode() { String testStr = "00001010001011010011101100110010011011110100111010101011001101101100100001010111001001110100010010100000"; BitMatrix result = new EAN13Writer().encode("590123412345", BarcodeFormat.EAN_13, testStr.length(), 0); assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); } @Test(expected = IllegalArgumentException.class) - public void testEncodeIllegalCharacters() throws WriterException { + public void testEncodeIllegalCharacters() { new EAN13Writer().encode("5901234123abc", BarcodeFormat.EAN_13, 0, 0); } } diff --git a/core/src/test/java/com/google/zxing/oned/EAN8WriterTestCase.java b/core/src/test/java/com/google/zxing/oned/EAN8WriterTestCase.java index 512e8ef00..86598224c 100644 --- a/core/src/test/java/com/google/zxing/oned/EAN8WriterTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/EAN8WriterTestCase.java @@ -17,7 +17,6 @@ package com.google.zxing.oned; import com.google.zxing.BarcodeFormat; -import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrixTestCase; import org.junit.Assert; @@ -29,21 +28,21 @@ import org.junit.Test; public final class EAN8WriterTestCase extends Assert { @Test - public void testEncode() throws WriterException { + public void testEncode() { String testStr = "0000001010001011010111101111010110111010101001110111001010001001011100101000000"; BitMatrix result = new EAN8Writer().encode("96385074", BarcodeFormat.EAN_8, testStr.length(), 0); assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); } @Test - public void testAddChecksumAndEncode() throws WriterException { + public void testAddChecksumAndEncode() { String testStr = "0000001010001011010111101111010110111010101001110111001010001001011100101000000"; BitMatrix result = new EAN8Writer().encode("9638507", BarcodeFormat.EAN_8, testStr.length(), 0); assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); } @Test(expected = IllegalArgumentException.class) - public void testEncodeIllegalCharacters() throws WriterException { + public void testEncodeIllegalCharacters() { new EAN8Writer().encode("96385abc", BarcodeFormat.EAN_8, 0, 0); } } diff --git a/core/src/test/java/com/google/zxing/oned/ITFWriterTestCase.java b/core/src/test/java/com/google/zxing/oned/ITFWriterTestCase.java index 79635658d..598741a3f 100644 --- a/core/src/test/java/com/google/zxing/oned/ITFWriterTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/ITFWriterTestCase.java @@ -17,7 +17,6 @@ package com.google.zxing.oned; import com.google.zxing.BarcodeFormat; -import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrixTestCase; import org.junit.Assert; @@ -29,19 +28,19 @@ import org.junit.Test; public final class ITFWriterTestCase extends Assert { @Test - public void testEncode() throws WriterException { + public void testEncode() { doTest("00123456789012", "0000010101010111000111000101110100010101110001110111010001010001110100011" + "100010101000101011100011101011101000111000101110100010101110001110100000"); } - private static void doTest(String input, CharSequence expected) throws WriterException { + private static void doTest(String input, CharSequence expected) { BitMatrix result = new ITFWriter().encode(input, BarcodeFormat.ITF, 0, 0); assertEquals(expected, BitMatrixTestCase.matrixToString(result)); } @Test(expected = IllegalArgumentException.class) - public void testEncodeIllegalCharacters() throws WriterException { + public void testEncodeIllegalCharacters() { new ITFWriter().encode("00123456789abc", BarcodeFormat.ITF, 0, 0); } diff --git a/core/src/test/java/com/google/zxing/oned/UPCAWriterTestCase.java b/core/src/test/java/com/google/zxing/oned/UPCAWriterTestCase.java index b919b2680..73fe98297 100644 --- a/core/src/test/java/com/google/zxing/oned/UPCAWriterTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/UPCAWriterTestCase.java @@ -17,7 +17,6 @@ package com.google.zxing.oned; import com.google.zxing.BarcodeFormat; -import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrixTestCase; @@ -30,14 +29,14 @@ import org.junit.Test; public final class UPCAWriterTestCase extends Assert { @Test - public void testEncode() throws WriterException { + public void testEncode() { String testStr = "00001010100011011011101100010001011010111101111010101011100101110100100111011001101101100101110010100000"; BitMatrix result = new UPCAWriter().encode("485963095124", BarcodeFormat.UPC_A, testStr.length(), 0); assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); } @Test - public void testAddChecksumAndEncode() throws WriterException { + public void testAddChecksumAndEncode() { String testStr = "00001010011001001001101111010100011011000101011110101010001001001000111010011100101100110110110010100000"; BitMatrix result = new UPCAWriter().encode("12345678901", BarcodeFormat.UPC_A, testStr.length(), 0); assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); diff --git a/core/src/test/java/com/google/zxing/oned/UPCEWriterTestCase.java b/core/src/test/java/com/google/zxing/oned/UPCEWriterTestCase.java index 93eb4f415..3a7a9e0b6 100644 --- a/core/src/test/java/com/google/zxing/oned/UPCEWriterTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/UPCEWriterTestCase.java @@ -17,7 +17,6 @@ package com.google.zxing.oned; import com.google.zxing.BarcodeFormat; -import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrixTestCase; import org.junit.Assert; @@ -29,30 +28,30 @@ import org.junit.Test; public final class UPCEWriterTestCase extends Assert { @Test - public void testEncode() throws WriterException { + public void testEncode() { doTest("05096893", "0000000000010101110010100111000101101011110110111001011101010100000000000"); } @Test - public void testEncodeSystem1() throws WriterException { + public void testEncodeSystem1() { doTest("12345670", "0000000000010100100110111101010001101110010000101001000101010100000000000"); } @Test - public void testAddChecksumAndEncode() throws WriterException { + public void testAddChecksumAndEncode() { doTest("0509689", "0000000000010101110010100111000101101011110110111001011101010100000000000"); } - private static void doTest(String content, String encoding) throws WriterException { + private static void doTest(String content, String encoding) { BitMatrix result = new UPCEWriter().encode(content, BarcodeFormat.UPC_E, encoding.length(), 0); assertEquals(encoding, BitMatrixTestCase.matrixToString(result)); } @Test(expected = IllegalArgumentException.class) - public void testEncodeIllegalCharacters() throws WriterException { + public void testEncodeIllegalCharacters() { new UPCEWriter().encode("05096abc", BarcodeFormat.UPC_E, 0, 0); } } diff --git a/core/src/test/java/com/google/zxing/qrcode/encoder/BitVectorTestCase.java b/core/src/test/java/com/google/zxing/qrcode/encoder/BitVectorTestCase.java index 0fed100a3..c67e84cad 100644 --- a/core/src/test/java/com/google/zxing/qrcode/encoder/BitVectorTestCase.java +++ b/core/src/test/java/com/google/zxing/qrcode/encoder/BitVectorTestCase.java @@ -26,9 +26,9 @@ import org.junit.Test; */ public final class BitVectorTestCase extends Assert { - private static long getUnsignedInt(BitArray v, int index) { + private static long getUnsignedInt(BitArray v) { long result = 0L; - for (int i = 0, offset = index * 8; i < 32; i++) { + for (int i = 0, offset = 0; i < 32; i++) { if (v.get(offset + i)) { result |= 1L << (31 - i); } @@ -43,43 +43,43 @@ public final class BitVectorTestCase extends Assert { // 1 v.appendBit(true); assertEquals(1, v.getSize()); - assertEquals(0x80000000L, getUnsignedInt(v, 0)); + assertEquals(0x80000000L, getUnsignedInt(v)); // 10 v.appendBit(false); assertEquals(2, v.getSize()); - assertEquals(0x80000000L, getUnsignedInt(v, 0)); + assertEquals(0x80000000L, getUnsignedInt(v)); // 101 v.appendBit(true); assertEquals(3, v.getSize()); - assertEquals(0xa0000000L, getUnsignedInt(v, 0)); + assertEquals(0xa0000000L, getUnsignedInt(v)); // 1010 v.appendBit(false); assertEquals(4, v.getSize()); - assertEquals(0xa0000000L, getUnsignedInt(v, 0)); + assertEquals(0xa0000000L, getUnsignedInt(v)); // 10101 v.appendBit(true); assertEquals(5, v.getSize()); - assertEquals(0xa8000000L, getUnsignedInt(v, 0)); + assertEquals(0xa8000000L, getUnsignedInt(v)); // 101010 v.appendBit(false); assertEquals(6, v.getSize()); - assertEquals(0xa8000000L, getUnsignedInt(v, 0)); + assertEquals(0xa8000000L, getUnsignedInt(v)); // 1010101 v.appendBit(true); assertEquals(7, v.getSize()); - assertEquals(0xaa000000L, getUnsignedInt(v, 0)); + assertEquals(0xaa000000L, getUnsignedInt(v)); // 10101010 v.appendBit(false); assertEquals(8, v.getSize()); - assertEquals(0xaa000000L, getUnsignedInt(v, 0)); + assertEquals(0xaa000000L, getUnsignedInt(v)); // 10101010 1 v.appendBit(true); assertEquals(9, v.getSize()); - assertEquals(0xaa800000L, getUnsignedInt(v, 0)); + assertEquals(0xaa800000L, getUnsignedInt(v)); // 10101010 10 v.appendBit(false); assertEquals(10, v.getSize()); - assertEquals(0xaa800000L, getUnsignedInt(v, 0)); + assertEquals(0xaa800000L, getUnsignedInt(v)); } @Test @@ -87,15 +87,15 @@ public final class BitVectorTestCase extends Assert { BitArray v = new BitArray(); v.appendBits(0x1, 1); assertEquals(1, v.getSize()); - assertEquals(0x80000000L, getUnsignedInt(v, 0)); + assertEquals(0x80000000L, getUnsignedInt(v)); v = new BitArray(); v.appendBits(0xff, 8); assertEquals(8, v.getSize()); - assertEquals(0xff000000L, getUnsignedInt(v, 0)); + assertEquals(0xff000000L, getUnsignedInt(v)); v = new BitArray(); v.appendBits(0xff7, 12); assertEquals(12, v.getSize()); - assertEquals(0xff700000L, getUnsignedInt(v, 0)); + assertEquals(0xff700000L, getUnsignedInt(v)); } @Test @@ -132,7 +132,7 @@ public final class BitVectorTestCase extends Assert { BitArray v2 = new BitArray(); v2.appendBits(0xaaaa5555, 32); v1.xor(v2); - assertEquals(0xffffffffL, getUnsignedInt(v1, 0)); + assertEquals(0xffffffffL, getUnsignedInt(v1)); } @Test @@ -142,7 +142,7 @@ public final class BitVectorTestCase extends Assert { BitArray v2 = new BitArray(); v2.appendBits(0x55, 7); // 101 0101 v1.xor(v2); - assertEquals(0xfe000000L, getUnsignedInt(v1, 0)); // 1111 1110 + assertEquals(0xfe000000L, getUnsignedInt(v1)); // 1111 1110 } @Test |
