summaryrefslogtreecommitdiff
path: root/core/src/test/java
diff options
context:
space:
mode:
authorSean Owen <srowen@gmail.com>2016-07-24 20:29:42 +0300
committerSean Owen <srowen@gmail.com>2016-07-24 20:29:42 +0300
commit2f11529aa35e01354f9036c2aa7747ab23a604ef (patch)
treee6bc505b56e393c9febe9e375b42663b0bf1e79c /core/src/test/java
parent78fbdc58fc24318e1caadc1f60b9159dc255f697 (diff)
downloadzxing-2f11529aa35e01354f9036c2aa7747ab23a604ef.tar.xz
A bunch of inspection changes, including some dead code removal and tightening visibility, removing unnecessary casts
Diffstat (limited to 'core/src/test/java')
-rw-r--r--core/src/test/java/com/google/zxing/AllPositiveBlackBoxTester.java117
-rw-r--r--core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java1
-rw-r--r--core/src/test/java/com/google/zxing/aztec/detector/DetectorTest.java4
-rw-r--r--core/src/test/java/com/google/zxing/aztec/encoder/EncoderTest.java12
-rw-r--r--core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java3
-rw-r--r--core/src/test/java/com/google/zxing/common/SummaryResults.java49
-rw-r--r--core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java3
-rw-r--r--core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java4
8 files changed, 15 insertions, 178 deletions
diff --git a/core/src/test/java/com/google/zxing/AllPositiveBlackBoxTester.java b/core/src/test/java/com/google/zxing/AllPositiveBlackBoxTester.java
deleted file mode 100644
index 9f05a8d85..000000000
--- a/core/src/test/java/com/google/zxing/AllPositiveBlackBoxTester.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.zxing;
-
-import com.google.zxing.common.AbstractBlackBoxTestCase;
-import com.google.zxing.common.SummaryResults;
-import com.google.zxing.datamatrix.DataMatrixBlackBox1TestCase;
-import com.google.zxing.datamatrix.DataMatrixBlackBox2TestCase;
-import com.google.zxing.oned.Code128BlackBox1TestCase;
-import com.google.zxing.oned.Code128BlackBox2TestCase;
-import com.google.zxing.oned.Code128BlackBox3TestCase;
-import com.google.zxing.oned.Code39BlackBox1TestCase;
-import com.google.zxing.oned.Code39BlackBox3TestCase;
-import com.google.zxing.oned.Code39ExtendedBlackBox2TestCase;
-import com.google.zxing.oned.EAN13BlackBox1TestCase;
-import com.google.zxing.oned.EAN13BlackBox2TestCase;
-import com.google.zxing.oned.EAN13BlackBox3TestCase;
-import com.google.zxing.oned.EAN13BlackBox4TestCase;
-import com.google.zxing.oned.EAN8BlackBox1TestCase;
-import com.google.zxing.oned.ITFBlackBox1TestCase;
-import com.google.zxing.oned.ITFBlackBox2TestCase;
-import com.google.zxing.oned.UPCABlackBox1TestCase;
-import com.google.zxing.oned.UPCABlackBox2TestCase;
-import com.google.zxing.oned.UPCABlackBox3ReflectiveTestCase;
-import com.google.zxing.oned.UPCABlackBox4TestCase;
-import com.google.zxing.oned.UPCABlackBox5TestCase;
-import com.google.zxing.oned.UPCEBlackBox1TestCase;
-import com.google.zxing.oned.UPCEBlackBox2TestCase;
-import com.google.zxing.oned.UPCEBlackBox3ReflectiveTestCase;
-import com.google.zxing.pdf417.PDF417BlackBox1TestCase;
-import com.google.zxing.pdf417.PDF417BlackBox2TestCase;
-import com.google.zxing.qrcode.QRCodeBlackBox1TestCase;
-import com.google.zxing.qrcode.QRCodeBlackBox2TestCase;
-import com.google.zxing.qrcode.QRCodeBlackBox3TestCase;
-import com.google.zxing.qrcode.QRCodeBlackBox4TestCase;
-import com.google.zxing.qrcode.QRCodeBlackBox5TestCase;
-
-import java.util.logging.Logger;
-
-/**
- * This is a quick and dirty way to get totals across all the positive black box tests. It is
- * necessary because we spawn multiple processes when using the standard test-blackbox Ant target.
- * It would be a shame to change that because it does help with performance. Perhaps we can find a
- * way to unify these in the future.
- *
- * @author dswitkin@google.com (Daniel Switkin)
- */
-public final class AllPositiveBlackBoxTester {
-
- private static final Logger log = Logger.getLogger(AllPositiveBlackBoxTester.class.getSimpleName());
-
- // This list has to be manually kept up to date. I don't know any automatic way to include every
- // subclass of AbstractBlackBoxTestCase, and furthermore to exclude subclasses of
- // AbstractNegativeBlackBoxTestCase which derives from it.
- private static final AbstractBlackBoxTestCase[] TESTS = {
- new DataMatrixBlackBox1TestCase(),
- new DataMatrixBlackBox2TestCase(),
- new Code128BlackBox1TestCase(),
- new Code128BlackBox2TestCase(),
- new Code128BlackBox3TestCase(),
- new Code39BlackBox1TestCase(),
- new Code39ExtendedBlackBox2TestCase(),
- new Code39BlackBox3TestCase(),
- new EAN13BlackBox1TestCase(),
- new EAN13BlackBox2TestCase(),
- new EAN13BlackBox3TestCase(),
- new EAN13BlackBox4TestCase(),
- new EAN8BlackBox1TestCase(),
- new ITFBlackBox1TestCase(),
- new ITFBlackBox2TestCase(),
- new UPCABlackBox1TestCase(),
- new UPCABlackBox2TestCase(),
- new UPCABlackBox3ReflectiveTestCase(),
- new UPCABlackBox4TestCase(),
- new UPCABlackBox5TestCase(),
- new UPCEBlackBox1TestCase(),
- new UPCEBlackBox2TestCase(),
- new UPCEBlackBox3ReflectiveTestCase(),
- new PDF417BlackBox1TestCase(),
- new PDF417BlackBox2TestCase(),
- new QRCodeBlackBox1TestCase(),
- new QRCodeBlackBox2TestCase(),
- new QRCodeBlackBox3TestCase(),
- new QRCodeBlackBox4TestCase(),
- new QRCodeBlackBox5TestCase()
- };
-
- private AllPositiveBlackBoxTester() {
- System.setProperty("java.util.logging.SimpleFormatter.format", "%4$s: %5$s%6$s%n");
- }
-
- public static void main(String[] args) throws Exception {
- long start = System.currentTimeMillis();
- SummaryResults results = new SummaryResults();
-
- for (AbstractBlackBoxTestCase test : TESTS) {
- results.add(test.testBlackBoxCountingResults(false));
- }
-
- log.info(results.toString());
- log.info(String.format("Total time: %d ms", System.currentTimeMillis() - start));
- }
-}
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 5bab590fd..7cd2a6f42 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
@@ -34,7 +34,6 @@ public final class DecoderTest extends Assert {
* at com.google.zxing.aztec.decoder.Decoder.correctBits(Decoder.java:231)
* at com.google.zxing.aztec.decoder.Decoder.decode(Decoder.java:77)
* at com.google.zxing.aztec.decoder.DecoderTest.testDecodeBug1(DecoderTest.java:66)</pre>
- * @throws FormatException
*/
@Test(expected = FormatException.class)
public void testDecodeTooManyErrors() throws FormatException {
diff --git a/core/src/test/java/com/google/zxing/aztec/detector/DetectorTest.java b/core/src/test/java/com/google/zxing/aztec/detector/DetectorTest.java
index c4fca8337..11963c691 100644
--- a/core/src/test/java/com/google/zxing/aztec/detector/DetectorTest.java
+++ b/core/src/test/java/com/google/zxing/aztec/detector/DetectorTest.java
@@ -101,7 +101,9 @@ public final class DetectorTest extends Assert {
try {
new Detector(makeLarger(copy, 3)).detect(false);
fail("Should not reach here");
- } catch (NotFoundException expected) { }
+ } catch (NotFoundException expected) {
+ // continue
+ }
}
}
}
diff --git a/core/src/test/java/com/google/zxing/aztec/encoder/EncoderTest.java b/core/src/test/java/com/google/zxing/aztec/encoder/EncoderTest.java
index 15de77263..d92b82969 100644
--- a/core/src/test/java/com/google/zxing/aztec/encoder/EncoderTest.java
+++ b/core/src/test/java/com/google/zxing/aztec/encoder/EncoderTest.java
@@ -400,12 +400,16 @@ public final class EncoderTest extends Assert {
try {
Encoder.encode(alphabet, 25, 33);
fail("Encode should have failed. No such thing as 33 layers");
- } catch (IllegalArgumentException expected) {}
+ } catch (IllegalArgumentException expected) {
+ // continue
+ }
try {
Encoder.encode(alphabet, 25, -1);
fail("Encode should have failed. Text can't fit in 1-layer compact");
- } catch (IllegalArgumentException expected) {}
+ } catch (IllegalArgumentException expected) {
+ // continue
+ }
}
@Test
@@ -419,7 +423,9 @@ public final class EncoderTest extends Assert {
try {
Encoder.encode(data, 0, -4);
fail("Encode should have failed. Text can't fit in 1-layer compact");
- } catch (IllegalArgumentException expected) {}
+ } catch (IllegalArgumentException expected) {
+ // continue
+ }
// If we just try to encode it normally, it will go to a non-compact 4 layer
AztecCode aztecCode = Encoder.encode(data, 0, Encoder.DEFAULT_AZTEC_LAYERS);
diff --git a/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java b/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java
index e933d3dfb..da37c8d93 100644
--- a/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java
+++ b/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java
@@ -128,7 +128,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
testBlackBoxCountingResults(true);
}
- public final SummaryResults testBlackBoxCountingResults(boolean assertOnFailure) throws IOException {
+ private void testBlackBoxCountingResults(boolean assertOnFailure) throws IOException {
assertFalse(testResults.isEmpty());
List<Path> imageFiles = getImageFiles();
@@ -246,7 +246,6 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
tryHaderMisreadCounts[x] <= testResult.getMaxTryHarderMisreads());
}
}
- return new SummaryResults(totalFound, totalMustPass, totalTests);
}
private boolean decode(BinaryBitmap source,
diff --git a/core/src/test/java/com/google/zxing/common/SummaryResults.java b/core/src/test/java/com/google/zxing/common/SummaryResults.java
deleted file mode 100644
index f60b1aa2c..000000000
--- a/core/src/test/java/com/google/zxing/common/SummaryResults.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.zxing.common;
-
-public final class SummaryResults {
-
- private int totalFound;
- private int totalMustPass;
- private int totalTests;
-
- public SummaryResults() {
- totalFound = 0;
- totalMustPass = 0;
- totalTests = 0;
- }
-
- public SummaryResults(int found, int mustPass, int total) {
- totalFound = found;
- totalMustPass = mustPass;
- totalTests = total;
- }
-
- public void add(SummaryResults other) {
- totalFound += other.totalFound;
- totalMustPass += other.totalMustPass;
- totalTests += other.totalTests;
- }
-
- @Override
- public String toString() {
- return "\nSUMMARY RESULTS:\n Decoded " + totalFound + " images out of " + totalTests +
- " (" + (totalFound * 100 / totalTests) + "%, " + totalMustPass + " required)";
- }
-
-}
diff --git a/core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java b/core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java
index ad403fb2a..d5352c662 100644
--- a/core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java
+++ b/core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java
@@ -21,7 +21,6 @@ import org.junit.Before;
import org.junit.Test;
import com.google.zxing.BarcodeFormat;
-import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import com.google.zxing.Writer;
import com.google.zxing.WriterException;
@@ -86,7 +85,7 @@ public class Code128WriterTestCase extends Assert {
}
@Test
- public void testRoundtrip() throws WriterException, ReaderException {
+ public void testRoundtrip() throws Exception {
String toEncode = "\u00f1" + "10958" + "\u00f1" + "17160526";
String expected = "1095817160526";
diff --git a/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java b/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java
index e93f0cfd0..d15d3d1ba 100644
--- a/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java
+++ b/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java
@@ -26,7 +26,6 @@ import com.google.zxing.Result;
import com.google.zxing.ResultMetadataType;
import com.google.zxing.common.AbstractBlackBoxTestCase;
import com.google.zxing.common.HybridBinarizer;
-import com.google.zxing.common.SummaryResults;
import com.google.zxing.common.TestResult;
import com.google.zxing.multi.MultipleBarcodeReader;
@@ -74,7 +73,7 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
testPDF417BlackBoxCountingResults(true);
}
- private SummaryResults testPDF417BlackBoxCountingResults(boolean assertOnFailure) throws IOException {
+ private void testPDF417BlackBoxCountingResults(boolean assertOnFailure) throws IOException {
assertFalse(testResults.isEmpty());
Map<String,List<Path>> imageFiles = getImageFileLists();
@@ -174,7 +173,6 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
assertTrue("Try harder, " + label, tryHarderCounts[x] >= testResult.getTryHarderCount());
}
}
- return new SummaryResults(totalFound, totalMustPass, totalTests);
}
private static PDF417ResultMetadata getMeta(Result result) {